fifixed: installer

This commit is contained in:
fwhite 2010-03-31 23:52:04 +00:00
parent cf3489e96e
commit ae0dcf4947
13 changed files with 130 additions and 216 deletions

View file

@ -11,10 +11,10 @@
define("ClipBucket","ClipBucket - Open Source Media Sharing Script by Arslan Hassan"); define("ClipBucket","ClipBucket - Open Source Media Sharing Script by Arslan Hassan");
define("VERSION","2.0.3"); define("VERSION","2.0.6");
define("STATE","beta"); define("STATE","RC2");
define("REV","109"); define("REV","241");
define("RELEASED","26-01-2010"); define("RELEASED","3-23-2010");
define("AUTHORS","ARSLAN HASSAN,Fawaz Tahir"); define("AUTHORS","ARSLAN HASSAN,FAWAZ TAHIR");
?> ?>

View file

@ -43,12 +43,11 @@ if(!@$in_bg_cron)
session_start(); 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('dbconnect.php');
require_once('classes/pages.class.php'); require_once('classes/pages.class.php');
require_once('classes/actions.class.php'); require_once('classes/actions.class.php');
@ -271,8 +270,6 @@ switch(DEBUG_LEVEL)
define('TOPIC_ICON_DIR',BASEDIR.'/images/icons/topic_icons'); define('TOPIC_ICON_DIR',BASEDIR.'/images/icons/topic_icons');
define('TOPIC_ICON_URL',BASEURL.'/images/icons/topic_icons'); define('TOPIC_ICON_URL',BASEURL.'/images/icons/topic_icons');
include 'functions.php';
include 'plugin.functions.php'; include 'plugin.functions.php';
include 'plugins_functions.php'; include 'plugins_functions.php';
require BASEDIR.'/includes/templatelib/Template.class.php'; require BASEDIR.'/includes/templatelib/Template.class.php';

View file

@ -1,32 +0,0 @@
<?php
/**
* @Software : ClipBucket
* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
* @version :ClipBucket v2
*/
$BDTYPE = 'mysql';
//Database Host
$DBHOST = 'localhost';
//Database Name
$DBNAME = 'clipbucket_svn';
//Database Username
$DBUSER = 'root';
//Database Password
$DBPASS = '';
//Setting Table Prefix
define("TABLE_PREFIX","cb_");
require 'adodb/adodb.inc.php';
$db = ADONewConnection($BDTYPE);
$db->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);
?>

View file

@ -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;
}
}
?> ?>

View file

@ -182,7 +182,7 @@
$tbpre= TABLE_PREFIX; $tbpre= TABLE_PREFIX;
//Checking weather there is any evidence of prior installation or not //Checking weather there is any evidence of prior installation or not
$query = mysql_query("SELECT * FROM ".$tbpre."config WHERE name='version' "); $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); $version = substr($data['value'],0,3);
if($version=='1.7') if($version=='1.7')
{ {

View file

@ -6,17 +6,17 @@
* @version :ClipBucket v2 * @version :ClipBucket v2
*/ */
$BDTYPE = "mysql"; $BDTYPE = 'mysql';
//Database Host //Database Host
$DBHOST = "localhost"; $DBHOST = '_DB_HOST_';
//Database Name //Database Name
$DBNAME = "sample_cbv2"; $DBNAME = '_DB_NAME_';
//Database Username //Database Username
$DBUSER = "root"; $DBUSER = '_DB_USER_';
//Database Password //Database Password
$DBPASS = ""; $DBPASS = '_DB_PASS_';
//Setting Table Prefix //Setting Table Prefix
define("TABLE_PREFIX","cb_"); define('TABLE_PREFIX','_TABLE_PREFIX_');
require 'adodb/adodb.inc.php'; require 'adodb/adodb.inc.php';

View file

@ -1,33 +0,0 @@
<?php
/**
* @Software : ClipBucket
* @License : CBLA
* @version :ClipBucket v2
*/
$BDTYPE = "mysql";
//Database Host
$DBHOST = "localhost";
//Database Name
$DBNAME = "sample_cbv2";
//Database Username
$DBUSER = "root";
//Database Password
$DBPASS = "";
//Setting Table Prefix
define("TABLE_PREFIX","cb_");
require 'adodb/adodb.inc.php';
$db = ADONewConnection($BDTYPE);
$db->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);
?>

View file

@ -8,7 +8,27 @@
* @ author: Arslan Hassan * @ 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("config.php");
include("checkup.php"); include("checkup.php");
@ -34,7 +54,7 @@ $msgs = array();
$step = $_POST['step']; $step = $_POST['step'];
if(file_exists(SCRIPT_DIR.'/files/install.loc')) if(file_exists(SCRIPT_DIR.'/files/install.lock'))
$step = 'already_installed'; $step = 'already_installed';
switch($step) switch($step)
@ -63,12 +83,12 @@ switch($step)
{ {
$connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass'));
if(!$connect) if(!$connect)
$errors[] = "Unabele to connect to datbase server : ".mysql_error(); $errors[] = "Unable to connect to database server : ".mysql_error();
else else
{ {
$db = @mysql_select_db(post('dbname')); $db = @mysql_select_db(post('dbname'));
if(!$db) if(!$db)
$errors[] = "Unable to connect select databse : ".mysql_error(); $errors[] = "Unable to connect select database : ".mysql_error();
else else
$msgs[] = "Connected to database successfully"; $msgs[] = "Connected to database successfully";
} }
@ -89,51 +109,22 @@ switch($step)
$connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass'));
if(!$connect) if(!$connect)
$errors[] = "Unable to connect to datbase server : ".mysql_error(); $errors[] = "Unable to connect to database server : ".mysql_error();
else else
{ {
$db = @mysql_select_db(post('dbname')); $db = @mysql_select_db(post('dbname'));
if(!$db) if(!$db)
$errors[] = "Unable to connect select databse : ".mysql_error(); $errors[] = "Unable to select database : ".mysql_error();
else 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);
'<?php file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect);
/**
* @Software : ClipBucket
* @License : CBLA
* @version :ClipBucket v2
*/
$BDTYPE = "mysql";
//Database Host
$DBHOST = "'.post('host').'";
//Database Name
$DBNAME = "'.post('dbname').'";
//Database Username
$DBUSER = "'.post('dbuser').'";
//Database Password
$DBPASS = "'.post('dbpass').'";
//Setting Table Prefix
define("TABLE_PREFIX","'.$prefix.'");
require \'adodb/adodb.inc.php\';
$db = ADONewConnection($BDTYPE);
$db->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);
require '../includes/adodb/adodb.inc.php'; require '../includes/adodb/adodb.inc.php';
require '../includes/classes/category.class.php'; require '../includes/classes/category.class.php';
@ -183,8 +174,9 @@ switch($step)
$db->update($prefix."users",$query_field,$query_val," username='admin' "); $db->update($prefix."users",$query_field,$query_val," username='admin' ");
copy("install.loc",SCRIPT_DIR.'/files/install.loc'); file_put_contents(SCRIPT_DIR.'/files/install.lock',time());
copy("clipbucket.php",SCRIPT_DIR."/includes/clipbucket.php"); file_put_contents(SCRIPT_DIR.'/includes/clipbucket.php',file_get_contents('clipbucket.php'));
unlink(SCRIPT_DIR.'/files/temp/install.me');
} }
} }
@ -278,42 +270,14 @@ switch($step)
$db->update($prefix."config",array("value"),array("PGRpdiBhbGlnbj0iY2VudGVyIj48IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPg0KUG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tLyI+Q2xpcEJ1Y2tldDwvYT4gJXMgfCA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tL2Fyc2xhbi1oYXNzYW4iPkFyc2xhbiBIYXNzYW48L2E+DQo8IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPjwvZGl2Pg==")," name='cbhash'"); $db->update($prefix."config",array("value"),array("PGRpdiBhbGlnbj0iY2VudGVyIj48IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPg0KUG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tLyI+Q2xpcEJ1Y2tldDwvYT4gJXMgfCA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tL2Fyc2xhbi1oYXNzYW4iPkFyc2xhbiBIYXNzYW48L2E+DQo8IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPjwvZGl2Pg==")," name='cbhash'");
$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);
'<?php file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect);
/**
* @Software : ClipBucket
* @License : CBLA
* @version :ClipBucket v2
*/
$BDTYPE = "mysql";
//Database Host
$DBHOST = "'.$DBHOST.'";
//Database Name
$DBNAME = "'.$DBNAME.'";
//Database Username
$DBUSER = "'.$DBUSER.'";
//Database Password
$DBPASS = "'.$DBPASS.'";
//Setting Table Prefix
define("TABLE_PREFIX","'.$prefix.'");
require \'adodb/adodb.inc.php\';
$db = ADONewConnection($BDTYPE);
$db->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);
} }
@ -351,9 +315,8 @@ switch($step)
$db->update($prefix."config",array("value"),array(VERSION)," name='version'"); $db->update($prefix."config",array("value"),array(VERSION)," name='version'");
$db->update($prefix."config",array("value"),array(STATE)," name='type'"); $db->update($prefix."config",array("value"),array(STATE)," name='type'");
copy("install.loc",SCRIPT_DIR.'/files/install.loc'); file_put_contents(SCRIPT_DIR.'/files/install.lock',time());
unlink(SCRIPT_DIR."/includes/clipbucket.php"); file_put_contents(SCRIPT_DIR.'/includes/clipbucket.php',file_get_contents('clipbucket.php'));
copy("clipbucket.php",SCRIPT_DIR."/includes/clipbucket.php");
} }
break; break;
@ -381,7 +344,7 @@ switch($step)
{ {
$connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass')); $connect = @mysql_connect(post('host'),post('dbuser'),post('dbpass'));
if(!$connect) if(!$connect)
$errors[] = "Unabele to connect to datbase server : ".mysql_error(); $errors[] = "Unabele to connect to database server : ".mysql_error();
else else
{ {
$db = @mysql_select_db(post('dbname')); $db = @mysql_select_db(post('dbname'));
@ -410,43 +373,14 @@ switch($step)
$prefix = "cb_"; $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);
'<?php file_put_contents(SCRIPT_DIR.'/includes/dbconnect.php',$dbconnect);
/**
* @Software : ClipBucket
* @License : CBLA
* @version :ClipBucket v2
*/
$BDTYPE = "mysql";
//Database Host
$DBHOST = "'.post('host').'";
//Database Name
$DBNAME = "'.post('dbname').'";
//Database Username
$DBUSER = "'.post('dbuser').'";
//Database Password
$DBPASS = "'.post('dbpass').'";
//Setting Table Prefix
define("TABLE_PREFIX","'.$prefix.'");
require \'adodb/adodb.inc.php\';
$db = ADONewConnection($BDTYPE);
$db->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);
$templine = ''; $templine = '';
$lines = file("cb_v2.sql"); $lines = file("cb_v2.sql");

View file

@ -15,6 +15,12 @@
else else
$msgs[] = '"/files/'.$subdir.'" directory is writeable'; $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 //Checking Images
if(!is_images_writeable()) if(!is_images_writeable())
$errors[] = '"/images" directory is not writeable - Please changes its permission to 0777'; $errors[] = '"/images" directory is not writeable - Please changes its permission to 0777';
@ -44,9 +50,15 @@
$msgs[] = '"/install" directory is writeable'; $msgs[] = '"/install" directory is writeable';
//Checking includes Directory //Checking includes Directory
if(!is_writeable("../includes")) if(!is_writeable("../includes/clipbucket.php"))
$errors[] = '"/includes" directory is not writeable - Please changes its permission to 0777'; $errors[] = '"/includes/clipbucket.php" is not writeable - Please changes its permission to 0777';
else else
$msgs[] = '"/includes" directory is writeable'; $msgs[] = '"/includes/clipbucket.php" is writeable';
//Checking includes Directory
if(!is_writeable("../includes/dbconnect.php"))
$errors[] = '"/includes/dbconnect.php" is not writeable - Please changes its permission to 0777';
else
$msgs[] = '"/includes/dbconnect.php" is writeable';
?> ?>

View file

@ -5,7 +5,7 @@
<div class="footer" align="right"> <div class="footer" align="right">
<form name="form1" method="post" action=""> <form name="form1" method="post" action="">
<input type="submit" name="step2" id="step1" value="I Accept CBLA" class="button"> <input type="submit" name="step2" id="step1" value="I Accept" class="button">
<input type="hidden" name="step" value="2" > <input type="hidden" name="step" value="2" >
</form> </form>

View file

@ -1,5 +1,5 @@
<div class="content"><h2>ClipBucket is already installed</h2> <div class="content"><h2>ClipBucket is already installed</h2>
Clipbucket is already installed, if you want to update your ClipBucket, please delete "/files/install.loc" file Clipbucket is already installed, if you want to update your ClipBucket, please delete "/files/install.lock" file
</div> </div>
<div class="footer" align="right"> <div class="footer" align="right">
</div> </div>

View file

@ -19,7 +19,7 @@ $msgs = array();
$step = $_POST['step']; $step = $_POST['step'];
if(file_exists(BASEDIR.'/files/install.loc')) if(file_exists(BASEDIR.'/files/install.lock'))
exit("Installation Loc Found"); exit("Installation Loc Found");
@ -305,8 +305,8 @@ if($_POST['upgrade'])
{ {
//Finalize Upgrade //Finalize Upgrade
//Setting Up The lock //Setting Up The lock
copy("install.loc",BASEDIR.'/files/install.loc'); file_put_contents(BASEDIR.'/files/install.lock',time());
copy("clipbucket.php",BASEDIR."/includes/clipbucket.php"); file_put_contents(BASEDIR.'/includes/clipbucket.php',file_get_contents('clipbucket.php'));
//Dropin Db Tbls //Dropin Db Tbls
$tbls = array("ads_data","ads_placements","category","channel_comments","config","contacts","editors_picks","email_settings","flagged_videos","groups","group_invitations","group_members","group_posts","group_topics","group_videos","logs","logs_ping","messages","modules","players","player_configs","player_skins","plugins","plugin_config","stats","subscriptions","template","users","video","video_comments","video_detail","video_favourites"); $tbls = array("ads_data","ads_placements","category","channel_comments","config","contacts","editors_picks","email_settings","flagged_videos","groups","group_invitations","group_members","group_posts","group_topics","group_videos","logs","logs_ping","messages","modules","players","player_configs","player_skins","plugins","plugin_config","stats","subscriptions","template","users","video","video_comments","video_detail","video_favourites");
foreach($tbls as $tbl){ foreach($tbls as $tbl){