Ejemplo n.º 1
0
    /** METHOD: ResetHTACCESS
     *  Resetst the .htaccess file
     */
    public static function Setup()
    {
        if (!isset($_POST['url_new'])) {
            return;
        }
        DUPX_Log::Info("\nWEB SERVER CONFIGURATION FILE BASIC SETUP:");
        $currdata = parse_url($_POST['url_old']);
        $newdata = parse_url($_POST['url_new']);
        $currpath = DupUtil::add_slash(isset($currdata['path']) ? $currdata['path'] : "");
        $newpath = DupUtil::add_slash(isset($newdata['path']) ? $newdata['path'] : "");
        $tmp_htaccess = <<<HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$newpath}
RewriteRule ^index\\.php\$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$newpath}index.php [L]
</IfModule>
# END WordPress
HTACCESS;
        file_put_contents('.htaccess', $tmp_htaccess);
        @chmod('.htaccess', 0644);
        DUPX_Log::Info("created basic .htaccess file.  If using IIS web.config this process will need to be done manually.");
    }
Ejemplo n.º 2
0
 /** 
  * Updates the web server config files in Step 1  */
 public static function UpdateStep1()
 {
     if (!file_exists('wp-config.php')) {
         return;
     }
     $root_path = DUPX_Util::set_safe_path($GLOBALS['CURRENT_ROOT_PATH']);
     $wpconfig = @file_get_contents('wp-config.php', true);
     $patterns = array("/'DB_NAME',\\s*'.*?'/", "/'DB_USER',\\s*'.*?'/", "/'DB_PASSWORD',\\s*'.*?'/", "/'DB_HOST',\\s*'.*?'/");
     $db_host = $_POST['dbport'] == 3306 ? $_POST['dbhost'] : "{$_POST['dbhost']}:{$_POST['dbport']}";
     $replace = array("'DB_NAME', " . '\'' . $_POST['dbname'] . '\'', "'DB_USER', " . '\'' . $_POST['dbuser'] . '\'', "'DB_PASSWORD', " . '\'' . DUPX_Util::preg_replacement_quote($_POST['dbpass']) . '\'', "'DB_HOST', " . '\'' . $db_host . '\'');
     //SSL CHECKS
     if ($_POST['ssl_admin']) {
         if (!strstr($wpconfig, 'FORCE_SSL_ADMIN')) {
             $wpconfig = $wpconfig . PHP_EOL . "define('FORCE_SSL_ADMIN', true);";
         }
     } else {
         array_push($patterns, "/'FORCE_SSL_ADMIN',\\s*true/");
         array_push($replace, "'FORCE_SSL_ADMIN', false");
     }
     if ($_POST['ssl_login']) {
         if (!strstr($wpconfig, 'FORCE_SSL_LOGIN')) {
             $wpconfig = $wpconfig . PHP_EOL . "define('FORCE_SSL_LOGIN', true);";
         }
     } else {
         array_push($patterns, "/'FORCE_SSL_LOGIN',\\s*true/");
         array_push($replace, "'FORCE_SSL_LOGIN', false");
     }
     //CACHE CHECKS
     if ($_POST['cache_wp']) {
         if (!strstr($wpconfig, 'WP_CACHE')) {
             $wpconfig = $wpconfig . PHP_EOL . "define('WP_CACHE', true);";
         }
     } else {
         array_push($patterns, "/'WP_CACHE',\\s*true/");
         array_push($replace, "'WP_CACHE', false");
     }
     if (!$_POST['cache_path']) {
         array_push($patterns, "/'WPCACHEHOME',\\s*'.*?'/");
         array_push($replace, "'WPCACHEHOME', ''");
     }
     if (!is_writable("{$root_path}/wp-config.php")) {
         if (file_exists("{$root_path}/wp-config.php")) {
             chmod("{$root_path}/wp-config.php", 0644) ? DUPX_Log::Info('File Permission Update: wp-config.php set to 0644') : DUPX_Log::Info('WARNING: Unable to update file permissions and write to wp-config.php.  Please visit the online FAQ for setting file permissions and work with your hosting provider or server administrator to enable this installer.php script to write to the wp-config.php file.');
         } else {
             DUPX_Log::Info('WARNING: Unable to locate wp-config.php file.  Be sure the file is present in your archive.');
         }
     }
     $wpconfig = preg_replace($patterns, $replace, $wpconfig);
     file_put_contents('wp-config.php', $wpconfig);
     $wpconfig = null;
 }
Ejemplo n.º 3
0
    DUPX_Log::Error("No tables where created during step 1 of the install.  Please review the installer-log.txt file for sql error messages.\n\t\tYou may have to manually run the installer-data.sql with a tool like phpmyadmin to validate the data input.  If you have enabled compatibility mode\n\t\tduring the package creation process then the database server version your using may not be compatible with this script.\n");
}
//DATA CLEANUP: Perform Transient Cache Cleanup
//Remove all duplicator entries and record this one since this is a new install.
$dbdelete_count = 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}duplicator_packages`");
$dbdelete_count1 = @mysqli_affected_rows($dbh) or 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE `option_name` LIKE ('_transient%') OR `option_name` LIKE ('_site_transient%')");
$dbdelete_count2 = @mysqli_affected_rows($dbh) or 0;
$dbdelete_count = abs($dbdelete_count1) + abs($dbdelete_count2);
DUPX_Log::Info("Removed '{$dbdelete_count}' cache/transient rows");
//Reset Duplicator Options
foreach ($GLOBALS['FW_OPTS_DELETE'] as $value) {
    mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE `option_name` = '{$value}'");
}
@mysqli_close($dbh);
$profile_end = DupUtil::get_microtime();
DUPX_Log::Info("\nSECTION RUNTIME: " . DupUtil::elapsed_time($profile_end, $profile_start));
//FINAL RESULTS
$ajax1_end = DupUtil::get_microtime();
$ajax1_sum = DupUtil::elapsed_time($ajax1_end, $ajax1_start);
DUPX_Log::Info("\n{$GLOBALS['SEPERATOR1']}");
DUPX_Log::Info('STEP1 COMPLETE @ ' . @date('h:i:s') . " - TOTAL RUNTIME: {$ajax1_sum}");
DUPX_Log::Info("{$GLOBALS['SEPERATOR1']}");
$JSON['pass'] = 1;
$JSON['table_count'] = $dbtable_count;
$JSON['table_rows'] = $dbtable_rows;
$JSON['query_errs'] = $dbquery_errs;
echo json_encode($JSON);
error_reporting($ajax1_error_level);
die('');
Ejemplo n.º 4
0
 /**
  * Take a serialised array and unserialise it replacing elements and
  * unserialising any subordinate arrays and performing the replace.
  * @param string $from       String we're looking to replace.
  * @param string $to         What we want it to be replaced with
  * @param array  $data       Used to pass any subordinate arrays back to in.
  * @param bool   $serialised Does the array passed via $data need serialising.
  * @return array	The original array with all elements replaced as needed. 
  */
 private static function recursive_unserialize_replace($from = '', $to = '', $data = '', $serialised = false)
 {
     // some unseriliased data cannot be re-serialised eg. SimpleXMLElements
     try {
         if (is_string($data) && ($unserialized = @unserialize($data)) !== false) {
             $data = self::recursive_unserialize_replace($from, $to, $unserialized, true);
         } elseif (is_array($data)) {
             $_tmp = array();
             foreach ($data as $key => $value) {
                 $_tmp[$key] = self::recursive_unserialize_replace($from, $to, $value, false);
             }
             $data = $_tmp;
             unset($_tmp);
         } elseif (is_object($data)) {
             $dataClass = get_class($data);
             $_tmp = new $dataClass();
             foreach ($data as $key => $value) {
                 $_tmp->{$key} = self::recursive_unserialize_replace($from, $to, $value, false);
             }
             $data = $_tmp;
             unset($_tmp);
         } else {
             if (is_string($data)) {
                 $data = str_replace($from, $to, $data);
             }
         }
         if ($serialised) {
             return serialize($data);
         }
     } catch (Exception $error) {
         DUPX_Log::Info("\nRECURSIVE UNSERIALIZE ERROR: With string\n" . $error, 2);
     }
     return $data;
 }
Ejemplo n.º 5
0
    $JSON['step2']['warnlist'][] = $msg;
    DUPX_Log::Info($msg);
}
//Database
$result = @mysqli_query($dbh, "SELECT option_value FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE option_name IN ('upload_url_path','upload_path')");
if ($result) {
    while ($row = mysqli_fetch_row($result)) {
        if (strlen($row[0])) {
            $msg = "MEDIA SETTINGS WARNING: The table '{$GLOBALS['FW_TABLEPREFIX']}options' has at least one the following values ['upload_url_path','upload_path'] set please validate settings. These settings can be changed in the wp-admin by going to Settings->Media area see 'Uploading Files'";
            $JSON['step2']['warnlist'][] = $msg;
            DUPX_Log::Info($msg);
            break;
        }
    }
}
if (empty($JSON['step2']['warnlist'])) {
    DUPX_Log::Info("No Warnings Found\n");
}
$JSON['step2']['warn_all'] = empty($JSON['step2']['warnlist']) ? 0 : count($JSON['step2']['warnlist']);
mysqli_close($dbh);
@unlink('database.sql');
//CONFIG Setup
DUPX_Config::Setup();
$ajax2_end = DupUtil::get_microtime();
$ajax2_sum = DupUtil::elapsed_time($ajax2_end, $ajax2_start);
DUPX_Log::Info("********************************************************************************");
DUPX_Log::Info('STEP 2 COMPLETE @ ' . @date('h:i:s') . " - TOTAL RUNTIME: {$ajax2_sum}");
DUPX_Log::Info("********************************************************************************");
$JSON['step2']['pass'] = 1;
error_reporting($ajax2_error_level);
die(json_encode($JSON));
Ejemplo n.º 6
0
 /**
  * Take a serialised array and unserialise it replacing elements and
  * unserialising any subordinate arrays and performing the replace.
  * @param string $from       String we're looking to replace.
  * @param string $to         What we want it to be replaced with
  * @param array  $data       Used to pass any subordinate arrays back to in.
  * @param bool   $serialised Does the array passed via $data need serialising.
  * @return array	The original array with all elements replaced as needed. 
  */
 public static function recursive_unserialize_replace($from = '', $to = '', $data = '', $serialised = false)
 {
     // some unseriliased data cannot be re-serialised eg. SimpleXMLElements
     try {
         if (is_string($data) && ($unserialized = @unserialize($data)) !== false) {
             $data = self::recursive_unserialize_replace($from, $to, $unserialized, true);
         } elseif (is_array($data)) {
             $_tmp = array();
             foreach ($data as $key => $value) {
                 $_tmp[$key] = self::recursive_unserialize_replace($from, $to, $value, false);
             }
             $data = $_tmp;
             unset($_tmp);
             /* CJL
             				Check for an update to the key of an array e.g.   [http://localhost/projects/wpplugins/] => 1.41
             				This could have unintended consequences would need to enable with full-search needs more testing
             			if (array_key_exists($from, $data)) 
             			{
             				$data[$to] = $data[$from];
             				unset($data[$from]);
             			}*/
         } elseif (is_object($data)) {
             /* RSR Old logic that didn't work with Beaver Builder - they didn't want to create a brand new 
             			object instead reused the existing one... 
             			$dataClass = get_class($data);
             			$_tmp = new $dataClass();
             			foreach ($data as $key => $value) {
             				$_tmp->$key = self::recursive_unserialize_replace($from, $to, $value, false);
             			}
             			$data = $_tmp;
             			unset($_tmp);*/
             // RSR NEW LOGIC
             $_tmp = $data;
             $props = get_object_vars($data);
             foreach ($props as $key => $value) {
                 $_tmp->{$key} = self::recursive_unserialize_replace($from, $to, $value, false);
             }
             $data = $_tmp;
             unset($_tmp);
         } else {
             if (is_string($data)) {
                 $data = str_replace($from, $to, $data);
             }
         }
         if ($serialised) {
             return serialize($data);
         }
     } catch (Exception $error) {
         DUPX_Log::Info("\nRECURSIVE UNSERIALIZE ERROR: With string\n" . $error, 2);
     }
     return $data;
 }