diff --git a/include/cookies.php b/include/cookies.php
index 096cc37..05e2f0d 100644
--- a/include/cookies.php
+++ b/include/cookies.php
@@ -9,7 +9,7 @@ if ( !defined('USER_COOKIE') )
define('USER_COOKIE', 'megatokyoadmin_user_'. COOKIEHASH);
if ( !defined('PASS_COOKIE') )
define('PASS_COOKIE', 'megatokyoadmin_pass_'. COOKIEHASH);
-
+
if ( !defined('COOKIEPATH') )
define('COOKIEPATH', ADMIN_PATH . '/' );
if ( !defined('COOKIE_DOMAIN') )
@@ -49,4 +49,4 @@ function mt_clearcookie() {
setcookie(PASS_COOKIE, ' ', time() - 36000, COOKIEPATH );
}
-?>
\ No newline at end of file
+?>
diff --git a/include/error.php b/include/error.php
index 329a43c..3d6dc52 100644
--- a/include/error.php
+++ b/include/error.php
@@ -28,7 +28,7 @@ function adminlog($msg, $section, $action, $level=E_USER_NOTICE, $email=false)
$sql = sprintf('INSERT INTO admin_log (contributor, section, action, level, message) VALUES (%s, %d, "%s", %d, "%s")',
(is_numeric($currentuser->id) ? $currentuser->id : "NULL"), $section, mysqli_real_escape_string($mtdb->link, $action), $level, mysqli_real_escape_string($mtdb->link, $msg));
- $mtdb->query( $sql ) or die($sql."
".mysqli_error()."
\n".var_export(debug_backtrace()));
+ $mtdb->query( $sql ) or die($sql."
".mysqli_error($mtdb->link)."
\n".var_export(debug_backtrace()));
// Log all important sorts of messages in the Apache log
if( $level & (E_USER_WARNING | E_USER_ERROR) ) {
diff --git a/include/extra.php b/include/extra.php
index 0eeddef..68525b5 100644
--- a/include/extra.php
+++ b/include/extra.php
@@ -16,9 +16,9 @@ function extra_sort_file_objects($a, $b) {
function extra_handle_upload() {
global $info,$error,$dir;
-
+
if( !$_FILES['extra_file'] ) return false;
-
+
if( '' == $_FILES['extra_file']['name'] ) return false;
if( UPLOAD_ERR_NO_FILE == $_FILES['extra_file']['error'] ) return false;
if( 0 == $_FILES['extra_file']['size'] ) return false;
@@ -27,10 +27,10 @@ function extra_handle_upload() {
if(isset( $_POST['name'] )) $dest = $_POST['name'];
$dest = extra_sanitize_filename($dest);
-
+
if( !is_uploaded_file( $_FILES['extra_file']['tmp_name'] )) return false;
if( move_uploaded_file($_FILES['extra_file']['tmp_name'], $dir.'/'.$dest) ) return $true;
-
+
return false;
}
@@ -51,15 +51,15 @@ function extra_sanitize_filename( $raw_filename ) {
function extra_get_directory_list($dir) {
if( !is_dir( $dir ) ) return false;
if( ! $handle = opendir( $dir ) ) return false;
-
+
$files = array();
-
+
class ExtraFile {
var $name;
var $rwx;
var $mtime;
var $inode;
-
+
function ExtraFile($path, $file) {
$this->name = $file;
$this->fullpath = $path . $file;
@@ -69,14 +69,14 @@ function extra_get_directory_list($dir) {
$this->mtime = filemtime($this->fullpath);
$this->inode = fileinode($this->fullpath);
}
-
+
}
-
+
while (false !== ($file = readdir($handle))) {
if( is_file( $dir.'/'.$file )) $files[] = new ExtraFile($dir.'/', $file);
}
- return $files;
+ return $files;
}
-?>
\ No newline at end of file
+?>
diff --git a/include/functions.php b/include/functions.php
index 2987b56..c1af27a 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -27,14 +27,14 @@ function clean_url( $url, $protocols = null ) {
$url = str_replace($strip, '', $url);
if ( strpos($url, '://') === false && substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
-
+
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
return $url;
}
// Like htmlspecialchars except don't double-encode HTML entities
function mt_specialchars( $text, $quotes = false ) {
-
+
$text = str_replace('&&', '&&', $text);
$text = str_replace('&&', '&&', $text);
$text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&$1', $text);
@@ -72,7 +72,7 @@ function sanitize_type_name( $name ) {
function check_type_name( $name ) {
global $error;
-
+
if( $name == '' )
$error.='A type must be supplied with a name, but none was given. Valid characters include letters, numbers, apostrophes, colons, and whitespace.';
elseif ( $name !== sanitize_type_name($name) )
@@ -88,4 +88,4 @@ function _objectInArrayWithIdExists( $id, $arrobj ) {
return false;
}
-?>
\ No newline at end of file
+?>
diff --git a/include/images.php b/include/images.php
index a1c41a0..627c35d 100644
--- a/include/images.php
+++ b/include/images.php
@@ -4,7 +4,7 @@ function getimagefromfile($filename)
{
$img_data = getimagesize($filename);
$ext = image_type_to_extension($img_data[2]);
-
+
switch($ext)
{
case '.gif':
@@ -31,21 +31,21 @@ function crop_resize($filename, $dest_file)
return false;
}
$dest = imagecreatetruecolor(300, 245);
-
+
#attempt to determine scaling factor
$data = getimagesize($filename);
#300x245 reduces to 60x49
$factor = min(floor($data[0]/60), floor($data[1]/49));
#well, that should give us a good scaling factor
-
+
#now we have to determine what point to start from
$src_x = floor(($data[0]/2) - ($factor*30));
$src_y = floor(($data[1]/2) - ($factor*24.5));
-
+
#make sure we don't fuck things up
if($src_x < 0) $src_x=0;
if($src_y < 0) $src_y=0;
-
+
#now resample
imagecopyresampled($dest, $source, 0, 0, $src_x, $src_y, 300, 245, $factor*60, $factor*49);
#and output
diff --git a/include/mysql.php b/include/mysql.php
index a4dc61c..31da135 100644
--- a/include/mysql.php
+++ b/include/mysql.php
@@ -11,7 +11,7 @@ class MysqlStore {
function query($sql, $showerror = true ) {
$r = mysqli_query( $this->link, $sql );
- if( false === $r && $showerror ) echo mysqli_error();
+ if( false === $r && $showerror ) echo mysqli_error($this->link);
return $r;
}
@@ -28,7 +28,7 @@ class MysqlStore {
function getRow($sql) {
if( $r = $this->query( $sql ) ) {
if( false === $r ) {
- echo mysqli_error();
+ echo mysqli_error($this->link);
return false;
}
if( mysqli_num_rows( $r ) == 0 ) return false;
diff --git a/include/nonce.php b/include/nonce.php
index 6417760..2b11f24 100644
--- a/include/nonce.php
+++ b/include/nonce.php
@@ -76,16 +76,16 @@ function mt_explain_nonce($action) {
global $mtdb;
$c = explode('-',$action);
$i = (int)$c[2];
-
+
$message = array();
$message['rant']['new'] = 'Are you sure you want to create a new rant?';
$message['rant']['save'] = 'Are you sure you want to save changes to the rant "%s"?';
$message['rant']['delete'] = 'Are you sure you want to delete the rant "%s"? This is a destructive action, and cannot be undone!';
-
+
$message['type']['new'] = 'Are you sure you want to create a new type?';
$message['type']['save'] = 'Are you sure you want to save changes to the type "%s"?';
$message['type']['delete'] = 'Are you sure you want to delete the type "%s"? This is a destructive action, and cannot be undone!';
-
+
$message['metatype']['new'] = 'Are you sure you want to create a new metatype?';
$message['metatype']['save'] = 'Are you sure you want to save changes to the metatype "%s"?';
$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) {
$message['strip']['save'] = 'Are you sure you want to save changes to the strip "%s"?';
$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 edit the existing strip.';
$message['strip']['swap'] = 'Are you sure you want to swap these two strips? This is a destructive action, and cannot be undone!';
-
+
$message['statusbox']['update'] = 'Are you sure you want to update the statusbox information?';
$message['scratchpad']['new'] = 'Are you sure you want to update the scratchpad information?';
$message['twitter']['new'] = 'Are you sure you want to update the Twitter feed?';
-
+
$message['extra']['new'] = 'Are you sure you want to upload a new file to /extra?';
$message['extra']['delete'] = 'Are you sure you want to delete the file from /extra named "%s"?';
-
+
$message['twitteruser']['delete'] = 'Are you sure you want to delete the twitter user "%s"?';
-
+
if( isset( $message[ $c[1] ][ $c[0] ] )) {
$t = $message[ $c[1] ][ $c[0] ];
-
+
if( false !== strpos( $t, '%' ) ) {
-
+
switch( $c[1] ) {
case 'rant': $v = $mtdb->getOne('SELECT title FROM rant WHERE id=' . $i); break;
case 'strip': $v = $mtdb->getOne('SELECT id FROM strip WHERE id=' . $i); break;
@@ -118,11 +118,11 @@ function mt_explain_nonce($action) {
case 'twitteruser': $v = $mtdb->getOne('SELECT username FROM twitter_user WHERE id=' . $i); break;
default: $v = $i;
}
-
+
return sprintf( $t, mt_specialchars($v,true) );
}
- return $t;
+ return $t;
}
return "Are you sure you want to perform the action $action?";
}
@@ -131,4 +131,4 @@ function nonce_field($action) {
echo '';
}
-?>
\ No newline at end of file
+?>
diff --git a/include/transcript.php b/include/transcript.php
index cf0196d..2697e25 100644
--- a/include/transcript.php
+++ b/include/transcript.php
@@ -121,7 +121,7 @@ function savetranscript( &$strip ) {
if( $insert_sql && false === $mtdb->query( $insert_sql ) ) {
$mtdb->query('ROLLBACK');
- mtdie (mysqli_error(), 'Error inserting transcript.');
+ mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
}
}
@@ -129,7 +129,7 @@ function savetranscript( &$strip ) {
$insert_sql = sprintf($inserter, (int)$strip->id, $i, $j, mysqli_real_escape_string($mtdb->link, $speaker), '', '');
if( false === $mtdb->query( $insert_sql ) ) {
$mtdb->query('ROLLBACK');
- mtdie (mysqli_error(), 'Error inserting transcript.');
+ mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
}
}
}
@@ -164,7 +164,7 @@ function savetranscript( &$strip ) {
mysqli_real_escape_string($mtdb->link, $spoken[1]), mysqli_real_escape_string($mtdb->link, $spoken[2]) );
if( false === $mtdb->query( $insert_sql ) ) {
$mtdb->query('ROLLBACK');
- mtdie (mysqli_error(), 'Error inserting transcript.');
+ mtdie (mysqli_error($mtdb->link), 'Error inserting transcript.');
}
}
}
diff --git a/include/type.php b/include/type.php
index 907c517..e3741b3 100644
--- a/include/type.php
+++ b/include/type.php
@@ -6,7 +6,7 @@ function get_typeByID( $id ) {
global $mtdb;
$id = (int)$id;
$r = $mtdb->getRow( 'SELECT id, name, description FROM strip_t WHERE id=' . $id );
- $r->meta = $mtdb->getAll( 'SELECT meta as id from meta where type=' . $id);
+ $r->meta = $mtdb->getAll( 'SELECT meta as id from meta where type=' . $id);
return $r;
}
@@ -24,4 +24,4 @@ function _getMetaNameFromObject($obj) {
return $obj->name;
}
-?>
\ No newline at end of file
+?>