Skip to content

Commit

Permalink
one click installer
Browse files Browse the repository at this point in the history
sql prefix handling
  • Loading branch information
serphacker committed Mar 23, 2013
1 parent c35150c commit 0fce70c
Show file tree
Hide file tree
Showing 23 changed files with 656 additions and 122 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/docs/
/tests/
/demo/
/modules/Test/
/modules/Test/
/inc/config_1.php
6 changes: 5 additions & 1 deletion ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*
* Redistributions of files must retain the above notice.
*/
include('inc/config.php');
if(!file_exists('inc/config.php')){
header("Location: install/",TRUE,302);
die();
}
require('inc/config.php');
include('inc/define.php');
include('inc/common.php');

Expand Down
2 changes: 1 addition & 1 deletion cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function my_ob_logs($str){

$date = "NOW()";
//$date = "DATE_SUB(NOW(),INTERVAL ".$interval." DAY)";
$qRun = "INSERT INTO `".SQL_PREFIX."check`(idGroup,date) VALUES(".intval($row['idGroup']).",".$date.")";
$qRun = "INSERT INTO `".SQL_PREFIX."check`(idGroup,idRun,date) VALUES(".intval($row['idGroup']).",".intval($runid).",".$date.")";

mysql_query($qRun);
$id= mysql_insert_id();
Expand Down
6 changes: 5 additions & 1 deletion edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*
* Redistributions of files must retain the above notice.
*/
include('inc/config.php');
if(!file_exists('inc/config.php')){
header("Location: install/",TRUE,302);
die();
}
require('inc/config.php');
include('inc/define.php');
include('inc/common.php');

Expand Down
6 changes: 5 additions & 1 deletion import.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*
* Redistributions of files must retain the above notice.
*/
include('inc/config.php');
if(!file_exists('inc/config.php')){
header("Location: install/",TRUE,302);
die();
}
require('inc/config.php');
include('inc/define.php');
include('inc/common.php');

Expand Down
18 changes: 16 additions & 2 deletions inc/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@
mysql_select_db(SQL_DATABASE) or die("Can't select ".SQL_DATABASE." database");
mysql_query("set names 'utf8'");

if(mysql_query('select 1 from `group`') === false){
die("Database ".SQL_DATABASE." ok but can't find tables, check <a href='http://serphacker.com/serposcope/doc/install.html' >install instruction</a>"); }
if(mysql_query('select 1 from `'.SQL_PREFIX.'group`') === false){
die("Database ".SQL_DATABASE." ok but can't find tables, check <a href='http://serphacker.com/serposcope/doc/install.html' >install instruction</a>");
}

$dbversion=1;
$result=@mysql_query("SELECT version FROM `".SQL_PREFIX."version`");
if($result){
$array = mysql_fetch_assoc($result);
if($array){
$dbversion=$array['version'];
}
}

if($dbversion != SQL_VERSION){
die("You need to upgrade your SQL tables to use this version, delete <code>inc/config.php</code> and go to <a href='".dirname($_SERVER['PHP_SELF'])."/install/' >installer</a>");
}

$modules = Array();

Expand Down
3 changes: 2 additions & 1 deletion inc/define.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

define('VERSION','0.9.7');
define('VERSION','0.9.8');
define('SQL_VERSION',2);
define('INCLUDE_OK',1);

define('IMPORT_SERPOSCOPE_CSV',1);
Expand Down
3 changes: 2 additions & 1 deletion inc/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title></title>
<title>Serposcope</title>
<meta charset="utf-8" />
<meta name="robots" content="noindex" />

<link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="lib/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
Expand Down
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* Redistributions of files must retain the above notice.
*/
if(!file_exists('inc/config.php')){
die("Can't find inc/config.php, check <a href='http://serphacker.com/serposcope/doc/install.html' >install instructions</a>");
header("Location: install/",TRUE,302);
die();
}

include('inc/config.php');
require('inc/config.php');
include('inc/define.php');
include('inc/common.php');
include("inc/header.php");
Expand Down Expand Up @@ -74,7 +74,7 @@ function cmpBadChange($a,$b){
$unchanged=array();

foreach ($groupsCheck as $check) {
$q="SELECT idCheck,rank.idTarget,keyword.name name,target.name url,position ".
$q="SELECT idCheck, `".SQL_PREFIX."rank`.idTarget, `".SQL_PREFIX."keyword`.name name, `".SQL_PREFIX."target`.name url, position ".
" FROM `".SQL_PREFIX."rank` ".
" JOIN `".SQL_PREFIX."keyword` USING(idKeyword) ".
" JOIN `".SQL_PREFIX."target` USING(idTarget) ".
Expand Down
101 changes: 0 additions & 101 deletions install/database.sql

This file was deleted.

Empty file removed install/index.html
Empty file.
72 changes: 72 additions & 0 deletions install/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

$incdir=dirname(dirname($_SERVER['SCRIPT_FILENAME'])."..")."/inc/";


function h8($str){
return htmlentities($str, ENT_QUOTES, "UTF-8");
}

include('../inc/define.php');
include('install-inc/db.php');

ini_set("default_charset", 'utf-8');

function check_db_co($host,$login,$pass,$db){
return @mysql_connect($host, $login, $pass) && @mysql_select_db($db) && @mysql_query("set names 'utf8'");
}

if(isset($_GET['do'])){
if($_GET['do'] === "info"){
die(phpinfo());
}
}
?>
<html>
<head>
<title>Serposcope installer</title>
<meta name="robots" content="noindex">
<link href="../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style>
.container-narrow {
margin: 0 auto;
max-width: 700px;
}
</style>
</head>
<body>
<div class="container">
<div class="masthead">
<div class="pull-right" >
<b>PHP version : <?php echo phpversion(); ?></b>
<a href='?do=info' >phpinfo</a>
</div>
<h3><a href='?step=1' class="muted" >Serposcope Installer</a></h3>
</div>

<hr/>
<div style='text-align:center;' ><h4>Before updating be sure to have done a SQL backup of your serposcope DB</h4></div>
<hr/>

<div>
<?php

if(file_exists($incdir."/config.php")){

// echo "<h3>Installation done !</h3>";
// echo "<a href='".dirname(dirname($_SERVER['PHP_SELF'])."..")."' >Go ninja go</a><br/><br/>";
echo "For security purpose, if you want to reinstall or upgrade the current installation, you must first remove <code>inc/config.php</code>.<br/>";
}else{

if(!isset($_GET['step']) || !is_numeric($_GET['step'])){
$_GET['step'] = 1;
}
echo '<div style="text-align:center" ><h2>Step '.$_GET['step'].'</h2></div>';
@include("step/step".intval($_GET['step']).".php");

}
?>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 0fce70c

Please sign in to comment.