[pLog-CVS] plog wizard.php,1.19,1.20
Brought to you by:
jondaley
From: <phu...@pr...> - 2004-01-28 21:02:00
|
Update of /cvsroot/plog/plog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24796 Modified Files: wizard.php Log Message: the wizard is now able to auto-detect where some of the helper tools needed for running plog (bzip2, gzip, tar, etc) are located in the disk, by checking from a set of pre-determined folders. It also detects wether GD, ImageMagick or none of them are available in the system and configures the installation accordingly. If none of them is available, it will set the render system to "null". Some of the templates have also been modified to provide more information to the user about what is going on. Index: wizard.php =================================================================== RCS file: /cvsroot/plog/plog/wizard.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** wizard.php 25 Jan 2004 00:35:16 -0000 1.19 --- wizard.php 28 Jan 2004 21:00:34 -0000 1.20 *************** *** 28,31 **** --- 28,33 ---- include_once( PLOG_CLASS_PATH."class/misc/version.class.php" ); include_once( PLOG_CLASS_PATH."class/file/file.class.php" ); + include_once( PLOG_CLASS_PATH."class/misc/filefinder.class.php" ); + include_once( PLOG_CLASS_PATH."class/gallery/resizers/gddetector.class.php" ); define( "TEMP_FOLDER", "./tmp" ); *************** *** 339,347 **** $Inserts[34] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('locale_folder','./locale',3);"; $Inserts[35] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('xmlrpc_ping_enabled','0',1);"; ! $Inserts[36] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_tar','/bin/tar',3);"; ! $Inserts[37] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_gzip','/bin/gzip',3);"; ! $Inserts[38] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_bz2','/bin/bzip2',3);"; ! $Inserts[39] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_unzip','/usr/bin/unzip',3);"; ! $Inserts[40] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('users_can_add_templates','/bin/unzip',3);"; $Inserts[41] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('maximum_file_upload_size', 2000000, 1);"; $Inserts[42] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('upload_forbidden_files', '*.php *.php3 *.php4 *.phtml', 3);"; --- 341,349 ---- $Inserts[34] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('locale_folder','./locale',3);"; $Inserts[35] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('xmlrpc_ping_enabled','0',1);"; ! $Inserts[36] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_tar','{path_to_tar}',3);"; ! $Inserts[37] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_gzip','{path_to_gzip}',3);"; ! $Inserts[38] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_bz2','{path_to_bz2}',3);"; ! $Inserts[39] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_unzip','{path_to_unzip}',3);"; ! $Inserts[40] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('users_can_add_templates',1,1);"; $Inserts[41] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('maximum_file_upload_size', 2000000, 1);"; $Inserts[42] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('upload_forbidden_files', '*.php *.php3 *.php4 *.phtml', 3);"; *************** *** 354,358 **** $Inserts[46] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('resources_enabled', 1, 1 );"; $Inserts[47] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_method', 'gd', 3);"; ! $Inserts[48] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_convert', '/usr/bin/convert', 3);"; $Inserts[49] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_height', 120, 1);"; $Inserts[50] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_width', 120, 1);"; --- 356,360 ---- $Inserts[46] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('resources_enabled', 1, 1 );"; $Inserts[47] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_method', 'gd', 3);"; ! $Inserts[48] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('path_to_convert', '{path_to_convert}', 3);"; $Inserts[49] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_height', 120, 1);"; $Inserts[50] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES ('thumbnail_width', 120, 1);"; *************** *** 619,622 **** --- 621,633 ---- $requestUrl = str_replace( "/wizard.php", "", $requestUrl ); $plogUrl = "http://".$httpHost.$requestUrl; + + // Find some of the tools we are going to need (last one is for os x, with fink installed) + $folders = Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" ); + $finder = new FileFinder( $folders ); + $pathToUnzip = $finder->find( "unzip" ); + $pathToTar = $finder->find( "tar" ); + $pathToGzip = $finder->find( "gzip" ); + $pathToBzip2 = $finder->find( "bzip2" ); + $pathToConvert = $finder->find( "convert" ); // and execute some insert's *************** *** 624,627 **** --- 635,645 ---- $query = str_replace( "{dbprefix}", $this->_dbPrefix, $insert ); $query = str_replace( "{plog_base_url}", $plogUrl, $query ); + // replace also the placeholders for the paths to the tools + $query = str_replace( "{path_to_tar}", $pathToTar, $query ); + $query = str_replace( "{path_to_unzip}", $pathToUnzip, $query ); + $query = str_replace( "{path_to_bz2}", $pathToBzip2, $query ); + $query = str_replace( "{path_to_gzip}", $pathToGzip, $query ); + $query = str_replace( "{path_to_convert}", $pathToConvert, $query ); + $query = str_replace( "{path_to_convert}", $pathToConvert, $query ); if( !$this->_db->Execute( $query )) { $message .= "Error executing code: ".$this->_db->ErrorMsg()."<br/>"; *************** *** 630,637 **** } if( $errors ) { $this->_view = new WizardView( "error" ); $message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>$message"; - } else --- 648,680 ---- } + // + // show some information regarding the helper tools we're going to need + // and wether they were found or not + // + $message .= "<br/><b>-- Helper tools --</b><br/>"; + if( $pathToTar == "" ) + $message .= "The helper tool 'tar' was not found<br/>"; + else + $message .= "The helper too 'tar' was found in $pathToTar<br/>"; + if( $pathToGzip == "" ) + $message .= "The helper tool 'gzip' was not found<br/>"; + else + $message .= "The helper too 'gzip' was found in $pathToGzip<br/>"; + if( $pathToUnzip == "" ) + $message .= "The helper tool 'unzip' was not found<br/>"; + else + $message .= "The helper too 'unzip' was found in $pathToUnzip<br/>"; + if( $pathToBzip2 == "" ) + $message .= "The helper tool 'bzip2' was not found<br/>"; + else + $message .= "The helper too 'bzip2' was found in $pathToTar<br/>"; + if( $pathToConvert == "" ) + $message .= "The helper tool 'convert' (from the ImageMagick package) was not found<br/>"; + else + $message .= "The helper too 'convert' (from the ImageMagick package) was found in $pathToConvert<br/>"; + if( $errors ) { $this->_view = new WizardView( "error" ); $message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>$message"; } else *************** *** 789,794 **** --- 832,858 ---- return false; } + + // + // detect wether we have GD available and set the blog to use it + // + if( GdDetector::detectGd()) { + $config->saveValue( "thumbnail_method", "gd" ); + $message = "GD has been detected and set as the backend for dealing with images."; + } + else { + $pathToConvert = $config->getValue( "path_to_convert" ); + if( $pathToConvert ) { + $config->saveValue( "thumbnail_method", "imagemagick" ); + $message = "ImageMagick has been detected and set as the backend for dealing with images."; + } + else { + // nothing was found, so we'll have to do away with the 'null' resizer... + $config->saveValue( "thumbnail_method", "null" ); + $message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images."; + } + } $this->_view = new WizardView( "step5" ); + $this->_view->setValue( "message", $message ); return true; } *************** *** 884,890 **** --- 948,957 ---- $newSettings = Array( 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 ); foreach( $newSettings as $settingId ) { + // find where the user is running the convert binary from the ImageMagick package + $pathToConvert = FileFinder::find( "convert", Array( "/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/" )); // get info about the table we'd like to use $setting = $Inserts[$settingId]; $query = str_replace( "{dbprefix}", $this->_dbPrefix, $setting ); + $query = str_replace( "{path_to_convert}", $pathToConvert, $query ); if( !$this->_db->Execute( $query )) { $message .= "There was an error executing: ".$this->_db->ErrorMsg()."<br/>"; *************** *** 892,896 **** } } ! if( !$errors ) { $message .= "** New configuration settings added successfully **<br/>"; } --- 959,971 ---- } } ! ! // give some more information to the user ! $message .= "** Helper Tools **<br/>"; ! if( $pathToConvert == "" ) ! $message .= "The helper tool 'convert' (from the ImageMagick package) could not be found.<br/>"; ! else ! $message .= "The helper tool 'convert' (from the ImageMagick package) was found in $pathToConvert<br/><br/>"; ! ! if( !$errors ) { $message .= "** New configuration settings added successfully **<br/>"; } *************** *** 926,930 **** --- 1001,1027 ---- $userPermissions->setSiteAdmin( $this->_userId ); + // + // detect wether we have GD available and set the blog to use it + // + $config =& Config::getConfig(); + if( GdDetector::detectGd()) { + $config->saveValue( "thumbnail_method", "gd" ); + $message = "GD has been detected and set as the backend for dealing with images."; + } + else { + $pathToConvert = $config->getValue( "path_to_convert" ); + if( $pathToConvert ) { + $config->saveValue( "thumbnail_method", "imagemagick" ); + $message = "ImageMagick has been detected and set as the backend for dealing with images."; + } + else { + // nothing was found, so we'll have to do away with the 'null' resizer... + $config->saveValue( "thumbnail_method", "null" ); + $message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images."; + } + } + $this->_view = new WizardView( "update3" ); + $this->_view->setValue( "message", $message ); } *************** *** 935,939 **** // from Smarty if( !File::isWritable( TEMP_FOLDER ) || !File::isDir( TEMP_FOLDER )) { ! print("<span style=\"color:red\">Error</span><br/><br/>This wizard needs the ".TEMP_FOLDER." folder to be writable by the web server user.<br/><br/>Please correct that and try again."); die(); } --- 1032,1036 ---- // from Smarty if( !File::isWritable( TEMP_FOLDER ) || !File::isDir( TEMP_FOLDER )) { ! print("<span style=\"color:red; font-size: 14px;\">Error</span><br/><br/>This wizard needs the ".TEMP_FOLDER." folder to be writable by the web server user.<br/><br/>Please correct that and try again."); die(); } |