diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fe67d00
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+plog-config.php
+.idea
diff --git a/.htaccess b/.htaccess
index e69de29..f3323bb 100644
--- a/.htaccess
+++ b/.htaccess
@@ -0,0 +1,4 @@
+
+
+# BEGIN Plogger
+# END Plogger
diff --git a/plog-admin/includes/install-functions.php b/plog-admin/includes/install-functions.php
index 97dff83..7ea898f 100644
--- a/plog-admin/includes/install-functions.php
+++ b/plog-admin/includes/install-functions.php
@@ -10,13 +10,13 @@ require_once(PLOGGER_DIR.'plog-admin/plog-admin-functions.php');
function maybe_add_column($table, $column, $add_sql) {
$sql = "DESCRIBE $table";
- $res = mysql_query($sql);
+ $res = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
$found = false;
- while($row = mysql_fetch_array($res, MYSQL_NUM)) {
+ while($row = mysqli_fetch_array($res, MYSQL_NUM)) {
if ($row[0] == $column) $found = true;
}
if (!$found) {
- mysql_query("ALTER TABLE $table ADD `$column` ".$add_sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],"ALTER TABLE $table ADD `$column` ".$add_sql);
return plog_tr('Added new field to database').': '.$column;
} else {
if (defined('PLOGGER_DEBUG')) {
@@ -28,14 +28,14 @@ function maybe_add_column($table, $column, $add_sql) {
function maybe_drop_column($table, $column) {
$sql = "DESCRIBE $table";
- $res = mysql_query($sql);
+ $res = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
$found = false;
- while($row = mysql_fetch_array($res, MYSQL_NUM)) {
+ while($row = mysqli_fetch_array($res, MYSQL_NUM)) {
if ($row[0] == $column) $found = true;
}
if ($found) {
$sql = "ALTER TABLE $table DROP `$column`";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
return plog_tr('Dropped column').': '.$column;
} else {
if (defined('PLOGGER_DEBUG')) {
@@ -47,12 +47,12 @@ function maybe_drop_column($table, $column) {
function maybe_add_table($table, $add_sql, $options = '') {
$sql = "DESCRIBE $table";
- $res = mysql_query($sql);
+ $res = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
if (!$res) {
$q = "CREATE table `$table` ($add_sql) $options";
- mysql_query($q);
- if (mysql_error()) {
- var_dump(mysql_error());
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$q);
+ if (mysqli_error($GLOBALS["PLOGGER_DBH"])) {
+ var_dump(mysqli_error($GLOBALS["PLOGGER_DBH"]));
} else {
return true;
}
@@ -68,7 +68,7 @@ function get_default_charset() {
// Since 4.1 MySQL has support for specifying character encoding for tables
// and I really want to use it if available. So we need figure out what version
// we are running on and to the right thing
- $mysql_version = mysql_get_server_info();
+ $mysql_version = mysqli_get_server_info($GLOBALS["PLOGGER_DBH"]);
$mysql_charset_support = '4.1';
$default_charset = '';
@@ -351,7 +351,7 @@ function create_tables() {
`id` int(11) NOT NULL auto_increment,
`thumbnail_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'albums'
@@ -363,7 +363,7 @@ function create_tables() {
`thumbnail_id` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
INDEX pid_idx (`parent_id`)"
- ," Type=MyISAM $default_charset");
+ ," Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'pictures'
@@ -373,8 +373,8 @@ function create_tables() {
`caption` mediumtext NOT NULL,
`description` text NOT NULL,
`id` int(11) NOT NULL auto_increment,
- `date_modified` timestamp(14) NOT NULL,
- `date_submitted` timestamp(14) NOT NULL,
+ `date_modified` timestamp(6) NOT NULL,
+ `date_submitted` timestamp(6) NOT NULL,
`EXIF_date_taken` varchar(64) NOT NULL default '',
`EXIF_camera` varchar(64) NOT NULL default '',
`EXIF_shutterspeed` varchar(64) NOT NULL default '',
@@ -386,7 +386,7 @@ function create_tables() {
PRIMARY KEY (`id`),
INDEX pa_idx (`parent_album`),
INDEX pc_idx (`parent_collection`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'comments'
@@ -402,7 +402,7 @@ function create_tables() {
PRIMARY KEY (`id`),
INDEX pid_idx (`parent_id`),
INDEX approved_idx (`approved`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'config'
@@ -435,7 +435,7 @@ function create_tables() {
`thumb_nav_range` int(11) NOT NULL default '0',
`allow_fullpic` tinyint default '1',
PRIMARY KEY (`thumb_num`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'thumbnail_config'
@@ -445,7 +445,7 @@ function create_tables() {
`disabled` tinyint default '0',
`resize_option` tinyint default '2',
PRIMARY KEY (`id`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
/*maybe_add_table(
PLOGGER_TABLE_PREFIX.'tag2picture'
@@ -454,7 +454,7 @@ function create_tables() {
`tagdate` datetime default NULL,
KEY `tag_id` (`tag_id`),
KEY `picture_id` (`picture_id`)"
- ,"Type=MyISAM $default_charset");
+ ,"Engine=MyISAM $default_charset");
maybe_add_table(
PLOGGER_TABLE_PREFIX.'tags'
@@ -465,7 +465,7 @@ function create_tables() {
PRIMARY KEY (`id`),
UNIQUE `tag` (`tag`),
UNIQUE `urlified` (`urlified`)"
- ,"Type=MyISAM $default_charset");*/
+ ,"Engine=MyISAM $default_charset");*/
}
@@ -484,7 +484,7 @@ function configure_plogger($form) {
$resize = ($key == THUMB_SMALL || $key == THUMB_NAV) ? 3: 2;
$sql = "INSERT INTO `".PLOGGER_TABLE_PREFIX."thumbnail_config` (`id`, `update_timestamp`, `max_size`, `resize_option`)
VALUES('$key', '$long_ago', '$size', '$resize')";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
$config['gallery_url'] = 'http://'.$_SERVER['SERVER_NAME'].dirname(dirname($_SERVER['PHP_SELF']));
@@ -507,8 +507,8 @@ function configure_plogger($form) {
$config = array_map('mysql_real_escape_string', $config);
- $row_exist = mysql_query("SELECT * FROM `".PLOGGER_TABLE_PREFIX."config`");
- $row_exist_num = mysql_num_rows($row_exist);
+ $row_exist = mysqli_query($GLOBALS["PLOGGER_DBH"],"SELECT * FROM `".PLOGGER_TABLE_PREFIX."config`");
+ $row_exist_num = mysqli_num_rows($row_exist);
if ($row_exist_num == 0) {
$query = "INSERT INTO `".PLOGGER_TABLE_PREFIX."config`
@@ -546,7 +546,7 @@ function configure_plogger($form) {
`gallery_name` = '${config['gallery_name']}',
`gallery_url` = '${config['gallery_url']}'";
}
- mysql_query($query);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
// Create the FTP columns in the config table if safe_mode enabled/
if (is_safe_mode() && isset($_SESSION['ftp_values'])) {
@@ -570,11 +570,11 @@ function configure_ftp($form) {
maybe_add_column(PLOGGER_TABLE_PREFIX.'config', 'ftp_pass', "varchar(64) NOT NULL default ''");
maybe_add_column(PLOGGER_TABLE_PREFIX.'config', 'ftp_path', "varchar(255) NOT NULL default ''");
$query = "UPDATE `".PLOGGER_TABLE_PREFIX."config` SET
- `ftp_host` = '".mysql_real_escape_string($form['ftp_host'])."',
- `ftp_user` = '".mysql_real_escape_string($form['ftp_user'])."',
- `ftp_pass` = '".mysql_real_escape_string($form['ftp_pass'])."',
- `ftp_path` = '".mysql_real_escape_string($form['ftp_path'])."'";
- mysql_query($query);
+ `ftp_host` = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$form['ftp_host'])."',
+ `ftp_user` = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$form['ftp_user'])."',
+ `ftp_pass` = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$form['ftp_pass'])."',
+ `ftp_path` = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$form['ftp_path'])."'";
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
}
function fix_open_perms($dirs, $action = 'rename') {
@@ -664,7 +664,7 @@ function upgrade_database() {
if (!isset($thumbnail_config[THUMB_SMALL]) || empty($thumbnail_config[THUMB_SMALL]['size'])) {
$sql = "INSERT INTO `".PLOGGER_TABLE_PREFIX."thumbnail_config` (id, update_timestamp, max_size)
VALUES('".THUMB_SMALL."', '".$long_ago."', '".$config['max_thumbnail_size']."')";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
if (!isset($config['max_display_size'])) {
@@ -673,7 +673,7 @@ function upgrade_database() {
if (!isset($thumbnail_config[THUMB_LARGE]) || empty($thumbnail_config[THUMB_LARGE]['size'])) {
$sql = "INSERT INTO `".PLOGGER_TABLE_PREFIX."thumbnail_config` (id, update_timestamp, max_size)
VALUES('".THUMB_LARGE."', '".$long_ago."', '".$config['max_display_size']."')";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
if (!isset($config['rss_thumbsize'])) {
@@ -682,7 +682,7 @@ function upgrade_database() {
if (!isset($thumbnail_config[THUMB_RSS]) || empty($thumbnail_config[THUMB_RSS]['size'])) {
$sql = "INSERT INTO `".PLOGGER_TABLE_PREFIX."thumbnail_config` (id, update_timestamp, max_size)
VALUES('".THUMB_RSS."', '".$long_ago."', '".$config['rss_thumbsize']."')";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
if (!isset($config['nav_thumbsize'])) {
@@ -691,7 +691,7 @@ function upgrade_database() {
if (!isset($thumbnail_config[THUMB_NAV]) || empty($thumbnail_config[THUMB_NAV]['size'])) {
$sql = "INSERT INTO `".PLOGGER_TABLE_PREFIX."thumbnail_config` (id, update_timestamp, max_size)
VALUES('".THUMB_NAV."', '".$long_ago."', '".$config['nav_thumbsize']."')";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
}
@@ -709,19 +709,19 @@ function upgrade_database() {
// Make sure to set the resize_option to square for small thumbs if previously set
if (isset($config['square_thumbs']) && $config['square_thumbs'] == 1) {
$sql = "UPDATE `".PLOGGER_TABLE_PREFIX."thumbnail_config` SET `resize_option` = '3' WHERE `id` = '".THUMB_SMALL."'";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
// Move enable_thumb_nav setting to plogger_thumbnail_config table
if (isset($config['enable_thumb_nav'])) {
$disabled = ($config['enable_thumb_nav'] == 0) ? 1 : 0;
$sql = "UPDATE `".PLOGGER_TABLE_PREFIX."thumbnail_config` SET `disabled` = '$disabled' WHERE `id` = '".THUMB_NAV."'";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
// set navigation thumbnails to square
$sql = "UPDATE `".PLOGGER_TABLE_PREFIX."thumbnail_config` SET `resize_option` = '3' WHERE `id` = '".THUMB_NAV."'";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
/** plogger_config **/
@@ -783,14 +783,14 @@ function upgrade_database() {
$config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].dirname(dirname($_SERVER['PHP_SELF'])).'/';
$output[] = plog_tr('Setting gallery url to ').$config['baseurl'];
$sql = "UPDATE `".PLOGGER_TABLE_PREFIX."config` SET gallery_url = '".$config['baseurl']."'";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
// Insert default theme directory if not already set
if (!isset($config['theme_dir']) || empty($config['theme_dir'])) {
$output[] = plog_tr('Setting default theme directory to \'default\'');
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."config SET `theme_dir` = 'default' WHERE 1";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
}
/** plogger_collections **/
@@ -866,17 +866,17 @@ function upgrade_database() {
");*/
$sql = 'ALTER TABLE '.PLOGGER_TABLE_PREFIX.'comments ADD INDEX approved_idx (`approved`)';
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
// Add ip and approved fields to comments table
$sql = 'ALTER TABLE '.PLOGGER_TABLE_PREFIX.'comments CHANGE `date` `date` datetime';
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
// Convert charsets
// Since 4.1 MySQL has support for specifying character encoding for tables
// and I really want to use it if available. So we need figure out what version
// we are running on and to the right hting
- $mysql_version = mysql_get_server_info();
+ $mysql_version = mysqli_get_server_info($GLOBALS["PLOGGER_DBH"]);
$mysql_charset_support = '4.1';
$default_charset = '';
@@ -886,8 +886,8 @@ function upgrade_database() {
foreach($tables as $table) {
$tablename = PLOGGER_TABLE_PREFIX.$table;
$sql = "ALTER TABLE $tablename DEFAULT CHARACTER SET $charset";
- if (!mysql_query($sql)) {
- $output[] = "failed to convert $tablename to $charset
".mysql_error();
+ if (!mysqli_query($GLOBALS["PLOGGER_DBH"],$sql)) {
+ $output[] = "failed to convert $tablename to $charset
".mysqli_error($GLOBALS["PLOGGER_DBH"]);
}
}
}
@@ -901,14 +901,14 @@ function upgrade_image_list() {
// Strip 'images/' prefix from pictures table
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET path = SUBSTRING(path,8) WHERE SUBSTRING(path,1,7) = 'images/'";
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
// Update 'path' for collections table
$sql = "SELECT id,name FROM ".PLOGGER_TABLE_PREFIX."collections";
- $result = mysql_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
+ while($row = mysqli_fetch_assoc($result)) {
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."collections SET path = '".strtolower(sanitize_filename($row['name']))."' WHERE id = ".$row['id'];
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
if (!file_exists(PLOGGER_DIR.'plog-content/images/'.strtolower(sanitize_filename($row['name'])))) {
$list[$total] = array('container' => 1, 'new_path' => 'plog-content/images/'.strtolower(sanitize_filename($row['name'])));
$total++;
@@ -919,10 +919,10 @@ function upgrade_image_list() {
$sql = "SELECT a.id AS id, a.name AS name, c.path AS collection_path
FROM ".PLOGGER_TABLE_PREFIX."albums a, ".PLOGGER_TABLE_PREFIX."collections c
WHERE a.parent_id = c.id";
- $result = mysql_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
+ while($row = mysqli_fetch_assoc($result)) {
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."albums SET path = '".strtolower(sanitize_filename($row['name']))."' WHERE id = ".$row['id'];
- mysql_query($sql);
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
if (!file_exists(PLOGGER_DIR.'plog-content/images/'.$row['collection_path'].'/'.strtolower(sanitize_filename($row['name'])))) {
$list[$total] = array('container' => 1, 'new_path' => 'plog-content/images/'.$row['collection_path'].'/'.strtolower(sanitize_filename($row['name'])));
$total++;
@@ -933,9 +933,9 @@ function upgrade_image_list() {
$sql = "SELECT p.path AS path, p.id AS pid,c.path AS collection_path, a.path AS album_path
FROM ".PLOGGER_TABLE_PREFIX."albums a, ".PLOGGER_TABLE_PREFIX."pictures p, ".PLOGGER_TABLE_PREFIX."collections c
WHERE p.parent_album = a.id AND p.parent_collection = c.id";
- $result = mysql_query($sql);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$sql);
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$filename = sanitize_filename(basename($row['path']));
$c_directory = $row['collection_path'].'/';
$a_directory = $row['collection_path'].'/'.$row['album_path'].'/';
@@ -996,7 +996,7 @@ function upgrade_images($num, $list) {
@chmod(PLOGGER_DIR.$new_path, PLOGGER_CHMOD_DIR);
$output[] = sprintf(plog_tr('Moved file %s -> %s'), ''.$image['old_path'].'', ''.'plog-content/images/'.$image['new_path'].'');
// Update database
- $sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET path = '".mysql_real_escape_string($image['new_path'])."' WHERE id = '".$image['id']."'";
+ $sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET path = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$image['new_path'])."' WHERE id = '".$image['id']."'";
run_query($sql);
// Generate a new small thumbnail after database has been updated in case script times out
$thumbpath = generate_thumb($image['new_path'], $image['id'], THUMB_SMALL);
@@ -1142,4 +1142,4 @@ function cleanup_files($files, $folders) {
return array('errors' => $errors, 'output' => $output);
}
-?>
\ No newline at end of file
+?>
diff --git a/plog-admin/plog-admin-functions.php b/plog-admin/plog-admin-functions.php
index 19f15c3..85735d7 100644
--- a/plog-admin/plog-admin-functions.php
+++ b/plog-admin/plog-admin-functions.php
@@ -235,7 +235,7 @@ function add_picture($album_id, $tmpname, $filename, $caption, $desc, $allow_com
WHERE c.id = a.parent_id AND a.id = '$album_id'";
$sql_result = run_query($sql);
- $albumdata = mysql_fetch_assoc($sql_result);
+ $albumdata = mysqli_fetch_assoc($sql_result);
// This shouldn't happen in normal cases
if (empty($albumdata)) {
@@ -323,24 +323,24 @@ function add_picture($album_id, $tmpname, $filename, $caption, $desc, $allow_com
VALUES
('".$albumdata['collection_id']."',
'".$albumdata['album_id']."',
- '".mysql_real_escape_string($picture_path)."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$picture_path)."',
NOW(),
NOW(),
".intval($allow_comm).",
- '".mysql_real_escape_string($exif['date_taken'])."',
- '".mysql_real_escape_string($exif['camera'])."',
- '".mysql_real_escape_string($exif['shutter_speed'])."',
- '".mysql_real_escape_string($exif['focal_length'])."',
- '".mysql_real_escape_string($exif['flash'])."',
- '".mysql_real_escape_string($exif['aperture'])."',
- '".mysql_real_escape_string($exif['iso'])."',
- '".mysql_real_escape_string($caption)."',
- '".mysql_real_escape_string($desc)."')";
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['date_taken'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['camera'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['shutter_speed'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['focal_length'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['flash'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['aperture'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$exif['iso'])."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$caption)."',
+ '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$desc)."')";
$sql_result = run_query($query);
$result['output'] .= sprintf(plog_tr('Your image %s was uploaded successfully.'), ''.$filename.'');
- $result['picture_id'] = mysql_insert_id();
+ $result['picture_id'] = mysqli_insert_id($GLOBALS["PLOGGER_DBH"]);
// Let's generate the thumbnail and the large thumbnail right away.
// This way, the user won't see any latency from the thumbnail generation
@@ -357,19 +357,19 @@ function add_picture($album_id, $tmpname, $filename, $caption, $desc, $allow_com
function update_picture($id, $caption, $allow_comments, $description) {
$id = intval($id);
- $caption = mysql_real_escape_string($caption);
- $description = mysql_real_escape_string($description);
+ $caption = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$caption);
+ $description = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$description);
$allow_comments = intval($allow_comments);
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET
caption = '$caption',
description = '$description',
allow_comments = '$allow_comments'
WHERE id='$id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected picture.'));
} else {
- return array('errors' => mysql_error());
+ return array('errors' => mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
}
@@ -382,11 +382,11 @@ function update_picture_field($picture_id, $field, $value) {
$errors = $output = '';
$picture_id = intval($picture_id);
- $value = mysql_real_escape_string(trim($value));
+ $value = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],trim($value));
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET $field = '$value' WHERE id='$picture_id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected picture.'));
} else {
@@ -403,7 +403,7 @@ function move_picture($pic_id, $to_album) {
$query = "SELECT * FROM ".PLOGGER_TABLE_PREFIX."albums WHERE `id` = '".$to_album."'";
$result = run_query($query);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
if (!is_array($row)) {
return array('errors' => sprintf(plog_tr('There is no album with id %s.'), ''.$to_album.''));
@@ -470,12 +470,12 @@ function move_picture($pic_id, $to_album) {
// Update database
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET
- path = '".mysql_real_escape_string($picture_path)."',
+ path = '".mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$picture_path)."',
parent_album = '".$to_album."',
parent_collection = '".$new_collection."'
WHERE id = '".$pic_id."'";
- if (!mysql_query($sql)) {
- return array('errors' => mysql_error());
+ if (!mysqli_query($GLOBALS["PLOGGER_DBH"],$sql)) {
+ return array('errors' => mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
return array('output' => plog_tr('Success'));
}
@@ -570,12 +570,12 @@ function add_collection($collection_name, $description) {
if (!makeDirs($create_path)) {
$errors .= sprintf(plog_tr('Could not create directory %s!'), ''.$create_path.'');
} else {
- $sql_name = mysql_real_escape_string($collection_name);
- $description = mysql_real_escape_string($description);
- $collection_folder = mysql_real_escape_string($collection_folder);
+ $sql_name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$collection_name);
+ $description = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$description);
+ $collection_folder = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$collection_folder);
$query = "INSERT INTO ".PLOGGER_TABLE_PREFIX."collections (`name`,`description`,`path`) VALUES ('$sql_name', '$description', '$collection_folder')";
$result = run_query($query);
- $id = mysql_insert_id();
+ $id = mysqli_insert_id($GLOBALS["PLOGGER_DBH"]);
$output .= sprintf(plog_tr('You have successfully created the collection %s.'), ''.$collection_name.'');
}
@@ -609,8 +609,8 @@ function update_collection($collection_id, $name, $description, $thumbnail_id =
$collection_id = intval($collection_id);
$thumbnail_id = intval($thumbnail_id);
- $name = mysql_real_escape_string($name);
- $description = mysql_real_escape_string($description);
+ $name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$name);
+ $description = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$description);
// Rename the directory
// First, get the collection name of our source collection
@@ -619,7 +619,7 @@ function update_collection($collection_id, $name, $description, $thumbnail_id =
WHERE c.id = '$collection_id'";
$result = run_query($sql);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
$source_collection_name = SmartStripSlashes($row['collection_path']);
$source_path = $config['basedir'].'plog-content/images/'.$source_collection_name;
@@ -650,12 +650,12 @@ function update_collection($collection_id, $name, $description, $thumbnail_id =
}
}
- $target_name = mysql_real_escape_string($target_name);
+ $target_name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$target_name);
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."collections SET name = '$name', path = '$target_name', description = '$description', thumbnail_id = '$thumbnail_id' WHERE id='$collection_id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if (!$result) {
- return array('errors' => mysql_error());
+ return array('errors' => mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
$output = plog_tr('You have successfully modified the selected collection.');
@@ -670,16 +670,16 @@ function update_collection($collection_id, $name, $description, $thumbnail_id =
$result = run_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$filename = basename($row['path']);
$album_path = $row['album_path'];
- $new_path = mysql_real_escape_string(SmartStripSlashes($target_name.'/'.$album_path.'/'.$filename));
+ $new_path = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],SmartStripSlashes($target_name.'/'.$album_path.'/'.$filename));
// Update database
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET path = '$new_path' WHERE id = '$row[id]'";
- mysql_query($sql) or ($output .= mysql_error());
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql) or ($output .= mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
return array(
@@ -697,11 +697,11 @@ function update_collection_field($collection_id, $field, $value) {
$errors = $output = '';
$collection_id = intval($collection_id);
- $value = mysql_real_escape_string(trim($value));
+ $value = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],trim($value));
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."collections SET $field = '$value' WHERE id='$collection_id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected collection.'));
} else {
@@ -717,7 +717,7 @@ function delete_collection($del_id) {
WHERE c.id = '$del_id'";
$result = run_query($sql);
- $collection = mysql_fetch_assoc($result);
+ $collection = mysqli_fetch_assoc($result);
if (!$collection) {
return array('errors' => plog_tr('No such collection.'));
@@ -726,7 +726,7 @@ function delete_collection($del_id) {
// First delete all albums registered with this album
$sql = 'SELECT * FROM '.PLOGGER_TABLE_PREFIX.'albums WHERE parent_id = '.$collection['collection_id'];
$result = run_query($sql);
- while ($row = mysql_fetch_assoc($result)) {
+ while ($row = mysqli_fetch_assoc($result)) {
delete_album($row['id']);
}
@@ -768,7 +768,7 @@ function add_album($album_name, $description, $pid) {
$query = "SELECT c.path as collection_path FROM ". PLOGGER_TABLE_PREFIX."collections c WHERE id = '$pid'";
$result = run_query($query);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
// This shouldn't happen
if (empty($row)) {
@@ -800,12 +800,12 @@ function add_album($album_name, $description, $pid) {
if (!makeDirs($create_path)) {
$errors .= sprintf(plog_tr('Could not create directory %s!'), ''.$path.'');
} else {
- $sql_name = mysql_real_escape_string($album_name);
- $description = mysql_real_escape_string($description);
- $album_folder = mysql_real_escape_string($album_folder);
+ $sql_name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$album_name);
+ $description = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$description);
+ $album_folder = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$album_folder);
$query = "INSERT INTO ".PLOGGER_TABLE_PREFIX."albums (`name`,`description`,`parent_id`,`path`) VALUES ('$sql_name', '$description', '$pid', '$album_folder')";
$result = run_query($query);
- $id = mysql_insert_id();
+ $id = mysqli_insert_id($GLOBALS["PLOGGER_DBH"]);
$output .= sprintf(plog_tr('You have successfully created the album %s.'), ''.$album_name.'');
}
@@ -826,8 +826,8 @@ function update_album($album_id, $name, $description, $thumbnail_id = 0) {
$album_id = intval($album_id);
$thumbnail_id = intval($thumbnail_id);
- $name = mysql_real_escape_string(SmartStripSlashes(trim($name)));
- $description = mysql_real_escape_string(SmartStripSlashes($description));
+ $name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],SmartStripSlashes(trim($name)));
+ $description = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],SmartStripSlashes($description));
if (empty($name)) {
return array('errors' => plog_tr('Please enter a valid name for the album.'));
}
@@ -840,7 +840,7 @@ function update_album($album_id, $name, $description, $thumbnail_id = 0) {
WHERE c.id = a.parent_id AND a.id = ".$album_id;
$result = run_query($sql);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
$source_album_name = SmartStripSlashes($row['album_path']);
$source_collection_name = SmartStripSlashes($row['collection_path']);
@@ -873,7 +873,7 @@ function update_album($album_id, $name, $description, $thumbnail_id = 0) {
}
}
- $target_name = mysql_real_escape_string($target_name);
+ $target_name = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$target_name);
// Proceed only if rename succeeded
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."albums SET
@@ -883,9 +883,9 @@ function update_album($album_id, $name, $description, $thumbnail_id = 0) {
path = '$target_name'
WHERE id='$album_id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if (!$result) {
- return array('errors' => mysql_error());
+ return array('errors' => mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
$output .= plog_tr('You have successfully modified the selected album.');
@@ -897,14 +897,14 @@ function update_album($album_id, $name, $description, $thumbnail_id = 0) {
$result = run_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$filename = basename($row['path']);
- $new_path = mysql_real_escape_string(SmartStripSlashes($source_collection_name.'/'.$target_name.'/'.$filename));
+ $new_path = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],SmartStripSlashes($source_collection_name.'/'.$target_name.'/'.$filename));
// Update database
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET path = '$new_path' WHERE id = '$row[id]'";
- mysql_query($sql) or ($errors .= mysql_error());
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql) or ($errors .= mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
return array(
@@ -919,7 +919,7 @@ function update_album_field($album_id, $field, $value) {
return array('errors' => plog_tr('Invalid action'));
}
- $value = mysql_real_escape_string(trim(SmartStripSlashes($value)));
+ $value = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],trim(SmartStripSlashes($value)));
$errors = $output = '';
$album_id = intval($album_id);
@@ -928,7 +928,7 @@ function update_album_field($album_id, $field, $value) {
$field = '$value'
WHERE id='$album_id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected album.'));
@@ -957,7 +957,7 @@ function move_album($album_id, $to_collection) {
WHERE c.id = a.parent_id AND a.id = '$album_id'";
$result = run_query($sql);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
$source_album_name = SmartStripSlashes($row['album_path']);
$source_collection_name = SmartStripSlashes($row['collection_path']);
@@ -973,7 +973,7 @@ function move_album($album_id, $to_collection) {
$sql = "SELECT c.path as collection_path FROM ".PLOGGER_TABLE_PREFIX."collections c WHERE c.id = '$to_collection'";
$result = run_query($sql);
- $row = mysql_fetch_assoc($result);
+ $row = mysqli_fetch_assoc($result);
$target_collection_name = SmartStripSlashes($row['collection_path']);
$source_path = $config['basedir'].'plog-content/images/'.$source_collection_name.'/'.$source_album_name.'/';
@@ -1009,7 +1009,7 @@ function move_album($album_id, $to_collection) {
$result = run_query($sql);
$pic_ids = array();
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$filename = SmartStripSlashes(basename($row['path']));
$pic_ids[] = $row['picture_id'];
$old_path = $source_path.$filename;
@@ -1021,13 +1021,13 @@ function move_album($album_id, $to_collection) {
@chmod($new_path, PLOGGER_CHMOD_FILE);
}
- $path_insert = mysql_real_escape_string($target_collection_name.'/'.$source_album_name.'/'.$filename);
+ $path_insert = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$target_collection_name.'/'.$source_album_name.'/'.$filename);
$sql = "UPDATE ".PLOGGER_TABLE_PREFIX."pictures SET
parent_collection = '$to_collection',
path = '$path_insert'
WHERE id = '$row[picture_id]'";
- mysql_query($sql) or ($res['errors'] .= mysql_error());
+ mysqli_query($GLOBALS["PLOGGER_DBH"],$sql) or ($res['errors'] .= mysqli_error($GLOBALS["PLOGGER_DBH"]));
}
// Check if collection thumbnail = picture moved to different collection and set to default if so
@@ -1058,7 +1058,7 @@ function delete_album($del_id) {
WHERE c.id = a.parent_id AND a.id = '$del_id'";
$result = run_query($sql);
- $album = mysql_fetch_assoc($result);
+ $album = mysqli_fetch_assoc($result);
if (!$album) {
return array('errors' => plog_tr('No such album'));
@@ -1067,7 +1067,7 @@ function delete_album($del_id) {
// First delete all pictures registered with this album
$sql = 'SELECT * FROM '.PLOGGER_TABLE_PREFIX.'pictures WHERE parent_album = '.$album['album_id'];
$result = run_query($sql);
- while ($row = mysql_fetch_assoc($result)) {
+ while ($row = mysqli_fetch_assoc($result)) {
delete_picture($row['id']);
}
@@ -1101,13 +1101,13 @@ function delete_album($del_id) {
function update_comment($id, $author, $email, $url, $comment) {
$id = intval($id);
- $author = mysql_real_escape_string($author);
- $email = mysql_real_escape_string($email);
- $url = mysql_real_escape_string($url);
- $comment = mysql_real_escape_string(trim($comment));
+ $author = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$author);
+ $email = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$email);
+ $url = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$url);
+ $comment = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],trim($comment));
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."comments SET author = '$author', comment = '$comment', url = '$url', email = '$email' WHERE id='$id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected comment.'));
} else {
@@ -1122,10 +1122,10 @@ function update_comment_field($id, $field, $value) {
}
$id = intval($id);
- $value = mysql_real_escape_string($value);
+ $value = mysqli_real_escape_string($GLOBALS["PLOGGER_DBH"],$value);
$query = "UPDATE ".PLOGGER_TABLE_PREFIX."comments SET $field = '$value' WHERE id='$id'";
- $result = mysql_query($query);
+ $result = mysqli_query($GLOBALS["PLOGGER_DBH"],$query);
if ($result) {
return array('output' => plog_tr('You have successfully modified the selected comment.'));
} else {
@@ -1140,7 +1140,7 @@ function count_albums($parent_id = 0) {
$numquery = "SELECT COUNT(*) AS `num_albums` FROM `".PLOGGER_TABLE_PREFIX."albums` WHERE parent_id = '$parent_id'";
$numresult = run_query($numquery);
- $num_albums = mysql_result($numresult, 0, 'num_albums');
+ $num_albums = mysqli_result($numresult, 0, 'num_albums');
return $num_albums;
}
@@ -1149,7 +1149,7 @@ function count_collections() {
$numquery = "SELECT COUNT(*) AS `num_collections` FROM `".PLOGGER_TABLE_PREFIX."collections`";
$numresult = run_query($numquery);
- $num_albums = mysql_result($numresult, 0, 'num_collections');
+ $num_albums = mysqli_result($numresult, 0, 'num_collections');
return $num_albums;
}
@@ -1160,7 +1160,7 @@ function count_pictures($parent_id = 0) {
$numquery = "SELECT COUNT(*) AS `num_pics` FROM `".PLOGGER_TABLE_PREFIX."pictures` WHERE parent_album = '$parent_id'";
$numresult = run_query($numquery);
- $num_pics = mysql_result($numresult, 0, 'num_pics');
+ $num_pics = mysqli_result($numresult, 0, 'num_pics');
return $num_pics;
}
@@ -1171,7 +1171,7 @@ function count_comments($parent_id = false) {
}
$numresult = run_query($numquery);
- $num_comments = mysql_result($numresult, 0, 'num_comments');
+ $num_comments = mysqli_result($numresult, 0, 'num_comments');
return $num_comments;
}
@@ -1180,7 +1180,7 @@ function plog_edit_comment_form($comment_id) {
$comment_id = intval($comment_id);
$sql = "SELECT * FROM ".PLOGGER_TABLE_PREFIX."comments c WHERE c.id = '$comment_id'";
$result = run_query($sql);
- $comment = mysql_fetch_assoc($result);
+ $comment = mysqli_fetch_assoc($result);
if (!is_array($comment)) {
// XXX: return an error message instead
return false;
@@ -1530,7 +1530,7 @@ function plog_edit_collection_form($collection_id) {
ORDER BY a.name, p.date_submitted";
$result = run_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$selected = ($row['id'] == $collection['thumbnail_id']) ? ' selected="selected"' : '';
$style = 'class="thumboption" style="padding-left: '.($thumbnail_config[THUMB_SMALL]['size'] + 5).'px; background-image: url('.generate_thumb(SmartStripSlashes($row['path']), $row['id']).');"';
@@ -1582,7 +1582,7 @@ function plog_edit_album_form($album_id) {
$sql = "SELECT id, caption, path FROM ".PLOGGER_TABLE_PREFIX."pictures p WHERE p.parent_album = '".$album_id."'";
$result = run_query($sql);
- while($row = mysql_fetch_assoc($result)) {
+ while($row = mysqli_fetch_assoc($result)) {
$selected = ($row['id'] == $album['thumbnail_id']) ? ' selected="selected"' : '';
$style = 'class="thumboption" style="padding-left: '.($thumbnail_config[THUMB_SMALL]['size'] + 5).'px; background-image: url('.generate_thumb(SmartStripSlashes($row['path']), $row['id']).');"';
$images .= "\n\t\t\t\t" . '