public static function start() { $OSCOM_Language = Registry::get('Language'); $OSCOM_MessageStack = Registry::get('MessageStack'); if (SERVICE_DEBUG_CHECK_LOCALE == '1') { $setlocale = setlocale(LC_TIME, explode(',', $OSCOM_Language->getLocale())); if ($setlocale === false || $setlocale === null) { $OSCOM_MessageStack->add('debug', 'Error: Locale does not exist: ' . $OSCOM_Language->getLocale(), 'error'); } } if (SERVICE_DEBUG_CHECK_INSTALLATION_MODULE == '1' && file_exists(OSCOM::BASE_DIRECTORY . 'Core/Site/Setup')) { $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_install_directory_exists'), OSCOM::BASE_DIRECTORY . 'Core/Site/Setup'), 'warning'); } if (SERVICE_DEBUG_CHECK_CONFIGURATION == '1' && is_writeable(OSCOM::BASE_DIRECTORY . 'Config/settings.ini')) { $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_config_file_writeable'), OSCOM::BASE_DIRECTORY . 'Config//settings.ini'), 'warning'); } if (SERVICE_DEBUG_CHECK_SESSION_DIRECTORY == '1' && OSCOM::getConfig('store_sessions') == '') { if (!is_dir(OSCOM_Registry::get('Session')->getSavePath())) { $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_non_existent'), OSCOM_Registry::get('Session')->getSavePath()), 'warning'); } elseif (!is_writeable(OSCOM_Registry::get('Session')->getSavePath())) { $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_not_writeable'), OSCOM_Registry::get('Session')->getSavePath()), 'warning'); } } if (SERVICE_DEBUG_CHECK_SESSION_AUTOSTART == '1' && (bool) ini_get('session.auto_start')) { $OSCOM_MessageStack->add('debug', OSCOM::getDef('warning_session_auto_start'), 'warning'); } if (SERVICE_DEBUG_CHECK_DOWNLOAD_DIRECTORY == '1' && DOWNLOAD_ENABLED == '1') { if (!is_dir(DIR_FS_DOWNLOAD)) { $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_download_directory_non_existent'), DIR_FS_DOWNLOAD), 'warning'); } } return true; }
/** * Verify an existing session ID and create or resume the session if the existing session ID is valid * * @return boolean * @since v3.0.0 */ public function start() { if ($this->_life_time > 0) { ini_set('session.gc_maxlifetime', $this->_life_time); } else { $this->_life_time = ini_get('session.gc_maxlifetime'); } session_set_cookie_params(0, OSCOM::getRequestType() == 'NONSSL' ? OSCOM::getConfig('http_cookie_path') : OSCOM::getConfig('https_cookie_path'), OSCOM::getRequestType() == 'NONSSL' ? OSCOM::getConfig('http_cookie_domain') : OSCOM::getConfig('https_cookie_domain')); if (isset($_GET[$this->_name]) && (empty($_GET[$this->_name]) || !ctype_alnum($_GET[$this->_name]) || !$this->exists($_GET[$this->_name]))) { unset($_GET[$this->_name]); } if (isset($_POST[$this->_name]) && (empty($_POST[$this->_name]) || !ctype_alnum($_POST[$this->_name]) || !$this->exists($_POST[$this->_name]))) { unset($_POST[$this->_name]); } if (isset($_COOKIE[$this->_name]) && (empty($_COOKIE[$this->_name]) || !ctype_alnum($_COOKIE[$this->_name]) || !$this->exists($_COOKIE[$this->_name]))) { setcookie($this->_name, '', time() - 42000, $this->getCookieParameters('path'), $this->getCookieParameters('domain')); } if (session_start()) { register_shutdown_function(array($this, 'close')); $this->_is_started = true; $this->_id = session_id(); return true; } return false; }
public static function hasAccess($application) { if (OSCOM::configExists('offline') && OSCOM::getConfig('offline') == 'true' && $application != 'Offline') { return false; } return true; }
protected function process() { $OSCOM_MessageStack = Registry::get('MessageStack'); $this->_page_title = OSCOM::getDef('heading_title'); if ( isset($_GET['cid']) && is_numeric($_GET['cid']) ) { $this->_category_id = $_GET['cid']; } $this->_tree = new CategoryTree(); Registry::set('CategoryTree', $this->_tree); Registry::set('Currencies', new Currencies()); Registry::set('Tax', new Tax()); Registry::set('Image', new Image()); // check if the products image directory exists if ( is_dir(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'products') ) { if ( !is_writeable(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'products') ) { $OSCOM_MessageStack->add('header', sprintf(OSCOM::getDef('ms_error_image_directory_not_writable'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'products'), 'error'); } } else { $OSCOM_MessageStack->add('header', sprintf(OSCOM::getDef('ms_error_image_directory_non_existant'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'products'), 'error'); } // check for imagemagick or GD if ( !Image::hasGDSupport() && ((strlen(CFG_APP_IMAGEMAGICK_CONVERT) < 1) || !file_exists(CFG_APP_IMAGEMAGICK_CONVERT)) ) { $OSCOM_MessageStack->add('header', OSCOM::getDef('ms_warning_image_processor_not_available'), 'warning'); } }
public static function initialize() { Registry::set('MessageStack', new MessageStack()); Registry::set('Cache', new Cache()); Registry::set('PDO', PDO::initialize()); foreach (OSCOM::callDB('Shop\\GetConfiguration', null, 'Site') as $param) { define($param['cfgKey'], $param['cfgValue']); } Registry::set('Session', Session::load('adminSid')); Registry::get('Session')->start(); Registry::get('MessageStack')->loadFromSession(); Registry::set('Language', new Language()); if (!self::hasAccess(OSCOM::getSiteApplication())) { Registry::get('MessageStack')->add('header', 'No access.', 'error'); OSCOM::redirect(OSCOM::getLink(null, OSCOM::getDefaultSiteApplication())); } $application = 'osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Controller'; Registry::set('Application', new $application()); Registry::set('Template', new Template()); Registry::get('Template')->setApplication(Registry::get('Application')); // HPDL move following checks elsewhere // check if a default currency is set if (!defined('DEFAULT_CURRENCY')) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_error_no_default_currency'), 'error'); } // check if a default language is set if (!defined('DEFAULT_LANGUAGE')) { Registry::get('MessageStack')->add('header', ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error'); } if (function_exists('ini_get') && (bool) ini_get('file_uploads') == false) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_uploads_disabled'), 'warning'); } // check if Work directories are writable $work_dirs = array(); foreach (array('Cache', 'CoreUpdate', 'Database', 'Logs', 'Session', 'Temp') as $w) { if (!is_writable(OSCOM::BASE_DIRECTORY . 'Work/' . $w)) { $work_dirs[] = $w; } } if (!empty($work_dirs)) { Registry::get('MessageStack')->add('header', sprintf(OSCOM::getDef('ms_error_work_directories_not_writable'), OSCOM::BASE_DIRECTORY . 'Work/', implode(', ', $work_dirs)), 'error'); } if (!OSCOM::configExists('time_zone', 'OSCOM')) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_time_zone_not_defined'), 'warning'); } if (!OSCOM::configExists('dir_fs_public', 'OSCOM') || !file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM'))) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_dir_fs_public_not_defined'), 'warning'); } // check if the upload directory exists if (is_dir(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload')) { if (!is_writeable(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload')) { Registry::get('MessageStack')->add('header', sprintf(OSCOM::getDef('ms_error_upload_directory_not_writable'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload'), 'error'); } } else { Registry::get('MessageStack')->add('header', sprintf(OSCOM::getDef('ms_error_upload_directory_non_existant'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload'), 'error'); } }
/** * Loads the session storage handler * * @param string $name The name of the session * @access public */ public static function load($name = null) { $class_name = 'osCommerce\\OM\\Core\\Session\\' . OSCOM::getConfig('store_sessions'); if (class_exists($class_name)) { return new $class_name($name); } trigger_error('Session Handler \'' . $class_name . '\' does not exist, using default \'osCommerce\\OM\\Core\\Session\\File\'', E_USER_ERROR); return new Session\File($name); }
public static function execute($id) { if (Registry::exists('CategoryTree')) { $OSCOM_CategoryTree = Registry::get('CategoryTree'); } else { $OSCOM_CategoryTree = new CategoryTree(); Registry::set('CategoryTree', $OSCOM_CategoryTree); } $data = $OSCOM_CategoryTree->getData($id); if (!empty($data['image']) && file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $data['image'])) { unlink(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $data['image']); } }
public static function execute() { $result = array('images' => array()); $OSCOM_DL = new DirectoryListing(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload'); $OSCOM_DL->setIncludeDirectories(false); $OSCOM_DL->setCheckExtension('gif'); $OSCOM_DL->setCheckExtension('jpg'); $OSCOM_DL->setCheckExtension('png'); foreach ($OSCOM_DL->getFiles() as $f) { $result['images'][] = $f['name']; } $result['rpcStatus'] = RPC::STATUS_SUCCESS; echo json_encode($result); }
public static function execute() { $error = true; $image = new Upload('qqfile', OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload', null, array('gif', 'jpg', 'png')); if ($image->check() && $image->save()) { $error = false; } if ($error === false) { $result = array('success' => true, 'filename' => $image->getFilename()); } else { $result = array('error' => 'Error'); } echo json_encode($result); }
public static function execute() { $result = array(); $db_time = OSCOM::callDB('Admin\\ServerInfo\\GetTime'); $db_uptime = OSCOM::callDB('Admin\\ServerInfo\\GetUptime'); $db_version = OSCOM::callDB('Admin\\ServerInfo\\GetVersion'); $uptime = '---'; if (!in_array('exec', explode(',', str_replace(' ', '', ini_get('disable_functions'))))) { $uptime = @exec('uptime'); } $data = array(array('key' => 'date', 'title' => OSCOM::getDef('field_server_date'), 'value' => DateTime::getShort(null, true)), array('key' => 'system', 'title' => OSCOM::getDef('field_server_operating_system'), 'value' => php_uname('s') . ' ' . php_uname('r')), array('key' => 'host', 'title' => OSCOM::getDef('field_server_host'), 'value' => php_uname('n') . ' (' . gethostbyname(php_uname('n')) . ')'), array('key' => 'uptime', 'title' => OSCOM::getDef('field_server_up_time'), 'value' => $uptime), array('key' => 'http_server', 'title' => OSCOM::getDef('field_http_server'), 'value' => $_SERVER['SERVER_SOFTWARE']), array('key' => 'php', 'title' => OSCOM::getDef('field_php_version'), 'value' => 'PHP v' . PHP_VERSION . ' / Zend v' . zend_version()), array('key' => 'db_server', 'title' => OSCOM::getDef('field_database_host'), 'value' => OSCOM::getConfig('db_server') . ' (' . gethostbyname(OSCOM::getConfig('db_server')) . ')'), array('key' => 'db_version', 'title' => OSCOM::getDef('field_database_version'), 'value' => $db_version), array('key' => 'db_date', 'title' => OSCOM::getDef('field_database_date'), 'value' => DateTime::getShort($db_time, true)), array('key' => 'db_uptime', 'title' => OSCOM::getDef('field_database_up_time'), 'value' => $db_uptime)); $result['entries'] = $data; $result['total'] = count($data); return $result; }
protected function process() { $OSCOM_MessageStack = Registry::get('MessageStack'); $this->_page_title = OSCOM::getDef('heading_title'); if (isset($_GET['cid']) && is_numeric($_GET['cid'])) { $this->_category_id = $_GET['cid']; } $this->_tree = new CategoryTree(); Registry::set('CategoryTree', $this->_tree); // check if the categories image directory exists if (is_dir(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories')) { if (!is_writeable(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories')) { $OSCOM_MessageStack->add('header', sprintf(OSCOM::getDef('ms_error_image_directory_not_writable'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories'), 'error'); } } else { $OSCOM_MessageStack->add('header', sprintf(OSCOM::getDef('ms_error_image_directory_non_existant'), OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories'), 'error'); } }
public static function execute($id = null, $data) { if (Registry::exists('CategoryTree')) { $OSCOM_CategoryTree = Registry::get('CategoryTree'); } else { $OSCOM_CategoryTree = new CategoryTree(); Registry::set('CategoryTree', $OSCOM_CategoryTree); } if (is_numeric($id)) { $data['id'] = $id; } // Prevent another big bang and check if category is not being moved to a child category if (isset($data['id']) && $OSCOM_CategoryTree->getParentID($data['id']) != $data['parent_id']) { if (in_array($data['id'], explode('_', $OSCOM_CategoryTree->buildBreadcrumb($data['parent_id'])))) { return false; } } if (isset($data['image'])) { $new_image = $data['image']; while (file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) { $new_image = rand(10, 99) . $new_image; } if (rename(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload/' . $data['image'], OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) { if (is_numeric($id)) { $old_image = Categories::get($id, 'categories_image'); unlink(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $old_image); } $data['image'] = $new_image; } else { $data['image'] = null; } } if (OSCOM::callDB('Admin\\Categories\\Save', $data)) { Cache::clear('categories'); Cache::clear('category_tree'); Cache::clear('also_purchased'); return true; } return false; }
protected function _autoPrefixTables($statement) { if ( OSCOM::configExists('db_table_prefix') ) { $statement = str_replace(':table_', OSCOM::getConfig('db_table_prefix'), $statement); } return $statement; }
public function getAddress($image, $group = 'default') { $group_id = $this->getID($group); $url = OSCOM::getRequestType() == 'NONSSL' ? OSCOM::getConfig('product_images_http_server') . OSCOM::getConfig('product_images_dir_ws_http_server') : OSCOM::getConfig('product_images_http_server') . OSCOM::getConfig('product_images_dir_ws_http_server'); return $url . $this->_groups[$group_id]['code'] . '/' . $image; }
public function execute($input_parameters = array()) { $query_action = strtolower(substr($this->queryString, 0, strpos($this->queryString, ' '))); $db_table_prefix = OSCOM::getConfig('db_table_prefix'); if ($query_action == 'delete') { $query_data = explode(' ', $this->queryString, 4); $query_table = substr($query_data[2], strlen($db_table_prefix)); if ($this->_pdo->hasForeignKey($query_table)) { // check for RESTRICT constraints first foreach ($this->_pdo->getForeignKeys($query_table) as $fk) { if ($fk['on_delete'] == 'restrict') { $Qchild = $this->_pdo->prepare('select ' . $fk['to_field'] . ' from ' . $query_data[2] . ' ' . $query_data[3]); foreach ($this->_binded_params as $key => $value) { $Qchild->bindValue($key, $value['value'], $value['data_type']); } $Qchild->execute(); while ($Qchild->fetch()) { $Qcheck = $this->_pdo->prepare('select ' . $fk['from_field'] . ' from ' . $db_table_prefix . $fk['from_table'] . ' where ' . $fk['from_field'] . ' = "' . $Qchild->value($fk['to_field']) . '" limit 1'); $Qcheck->execute(); if (count($Qcheck->fetchAll()) === 1) { trigger_error('RESTRICT constraint condition from table ' . $db_table_prefix . $fk['from_table']); return false; } } } } foreach ($this->_pdo->getForeignKeys($query_table) as $fk) { $Qparent = $this->_pdo->prepare('select * from ' . $query_data[2] . ' ' . $query_data[3]); foreach ($this->_binded_params as $key => $value) { $Qparent->bindValue($key, $value['value'], $value['data_type']); } $Qparent->execute(); while ($Qparent->fetch()) { if ($fk['on_delete'] == 'cascade') { $Qdel = $this->_pdo->prepare('delete from ' . $db_table_prefix . $fk['from_table'] . ' where ' . $fk['from_field'] . ' = :' . $fk['from_field']); $Qdel->bindValue(':' . $fk['from_field'], $Qparent->value($fk['to_field'])); $Qdel->execute(); } elseif ($fk['on_delete'] == 'set_null') { $Qupdate = $this->_pdo->prepare('update ' . $db_table_prefix . $fk['from_table'] . ' set ' . $fk['from_field'] . ' = null where ' . $fk['from_field'] . ' = :' . $fk['from_field']); $Qupdate->bindValue(':' . $fk['from_field'], $Qparent->value($fk['to_field'])); $Qupdate->execute(); } } } } } elseif ($query_action == 'update') { $query_data = explode(' ', $this->queryString, 3); $query_table = substr($query_data[1], strlen($db_table_prefix)); if ($this->_pdo->hasForeignKey($query_table)) { // check for RESTRICT constraints first foreach ($this->_pdo->getForeignKeys($query_table) as $fk) { if ($fk['on_update'] == 'restrict') { $Qchild = $this->_pdo->prepare('select ' . $fk['to_field'] . ' from ' . $query_data[2] . ' ' . $query_data[3]); foreach ($this->_binded_params as $key => $value) { $Qchild->bindValue($key, $value['value'], $value['data_type']); } $Qchild->execute(); while ($Qchild->fetch()) { $Qcheck = $this->_pdo->prepare('select ' . $fk['from_field'] . ' from ' . $db_table_prefix . $fk['from_table'] . ' where ' . $fk['from_field'] . ' = "' . $Qchild->value($fk['to_field']) . '" limit 1'); $Qcheck->execute(); if (count($Qcheck->fetchAll()) === 1) { trigger_error('RESTRICT constraint condition from table ' . $db_table_prefix . $fk['from_table']); return false; } } } } foreach ($this->_pdo->getForeignKeys($query_table) as $fk) { // check to see if foreign key column value is being changed if (strpos(substr($this->queryString, strpos($this->queryString, ' set ') + 4, strpos($this->queryString, ' where ') - strpos($this->queryString, ' set ') - 4), ' ' . $fk['to_field'] . ' ') !== false) { $Qparent = $this->_pdo->prepare('select * from ' . $query_data[1] . substr($this->queryString, strrpos($this->queryString, ' where '))); foreach ($this->_binded_params as $key => $value) { if (preg_match('/:\\b' . substr($key, 1) . '\\b/', $Qparent->queryString)) { $Qparent->bindValue($key, $value['value'], $value['data_type']); } } $Qparent->execute(); while ($Qparent->fetch()) { if ($fk['on_update'] == 'cascade' || $fk['on_update'] == 'set_null') { $on_update_value = ''; if ($fk['on_update'] == 'cascade') { $on_update_value = $this->_binded_params[':' . $fk['to_field']]['value']; } $Qupdate = $this->_pdo->prepare('update ' . $db_table_prefix . $fk['from_table'] . ' set ' . $fk['from_field'] . ' = :' . $fk['from_field'] . ' where ' . $fk['from_field'] . ' = :' . $fk['from_field'] . '_orig'); if (empty($on_update_value)) { $Qupdate->bindNull(':' . $fk['from_field']); } else { $Qupdate->bindValue(':' . $fk['from_field'], $on_update_value); } $Qupdate->bindValue(':' . $fk['from_field'] . '_orig', $Qparent->value($fk['to_field'])); $Qupdate->execute(); } } } } } } return parent::execute($input_parameters); }
public static function execute() { $phar_can_open = true; $meta = array(); $pro_hart = array(); try { $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar'); $meta = $phar->getMetadata(); self::$_to_version = $meta['version_to']; // reset the log if (file_exists(OSCOM::BASE_DIRECTORY . 'Work/Logs/update-' . self::$_to_version . '.txt') && is_writable(OSCOM::BASE_DIRECTORY . 'Work/Logs/update-' . self::$_to_version . '.txt')) { unlink(OSCOM::BASE_DIRECTORY . 'Work/Logs/update-' . self::$_to_version . '.txt'); } self::log('##### UPDATE TO ' . self::$_to_version . ' STARTED'); // first delete files before extracting new files if (isset($meta['delete'])) { foreach ($meta['delete'] as $file) { $directory = (substr($file, 0, 14) == 'osCommerce/OM/' ? realpath(OSCOM::BASE_DIRECTORY . '../../') : realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../')) . '/'; if (file_exists($directory . $file)) { if (is_dir($directory . $file)) { if (rename($directory . $file, $directory . dirname($file) . '/.CU_' . basename($file))) { $pro_hart[] = array('type' => 'directory', 'where' => $directory, 'path' => dirname($file) . '/.CU_' . basename($file), 'log' => true); } } else { if (rename($directory . $file, $directory . dirname($file) . '/.CU_' . basename($file))) { $pro_hart[] = array('type' => 'file', 'where' => $directory, 'path' => dirname($file) . '/.CU_' . basename($file), 'log' => true); } } } } } // loop through each file individually as extractTo() does not work with // directories (see http://bugs.php.net/bug.php?id=54289) foreach (new RecursiveIteratorIterator($phar) as $iteration) { if (($pos = strpos($iteration->getPathName(), 'update.phar')) !== false) { $file = substr($iteration->getPathName(), $pos + 12); $directory = (substr($file, 0, 14) == 'osCommerce/OM/' ? realpath(OSCOM::BASE_DIRECTORY . '../../') : realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../')) . '/'; if (file_exists($directory . $file)) { if (rename($directory . $file, $directory . dirname($file) . '/.CU_' . basename($file))) { $pro_hart[] = array('type' => 'file', 'where' => $directory, 'path' => dirname($file) . '/.CU_' . basename($file), 'log' => false); } } if ($phar->extractTo($directory, $file, true)) { self::log('Extracted: ' . $file); } else { self::log('*** Could Not Extract: ' . $file); } } } self::log('##### CLEANUP'); foreach (array_reverse($pro_hart, true) as $mess) { if ($mess['type'] == 'directory') { if (self::rmdir_r($mess['where'] . $mess['path'])) { if ($mess['log'] === true) { self::log('Deleted: ' . str_replace('/.CU_', '/', $mess['path'])); } } else { if ($mess['log'] === true) { self::log('*** Could Not Delete: ' . str_replace('/.CU_', '/', $mess['path'])); } } } else { if (unlink($mess['where'] . $mess['path'])) { if ($mess['log'] === true) { self::log('Deleted: ' . str_replace('/.CU_', '/', $mess['path'])); } } else { if ($mess['log'] === true) { self::log('*** Could Not Delete: ' . str_replace('/.CU_', '/', $mess['path'])); } } } } } catch (\Exception $e) { $phar_can_open = false; self::log('##### ERROR: ' . $e->getMessage()); self::log('##### REVERTING STARTED'); foreach (array_reverse($pro_hart, true) as $mess) { if ($mess['type'] == 'directory') { if (file_exists($mess['where'] . str_replace('/.CU_', '/', $mess['path']))) { self::rmdir_r($mess['where'] . str_replace('/.CU_', '/', $mess['path'])); } } else { if (file_exists($mess['where'] . str_replace('/.CU_', '/', $mess['path']))) { unlink($mess['where'] . str_replace('/.CU_', '/', $mess['path'])); } } if (file_exists($mess['where'] . $mess['path'])) { rename($mess['where'] . $mess['path'], $mess['where'] . str_replace('/.CU_', '/', $mess['path'])); } self::log('Reverted: ' . str_replace('/.CU_', '/', $mess['path'])); } self::log('##### REVERTING COMPLETE'); self::log('##### UPDATE TO ' . self::$_to_version . ' FAILED'); trigger_error($e->getMessage()); trigger_error('Please review the update log at: ' . OSCOM::BASE_DIRECTORY . 'Work/Logs/update-' . self::$_to_version . '.txt'); } if ($phar_can_open === true) { if (isset($meta['run']) && method_exists('osCommerce\\OM\\Work\\CoreUpdate\\' . $meta['run'] . '\\Controller', 'runAfter')) { $results = call_user_func(array('osCommerce\\OM\\Work\\CoreUpdate\\' . $meta['run'] . '\\Controller', 'runAfter')); if (!empty($results)) { self::log('##### RAN AFTER'); foreach ($results as $r) { self::log($r); } } self::log('##### CLEANUP'); if (self::rmdir_r(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/' . $meta['run'])) { self::log('Deleted: osCommerce/OM/Work/CoreUpdate/' . $meta['run']); } else { self::log('*** Could Not Delete: osCommerce/OM/Work/CoreUpdate/' . $meta['run']); } } self::log('##### UPDATE TO ' . self::$_to_version . ' COMPLETE'); } return $phar_can_open; }
public static function start() { Registry::set('Session', SessionClass::load()); $OSCOM_Session = Registry::get('Session'); $OSCOM_Session->setLifeTime(SERVICE_SESSION_EXPIRATION_TIME * 60); if (SERVICE_SESSION_FORCE_COOKIE_USAGE == '1' || (bool) ini_get('session.use_only_cookies') === true) { OSCOM::setCookie('cookie_test', 'please_accept_for_session', time() + 60 * 60 * 24 * 90); if (isset($_COOKIE['cookie_test'])) { $OSCOM_Session->start(); } } elseif (SERVICE_SESSION_BLOCK_SPIDERS == '1') { $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); $spider_flag = false; if (!empty($user_agent)) { $spiders = file(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/assets/spiders.txt'); foreach ($spiders as $spider) { if (!empty($spider)) { if (strpos($user_agent, trim($spider)) !== false) { $spider_flag = true; break; } } } } if ($spider_flag === false) { $OSCOM_Session->start(); } } else { $OSCOM_Session->start(); } // verify the ssl_session_id if (OSCOM::getRequestType() == 'SSL' && SERVICE_SESSION_CHECK_SSL_SESSION_ID == '1' && OSCOM::getConfig('enable_ssl') == 'true') { if (isset($_SERVER['SSL_SESSION_ID']) && ctype_xdigit($_SERVER['SSL_SESSION_ID'])) { if (!isset($_SESSION['SESSION_SSL_ID'])) { $_SESSION['SESSION_SSL_ID'] = $_SERVER['SSL_SESSION_ID']; } if ($_SESSION['SESSION_SSL_ID'] != $_SERVER['SSL_SESSION_ID']) { $OSCOM_Session->destroy(); OSCOM::redirect(OSCOM::getLink(null, 'Info', 'SSLcheck', 'AUTO')); } } } // verify the browser user agent if (SERVICE_SESSION_CHECK_USER_AGENT == '1') { $http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if (!isset($_SESSION['SESSION_USER_AGENT'])) { $_SESSION['SESSION_USER_AGENT'] = $http_user_agent; } if ($_SESSION['SESSION_USER_AGENT'] != $http_user_agent) { $OSCOM_Session->destroy(); OSCOM::redirect(OSCOM::getLink(null, 'Account', 'LogIn', 'SSL')); } } // verify the IP address if (SERVICE_SESSION_CHECK_IP_ADDRESS == '1') { if (!isset($_SESSION['SESSION_IP_ADDRESS'])) { $_SESSION['SESSION_IP_ADDRESS'] = OSCOM::getIPAddress(); } if ($_SESSION['SESSION_IP_ADDRESS'] != OSCOM::getIPAddress()) { $OSCOM_Session->destroy(); OSCOM::redirect(OSCOM::getLink(null, 'Account', 'LogIn', 'SSL')); } } Registry::get('MessageStack')->loadFromSession(); return true; }
public static function execute() { $result = array('entries' => array()); $phar_can_open = true; try { $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar'); } catch (\Exception $e) { $phar_can_open = false; trigger_error($e->getMessage()); } if ($phar_can_open === true) { $update_pkg = array(); foreach (new RecursiveIteratorIterator($phar) as $iteration) { if (($pos = strpos($iteration->getPathName(), 'update.phar')) !== false) { $update_pkg[] = substr($iteration->getPathName(), $pos + 12); } } natcasesort($update_pkg); $counter = 0; foreach ($update_pkg as $file) { if (substr($file, 0, 14) == 'osCommerce/OM/') { $custom = false; if (substr($file, 14, 5) == 'Core/') { $custom = file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/osCommerce/OM/Custom/' . substr($file, 19)); } $result['entries'][] = array('key' => $counter, 'name' => $file, 'exists' => file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file), 'writable' => self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file) && self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . dirname($file)), 'custom' => $custom, 'to_delete' => false); $counter++; } elseif (substr($file, 0, 7) == 'public/') { $result['entries'][] = array('key' => $counter, 'name' => $file, 'exists' => file_exists(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file), 'writable' => self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file) && self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . dirname($file)), 'custom' => false, 'to_delete' => false); $counter++; } } } $meta = $phar->getMetadata(); if (isset($meta['delete'])) { $files = array(); foreach ($meta['delete'] as $file) { if (substr($file, 0, 14) == 'osCommerce/OM/') { if (file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file)) { if (is_dir(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file)) { $DL = new DirectoryListing(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file); $DL->setRecursive(true); $DL->setAddDirectoryToFilename(true); $DL->setIncludeDirectories(false); foreach ($DL->getFiles() as $f) { $files[] = $file . '/' . $f['name']; } } else { $files[] = $file; } } } elseif (substr($file, 0, 7) == 'public/') { if (file_exists(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file)) { if (is_dir(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file)) { $DL = new DirectoryListing(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file); $DL->setRecursive(true); $DL->setAddDirectoryToFilename(true); $DL->setIncludeDirectories(false); foreach ($DL->getFiles() as $f) { $files[] = $file . '/' . $f['name']; } } else { $files[] = $file; } } } } natcasesort($files); foreach ($files as $d) { $writable = false; $custom = false; if (substr($d, 0, 14) == 'osCommerce/OM/') { $writable = self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $d) && self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . dirname($d)); } elseif (substr($d, 0, 7) == 'public/') { $writable = self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $d) && self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . dirname($d)); } $result['entries'][] = array('key' => $counter, 'name' => $d, 'exists' => true, 'writable' => $writable, 'custom' => $custom, 'to_delete' => true); $counter++; } } $result['total'] = count($result['entries']); return $result; }