Update include/*.php to use mysqli_* functions.
darkmorford -
2f20c7105050
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -45,7 +45,7 define('USING_TIDY', false);
45 45 // Call mysql to hash a password
46 46 function mt_hash_password($password) {
47 47 global $mtdb;
48 return $mtdb->getOne('SELECT SHA1("' . mysql_real_escape_string($password) . '")') ;
48 return $mtdb->getOne('SELECT SHA1("' . mysqli_real_escape_string($mtdb->link, $password) . '")') ;
49 49 }
50 50
51 51 // Remove invalid characters from username. Permit only alpha, underscore, period, at, hypen
@@ -67,7 +67,7 function mt_login($username, $password, $already_hashed = false) {
67 67
68 68 $username = sanitize_username( $username );
69 69
70 $login = $mtdb->getRow( 'SELECT id,name,email,nameplate,default_image,default_link,password FROM contributor WHERE name = "' . mysql_real_escape_string($username) . '"');
70 $login = $mtdb->getRow( 'SELECT id,name,email,nameplate,default_image,default_link,password FROM contributor WHERE name = "' . mysqli_real_escape_string($mtdb->link, $username) . '"');
71 71 if (!$login) {
72 72 $error = ('<strong>ERROR</strong>: Invalid username or password.');
73 73 adminlog("Failed login attempt from ".$_SERVER['REMOTE_ADDR']." for $username.", MTS_LOGIN, MTA_CHANGE);
@@ -131,7 +131,7 function _redirect($location, $status = 302) {
131 131
132 132 if ( substr(php_sapi_name(), 0, 3) != 'cgi' )
133 133 header('Status: '.$status); // This causes problems on IIS and some FastCGI setups
134
134
135 135 header("Location: $location");
136 136 die();
137 137 }
@@ -25,10 +25,10 define('MTA_CHANGE', 'update'); // Modification action
25 25 function adminlog($msg, $section, $action, $level=E_USER_NOTICE, $email=false)
26 26 {
27 27 global $mtdb, $currentuser;
28
28
29 29 $sql = sprintf('INSERT INTO admin_log (contributor, section, action, level, message) VALUES (%s, %d, "%s", %d, "%s")',
30 (is_numeric($currentuser->id) ? $currentuser->id : "NULL"), $section, mysql_real_escape_string($action), $level, mysql_real_escape_string($msg));
31 $mtdb->query( $sql ) or die($sql."<br>".mysql_error()."<br>\n".var_export(debug_backtrace()));
30 (is_numeric($currentuser->id) ? $currentuser->id : "NULL"), $section, mysqli_real_escape_string($mtdb->link, $action), $level, mysqli_real_escape_string($mtdb->link, $msg));
31 $mtdb->query( $sql ) or die($sql."<br>".mysqli_error()."<br>\n".var_export(debug_backtrace()));
32 32
33 33 // Log all important sorts of messages in the Apache log
34 34 if( $level & (E_USER_WARNING | E_USER_ERROR) ) {
@@ -14,26 +14,26 function savepage($page) {
14 14 function insertpage($page) {
15 15 global $mtdb;
16 16 $sql = 'INSERT INTO static_page ( url_name, status, title, body, style ) VALUES ('
17 . ' "' . mysql_real_escape_string($page->url_name)
18 . '", "' . mysql_real_escape_string($page->status)
19 . '", "' . mysql_real_escape_string( trim( $page->title ) )
20 . '", "' . mysql_real_escape_string( trim( $page->body ) )
21 . '", "' . mysql_real_escape_string( trim( $page->style ) )
17 . ' "' . mysqli_real_escape_string($mtdb->link, $page->url_name)
18 . '", "' . mysqli_real_escape_string($mtdb->link, $page->status)
19 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $page->title ) )
20 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $page->body ) )
21 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $page->style ) )
22 22 . '")';
23 23 adminlog("Page '".$page->url_name."' has been added.", MTS_PAGE, MTA_ADD);
24 24 return $mtdb->query($sql);
25 }
25 }
26 26
27 27 function updatepage($page) {
28 28 if ( !$page->url_name ) return false;
29 29 global $mtdb;
30
31 $sql = 'UPDATE static_page SET url_name = "' . mysql_real_escape_string($page->url_name)
32 . '", status = "' . mysql_real_escape_string($page->status)
33 . '", title = "' . mysql_real_escape_string( trim($page->title) )
34 . '", body = "' . mysql_real_escape_string( trim($page->body ) )
35 . '", style = "' . mysql_real_escape_string( trim($page->style ) )
36 . '" WHERE url_name = "' . mysql_real_escape_string($page->url_name) . '"';
30
31 $sql = 'UPDATE static_page SET url_name = "' . mysqli_real_escape_string($page->url_name)
32 . '", status = "' . mysqli_real_escape_string($mtdb->link, $page->status)
33 . '", title = "' . mysqli_real_escape_string( trim($mtdb->link, $page->title) )
34 . '", body = "' . mysqli_real_escape_string( trim($mtdb->link, $page->body ) )
35 . '", style = "' . mysqli_real_escape_string( trim($mtdb->link, $page->style ) )
36 . '" WHERE url_name = "' . mysqli_real_escape_string($mtdb->link, $page->url_name) . '"';
37 37 adminlog("Page '".$page->url_name."' has been updated.", MTS_PAGE, MTA_MODIFY);
38 38 return $mtdb->query( $sql );
39 39 }
@@ -42,12 +42,12 function deletepage($url_name) {
42 42 if ( !$url_name ) return false;
43 43 global $mtdb;
44 44 adminlog("Page '".$page->url_name."' has been deleted.", MTS_PAGE, MTA_DELETE);
45 return $mtdb->query( 'DELETE FROM static_page WHERE url_name = "' . mysql_real_escape_string($url_name) . '"' );
45 return $mtdb->query( 'DELETE FROM static_page WHERE url_name = "' . mysqli_real_escape_string($mtdb->link, $url_name) . '"' );
46 46 }
47 47
48 48 function getpage($url_name) {
49 49 global $mtdb;
50 return $mtdb->getRow( 'SELECT url_name, status, title, body, style FROM static_page WHERE url_name = "'. mysql_real_escape_string($url_name) . '"' );
50 return $mtdb->getRow( 'SELECT url_name, status, title, body, style FROM static_page WHERE url_name = "'. mysqli_real_escape_string($mtdb->link, $url_name) . '"' );
51 51 }
52 52
53 53 ?>
@@ -15,22 +15,22 function insertrant($rant) {
15 15 global $mtdb;
16 16 $sql = 'INSERT INTO rant ( published, status, side, author, title, body, link, imagetype, imagetext ) VALUES ( FROM_UNIXTIME('
17 17 . (int)$rant->published
18 . '), "' . mysql_real_escape_string($rant->status)
19 . '", "' . mysql_real_escape_string($rant->side)
18 . '), "' . mysqli_real_escape_string($mtdb->link, $rant->status)
19 . '", "' . mysqli_real_escape_string($mtdb->link, $rant->side)
20 20 . '", "' . (int)$rant->author
21 . '", "' . mysql_real_escape_string( trim( $rant->title) )
22 . '", "' . mysql_real_escape_string( trim( $rant->body ) )
23 . '", "' . mysql_real_escape_string( trim( $rant->link ) )
24 . '", ' . mysql_real_escape_string($rant->imagetype)
25 . ', "' . mysql_real_escape_string( trim( $rant->imagetext ) )
21 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $rant->title) )
22 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $rant->body ) )
23 . '", "' . mysqli_real_escape_string( $mtdb->link, trim( $rant->link ) )
24 . '", ' . mysqli_real_escape_string($mtdb->link, $rant->imagetype)
25 . ', "' . mysqli_real_escape_string( $mtdb->link, trim( $rant->imagetext ) )
26 26 . '")';
27
27
28 28 if( $mtdb->query( $sql ) ) {
29 29 //logthis( 'Saved changes to rant ' . $rant->id );
30 $rant->id = mysql_insert_id( $mtdb->link );
31
30 $rant->id = mysqli_insert_id( $mtdb->link );
31
32 32 adminlog("Rant ".$rant->id." saved.", MTS_RANT, MTA_ADD);
33
33
34 34 if($rant->status == "published")
35 35 {
36 36 $poster = get_userdatabyid($rant->author);
@@ -41,34 +41,34 function insertrant($rant) {
41 41 tumblrpost($rant->title, $rant->body);
42 42 }
43 43 }
44
44
45 45 return $rant->id;
46 46 }
47 47 return false;
48 }
48 }
49 49
50 50 function updaterant($rant) {
51 51 if ( !(int)$rant->id ) return false;
52 52 global $mtdb;
53
53
54 54 #first, check if it's published already
55 55 $qr = $mtdb->query("SELECT status FROM rant WHERE id = ".$rant->id);
56 $row = mysql_fetch_row($qr);
56 $row = mysqli_fetch_row($qr);
57 57 $status = $row[0];
58
58
59 59 adminlog("Rant ".$rant->id." updated.", MTS_RANT, MTA_UPDATE);
60
60
61 61 $sql = 'UPDATE rant SET published=FROM_UNIXTIME(' . (int)$rant->published
62 . '), status = "' . mysql_real_escape_string($rant->status)
63 . '", side = "' . mysql_real_escape_string($rant->side)
62 . '), status = "' . mysqli_real_escape_string($mtdb->link, $rant->status)
63 . '", side = "' . mysqli_real_escape_string($mtdb->link, $rant->side)
64 64 . '", author = ' . (int)$rant->author
65 . ', title = "' . mysql_real_escape_string( trim($rant->title) )
66 . '", body = "' . mysql_real_escape_string( trim($rant->body ) )
67 . '", link = "' . mysql_real_escape_string( trim($rant->link ) )
65 . ', title = "' . mysqli_real_escape_string( $mtdb->link, trim($rant->title) )
66 . '", body = "' . mysqli_real_escape_string( $mtdb->link, trim($rant->body ) )
67 . '", link = "' . mysqli_real_escape_string( $mtdb->link, trim($rant->link ) )
68 68 . '", imagetype = ' . (int)$rant->imagetype
69 . ', imagetext = "' . mysql_real_escape_string( trim($rant->imagetext) )
69 . ', imagetext = "' . mysqli_real_escape_string( $mtdb->link, trim($rant->imagetext) )
70 70 . '" WHERE id=' . (int)$rant->id;
71
71
72 72 if($status == "draft" && $rant->status == "published")
73 73 {
74 74 $poster = get_userdatabyid($rant->author);
@@ -79,7 +79,7 function updaterant($rant) {
79 79 tumblrpost($rant->title, $rant->body);
80 80 }
81 81 }
82
82
83 83 return $mtdb->query( $sql );
84 84 }
85 85
@@ -3,10 +3,10
3 3 function rsspost($body, $url)
4 4 {
5 5 global $mtdb;
6
6
7 7 $mtdb->query('INSERT INTO rss_comment (body, url)
8 VALUES ("'.mysql_real_escape_string($body).'",
9 "'.mysql_real_escape_string($url).'")');
8 VALUES ("'.mysqli_real_escape_string($mtdb->link, $body).'",
9 "'.mysqli_real_escape_string($mtdb->link, $url).'")');
10 10
11 11 return true;
12 12 }
@@ -13,10 +13,10 class Strip {
13 13 // Strip id is automatically incremented
14 14 function insertstrip(&$strip) {
15 15 global $mtdb;
16
16
17 17 $strip->book = ($strip->book == '') ? 'NULL' : (int)$strip->book;
18 $strip->page = ($strip->page == '') ? 'NULL' : (int)$strip->page;
19
18 $strip->page = ($strip->page == '') ? 'NULL' : (int)$strip->page;
19
20 20 $mtdb->query('START TRANSACTION');
21 21 $newid = $mtdb->getOne('SELECT MAX(id) FROM strip') + 1;
22 22 $sql = 'INSERT INTO strip ( id, published, media, type, title, book, page ) VALUES ('
@@ -24,11 +24,11 function insertstrip(&$strip) {
24 24 . ', FROM_UNIXTIME(' . (int)$strip->published
25 25 . '), '. (int)$strip->media
26 26 . ', ' . (int)$strip->type
27 . ', "' . mysql_real_escape_string( trim($strip->title) )
27 . ', "' . mysqli_real_escape_string( $mtdb->link, trim($strip->title) )
28 28 . '", '. $strip->book
29 29 . ', ' . $strip->page
30 30 . ')';
31
31
32 32 $r = $mtdb->query( $sql );
33 33 if( !$r ) {
34 34 $mtdb->query('ROLLBACK');
@@ -36,24 +36,24 function insertstrip(&$strip) {
36 36 }
37 37 $mtdb->query('COMMIT');
38 38 adminlog("Comic ".$newid." posted.", MTS_STRIP, MTA_ADD);
39
39
40 40 $strip->id = $newid;
41 41 if( $strip->id == 0 ) return false;
42 42 return true;
43 }
43 }
44 44
45 45 function updatestrip(&$strip) {
46 46 global $mtdb;
47
47
48 48 $strip->book = ($strip->book === '') ? 'NULL' : (int)$strip->book;
49 49 $strip->page = ($strip->page === '') ? 'NULL' : (int)$strip->page;
50
50
51 51 $mtdb->query('START TRANSACTION');
52 52 $sql = 'UPDATE strip SET
53 53 published = FROM_UNIXTIME(' . (int)$strip->published .')
54 54 , media = '. (int)$strip->media .'
55 55 , type = ' . (int)$strip->type .'
56 , title = "' . mysql_real_escape_string( trim($strip->title) ) .'"
56 , title = "' . mysqli_real_escape_string( $mtdb->link, trim($strip->title) ) .'"
57 57 , book = ' . (int)$strip->book .'
58 58 , page = ' . (int)$strip->page .'
59 59 WHERE id = ' . (int)$strip->id;
@@ -61,7 +61,7 function updatestrip(&$strip) {
61 61 $mtdb->query('COMMIT');
62 62 adminlog("Comic ".$strip->id." modified.", MTS_STRIP, MTA_MODIFY);
63 63 return true;
64 }
64 }
65 65
66 66 // Delete destination strip from DB and FS, and Update/Rename the source strip into place. Destructive Move!
67 67 function move_strip($from_id, $to_id)
@@ -69,7 +69,7 function move_strip($from_id, $to_id)
69 69 global $mtdb;
70 70 $from_id = (int) $from_id;
71 71 $to_id = (int) $to_id;
72
72
73 73 // Ensure our source exists
74 74 $num_strips = $mtdb->getOne( "SELECT COUNT(*) FROM strip WHERE id = $from_id" );
75 75 if($num_strips < 1)
@@ -77,7 +77,7 function move_strip($from_id, $to_id)
77 77
78 78 // Ready the destination
79 79 deletestrip( $to_id );
80
80
81 81 // Update database
82 82 $mtdb->query( "UPDATE strip SET id = $to_id WHERE id = $from_id" );
83 83 $strip = $mtdb->getRow( "SELECT strip.id, extension FROM strip, media_t WHERE media_t.id = strip.media AND strip.id = $to_id" );
@@ -100,7 +100,7 function swap_strips( $from_id, $to_id ) {
100 100 function deletestrip($id) {
101 101 $id = (int)$id;
102 102 if ( !$id ) return false;
103
103
104 104 global $mtdb;
105 105 $r = $mtdb->query( 'DELETE FROM strip WHERE id=' . $id );
106 106 foreach(glob(sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/%04d*.*', $id)) as $item)
@@ -5,12 +5,12 function bracketbalance($line)
5 5 #first, if no angle brackets, we're OK
6 6 if(substr_count($line, "<") == 0 && substr_count($line, ">") == 0)
7 7 return true;
8
8
9 9 if(substr_count($line, "<") != substr_count($line, ">"))
10 10 {
11 11 return false;
12 12 }
13
13
14 14 return true;
15 15 }
16 16
@@ -18,7 +18,7 function bracketbalance($line)
18 18 function gettranscript(&$strip)
19 19 {
20 20 global $mtdb;
21
21
22 22 $result = $mtdb->query('SELECT strip FROM transcript WHERE strip=' . (int)$strip->id );
23 23
24 24 if($result)
@@ -34,14 +34,14 function gettranscript(&$strip)
34 34 if( $numPanels ) {
35 35 for($i = 1; $i <= $numPanels; $i++) {
36 36 $result = $mtdb->query( 'SELECT speaker, speech FROM transcript WHERE transcript.strip=' . (int)$strip->id . ' AND panel=' .$i.' ORDER BY line')
37 or mtdie("There was an error fetching the panel count in the transcript for $strip->id, panel $i. " . mysql_error(), 'SQL Error');
38
37 or mtdie("There was an error fetching the panel count in the transcript for $strip->id, panel $i. " . mysqli_error(), 'SQL Error');
38
39 39 if(!$result) continue;
40
40
41 41 $output.= "\nnewpanel\n";
42 while($row = mysql_fetch_row($result)) {
42 while($row = mysqli_fetch_row($result)) {
43 43 if(strlen($row[0]) < 1) continue;
44
44
45 45 $output.= $row[0];
46 46 if($row[1] !== '') $output.= ":: ".$row[1];
47 47 $output.= "\n";
@@ -58,9 +58,9 function gettranscript(&$strip)
58 58 function savetranscript( &$strip ) {
59 59 global $mtdb;
60 60 $info = '';
61
61
62 62 $mtdb->query('START TRANSACTION');
63
63
64 64 //remove any old transcript data - it's being replaced
65 65 $mtdb->query( 'DELETE FROM transcript WHERE transcript.strip=' . (int)$strip->id );
66 66
@@ -87,7 +87,7 function savetranscript( &$strip ) {
87 87
88 88 if(strpos($lines[$j], '(') === 0) {
89 89 # Line is a note, add it as a comment
90 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, '#', mysql_real_escape_string($lines[$j]), '');
90 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, '#', mysqli_real_escape_string($mtdb->link, $lines[$j]), '');
91 91 } elseif(strpos($lines[$j], '[') === 0 || strlen($lines[$j]) == 0) {
92 92 # Line is an annotation or blank, do nothing
93 93 continue;
@@ -95,13 +95,13 function savetranscript( &$strip ) {
95 95 # Line contains a list of nonspeaking characters
96 96 array_splice($lines, $j, 1, array_map('_nospeaker', explode(',', substr($lines[$j], 11))));
97 97 $speaker = trim(substr($lines[$j], 11));
98 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysql_real_escape_string($speaker), '', '');
98 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
99 99 } elseif($i > 0 && $lines[$j] == strtoupper($lines[$j])) {
100 100 # Line designates a new speaker, note speaker
101 101
102 102 # Handle speakers who did not say anything
103 103 if(null !== $speaker && !$has_spoken)
104 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysql_real_escape_string($speaker), '', '');
104 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
105 105
106 106 $speaker = ucfirst(strtolower($lines[$j]));
107 107 $has_spoken = false;
@@ -111,29 +111,29 function savetranscript( &$strip ) {
111 111 $info .= "<p>Warning: Open brackets do not match close brackets in panel $i for speaker ".htmlentities($speaker).'</p>';
112 112
113 113 $search = preg_replace( '/[[:punct:]]|(?<=\s)\s+/', ' ', strtolower($lines[$j]) );
114 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysql_real_escape_string($speaker),
115 mysql_real_escape_string($lines[$j]), mysql_real_escape_string($search));
114 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker),
115 mysqli_real_escape_string($mtdb->link, $lines[$j]), mysqli_real_escape_string($mtdb->link, $search));
116 116 $has_spoken = true;
117 117 } else {
118 118 # Line is unrecognized, add it as a comment
119 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, '#', mysql_real_escape_string($lines[$j]), '');
119 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, '#', mysqli_real_escape_string($mtdb->link, $lines[$j]), '');
120 120 }
121 121
122 122 if( $insert_sql && false === $mtdb->query( $insert_sql ) ) {
123 123 $mtdb->query('ROLLBACK');
124 mtdie (mysql_error(), 'Error inserting transcript.');
124 mtdie (mysqli_error(), 'Error inserting transcript.');
125 125 }
126 126 }
127 127
128 128 if(null !== $speaker && !$has_spoken) {
129 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysql_real_escape_string($speaker), '', '');
129 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
130 130 if( false === $mtdb->query( $insert_sql ) ) {
131 131 $mtdb->query('ROLLBACK');
132 mtdie (mysql_error(), 'Error inserting transcript.');
132 mtdie (mysqli_error(), 'Error inserting transcript.');
133 133 }
134 134 }
135 135 }
136
136
137 137 } else {
138 138 # Assume that this is a Kalium style transcript
139 139
@@ -141,30 +141,30 function savetranscript( &$strip ) {
141 141 $numPanels = count($panels);
142 142 foreach($panels as $currPanel)
143 143 $currPanel = trim($currPanel);
144
144
145 145 for($i = 1; $i < $numPanels; $i++) {
146 146 $lines = explode("\n", $panels[$i]);
147 147 $numLines = count($lines);
148 148 foreach($lines as $currLine)
149 149 $currLine = trim($currLine);
150
150
151 151 for($j = 1; $j < $numLines; $j++) {
152 152 $spoken = explode("::", $lines[$j]); // Distinguish between speaker and speech
153
153
154 154 $spoken[0] = trim($spoken[0]); // Strip excess whitespace
155 155 $spoken[1] = trim($spoken[1]);
156
156
157 157 if(strlen($spoken[0]) < 1) continue; // Disregard null
158 158 $spoken[2] = preg_replace('/[[:punct:]]|(?<=\s)\s+/', ' ', strtolower($spoken[1]) ); // Make searchable text
159
159
160 160 if(!bracketbalance($spoken[1]))
161 161 $info .= "<p>Warning: Open brackets do not match close brackets in panel $i for speaker ".htmlentities($spoken[0]).'</p>';
162 162
163 $insert_sql = sprintf($inserter, (int)$strip->id, (int)$i, (int)$j, mysql_real_escape_string($spoken[0]),
164 mysql_real_escape_string($spoken[1]), mysql_real_escape_string($spoken[2]) );
163 $insert_sql = sprintf($inserter, (int)$strip->id, (int)$i, (int)$j, mysqli_real_escape_string($mtdb->link, $spoken[0]),
164 mysqli_real_escape_string($mtdb->link, $spoken[1]), mysqli_real_escape_string($mtdb->link, $spoken[2]) );
165 165 if( false === $mtdb->query( $insert_sql ) ) {
166 166 $mtdb->query('ROLLBACK');
167 mtdie (mysql_error(), 'Error inserting transcript.');
167 mtdie (mysqli_error(), 'Error inserting transcript.');
168 168 }
169 169 }
170 170 }
@@ -22,20 +22,20 function twitterpost($message, $user=TWITTER_USER, $password=TWITTER_PASS)
22 22 adminlog("Twitter post failed for user $user!", MTS_TWITTER, MTA_ADD);
23 23 }
24 24 return !empty($buffer);
25
25
26 26 } else {
27 27 # OAuth Mode
28 $row = $mtdb->getRow( sprintf('SELECT id, username, oauth_token, oauth_token_secret FROM twitter_user WHERE username="%s"', mysql_real_escape_string($user)));
29
28 $row = $mtdb->getRow( sprintf('SELECT id, username, oauth_token, oauth_token_secret FROM twitter_user WHERE username="%s"', mysqli_real_escape_string($mtdb->link, $user)));
29
30 30 $username = $row->username;
31 31 $oauth_token = $row->oauth_token;
32 32 $oauth_token_secret = $row->oauth_token_secret;
33
33
34 34 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
35
35
36 36 $parameters = array('status' => $message );
37 37 $status = $connection->post('statuses/update', $parameters);
38
38
39 39 switch( $connection->http_code ) {
40 40 case 200:
41 41 adminlog("Twitter post succeeded for user $username!", MTS_TWITTER, MTA_ADD);
@@ -44,10 +44,10 function twitterpost($message, $user=TWITTER_USER, $password=TWITTER_PASS)
44 44 adminlog("Twitter post failed for user $username!", MTS_TWITTER, MTA_ADD);
45 45 return false;
46 46 }
47
48
47
48
49 49 }
50
50
51 51
52 52 }
53 53
@@ -34,7 +34,7 function pre_upload_rant_image( $pathtofile ) {
34 34 $doing_upload = false;
35 35 $upload_imagetype = null;
36 36 $upload_error = false;
37
37
38 38 if( false === $image_data ) {
39 39 $upload_error='<p>Something wronky happened with that upload, getimagesize() returned false!</p>';
40 40 } elseif( 300 > $image_data[0] ) {
@@ -53,7 +53,7 function pre_upload_rant_image( $pathtofile ) {
53 53 return compact( "upload_error", "doing_upload", "upload_imagetype" );
54 54 }
55 55
56 function save_stock_rant_image( $source, $rant ) {
56 function save_stock_rant_image( $source, $rant ) {
57 57 if( copy( sprintf( '%s/%s/%s', SITE_PATH_ABS,SITE_RANT,$source),
58 58 SITE_PATH_ABS .'/'.get_rantimage_filename($rant) ) ) {
59 59 $upload_info='<p>Default rant image copied.</p>';
@@ -72,7 +72,7 function save_upload_rant_image( $source, $rant ) {
72 72 $upload_info='<p>New rant image uploaded for rant '. $rant->id .'.</p>';
73 73 } else {
74 74 $upload_error='<p>Something went wrong while moving the uploaded image.</p>';
75 }
75 }
76 76 } else {
77 77 if( crop_resize($source, $destination) ) {
78 78 $upload_info='<p>New rant image uploaded and resized for rant '. $rant->id .'.</p>';
@@ -90,14 +90,14 function save_upload_rant_attachment( $source, $rant )
90 90
91 91 $image_data = getimagesize( $source );
92 92 $mtdb->query( "INSERT INTO rant_attachment (rant, media) VALUES ($rant, $image_data[2])" );
93 $rant_attachment_id = mysql_insert_id( $mtdb->link );
93 $rant_attachment_id = mysqli_insert_id( $mtdb->link );
94 94
95 95 if( move_uploaded_file($source, SITE_PATH_ABS.'/'.get_rantattachment_filename($rant_attachment_id) ) ) {
96 96 $upload_info='<p>New rant attachment uploaded for rant '. $rant .'.</p>';
97 97 adminlog('Rant attachment uploaded', MTS_RANT, MTA_ADD);
98 98 } else {
99 99 $upload_error='<p>Something went wrong while storing the attachment.</p>';
100 }
100 }
101 101
102 102 return compact("rant_attachment_id","upload_info","upload_error");
103 103 }
@@ -8,28 +8,28 function getCurrentUser() {
8 8 }
9 9
10 10 function get_userdatabyid( $id ) {
11 global $mtdb;
11 global $mtdb;
12 12 return $mtdb->getRow( 'SELECT id,name,email,nameplate,default_image,default_link FROM contributor WHERE id = ' . (int)$id );
13 13 }
14 14
15 15 function get_userdatabylogin( $username ) {
16 16 global $mtdb;
17 return $mtdb->getRow( 'SELECT id,name,email,nameplate,default_image,default_link FROM contributor WHERE name = "' . mysql_real_escape_string($username) . '"' );
17 return $mtdb->getRow( 'SELECT id,name,email,nameplate,default_image,default_link FROM contributor WHERE name = "' . mysqli_real_escape_string($mtdb->link, $username) . '"' );
18 18 }
19 19
20 20 function save_userdata( $user ) {
21 21 adminlog("Saved changes to user ".$user->id." (".$user->name.").", MTS_USER, MTA_UPDATE);
22 22 global $mtdb;
23 23 return $mtdb->query( sprintf( 'UPDATE contributor SET email="%s", nameplate="%s", default_image="%s", default_link="%s" WHERE id=%d',
24 mysql_real_escape_string($user->email), mysql_real_escape_string($user->nameplate),
25 mysql_real_escape_string($user->default_image), mysql_real_escape_string($user->default_link), $user->id) );
24 mysqli_real_escape_string($mtdb->link, $user->email), mysqli_real_escape_string($mtdb->link, $user->nameplate),
25 mysqli_real_escape_string($mtdb->link, $user->default_image), mysqli_real_escape_string($mtdb->link, $user->default_link), $user->id) );
26 26 }
27 27
28 28 function change_password( $user ) {
29 29 adminlog("Changed password for user ".$user->id." (".$user->name.").", MTS_USER, MTA_UPDATE);
30 30 global $mtdb, $currentuser;
31 31 if( $currentuser->id === $user->id ) mt_setcookie($user->name, $user->password, false, ADMINURL, FALSE );
32 return $mtdb->query( 'UPDATE contributor SET password=SHA1( "' . mysql_real_escape_string($user->password) . '" ) WHERE id = "' . mysql_real_escape_string($user->id) . '"' );
32 return $mtdb->query( 'UPDATE contributor SET password=SHA1( "' . mysqli_real_escape_string($mtdb->link, $user->password) . '" ) WHERE id = "' . mysqli_real_escape_string($mtdb->link, $user->id) . '"' );
33 33 }
34 34
35 35 ?>
Comments 0
You need to be logged in to leave comments. Login now