Changeset 373

Show
Ignore:
Timestamp:
04/11/06 17:47:04 (3 years ago)
Author:
stefan
Message:

merging changes from trunk into this branch

Location:
branches/plogger-with-tags
Files:
4 removed
34 modified
114 copied

Legend:

Unmodified
Added
Removed
  • branches/plogger-with-tags/.htaccess

    r100 r373  
     1# BEGIN Plogger 
     2# END Plogger 
  • branches/plogger-with-tags/_install.php

    r150 r373  
    11<?php 
    2  
    3 // Installation file. 
    4  
    5 error_reporting(E_ALL); 
     2error_reporting(E_ERROR); 
    63$TABLE_PREFIX = "plogger_"; 
     4$config_table = $TABLE_PREFIX.'config'; 
     5 
     6if (file_exists("plog-config.php")) { 
     7        require_once("plog-config.php"); 
     8        if (    @mysql_connect(PLOGGER_DB_HOST,PLOGGER_DB_USER,PLOGGER_DB_PW) && 
     9                @mysql_select_db(PLOGGER_DB_NAME)) { 
     10                die("Plogger seems to have been already installed!<br/>If this is not the case and you really wish to attempt to create the Plogger database tables, please remove the file 'plog-config.php' from the Plogger installation directory."); 
     11        }; 
     12}; 
     13 
     14 
     15 
     16require_once(dirname(__FILE__) . '/lib/plogger/install_functions.php'); 
     17$errors = check_requirements(); 
     18 
     19if (sizeof($errors) > 0) { 
     20        print '<ul>'; 
     21        foreach($errors as $error) { 
     22                print '<li>' . $error . '</li>'; 
     23        }; 
     24        print '</ul>'; 
     25        exit; 
     26 
     27}; 
    728 
    829foreach($_POST as $key => $val) $_POST[$key] = stripslashes($val); 
     
    1536}; 
    1637 
     38 
    1739if (!empty($_POST)) 
    1840{ 
    19 $connect_file_data = '<?php 
    20  
    21 // this is the file used to connect to your database. 
    22 // you must change these values in order to run the gallery. 
    23  
    24 $DB_HOST = "'.$_POST["db_host"].'"; 
    25 $DB_USER = "'.$_POST["db_user"].'"; 
    26 $DB_PW = "'.$_POST["db_pass"].'"; 
    27 $DB_NAME = "'.$_POST["db_name"].'"; 
    28  
    29 $dbh = mysql_connect ($DB_HOST, $DB_USER, $DB_PW) or die ("Plogger cannot connect to the database because: " . mysql_error()); 
    30 mysql_select_db ($DB_NAME); 
    31  
    32  
    33 function run_query($query){ 
    34         $result = mysql_query($query) or die(mysql_error() . "<br /><br />" . $query); 
    35         return $result; 
    36 } 
    37  
    38  
    39 ?>'; 
     41        $cfg_file = "<?php\n"; 
     42        $cfg_file .= '// this is the file used to connect to your database.'."\n"; 
     43        $cfg_file .= '// you must change these values in order to run the gallery.'."\n"; 
     44 
     45        $cfg_file .= 'define("PLOGGER_DB_HOST","'.$_POST["db_host"].'");'."\n"; 
     46        $cfg_file .= 'define("PLOGGER_DB_USER","'.$_POST["db_user"].'");'."\n"; 
     47        $cfg_file .= 'define("PLOGGER_DB_PW","'.$_POST["db_pass"].'");'."\n"; 
     48        $cfg_file .= 'define("PLOGGER_DB_NAME","'.$_POST["db_name"].'");'."\n"; 
     49 
     50        $cfg_file .= "?>\n"; 
     51 
    4052}; 
    4153 
     
    6678                $errors[] = 'Please enter a password.'; 
    6779        } 
     80        if (trim($_POST["password"]) != trim($_POST["confirm_password"])){ 
     81                $errors[] = 'Passwords do not match.'; 
     82        } 
    6883         
    6984        $files_to_read = array("./","./admin","./css","./images","./lib","./thumbs","./uploads"); 
     
    86101        if (count($errors) == 0){ 
    87102                if(!@mysql_connect($_POST["db_host"],$_POST["db_user"],$_POST["db_pass"])){ 
    88                         $errors[] = 'Plogger could not connect to the MySQL host with the information you provided.'; 
     103                        $errors[] = 'Plogger could not connect to the MySQL host with the information you provided. (' . mysql_error() . ')'; 
    89104                } 
    90105                elseif(!mysql_select_db($_POST["db_name"])){ 
     
    93108        } 
    94109         
    95         // Try to write the plog-connect.php file. 
     110        // Try to write the plog-config.php file. 
    96111        if (count($errors) == 0){ 
    97112                // Open the file for writing. 
    98113 
    99                 $handle = @fopen(realpath("./plog-connect.php"),"w"); 
     114                $handle = fopen(realpath("./plog-config.php"),"w"); 
    100115                 
    101116                if ($handle){ 
    102                         fwrite($handle, $connect_file_data); 
     117                        fwrite($handle, $cfg_file); 
    103118                        fclose($handle); 
    104119                } 
    105120                else{ 
    106121                        // Try chmodding the file. 
    107                         @chmod(realpath("./plog-connect.php"), 0666); 
    108                          
    109                         $handle = @fopen(realpath("./plog-connect.php"),"w"); 
     122                        @chmod(realpath("./plog-config.php"), 0666); 
     123                         
     124                        $handle = fopen(realpath("./plog-config.php"),"w"); 
    110125                         
    111126                        if ($handle){ 
    112                                 fwrite($handle, $connect_file_data); 
     127                                fwrite($handle, $cfg_file); 
    113128                                fclose($handle); 
    114129                        } 
    115130                        else{ 
    116                                 $config_errors[] = "Plogger could not write the plog-connect.php file.  Either make this file writable by the Web server and click 'Try Again', or replace the contents of the current plog-connect.php file with the following code:<br /><pre>" . htmlentities($connect_file_data) . "</pre>If you choose to overwrite the file manually, do so, and then delete the _install.php file.  Don't forget to change the permissions back on plog-connect.php after you overwrite it.  Proceed to your <a href=\"admin\">Administrative Tools</a> when you have fixed the connection file."; 
     131                                $config_errors[] = "Plogger could not write the plog-config.php file.  Either make this file writable by the Web server and click 'Try Again', or replace the contents of the current plog-config.php file with the following code:<br /><pre>" . htmlentities($cfg_file) . "</pre>If you choose to overwrite the file manually, do so, and don't forget to change the permissions back after you overwrite it.  Proceed to your <a href=\"admin\">Administrative Tools</a> when you have fixed the connection file."; 
    117132                        } 
    118133                } 
     
    132147                // first lets check if the tables have already been installed 
    133148                 
    134                 $query = "CREATE TABLE IF NOT EXISTS `".$TABLE_PREFIX."collections` ( 
     149                $query = "CREATE TABLE `".$TABLE_PREFIX."collections` ( 
    135150                  `name` varchar(128) NOT NULL default '', 
    136151                  `description` varchar(255) NOT NULL default '', 
    137152                  `path` varchar(255) NOT NULL default '', 
    138153                  `id` int(11) NOT NULL auto_increment, 
    139                   `thumbnail_id` int(11) NOT NULL, 
     154                  `thumbnail_id` int(11) NOT NULL DEFAULT '0', 
    140155                        PRIMARY KEY  (id) 
    141156                ) Type=MyISAM $default_charset"; 
    142157                mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
    143158                 
    144                 $query = "CREATE TABLE IF NOT EXISTS `".$TABLE_PREFIX."albums` ( 
     159                $query = "CREATE TABLE `".$TABLE_PREFIX."albums` ( 
    145160                  `name` varchar(128) NOT NULL default '', 
    146161                  `id` int(11) NOT NULL auto_increment, 
     
    148163                  `path` varchar(255) NOT NULL default '', 
    149164                  `parent_id` int(11) NOT NULL default '0', 
    150                   `thumbnail_id` int(11) NOT NULL, 
     165                  `thumbnail_id` int(11) NOT NULL default '0', 
    151166                  PRIMARY KEY  (id), 
    152167                        INDEX pid_idx (parent_id) 
     
    154169                mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
    155170 
    156                 $query = "CREATE TABLE IF NOT EXISTS `".$TABLE_PREFIX."config` ( 
     171                $query = "CREATE TABLE `".$TABLE_PREFIX."config` ( 
    157172                        `max_thumbnail_size` int(11) NOT NULL default '0', 
    158173                        `max_display_size` int(11) NOT NULL default '0', 
     
    162177                        `admin_email` varchar(50) NOT NULL default '', 
    163178                        `date_format` varchar(64) NOT NULL default '', 
    164                         `compression` int(11) NOT NULL default '', 
     179                        `compression` int(11) NOT NULL default '75', 
    165180                        `default_sortby` varchar(20) NOT NULL default '', 
    166181                        `default_sortdir` varchar(5) NOT NULL default '', 
     182                        `album_sortby` varchar(20) NOT NULL default '', 
     183                        `album_sortdir` varchar(5) NOT NULL default '', 
     184                        `collection_sortby` varchar(20) NOT NULL default '', 
     185                        `collection_sortdir` varchar(5) NOT NULL default '', 
    167186                        `gallery_name` varchar(255) NOT NULL default '', 
    168187                        `allow_dl` smallint(1) NOT NULL default '0', 
     
    170189                        `allow_print` smallint(1) NOT NULL default '1', 
    171190                        `truncate` int(11) NOT NULL default '12', 
     191                        `square_thumbs` tinyint default 1, 
    172192                        `feed_num_entries` int(15) NOT NULL default '15', 
    173193                        `rss_thumbsize` int(11) NOT NULL default '400', 
    174194                        `feed_title` text NOT NULL, 
    175195                        `use_mod_rewrite` tinyint NOT NULL default '0', 
     196                        `gallery_url` varchar(255) NOT NULL default '', 
    176197                        `comments_notify` tinyint NOT NULL default '1', 
    177                         `feed_language` varchar(255) NOT NULL default 'en-us' 
    178                          
    179                 ) Type=MyISAM $default_charset"; 
    180                 mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
    181                 $query = "CREATE TABLE IF NOT EXISTS `".$TABLE_PREFIX."pictures` ( 
     198                        `comments_moderate` tinyint NOT NULL default '0', 
     199                        `feed_language` varchar(255) NOT NULL default 'en-us', 
     200                        `theme_dir` varchar(128) NOT NULL default '', 
     201                        `thumb_nav_range` int(11) NOT NULL default '0', 
     202                        `enable_thumb_nav` tinyint default '0', 
     203                        `allow_fullpic` tinyint default '1' 
     204                ) Type=MyISAM $default_charset"; 
     205                mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
     206                $query = "CREATE TABLE `".$TABLE_PREFIX."pictures` ( 
    182207                  `path` varchar(255) NOT NULL default '', 
    183208                  `parent_album` int(11) NOT NULL default '0', 
    184209                  `parent_collection` int(11) NOT NULL default '0', 
    185210                  `caption` mediumtext NOT NULL, 
     211                  `description` text NOT NULL, 
    186212                  `id` int(11) NOT NULL auto_increment, 
    187213                  `date_modified` timestamp(14) NOT NULL, 
     
    200226                mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
    201227                 
    202                                 $query = "CREATE TABLE IF NOT EXISTS `".$TABLE_PREFIX."comments` ( 
     228                                $query = "CREATE TABLE `".$TABLE_PREFIX."comments` ( 
    203229                  `id` int(11) NOT NULL auto_increment, 
    204230                        `parent_id` int(11) NOT NULL default '0', 
     
    206232                  `email` varchar(64) NOT NULL default '', 
    207233                  `url` varchar(64) NOT NULL default '', 
    208                   `date` timestamp(14) NOT NULL, 
     234                  `date` datetime NOT NULL, 
    209235                  `comment` longtext NOT NULL, 
    210236                  `ip` char(64), 
     
    216242                mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 
    217243                 
     244                                $query = "CREATE TABLE `".$TABLE_PREFIX."tag2picture` (