Fix calls to mysqli_error().
darkmorford -
c3da001f5ff1
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -9,7 +9,7 if ( !defined('USER_COOKIE') )
9 define('USER_COOKIE', 'megatokyoadmin_user_'. COOKIEHASH);
9 define('USER_COOKIE', 'megatokyoadmin_user_'. COOKIEHASH);
10 if ( !defined('PASS_COOKIE') )
10 if ( !defined('PASS_COOKIE') )
11 define('PASS_COOKIE', 'megatokyoadmin_pass_'. COOKIEHASH);
11 define('PASS_COOKIE', 'megatokyoadmin_pass_'. COOKIEHASH);
12
12
13 if ( !defined('COOKIEPATH') )
13 if ( !defined('COOKIEPATH') )
14 define('COOKIEPATH', ADMIN_PATH . '/' );
14 define('COOKIEPATH', ADMIN_PATH . '/' );
15 if ( !defined('COOKIE_DOMAIN') )
15 if ( !defined('COOKIE_DOMAIN') )
@@ -49,4 +49,4 function mt_clearcookie() {
49 setcookie(PASS_COOKIE, ' ', time() - 36000, COOKIEPATH );
49 setcookie(PASS_COOKIE, ' ', time() - 36000, COOKIEPATH );
50 }
50 }
51
51
52 ?> No newline at end of file
52 ?>
@@ -28,7 +28,7 function adminlog($msg, $section, $action, $level=E_USER_NOTICE, $email=false)
28
28
29 $sql = sprintf('INSERT INTO admin_log (contributor, section, action, level, message) VALUES (%s, %d, "%s", %d, "%s")',
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, mysqli_real_escape_string($mtdb->link, $action), $level, mysqli_real_escape_string($mtdb->link, $msg));
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()));
31 $mtdb->query( $sql ) or die($sql."<br>".mysqli_error($mtdb->link)."<br>\n".var_export(debug_backtrace()));
32
32
33 // Log all important sorts of messages in the Apache log
33 // Log all important sorts of messages in the Apache log
34 if( $level & (E_USER_WARNING | E_USER_ERROR) ) {
34 if( $level & (E_USER_WARNING | E_USER_ERROR) ) {
@@ -16,9 +16,9 function extra_sort_file_objects($a, $b) {
16
16
17 function extra_handle_upload() {
17 function extra_handle_upload() {
18 global $info,$error,$dir;
18 global $info,$error,$dir;
19
19
20 if( !$_FILES['extra_file'] ) return false;
20 if( !$_FILES['extra_file'] ) return false;
21
21
22 if( '' == $_FILES['extra_file']['name'] ) return false;
22 if( '' == $_FILES['extra_file']['name'] ) return false;
23 if( UPLOAD_ERR_NO_FILE == $_FILES['extra_file']['error'] ) return false;
23 if( UPLOAD_ERR_NO_FILE == $_FILES['extra_file']['error'] ) return false;
24 if( 0 == $_FILES['extra_file']['size'] ) return false;
24 if( 0 == $_FILES['extra_file']['size'] ) return false;
@@ -27,10 +27,10 function extra_handle_upload() {
27
27
28 if(isset( $_POST['name'] )) $dest = $_POST['name'];
28 if(isset( $_POST['name'] )) $dest = $_POST['name'];
29 $dest = extra_sanitize_filename($dest);
29 $dest = extra_sanitize_filename($dest);
30
30
31 if( !is_uploaded_file( $_FILES['extra_file']['tmp_name'] )) return false;
31 if( !is_uploaded_file( $_FILES['extra_file']['tmp_name'] )) return false;
32 if( move_uploaded_file($_FILES['extra_file']['tmp_name'], $dir.'/'.$dest) ) return $true;
32 if( move_uploaded_file($_FILES['extra_file']['tmp_name'], $dir.'/'.$dest) ) return $true;
33
33
34 return false;
34 return false;
35 }
35 }
36
36
@@ -51,15 +51,15 function extra_sanitize_filename( $raw_filename ) {
51 function extra_get_directory_list($dir) {
51 function extra_get_directory_list($dir) {
52 if( !is_dir( $dir ) ) return false;
52 if( !is_dir( $dir ) ) return false;
53 if( ! $handle = opendir( $dir ) ) return false;
53 if( ! $handle = opendir( $dir ) ) return false;
54
54
55 $files = array();
55 $files = array();
56
56
57 class ExtraFile {
57 class ExtraFile {
58 var $name;
58 var $name;
59 var $rwx;
59 var $rwx;
60 var $mtime;
60 var $mtime;
61 var $inode;
61 var $inode;
62
62
63 function ExtraFile($path, $file) {
63 function ExtraFile($path, $file) {
64 $this->name = $file;
64 $this->name = $file;
65 $this->fullpath = $path . $file;
65 $this->fullpath = $path . $file;
@@ -69,14 +69,14 function extra_get_directory_list($dir) {
69 $this->mtime = filemtime($this->fullpath);
69 $this->mtime = filemtime($this->fullpath);
70 $this->inode = fileinode($this->fullpath);
70 $this->inode = fileinode($this->fullpath);
71 }
71 }
72
72
73 }
73 }
74
74
75 while (false !== ($file = readdir($handle))) {
75 while (false !== ($file = readdir($handle))) {
76 if( is_file( $dir.'/'.$file )) $files[] = new ExtraFile($dir.'/', $file);
76 if( is_file( $dir.'/'.$file )) $files[] = new ExtraFile($dir.'/', $file);
77 }
77 }
78
78
79 return $files;
79 return $files;
80 }
80 }
81
81
82 ?> No newline at end of file
82 ?>
@@ -27,14 +27,14 function clean_url( $url, $protocols = null ) {
27 $url = str_replace($strip, '', $url);
27 $url = str_replace($strip, '', $url);
28 if ( strpos($url, '://') === false && substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
28 if ( strpos($url, '://') === false && substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
29 $url = 'http://' . $url;
29 $url = 'http://' . $url;
30
30
31 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
31 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
32 return $url;
32 return $url;
33 }
33 }
34
34
35 // Like htmlspecialchars except don't double-encode HTML entities
35 // Like htmlspecialchars except don't double-encode HTML entities
36 function mt_specialchars( $text, $quotes = false ) {
36 function mt_specialchars( $text, $quotes = false ) {
37
37
38 $text = str_replace('&&', '&#038;&', $text);
38 $text = str_replace('&&', '&#038;&', $text);
39 $text = str_replace('&&', '&#038;&', $text);
39 $text = str_replace('&&', '&#038;&', $text);
40 $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $text);
40 $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $text);
@@ -72,7 +72,7 function sanitize_type_name( $name ) {
72
72
73 function check_type_name( $name ) {
73 function check_type_name( $name ) {
74 global $error;
74 global $error;
75
75
76 if( $name == '' )
76 if( $name == '' )
77 $error.='A type must be supplied with a name, but none was given. Valid characters include letters, numbers, apostrophes, colons, and whitespace.';
77 $error.='A type must be supplied with a name, but none was given. Valid characters include letters, numbers, apostrophes, colons, and whitespace.';
78 elseif ( $name !== sanitize_type_name($name) )
78 elseif ( $name !== sanitize_type_name($name) )
@@ -88,4 +88,4 function _objectInArrayWithIdExists( $id, $arrobj ) {
88 return false;
88 return false;
89 }
89 }
90
90
91 ?> No newline at end of file
91 ?>
@@ -4,7 +4,7 function getimagefromfile($filename)
4 {
4 {
5 $img_data = getimagesize($filename);
5 $img_data = getimagesize($filename);
6 $ext = image_type_to_extension($img_data[2]);
6 $ext = image_type_to_extension($img_data[2]);
7
7
8 switch($ext)
8 switch($ext)
9 {
9 {
10 case '.gif':
10 case '.gif':
@@ -31,21 +31,21 function crop_resize($filename, $dest_file)
31 return false;
31 return false;
32 }
32 }
33 $dest = imagecreatetruecolor(300, 245);
33 $dest = imagecreatetruecolor(300, 245);
34
34
35 #attempt to determine scaling factor
35 #attempt to determine scaling factor
36 $data = getimagesize($filename);
36 $data = getimagesize($filename);
37 #300x245 reduces to 60x49
37 #300x245 reduces to 60x49
38 $factor = min(floor($data[0]/60), floor($data[1]/49));
38 $factor = min(floor($data[0]/60), floor($data[1]/49));
39 #well, that should give us a good scaling factor
39 #well, that should give us a good scaling factor
40
40
41 #now we have to determine what point to start from
41 #now we have to determine what point to start from
42 $src_x = floor(($data[0]/2) - ($factor*30));
42 $src_x = floor(($data[0]/2) - ($factor*30));
43 $src_y = floor(($data[1]/2) - ($factor*24.5));
43 $src_y = floor(($data[1]/2) - ($factor*24.5));
44
44
45 #make sure we don't fuck things up
45 #make sure we don't fuck things up
46 if($src_x < 0) $src_x=0;
46 if($src_x < 0) $src_x=0;
47 if($src_y < 0) $src_y=0;
47 if($src_y < 0) $src_y=0;
48
48
49 #now resample
49 #now resample
50 imagecopyresampled($dest, $source, 0, 0, $src_x, $src_y, 300, 245, $factor*60, $factor*49);
50 imagecopyresampled($dest, $source, 0, 0, $src_x, $src_y, 300, 245, $factor*60, $factor*49);
51 #and output
51 #and output
@@ -11,7 +11,7 class MysqlStore {
11
11
12 function query($sql, $showerror = true ) {
12 function query($sql, $showerror = true ) {
13 $r = mysqli_query( $this->link, $sql );
13 $r = mysqli_query( $this->link, $sql );
14 if( false === $r && $showerror ) echo mysqli_error();
14 if( false === $r && $showerror ) echo mysqli_error($this->link);
15 return $r;
15 return $r;
16 }
16 }
17
17
@@ -28,7 +28,7 class MysqlStore {
28 function getRow($sql) {
28 function getRow($sql) {
29 if( $r = $this->query( $sql ) ) {
29 if( $r = $this->query( $sql ) ) {
30 if( false === $r ) {
30 if( false === $r ) {
31 echo mysqli_error();
31 echo mysqli_error($this->link);
32 return false;
32 return false;
33 }
33 }
34 if( mysqli_num_rows( $r ) == 0 ) return false;
34 if( mysqli_num_rows( $r ) == 0 ) return false;
@@ -76,16 +76,16 function mt_explain_nonce($action) {
76 global $mtdb;
76 global $mtdb;
77 $c = explode('-',$action);
77 $c = explode('-',$action);
78 $i = (int)$c[2];
78 $i = (int)$c[2];
79
79
80 $message = array();
80 $message = array();
81 $message['rant']['new'] = 'Are you sure you want to create a new rant?';
81 $message['rant']['new'] = 'Are you sure you want to create a new rant?';
82 $message['rant']['save'] = 'Are you sure you want to save changes to the rant "%s"?';
82 $message['rant']['save'] = 'Are you sure you want to save changes to the rant "%s"?';
83 $message['rant']['delete'] = 'Are you sure you want to delete the rant "%s"? This is a destructive action, and cannot be undone!';
83 $message['rant']['delete'] = 'Are you sure you want to delete the rant "%s"? This is a destructive action, and cannot be undone!';
84
84
85 $message['type']['new'] = 'Are you sure you want to create a new type?';
85 $message['type']['new'] = 'Are you sure you want to create a new type?';
86 $message['type']['save'] = 'Are you sure you want to save changes to the type "%s"?';
86 $message['type']['save'] = 'Are you sure you want to save changes to the type "%s"?';
87 $message['type']['delete'] = 'Are you sure you want to delete the type "%s"? This is a destructive action, and cannot be undone!';
87 $message['type']['delete'] = 'Are you sure you want to delete the type "%s"? This is a destructive action, and cannot be undone!';
88
88
89 $message['metatype']['new'] = 'Are you sure you want to create a new metatype?';
89 $message['metatype']['new'] = 'Are you sure you want to create a new metatype?';
90 $message['metatype']['save'] = 'Are you sure you want to save changes to the metatype "%s"?';
90 $message['metatype']['save'] = 'Are you sure you want to save changes to the metatype "%s"?';
91 $message['metatype']['delete'] = 'Are you sure you want to delete the metatype "%s"? This is a destructive action, and cannot be undone!';
91 $message['metatype']['delete'] = 'Are you sure you want to delete the metatype "%s"? This is a destructive action, and cannot be undone!';
@@ -94,21 +94,21 function mt_explain_nonce($action) {
94 $message['strip']['save'] = 'Are you sure you want to save changes to the strip "%s"?';
94 $message['strip']['save'] = 'Are you sure you want to save changes to the strip "%s"?';
95 $message['strip']['delete'] = 'Are you sure you want to delete the comic strip "%1$s"? This will break site navigation, which can be fixed by changing other strip numbers. This is a destructive action, and cannot be undone! It is far better to <a href="edit-comic.php?strip_id=%1$s">edit the existing strip</a>.';
95 $message['strip']['delete'] = 'Are you sure you want to delete the comic strip "%1$s"? This will break site navigation, which can be fixed by changing other strip numbers. This is a destructive action, and cannot be undone! It is far better to <a href="edit-comic.php?strip_id=%1$s">edit the existing strip</a>.';
96 $message['strip']['swap'] = 'Are you sure you want to swap these two strips? This is a destructive action, and cannot be undone!';
96 $message['strip']['swap'] = 'Are you sure you want to swap these two strips? This is a destructive action, and cannot be undone!';
97
97
98 $message['statusbox']['update'] = 'Are you sure you want to update the statusbox information?';
98 $message['statusbox']['update'] = 'Are you sure you want to update the statusbox information?';
99 $message['scratchpad']['new'] = 'Are you sure you want to update the scratchpad information?';
99 $message['scratchpad']['new'] = 'Are you sure you want to update the scratchpad information?';
100 $message['twitter']['new'] = 'Are you sure you want to update the Twitter feed?';
100 $message['twitter']['new'] = 'Are you sure you want to update the Twitter feed?';
101
101
102 $message['extra']['new'] = 'Are you sure you want to upload a new file to /extra?';
102 $message['extra']['new'] = 'Are you sure you want to upload a new file to /extra?';
103 $message['extra']['delete'] = 'Are you sure you want to delete the file from /extra named "%s"?';
103 $message['extra']['delete'] = 'Are you sure you want to delete the file from /extra named "%s"?';
104
104
105 $message['twitteruser']['delete'] = 'Are you sure you want to delete the twitter user "%s"?';
105 $message['twitteruser']['delete'] = 'Are you sure you want to delete the twitter user "%s"?';
106
106
107 if( isset( $message[ $c[1] ][ $c[0] ] )) {
107 if( isset( $message[ $c[1] ][ $c[0] ] )) {
108 $t = $message[ $c[1] ][ $c[0] ];
108 $t = $message[ $c[1] ][ $c[0] ];
109
109
110 if( false !== strpos( $t, '%' ) ) {
110 if( false !== strpos( $t, '%' ) ) {
111
111
112 switch( $c[1] ) {
112 switch( $c[1] ) {
113 case 'rant': $v = $mtdb->getOne('SELECT title FROM rant WHERE id=' . $i); break;
113 case 'rant': $v = $mtdb->getOne('SELECT title FROM rant WHERE id=' . $i); break;
114 case 'strip': $v = $mtdb->getOne('SELECT id FROM strip WHERE id=' . $i); break;
114 case 'strip': $v = $mtdb->getOne('SELECT id FROM strip WHERE id=' . $i); break;
@@ -118,11 +118,11 function mt_explain_nonce($action) {
118 case 'twitteruser': $v = $mtdb->getOne('SELECT username FROM twitter_user WHERE id=' . $i); break;
118 case 'twitteruser': $v = $mtdb->getOne('SELECT username FROM twitter_user WHERE id=' . $i); break;
119 default: $v = $i;
119 default: $v = $i;
120 }
120 }
121
121
122 return sprintf( $t, mt_specialchars($v,true) );
122 return sprintf( $t, mt_specialchars($v,true) );
123 }
123 }
124
124
125 return $t;
125 return $t;
126 }
126 }
127 return "Are you sure you want to perform the action $action?";
127 return "Are you sure you want to perform the action $action?";
128 }
128 }
@@ -131,4 +131,4 function nonce_field($action) {
131 echo '<input type="hidden" name="_mtnonce" value="' . create_nonce($action) . '" />';
131 echo '<input type="hidden" name="_mtnonce" value="' . create_nonce($action) . '" />';
132 }
132 }
133
133
134 ?> No newline at end of file
134 ?>
@@ -121,7 +121,7 function savetranscript( &$strip ) {
121
121
122 if( $insert_sql && false === $mtdb->query( $insert_sql ) ) {
122 if( $insert_sql && false === $mtdb->query( $insert_sql ) ) {
123 $mtdb->query('ROLLBACK');
123 $mtdb->query('ROLLBACK');
124 mtdie (mysqli_error(), 'Error inserting transcript.');
124 mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
125 }
125 }
126 }
126 }
127
127
@@ -129,7 +129,7 function savetranscript( &$strip ) {
129 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
129 $insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
130 if( false === $mtdb->query( $insert_sql ) ) {
130 if( false === $mtdb->query( $insert_sql ) ) {
131 $mtdb->query('ROLLBACK');
131 $mtdb->query('ROLLBACK');
132 mtdie (mysqli_error(), 'Error inserting transcript.');
132 mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
133 }
133 }
134 }
134 }
135 }
135 }
@@ -164,7 +164,7 function savetranscript( &$strip ) {
164 mysqli_real_escape_string($mtdb->link, $spoken[1]), mysqli_real_escape_string($mtdb->link, $spoken[2]) );
164 mysqli_real_escape_string($mtdb->link, $spoken[1]), mysqli_real_escape_string($mtdb->link, $spoken[2]) );
165 if( false === $mtdb->query( $insert_sql ) ) {
165 if( false === $mtdb->query( $insert_sql ) ) {
166 $mtdb->query('ROLLBACK');
166 $mtdb->query('ROLLBACK');
167 mtdie (mysqli_error(), 'Error inserting transcript.');
167 mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
168 }
168 }
169 }
169 }
170 }
170 }
@@ -6,7 +6,7 function get_typeByID( $id ) {
6 global $mtdb;
6 global $mtdb;
7 $id = (int)$id;
7 $id = (int)$id;
8 $r = $mtdb->getRow( 'SELECT id, name, description FROM strip_t WHERE id=' . $id );
8 $r = $mtdb->getRow( 'SELECT id, name, description FROM strip_t WHERE id=' . $id );
9 $r->meta = $mtdb->getAll( 'SELECT meta as id from meta where type=' . $id);
9 $r->meta = $mtdb->getAll( 'SELECT meta as id from meta where type=' . $id);
10 return $r;
10 return $r;
11 }
11 }
12
12
@@ -24,4 +24,4 function _getMetaNameFromObject($obj) {
24 return $obj->name;
24 return $obj->name;
25 }
25 }
26
26
27 ?> No newline at end of file
27 ?>
Comments 0
You need to be logged in to leave comments. Login now