function jaucValidServiceSettings($params) { $errMsg = ""; if (!is_dir(JA_WORKING_DATA_FOLDER)) { if (!mkdir(JA_WORKING_DATA_FOLDER, 0777)) { $errMsg .= JText::_("JA Updater can not create below folder automatically. Please manual do it!") . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } elseif (!is_writeable(JA_WORKING_DATA_FOLDER)) { if (!chmod(JA_WORKING_DATA_FOLDER, 0777)) { $errMsg .= JText::_("JA Updater can not automatically chmod for below folder to wriable. Please manual do it!") . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } else { $fileAccess = JA_WORKING_DATA_FOLDER . ".htaccess"; if (!is_file($fileAccess)) { $fp = fopen($fileAccess, 'wb'); fwrite($fp, "Order deny,allow\r\nDeny from all"); fclose($fp); } } if (substr(PHP_OS, 0, 3) == 'WIN') { if (!is_dir(dirname($params->get("MYSQL_PATH")))) { $errMsg .= JText::_("Path to mysql CLI is not correct!") . "<br />"; } if (!is_dir(dirname($params->get("MYSQLDUMP_PATH")))) { $errMsg .= JText::_("Path to mysql dump CLI is not correct!") . "<br />"; } } if ($errMsg != "") { if (JRequest::getVar('layout') == 'config_service') { jaucRaiseMessage($errMsg, true); } /*$errMsg .= "<a href=\"index.php?option=".JACOMPONENT."&view=default&layout=config_service\" title=\"\">".JText::_('Click here to edit settings')."</a>"; JError::raiseWarning(100, $errMsg);*/ } }
function jaucValidServiceSettings($params) { $errMsg = ""; if (!JFolder::exists(JA_WORKING_DATA_FOLDER)) { if (!JFolder::create(JA_WORKING_DATA_FOLDER, 0755)) { $errMsg .= JText::_("JA_UPDATER_CAN_NOT_CREATE_BELOW_FOLDER_AUTOMATICALLY_PLEASE_MANUAL_DO_IT") . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } elseif (!is_writeable(JA_WORKING_DATA_FOLDER)) { if (!chmod(JA_WORKING_DATA_FOLDER, 0755)) { $errMsg .= JText::_("JA_UPDATER_CAN_NOT_AUTOMATICALLY_CHMOD_FOR_BELOW_FOLDER_TO_WRIABLE_PLEASE_MANUAL_DO_IT") . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } else { $fileAccess = JA_WORKING_DATA_FOLDER . ".htaccess"; if (!JFile::exists($fileAccess)) { $buffer = "Order deny,allow\r\nDeny from all"; JFile::write($fileAccess, $buffer); } } if (substr(PHP_OS, 0, 3) == 'WIN') { if (!JFolder::exists(dirname($params->get("MYSQL_PATH")))) { $errMsg .= JText::_("PATH_TO_MYSQL_CLI_IS_NOT_CORRECT") . "<br />"; } if (!JFolder::exists(dirname($params->get("MYSQLDUMP_PATH")))) { $errMsg .= JText::_("PATH_TO_MYSQL_DUMP_CLI_IS_NOT_CORRECT") . "<br />"; } } if ($errMsg != "") { if (JRequest::getVar('layout') == 'config_service') { jaucRaiseMessage($errMsg, true); } /*$errMsg .= "<a href=\"index.php?option=com_jaextmanager&view=default&layout=config_service\" title=\"\">".JText::_('CLICK_HERE_TO_EDIT_SETTINGS')."</a>"; JError::raiseWarning(100, $errMsg);*/ } }
/** * * @param $url * @param $savePath * @param $options * * @return {array("savePath"=>$savePath, "error"=>curl_error(), "info"=>curl_getinfo())} */ function downloadFile($savePath, $url, $data, $options = null) { if (substr($savePath, -1) == '/' || is_dir($savePath)) { $targetDir = $savePath; $savePath = tempnam(sys_get_temp_dir(), 'c_'); } if (($fh = fopen($savePath, "wb")) === false) { jaucRaiseMessage("Can not open file: {$savePath}", true); //throw new Exception("CURL ERROR:: Can not open file: $savePath"); return false; } $result = NetworkHelper::doPOST($url, $data, $options); if (!empty($result["error"])) { return false; } if (($fp = fopen($savePath, 'wb')) !== false) { fwrite($fp, $result["content"]); fclose($fp); } else { return false; } $result["savePath"] = $savePath; return $result; }
defined('_JA') or die('Restricted access'); define('JA_WORKING_DATA_FOLDER', PATH_ROOT . DS . "jaextmanager_data" . DS); function jaucRaiseMessage($message, $error = false) { if ($error) { echo "<div style=\"color:red; font-weight:bold;\">{$message}</div>"; } else { echo "<div style=\"color:green; font-weight:bold;\">{$message}</div>"; } } $errMsg = ""; if (!is_dir(JA_WORKING_DATA_FOLDER)) { if (!mkdir(JA_WORKING_DATA_FOLDER, 0777)) { $errMsg .= "JA Updater can not create below folder automatically. Please manual create and chmod it to wriable!" . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } elseif (!is_writeable(JA_WORKING_DATA_FOLDER)) { if (!chmod(JA_WORKING_DATA_FOLDER, 0777)) { $errMsg .= "JA Updater can not automatically chmod for below folder to wriable. Please manual chmod it to wriable!" . "<br />"; $errMsg .= "<i>" . JA_WORKING_DATA_FOLDER . "</i>"; } } if ($errMsg != "") { jaucRaiseMessage($errMsg, true); } // This file will hold configuration for UpdaterClient global $config; //echo "other flatform"; $config = new UpdaterConfig(array("WS_MODE" => "remote", "WS_URI" => "http://update.joomlart.com/service/", "WS_USER" => "joomlart", "WS_PASS" => "joomlart", "REPO_PATH" => "", "MYSQL_HOST" => "localhost", "MYSQL_USER" => "thanhnv", "MYSQL_PASS" => "1234", "MYSQL_DB" => "ja_updater", "MYSQL_DB_PREFIX" => "jos_", "MYSQL_PATH" => 'mysql', "MYSQLDUMP_PATH" => 'mysqldump')); ini_set('xdebug.max_nesting_level', 100); ini_set('xdebug.var_display_max_depth', 100);
function doRecoveryFile($product, $file) { $folder = $this->getLocalBackupPath($product); $pro = new jaProducts($product, $this->config); $result = $pro->doRecovery($product, $folder, $file); if ($result) { return $result; } else { jaucRaiseMessage('Unsuccessfully Rollback', true); //throw new Exception('[UpdaterClient->doRecoveryFile] Recovery is fail', 100); return false; } }