diff --git a/php/Modules/Album.php b/php/Modules/Album.php index d95e18b..feb97ed 100644 --- a/php/Modules/Album.php +++ b/php/Modules/Album.php @@ -29,20 +29,20 @@ final class Album { Plugins::get()->activate(__METHOD__, 0, func_get_args()); // Properties - $public = 0; - $visible = 1; + $id = generateID(); + $sysstamp = time(); + $public = 0; + $visible = 1; // Database - $sysstamp = time(); - $query = Database::prepare(Database::get(), "INSERT INTO ? (title, sysstamp, public, visible) VALUES ('?', '?', '?', '?')", array(LYCHEE_TABLE_ALBUMS, $title, $sysstamp, $public, $visible)); - $result = Database::execute(Database::get(), $query, __METHOD__, __LINE__); - $insertID = Database::get()->insert_id; + $query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, sysstamp, public, visible) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_ALBUMS, $id, $title, $sysstamp, $public, $visible)); + $result = Database::execute(Database::get(), $query, __METHOD__, __LINE__); // Call plugins Plugins::get()->activate(__METHOD__, 1, func_get_args()); if ($result===false) return false; - return $insertID; + return $id; } diff --git a/php/Modules/Database.php b/php/Modules/Database.php index 91d9df7..60ee093 100755 --- a/php/Modules/Database.php +++ b/php/Modules/Database.php @@ -13,7 +13,8 @@ final class Database { '020700', // 2.7.0 '030000', // 3.0.0 '030001', // 3.0.1 - '030003' // 3.0.3 + '030003', // 3.0.3 + '030100' // 3.1.0 ); /** diff --git a/php/Modules/Photo.php b/php/Modules/Photo.php index deb5953..c7d20f3 100755 --- a/php/Modules/Photo.php +++ b/php/Modules/Photo.php @@ -139,8 +139,7 @@ final class Photo { } // Generate id - $id = str_replace('.', '', microtime(true)); - while(strlen($id)<14) $id .= 0; + $id = generateID(); // Set paths $tmp_name = $file['tmp_name']; @@ -1149,8 +1148,7 @@ final class Photo { while ($photo = $photos->fetch_object()) { // Generate id - $id = str_replace('.', '', microtime(true)); - while(strlen($id)<14) $id .= 0; + $id = generateID(); // Duplicate entry $values = array(LYCHEE_TABLE_PHOTOS, $id, LYCHEE_TABLE_PHOTOS, $photo->id); diff --git a/php/database/albums_table.sql b/php/database/albums_table.sql index 8303b88..ea94d41 100644 --- a/php/database/albums_table.sql +++ b/php/database/albums_table.sql @@ -2,7 +2,7 @@ # ------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `?` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` bigint(14) NOT NULL, `title` varchar(100) NOT NULL DEFAULT '', `description` varchar(1000) DEFAULT '', `sysstamp` int(11) NOT NULL, diff --git a/php/database/update_030100.php b/php/database/update_030100.php new file mode 100644 index 0000000..428ba92 --- /dev/null +++ b/php/database/update_030100.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/php/helpers/generateID.php b/php/helpers/generateID.php new file mode 100644 index 0000000..80f42c1 --- /dev/null +++ b/php/helpers/generateID.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/php/index.php b/php/index.php index be39f8f..4bacbd7 100755 --- a/php/index.php +++ b/php/index.php @@ -20,6 +20,7 @@ require(__DIR__ . '/define.php'); require(__DIR__ . '/autoload.php'); require(__DIR__ . '/helpers/fastImageCopyResampled.php'); +require(__DIR__ . '/helpers/generateID.php'); require(__DIR__ . '/helpers/getExtension.php'); require(__DIR__ . '/helpers/getGraphHeader.php'); require(__DIR__ . '/helpers/getHashedString.php');