Current File : /home/lecoinf/www/iwp/updateFinalize_v3.3.1.php
<?php

$iwpUpdateObject = new IWPUpdate();

$iwpUpdateObject->initUpdateFinalize();

$updateFinalizeStatus = true;//update succesfully done

class IWPUpdate {
	
	private $newVersion = '3.3.1';
	private $thisVersion;
	
	private $updateType; // a. oneClickUpdate b. manualUpate
	
	private $configFileContents;
	
	private $configFileModifiedSuccess;
	private $configFileModifiedError;
	private $configFileReadError;
	private $sqlUpdateError;
	private $sqlUpdateSuccess;
	
	private $messageSuffix;
	
	private $debugMode = false;
	
	function doAssignCommonUpdateMessages() {
		$this->configFileModifiedSuccess = '<br>Config file modified';
		$this->configFileModifiedError = '<br>Unable to modify config.php file';
		$this->configFileReadError = '<br>Unable to read config.php file';
		$this->sqlUpdateError = '<br>SQL Error: update failed';
		$this->sqlUpdateSuccess = '<br>Database updated';
		
		$this->messageSuffix = 'while doing common update.';		
	}
	
	function initUpdateManual() {
		
		$this->updateType = 'manualUpdate';
		
		@define('FS_METHOD', 'direct');

		include("config.php");
		include_once(APP_ROOT."/includes/registry.php");
		include_once(APP_ROOT."/includes/db.php");
		include_once(APP_ROOT."/controllers/appFunctions.php");

		Reg::set('config', $config);

		DBConnectAndSetOptions();

		$settings = DB::getRow("?:settings", "*", 1);
		Reg::set('settings', unserialize($settings['general']));

		if(!defined('SUPPORT_URL')){ define('SUPPORT_URL', (getOption('SUPPORT_URL') ? getOption('SUPPORT_URL') : 'https://support.infinitewp.com/')) ; } 

		if(version_compare(APP_VERSION, '2.3.5', '<=')){
			echo 'For this manual update, at least v2.4.0 is required. For older versions, <a target="_blank" href="'.SUPPORT_URL.'/solution/articles/212269-infinitewp-admin-panel-manual-update/">see here</a>. ';
			exit;
		}

		if(version_compare(APP_VERSION, $this->newVersion, '<')) {
			
			$this->initCommon();
			
			$this->runUpdate();
			
		} else{
			echo 'You are already have the latest version.';
			exit;
		}		
	}
	
	function initUpdateFinalize() {
		global $updateAvailable;
		
		$this->updateType = 'oneClickUpdate';
		
		if(!empty($updateAvailable['updateDetails'][$this->newVersion])){
			
			$this->initCommon();
			
			$this->runUpdate();
			
		}
	}
	
	function initCommon() {
		
		echo '<br>Running update finalizer..';
		require_once(APP_ROOT.'/includes/file.php');
		
		if(!is_object($GLOBALS['FileSystemObj'])){
			if(!initFileSystem()){
				appUpdateMsg('Unable to initiate file system.', true);
				exit;
			}
		}
		
		$GLOBALS['updatePanelLocation'] = $GLOBALS['FileSystemObj']->findFolder(APP_ROOT.'/v3');
		$GLOBALS['updatePanelLocation'] = removeTrailingSlash($GLOBALS['updatePanelLocation']);		
	}
	
	function runUpdate() {
		
		// This method should run initially.		
		$this->preCommonUpdate();
		
		$this->updateForV3_0_0();
		$this->updateForV3_1_0();
		$this->updateForV3_1_2();
		$this->updateForV3_1_6();
		$this->updateForV3_1_9();

		$this->thisVersion = '3.1.14';
		if (version_compare(APP_VERSION, $this->thisVersion, '<')) {
			$this->updateForV3_1_14();
		}
		$this->thisVersion = '3.2.0';
		if (version_compare(APP_VERSION, $this->thisVersion, '<')) {
			$this->updateForV3_2_0();
		}
		// This method should run finally.
		$this->postCommonUpdate();		
	}
	
	function doQuerySQLArray($sqlArray, $versionAppendMode = false) {
		foreach($sqlArray as $sql){
			$isDone = DB::doQuery($sql);
			$message = $this->sqlUpdateError.' '.$this->messageSuffix;
			if($versionAppendMode === true) {
				$message .= $this->thisVersion;
			}
			if(!$isDone){ die($message); }
		}
		$message = $this->sqlUpdateSuccess.' '.$this->messageSuffix;
		if($versionAppendMode === true) {
			$message .= $this->thisVersion.'.';
		}
		if($this->debugMode) {
			echo $message.'..';	
		}
		unset($message);
	}
	
	function isConfigFileEmpty($versionAppendMode = false) {
		$message = $this->configFileReadError.' '.$this->messageSuffix;
		if(empty($this->configFileContents)) {
			if($versionAppendMode === true) {
				$message .= $this->thisVersion.'.';
			}
			die($message);			
		}
		unset($message);
	}
	
	function doCheckAndPutConfigFileContents($versionAppendMode = false) {
		if ($GLOBALS['FileSystemObj']->putContents( $GLOBALS['updatePanelLocation'].'/config.php', $this->configFileContents, FS_CHMOD_FILE)) {
			$message = $this->configFileModifiedSuccess.' '.$this->messageSuffix;
			if($versionAppendMode === true) {
				$message .= $this->thisVersion.'.';
			}
			if($this->debugMode) {
				echo $message.'..';	
			}
			unset($message);
		} else {
			$message = $this->configFileModifiedError.' '.$this->messageSuffix;
			if($versionAppendMode === true) {
				$message .= $this->thisVersion.'.';
			}			
			die($message);
		}		
	}
	
	function preCommonUpdate() {
		
		$this->doAssignCommonUpdateMessages();
		
		$this->preCommonUpdateConfigFile();	
		
		//we dont have updates in database for common update.

		//we dont have updates in files for common update.		
		
	}
	
	function postCommonUpdate() {
		
		$this->doAssignCommonUpdateMessages();
		
		//we dont have updates in config file for common update.
		
		$this->postCommonUpdateDatabase();
		
		if($this->updateType === 'manualUpdate') {
			updateOption('updateAvailable', '');
		}
		
		//file delete, rename etc	
		$this->postCommonUpdateFiles();

		$this->showReloadMessage();
	}
	
	function preCommonUpdateConfigFile() {
		
		$this->configFileContents = file_get_contents(APP_ROOT . '/config.php');
		
		$this->isConfigFileEmpty();
		
		//update version number
		if (strstr($this->configFileContents, 'define(\'APP_VERSION\',')) {
			$this->configFileContents = preg_replace('/define\(\'APP_VERSION\', .*\);/mi', "define('APP_VERSION', '$this->newVersion');", $this->configFileContents);
		}
		
		$this->doCheckAndPutConfigFileContents();
	}
	
	function postCommonUpdateDatabase() {
	
		$sqlArray = array();		
		$sqlArray[] = "UPDATE `?:options` SET `optionValue` = '0' WHERE `optionName` = 'updateLastCheck'";//setting updateLastCheck to 0, makes new check Update call on next load
		
		$this->doQuerySQLArray($sqlArray);			
	}
	
	function postCommonUpdateFiles() {
		$this->clearOldAppErrorLogs();
	}

	function clearOldAppErrorLogs() {
		// appErrorLogs code clean script start here. This need to run every update so we not kept in any condition
		if (file_exists(APP_ROOT."/appErrorLogs.txt")) {
			$fp = fopen(APP_ROOT."/appErrorLogs.txt", "r");
			$pos = 0;
			$currentLine = "";
			$toKeep ="";
			while(-1 !== fseek($fp, $pos, SEEK_END)){
				$char = fgetc($fp);
				if ("\n" == $char) {
					if(!empty($currentLine)){
						if(strpos($currentLine,date("Y-m-d")) === 0){
							$toKeep = $currentLine.$toKeep;
							$currentLine = "";
						}else{
							break;
						}
					}
				} else {
					$currentLine = $char . $currentLine;
				}
				$pos--;
			}
			file_put_contents(APP_ROOT."/appErrorLogs.txt", $toKeep );
			// appErrorLogs code clean script start here
		}		

	}

	function showReloadMessage() {
		echo '<br><a href="'.trim(APP_URL, '/').'/v3/index.php" target="_parent">Reload your App</a>.';
		
		$GLOBALS['updateFinalizeStatus'] = true;//update succesfully done
		
		if($this->updateType === 'manualUpdate') {
			$fileName = 'updateManual.php';
		} else {
			$fileName = 'updateFinalize_v'.$this->newVersion.'.php';
		}
		$GLOBALS['FileSystemObj']->delete($GLOBALS['updatePanelLocation'].'/'.$fileName, false, 'f');
	}

	function updateForV3_0_0(){
		$this->updateConfigFileForV3_0_0();
		$this->updateDatabaseForV3_0_0();
		
	}
	
	function updateConfigFileForV3_0_0() {
		
		$this->configFileContents = file_get_contents(APP_ROOT . '/v3/config.php');
		
		$domainPath = trim(APP_DOMAIN_PATH, '/');
		$domainPath .='/v3';
		$this->isConfigFileEmpty(true);

		if (strstr($this->configFileContents, 'define(\'APP_DOMAIN_PATH\',')) {
			$this->configFileContents = preg_replace('/define\(\'APP_DOMAIN_PATH\', .*\);/mi', "define('APP_DOMAIN_PATH', '$domainPath');", $this->configFileContents);
		}
		$this->configFileContents = str_replace('?>', '', $this->configFileContents);
		$additionalContents = '
define(\'APP_V3\', 1);
define(\'APP_ROOT_V2\', dirname(dirname(__FILE__)));
define(\'APP_DOMAIN_PATH_V2\', \''.APP_DOMAIN_PATH.'\');

		';
		
		$this->configFileContents .= $additionalContents;
		
		$this->doCheckAndPutConfigFileContents(true);		
				
	}

	function updateDatabaseForV3_0_0(){
		updateOption('V3Installed', 1);
		updateOption('isDirectFSV3', 'Y');
	}

	function updateForV3_1_0(){
		
		$sqlArray[] = "CREATE TABLE IF NOT EXISTS `?:addons_v3` (
						  `slug` varchar(64) NOT NULL,
						  `status` enum('active','inactive') NOT NULL,
						  `addon` varchar(255) DEFAULT NULL,
						  `validityExpires` int(10) unsigned DEFAULT NULL,
						  `initialVersion` varchar(40) DEFAULT NULL,
						  `updateCurrentVersion` varchar(40) DEFAULT NULL,
						  UNIQUE KEY `slug` (`slug`)
						) ".$tableEnv.";";
		$this->doQuerySQLArray($sqlArray, true);
	}

	function updateForV3_1_2(){
		
		$sqlArray[] = "CREATE TABLE IF NOT EXISTS `?:additional_stats` (
						 `siteID` int(10) unsigned NOT NULL,
						   `lastUpdatedTime` int(10) unsigned DEFAULT NULL,
						   `stats` longtext,
						   `type` ENUM('comments','users','itheme','malware','wordfence','brokenLink')
						) ".$tableEnv.";";
		if (!DB::getExists("SHOW COLUMNS FROM `?:history` WHERE Field = 'isV3'")) {
			$sqlArray[] = "ALTER TABLE `?:history` ADD `isV3` ENUM('0','1') NOT NULL DEFAULT '0'";
		}
		$this->doQuerySQLArray($sqlArray, true);
	}

	function updateForV3_1_6(){
			$sqlArray[] = "ALTER TABLE `?:additional_stats` CHANGE `type` `type` enum('comments','users','itheme','malware','wordfence','brokenLink','posts','pages','links')";
		$this->doQuerySQLArray($sqlArray, true);
	}

	function updateForV3_1_9(){

		$sqlArray[] = "CREATE TABLE IF NOT EXISTS `?:popup_notification` 
		(`number` int(11) unsigned NOT NULL AUTO_INCREMENT,
		`ID` int(11) unsigned NOT NULL,
		`name` text,
		`status` enum('0','1') DEFAULT '0',
		`oneTimeOnly` enum('0','1') DEFAULT '0',
		`userTypes` enum('all','free','bundle','addon') NOT NULL DEFAULT 'all',
		`intervalTime` int(10) unsigned NOT NULL,
		`nextSchedule` int(10) unsigned NOT NULL,
		`breakTime` int(10) unsigned NOT NULL,
		`html` longtext,
		`isShowed` enum('0','1') DEFAULT '0',
		`version` ENUM('0','1','2') NOT NULL DEFAULT '0',
		PRIMARY KEY (`number`),
		UNIQUE KEY `ID` (`ID`))".$tableEnv.";";

		if (!DB::getExists("SHOW COLUMNS FROM `?:history` WHERE Field = 'isV3'")) {
			$sqlArray[] = "ALTER TABLE `?:history` ADD `isV3` ENUM('0','1') NOT NULL DEFAULT '0'";
		}
		if (DB::getExists("SHOW TABLES LIKE '?:popup_notification'") && !DB::getExists("SHOW COLUMNS FROM `?:popup_notification` WHERE Field = 'version'")) {
			$sqlArray[] = "ALTER TABLE `?:popup_notification` ADD `version` ENUM('0','1','2') NOT NULL DEFAULT '0'";
			// 0 - v2 , 1 - v3 , 2 - both panel
		}

		$this->doQuerySQLArray($sqlArray, true);
	}

	function updateForV3_1_14(){
		$this->configFileContents = file_get_contents(APP_ROOT . '/v3/config.php');
		$this->isConfigFileEmpty(true);
		if (strpos($this->configFileContents, 'error_reporting(error_reporting() & ~E_WARNING') === false) {
				$this->configFileContents = preg_replace('/define\(\'SHOW_SQL_ERROR\', .*\);/mi',"if(function_exists('phpversion')){".PHP_EOL." if(version_compare(phpversion(),'8.0.0','>=')){".PHP_EOL."  error_reporting(error_reporting() & ~E_WARNING);".PHP_EOL."  define('IWP_PHP8',true); ".PHP_EOL." }".PHP_EOL."} ".PHP_EOL."define('SHOW_SQL_ERROR', APP_SHOW_ERROR);", $this->configFileContents);
			}
		$this->doCheckAndPutConfigFileContents(true);
	}

	function updateForV3_2_0(){
		$sql = $sqlAlter = '';
		if (!DB::getExists("SHOW COLUMNS FROM `?:sites` WHERE Field = 'clientReportAutoDeleteLogLastUpdate'")){
			$sqlAlter = "ALTER TABLE `?:sites` ADD `clientReportAutoDeleteLogLastUpdate` INT(10) NOT NULL DEFAULT '0' ";
			$isDone = DB::doQuery($sqlAlter);
			if(!$isDone){ 
				$sql = "ALTER TABLE `?:sites` CHANGE `activationKey` `activationKey` varchar(255);";
				DB::doQuery($sql);
				DB::doQuery($sqlAlter);
			}
		}
	}

}
Le coin du marchand VO vente véhicule entre professionnels

Accès réservé aux professionnels

Site regroupant des annonces de véhicules marchands en vente entre professionnels. Vendez, achetez vos V.O entre pros en toute simplicité et sans intermédiaires.

Déposez gratuitement vos annonces*

*Offre de lancement

Marques
Nous avons trouvé annonces pour vous.

Slide Slide Slide Slide Slide En savoir plus

A propos de nous

Le Coin du Marchand
VO

Le Coin du Marchand
VO

Parce que le métier de marchand V.O. est en perpétuelle évolution
Le coin du marchand V.O. a décidé de vous accompagner à travers cette plateforme qui vous propose un service de petites annonces pour la vente et l’achat de véhicules entre professionnels revendeurs.

Pour l’approvisionnement de votre parc, pour une recherche personnalisée ou vendre des véhicules stockés , assurez-vous des transactions uniquement entre pros.
L’accès à la plateforme est sécurisé et exclusivement réservé aux professionnels.

Soigneusement sélectionnées

Annonces Récentes

Pourquoi Nous Choisir

Professionnalisme

Plateforme regroupant les professionnels qui proposent des véhicules de divers modèles à la vente

Sur toute la France

Les ventes se font uniquement entre professionnels

Meilleurs Tarifs

Vous trouverez de très bonnes occasions de véhicules à des tarifs marchands

Partenaires

  • Développement
  • Bénéfices Mutuelles
  • Collaborations
  • Visibilité
  • Soutenir d’autres Projets

Newsletter

Abonnez-vous à notre newsletter et restez informé de nos offres

Copyright © 2023 Le Coin du Marchand VO | All Rights Reserved | Yanacom