diff --git a/upload/install/install.loc b/upload/files/temp/install.me similarity index 100% rename from upload/install/install.loc rename to upload/files/temp/install.me diff --git a/upload/includes/clipbucket.php b/upload/includes/clipbucket.php index 7d710b91..6948fdac 100644 --- a/upload/includes/clipbucket.php +++ b/upload/includes/clipbucket.php @@ -11,10 +11,10 @@ define("ClipBucket","ClipBucket - Open Source Media Sharing Script by Arslan Hassan"); - define("VERSION","2.0.3"); - define("STATE","beta"); - define("REV","109"); - define("RELEASED","26-01-2010"); - define("AUTHORS","ARSLAN HASSAN,Fawaz Tahir"); + define("VERSION","2.0.6"); + define("STATE","RC2"); + define("REV","241"); + define("RELEASED","3-23-2010"); + define("AUTHORS","ARSLAN HASSAN,FAWAZ TAHIR"); ?> \ No newline at end of file diff --git a/upload/includes/common.php b/upload/includes/common.php index 22ce9b5a..f92c54f7 100644 --- a/upload/includes/common.php +++ b/upload/includes/common.php @@ -43,12 +43,11 @@ if(!@$in_bg_cron) session_start(); } -// Check Installation Directory -if(!file_exists(dirname(__FILE__).'/clipbucket.php')){ - header('location:install'); -} -//Required Files + //Required Files + + require_once('functions.php'); + check_install(); require_once('dbconnect.php'); require_once('classes/pages.class.php'); require_once('classes/actions.class.php'); @@ -270,9 +269,7 @@ switch(DEBUG_LEVEL) //TOPIC ICON DIR define('TOPIC_ICON_DIR',BASEDIR.'/images/icons/topic_icons'); define('TOPIC_ICON_URL',BASEURL.'/images/icons/topic_icons'); - - - include 'functions.php'; + include 'plugin.functions.php'; include 'plugins_functions.php'; require BASEDIR.'/includes/templatelib/Template.class.php'; diff --git a/upload/includes/dbconnect.php b/upload/includes/dbconnect.php deleted file mode 100644 index e806f484..00000000 --- a/upload/includes/dbconnect.php +++ /dev/null @@ -1,32 +0,0 @@ -debug = false; - $db->charpage = 'cp_utf8'; - $db->charset = 'utf8'; - if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) - { - exit($db->ErrorMsg()); - } - $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); -?> \ No newline at end of file diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 58aaaa9a..b21e2d60 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -4005,6 +4005,42 @@ } } - + function check_install() + { + if(file_exists('files/temp/install.me') && file_exists('install')) + { + header('Location: '.get_server_url().'/install'); + exit; + } + + if(file_exists('install')) + { + define('INSTALL_FILES',1); + } + } + + function get_server_url() + { + $DirName = dirname($_SERVER['PHP_SELF']); + if(preg_match('/admin_area/i', $DirName)) + { + $DirName = str_replace('/admin_area','',$DirName); + } + return get_server_protocol().$_SERVER['HTTP_HOST'].$DirName; + } + + function get_server_protocol() + { + if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') + { + return 'https://'; + } + else + { + $protocol = preg_replace('/^([a-z]+)\/.*$/', '\\1', strtolower($_SERVER['SERVER_PROTOCOL'])); + $protocol .= '://'; + return $protocol; + } + } ?> \ No newline at end of file diff --git a/upload/install/checkup.php b/upload/install/checkup.php index b7446fe6..13f4219e 100644 --- a/upload/install/checkup.php +++ b/upload/install/checkup.php @@ -182,7 +182,7 @@ $tbpre= TABLE_PREFIX; //Checking weather there is any evidence of prior installation or not $query = mysql_query("SELECT * FROM ".$tbpre."config WHERE name='version' "); - $data = mysql_fetch_array($query); + @$data = mysql_fetch_array($query); $version = substr($data['value'],0,3); if($version=='1.7') { diff --git a/upload/install/dbconnect.php b/upload/install/dbconnect.php index 4a4be73a..3626cf39 100644 --- a/upload/install/dbconnect.php +++ b/upload/install/dbconnect.php @@ -6,17 +6,17 @@ * @version :ClipBucket v2 */ - $BDTYPE = "mysql"; + $BDTYPE = 'mysql'; //Database Host - $DBHOST = "localhost"; + $DBHOST = '_DB_HOST_'; //Database Name - $DBNAME = "sample_cbv2"; + $DBNAME = '_DB_NAME_'; //Database Username - $DBUSER = "root"; + $DBUSER = '_DB_USER_'; //Database Password - $DBPASS = ""; + $DBPASS = '_DB_PASS_'; //Setting Table Prefix - define("TABLE_PREFIX","cb_"); + define('TABLE_PREFIX','_TABLE_PREFIX_'); require 'adodb/adodb.inc.php'; diff --git a/upload/install/dbconnect_sample.php b/upload/install/dbconnect_sample.php deleted file mode 100644 index 4a4be73a..00000000 --- a/upload/install/dbconnect_sample.php +++ /dev/null @@ -1,33 +0,0 @@ -debug = false; - $db->charpage = 'cp_utf8'; - $db->charset = 'utf8'; - if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) - { - exit($db->ErrorMsg()); - } - $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); - -?> \ No newline at end of file diff --git a/upload/install/index.php b/upload/install/index.php index aec16439..d326ab7a 100644 --- a/upload/install/index.php +++ b/upload/install/index.php @@ -8,7 +8,27 @@ * @ author: Arslan Hassan */ -error_reporting(E_ALL ^E_NOTICE ^E_DEPRECATED); +define('DEBUG_LEVEL', 1); +switch(DEBUG_LEVEL) +{ + case 0: + error_reporting(0); + ini_set('display_errors', '0'); + case 1: + error_reporting(E_ALL); + ini_set('display_errors', '1'); + default: + if(phpversion() >= '5.3.0') + { + error_reporting(E_ALL ^E_NOTICE ^E_DEPRECATED); + ini_set('display_errors', '1'); + } + else + { + error_reporting(E_ALL ^E_NOTICE); + ini_set('display_errors', '1'); + } +} include("config.php"); include("checkup.php"); @@ -34,7 +54,7 @@ $msgs = array(); $step = $_POST['step']; -if(file_exists(SCRIPT_DIR.'/files/install.loc')) +if(file_exists(SCRIPT_DIR.'/files/install.lock')) $step = 'already_installed'; switch($step) @@ -63,12 +83,12 @@ switch($step) { $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); if(!$connect) - $errors[] = "Unabele to connect to datbase server : ".mysql_error(); + $errors[] = "Unable to connect to database server : ".mysql_error(); else { $db = @mysql_select_db(post('dbname')); if(!$db) - $errors[] = "Unable to connect select databse : ".mysql_error(); + $errors[] = "Unable to connect select database : ".mysql_error(); else $msgs[] = "Connected to database successfully"; } @@ -89,51 +109,22 @@ switch($step) $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); if(!$connect) - $errors[] = "Unable to connect to datbase server : ".mysql_error(); + $errors[] = "Unable to connect to database server : ".mysql_error(); else { $db = @mysql_select_db(post('dbname')); if(!$db) - $errors[] = "Unable to connect select databse : ".mysql_error(); + $errors[] = "Unable to select database : ".mysql_error(); else { - $dbconnect = + $dbconnect = file_get_contents('dbconnect.php'); + $dbconnect = str_replace('_DB_HOST_', $_POST['host'], $dbconnect); + $dbconnect = str_replace('_DB_NAME_', $_POST['dbname'], $dbconnect); + $dbconnect = str_replace('_DB_USER_', $_POST['dbuser'], $dbconnect); + $dbconnect = str_replace('_DB_PASS_', $_POST['dbpass'], $dbconnect); + $dbconnect = str_replace('_TABLE_PREFIX_', $prefix, $dbconnect); -'debug = false; - $db->charpage = \'cp_utf8\'; - $db->charset = \'utf8\'; - if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) - { - exit($db->ErrorMsg()); - } - $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); - -?>'; - $fp = fopen('../includes/dbconnect.php', 'w'); - fwrite($fp, $dbconnect); - fclose($fp); + file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect); require '../includes/adodb/adodb.inc.php'; require '../includes/classes/category.class.php'; @@ -183,8 +174,9 @@ switch($step) $db->update($prefix."users",$query_field,$query_val," username='admin' "); - copy("install.loc",SCRIPT_DIR.'/files/install.loc'); - copy("clipbucket.php",SCRIPT_DIR."/includes/clipbucket.php"); + file_put_contents(SCRIPT_DIR.'/files/install.lock',time()); + file_put_contents(SCRIPT_DIR.'/includes/clipbucket.php',file_get_contents('clipbucket.php')); + unlink(SCRIPT_DIR.'/files/temp/install.me'); } } @@ -270,50 +262,22 @@ switch($step) , user_session_code ='$sess_code' WHERE userid='".$data['userid']."'"); } } - + //Rewriting Database File if(the_version()<'2.0.6') { //update cbhash(a general code of clipbucket that does nothing but tells clipbucket who it actually is) $db->update($prefix."config",array("value"),array("PGRpdiBhbGlnbj0iY2VudGVyIj48IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPg0KUG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tLyI+Q2xpcEJ1Y2tldDwvYT4gJXMgfCA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tL2Fyc2xhbi1oYXNzYW4iPkFyc2xhbiBIYXNzYW48L2E+DQo8IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPjwvZGl2Pg==")," name='cbhash'"); - - - $dbconnect = -'debug = false; - $db->charpage = \'cp_utf8\'; - $db->charset = \'utf8\'; - if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) - { - exit($db->ErrorMsg()); - } - $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); - -?>'; - $fp = fopen('../includes/dbconnect.php', 'w'); - fwrite($fp, $dbconnect); - fclose($fp); + file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect); } @@ -351,9 +315,8 @@ switch($step) $db->update($prefix."config",array("value"),array(VERSION)," name='version'"); $db->update($prefix."config",array("value"),array(STATE)," name='type'"); - copy("install.loc",SCRIPT_DIR.'/files/install.loc'); - unlink(SCRIPT_DIR."/includes/clipbucket.php"); - copy("clipbucket.php",SCRIPT_DIR."/includes/clipbucket.php"); + file_put_contents(SCRIPT_DIR.'/files/install.lock',time()); + file_put_contents(SCRIPT_DIR.'/includes/clipbucket.php',file_get_contents('clipbucket.php')); } break; @@ -381,7 +344,7 @@ switch($step) { $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); if(!$connect) - $errors[] = "Unabele to connect to datbase server : ".mysql_error(); + $errors[] = "Unabele to connect to database server : ".mysql_error(); else { $db = @mysql_select_db(post('dbname')); @@ -402,51 +365,22 @@ switch($step) $db = ADONewConnection('mysql'); $db->debug = false; $db->Connect(post('host'), post('dbuser'), post('dbpass'), post('dbname')); - - + + //Checking What sql files need to be called.... $prefix = post("prefix"); if(!$prefix || empty($prefix)) $prefix = "cb_"; - $dbconnect = + $dbconnect = file_get_contents('dbconnect.php'); + $dbconnect = str_replace('_DB_HOST_', $_POST['host'], $dbconnect); + $dbconnect = str_replace('_DB_NAME_', $_POST['dbname'], $dbconnect); + $dbconnect = str_replace('_DB_USER_', $_POST['dbuser'], $dbconnect); + $dbconnect = str_replace('_DB_PASS_', $_POST['dbpass'], $dbconnect); + $dbconnect = str_replace('_TABLE_PREFIX_', $prefix, $dbconnect); -'debug = false; - $db->charpage = \'cp_utf8\'; - $db->charset = \'utf8\'; - if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) - { - exit($db->ErrorMsg()); - } - $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); - -?>'; - $fp = fopen('../includes/dbconnect.php', 'w'); - fwrite($fp, $dbconnect); - fclose($fp); + file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect); $templine = ''; $lines = file("cb_v2.sql"); diff --git a/upload/install/perms_check.php b/upload/install/perms_check.php index 81ab230f..8a0c418d 100644 --- a/upload/install/perms_check.php +++ b/upload/install/perms_check.php @@ -15,6 +15,12 @@ else $msgs[] = '"/files/'.$subdir.'" directory is writeable'; } + + if(!is_writeable("../files/temp/install.me")) + $errors[] = '"/files/temp/install.me" is not writeable - Please changes its permission to 0777'; + else + $msgs[] = '"/files/temp/install.me" is writeable'; + //Checking Images if(!is_images_writeable()) $errors[] = '"/images" directory is not writeable - Please changes its permission to 0777'; @@ -42,11 +48,17 @@ $errors[] = '"/install" directory is not writeable - Please changes its permission to 0777'; else $msgs[] = '"/install" directory is writeable'; + + //Checking includes Directory + if(!is_writeable("../includes/clipbucket.php")) + $errors[] = '"/includes/clipbucket.php" is not writeable - Please changes its permission to 0777'; + else + $msgs[] = '"/includes/clipbucket.php" is writeable'; //Checking includes Directory - if(!is_writeable("../includes")) - $errors[] = '"/includes" directory is not writeable - Please changes its permission to 0777'; + if(!is_writeable("../includes/dbconnect.php")) + $errors[] = '"/includes/dbconnect.php" is not writeable - Please changes its permission to 0777'; else - $msgs[] = '"/includes" directory is writeable'; + $msgs[] = '"/includes/dbconnect.php" is writeable'; ?> \ No newline at end of file diff --git a/upload/install/steps/step_1.php b/upload/install/steps/step_1.php index 11b9f952..fcb74b3a 100644 --- a/upload/install/steps/step_1.php +++ b/upload/install/steps/step_1.php @@ -5,7 +5,7 @@