diff --git a/install/index.php b/install/index.php index d046550..c88e738 100755 --- a/install/index.php +++ b/install/index.php @@ -36,9 +36,9 @@ if(strlen($match[1])) $phpinfo[$match[1]] = array(); elseif(isset($match[3])) - $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; + @$phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; else - $phpinfo[end(array_keys($phpinfo))][] = $match[2]; + @$phpinfo[end(array_keys($phpinfo))][] = $match[2]; } ?> diff --git a/install/install2.php b/install/install2.php index 26cfb68..b3aaf89 100755 --- a/install/install2.php +++ b/install/install2.php @@ -12,12 +12,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ @@ -27,89 +27,89 @@ * Functions */ function apphp_db_install($database, $sql_file) { - global $link; - $db_error = false; - - if (!@apphp_db_select_db($database)) { - if (@apphp_db_query('create database ' . $database)) { - apphp_db_select_db($database); - } else { - $db_error = mysqli_error($link); - return false; + global $link; + $db_error = false; + + if (!@apphp_db_select_db($database)) { + if (@apphp_db_query('create database ' . $database)) { + apphp_db_select_db($database); + } else { + $db_error = mysqli_error($link); + return false; + } } - } - if (!$db_error) { - if (file_exists($sql_file)) { - $fd = fopen($sql_file, 'rb'); - $restore_query = fread($fd, filesize($sql_file)); - fclose($fd); - } else { - $db_error = 'SQL file does not exist: ' . $sql_file; - return false; - } + if (!$db_error) { + if (file_exists($sql_file)) { + $fd = fopen($sql_file, 'rb'); + $restore_query = fread($fd, filesize($sql_file)); + fclose($fd); + } else { + $db_error = 'SQL file does not exist: ' . $sql_file; + return false; + } - $sql_array = array(); - $sql_length = strlen($restore_query); - $pos = strpos($restore_query, ';'); - for ($i=$pos; $i<$sql_length; $i++) { - if ($restore_query[0] == '#') { - $restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n"))); + $sql_array = array(); $sql_length = strlen($restore_query); - $i = strpos($restore_query, ';')-1; - continue; - } - if ($restore_query[($i+1)] == "\n") { - for ($j=($i+2); $j<$sql_length; $j++) { - if (trim($restore_query[$j]) != '') { - $next = substr($restore_query, $j, 6); - if ($next[0] == '#') { - // find out where the break position is so we can remove this line (#comment line) - for ($k=$j; $k<$sql_length; $k++) { - if ($restore_query[$k] == "\n") break; - } - $query = substr($restore_query, 0, $i+1); - $restore_query = substr($restore_query, $k); - // join the query before the comment appeared, with the rest of the dump - $restore_query = $query . $restore_query; - $sql_length = strlen($restore_query); - $i = strpos($restore_query, ';')-1; - continue 2; + $pos = strpos($restore_query, ';'); + for ($i=$pos; $i<$sql_length; $i++) { + if ($restore_query[0] == '#') { + $restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n"))); + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + continue; + } + if (@$restore_query[($i+1)] == "\n") { + for ($j=($i+2); $j<$sql_length; $j++) { + if (trim($restore_query[$j]) != '') { + $next = substr($restore_query, $j, 6); + if ($next[0] == '#') { + // find out where the break position is so we can remove this line (#comment line) + for ($k=$j; $k<$sql_length; $k++) { + if ($restore_query[$k] == "\n") break; + } + $query = substr($restore_query, 0, $i+1); + $restore_query = substr($restore_query, $k); + // join the query before the comment appeared, with the rest of the dump + $restore_query = $query . $restore_query; + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + continue 2; + } + break; + } + } + if ($next == '') { // get the last insert query + $next = 'insert'; + } + if ( (stripos($next, 'create') === true) || (stripos($next, 'insert')) || (stripos($next, 'drop t')) ) { + $next = ''; + $sql_array[] = substr($restore_query, 0, $i); + $restore_query = ltrim(substr($restore_query, $i+1)); + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + } } - break; - } - } - if ($next == '') { // get the last insert query - $next = 'insert'; - } - if ( (stripos($next, 'create') === true) || (stripos($next, 'insert')) || (stripos($next, 'drop t')) ) { - $next = ''; - $sql_array[] = substr($restore_query, 0, $i); - $restore_query = ltrim(substr($restore_query, $i+1)); - $sql_length = strlen($restore_query); - $i = strpos($restore_query, ';')-1; } - } - } - for ($i=0; $i"; - } else { - @chmod($config_file_path,0777); - $f = @fopen($config_file_path, "w+"); - if (@fwrite($f, $config_file) > 0){ - $link = @mysqli_connect($database_host, $database_username, $database_password); - if($link){ - if (@mysqli_select_db($link, $database_name)) { - if(false == ($db_error = apphp_db_install($database_name, $sql_dump))){ - $error_mg[] = "
  • Could not read file ".$sql_dump."! Please check if the file exists or change its permission so it is readable by web server
  • "; - @unlink($config_file_path); - }else{ - if($_POST['install_sample'] == 'yes') - { - if(false == ($db_error = apphp_db_install($database_name, $sql_sample))){ - $error_mg[] = "
  • Could not read file ".$sql_sample."! Please check if the file exists or change its permission so it is readable by web server
  • "; - }else{ - $completed = true; - } - } else { - $completed = true; - } - } - } else { - $error_mg[] = "
  • Database connecting error! Check if your database exists
  • "; - @unlink($config_file_path); - } - } else { - $error_mg[] = "
  • Database connecting error! Check your connection parameters
  • "; - @unlink($config_file_path); - } - } else { - $error_mg[] = "
  • Can not open configuration file ".$config_file_directory.$config_file_name."
  • "; - } - @fclose($f); - @chmod($config_file_path,0755); - } - } - @fclose($f); + $database_host = isset($_POST['database_host'])?$_POST['database_host']:""; + $database_name = isset($_POST['database_name'])?$_POST['database_name']:""; + $database_username = isset($_POST['database_username'])?$_POST['database_username']:""; + $database_password = isset($_POST['database_password'])?$_POST['database_password']:""; + $database_sample = isset($_POST['install_sample'])?$_POST['install_sample']:""; + + if (empty($database_host)) { + $error_mg[] = "
  • Database host can not be empty
  • "; + } + + if (empty($database_name)) { + $error_mg[] = "
  • Database name can not be empty
  • "; + } + + if (empty($database_username)) { + $error_mg[] = "
  • Database username can not be empty
  • "; + } + + if (empty($database_password)) { + $error_mg[] = "
  • Database password can not be empty
  • "; + } + + if(empty($error_mg)) { + + $config_file = file_get_contents($config_file_default); + $config_file = str_replace("_DB_HOST_", $database_host, $config_file); + $config_file = str_replace("_DB_NAME_", $database_name, $config_file); + $config_file = str_replace("_DB_USER_", $database_username, $config_file); + $config_file = str_replace("_DB_PASSWORD_", $database_password, $config_file); + + if(!@copy('../sysconfig.local.inc-sample.php', $config_file_path)) { + $error_mg[] = "
  • Could not create file ".$config_file_name."! Please check if the sysconfig.local.inc-sample.php file is exists, or + try to manually copy this file and then rename it to sysconfig.local.inc.php and make sure this file is writable to your host's web server.
  • "; + } else { + @chmod($config_file_path,0777); + $f = @fopen($config_file_path, "w+"); + if (@fwrite($f, $config_file) > 0){ + $link = @mysqli_connect($database_host, $database_username, $database_password); + if($link){ + if (@mysqli_select_db($link, $database_name)) { + if(false == ($db_error = apphp_db_install($database_name, $sql_dump))){ + $error_mg[] = "
  • Could not read file ".$sql_dump."! Please check if the file exists or change its permission so it is readable by web server
  • "; + @unlink($config_file_path); + }else{ + if($_POST['install_sample'] == 'yes') { + if(false == ($db_error = apphp_db_install($database_name, $sql_sample))){ + $error_mg[] = "
  • Could not read file ".$sql_sample."! Please check if the file exists or change its permission so it is readable by web server
  • "; + }else{ + $completed = true; + } + } else { + $completed = true; + } + } + } else { + $error_mg[] = "
  • Database connecting error! Check if your database exists
  • "; + @unlink($config_file_path); + } + } else { + $error_mg[] = "
  • Database connecting error! Check your connection parameters
  • "; + @unlink($config_file_path); + } + } else { + $error_mg[] = "
  • Can not open configuration file ".$config_file_directory.$config_file_name."
  • "; + } + @fclose($f); + @chmod($config_file_path,0755); + } + } + @fclose($f); } ?> - Step 2 | Slims Installer - - + Step 2 | Slims Installer + + -
    - -
    -

    Step 2 - Installation Not Completed

    -
    -

    Please correct your information according to this message

    -
    - ".$msg.""; - } - ?> -
    - - -
    -
    -
    - -
    -

    Step 2 - Installation Completed

    -
    -

    Hooray, the installation was successful

    -
    -

    The file was sucessfully created.

    -

    For security reasons, please remove install/ folder from your server.

    -
    - -
    - - -
    - -
    +
    + +
    +

    Step 2 - Installation Not Completed

    +
    +

    Please correct your information according to this message

    +
    + ".$msg.""; + } + ?> +
    + + +
    +
    +
    + +
    +

    Step 2 - Installation Completed

    +
    +

    Hooray, the installation was successful

    +
    +

    The file was sucessfully created.

    +

    For security reasons, please remove install/ folder from your server.

    +
    + +
    +
    + + +