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; }
function execute() { global $osC_Database, $osC_NavigationHistory, $osC_Customer; if (!$osC_Customer->isLoggedOn()) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); return false; } $id = false; foreach ($_GET as $key => $value) { if ((preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $key) || preg_match('/^[a-zA-Z0-9 -_]*$/', $key)) && $key != OSCOM_Registry::get('Session')->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $Qcheck = $osC_Database->query('select products_id from :table_products_notifications where customers_id = :customers_id and products_id = :products_id limit 1'); $Qcheck->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->bindInt(':products_id', $osC_Product->getID()); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { $Qn = $osC_Database->query('delete from :table_products_notifications where customers_id = :customers_id and products_id = :products_id'); $Qn->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qn->bindInt(':customers_id', $osC_Customer->getID()); $Qn->bindInt(':products_id', $osC_Product->getID()); $Qn->execute(); } } osc_redirect(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')))); }
public static function delete($id) { global $osC_Database; OSCOM_Registry::get('Session')->delete($id); $Qwho = $osC_Database->query('delete from :table_whos_online where session_id = :session_id'); $Qwho->bindTable(':table_whos_online', TABLE_WHOS_ONLINE); $Qwho->bindValue(':session_id', $id); $Qwho->execute(); if (!$osC_Database->isError()) { return true; } return false; }
function execute() { global $osC_Database, $osC_NavigationHistory, $osC_Customer; if (!$osC_Customer->isLoggedOn()) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); return false; } $notifications = array(); if (isset($_GET['products']) && !empty($_GET['products'])) { $products_array = explode(';', $_GET['products']); foreach ($products_array as $product_id) { if (is_numeric($product_id) && !in_array($product_id, $notifications)) { $notifications[] = $product_id; } } } else { $id = false; foreach ($_GET as $key => $value) { if ((preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $key) || preg_match('/^[a-zA-Z0-9 -_]*$/', $key)) && $key != OSCOM_Registry::get('Session')->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $notifications[] = $osC_Product->getID(); } } if (!empty($notifications)) { foreach ($notifications as $product_id) { $Qcheck = $osC_Database->query('select products_id from :table_products_notifications where customers_id = :customers_id and products_id = :products_id limit 1'); $Qcheck->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->bindInt(':products_id', $product_id); $Qcheck->execute(); if ($Qcheck->numberOfRows() < 1) { $Qn = $osC_Database->query('insert into :table_products_notifications (products_id, customers_id, date_added) values (:products_id, :customers_id, :date_added)'); $Qn->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qn->bindInt(':products_id', $product_id); $Qn->bindInt(':customers_id', $osC_Customer->getID()); $Qn->bindRaw(':date_added', 'now()'); $Qn->execute(); } } } osc_redirect(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')))); }
$osC_Tax = new osC_Tax_Admin(); $osC_Weight = new osC_Weight(); $osC_GeoIP = osC_GeoIP_Admin::load(); if ($osC_GeoIP->isInstalled()) { $osC_GeoIP->activate(); } $osC_ObjectInfo = new osC_ObjectInfo(osC_WhosOnline_Admin::getData($_GET['info'])); if (STORE_SESSIONS == 'database') { $Qsession = $osC_Database->query('select value from :table_sessions where id = :id'); $Qsession->bindTable(':table_sessions', TABLE_SESSIONS); $Qsession->bindValue(':id', $osC_ObjectInfo->get('session_id')); $Qsession->execute(); $session_data = trim($Qsession->value('value')); } else { if (file_exists(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id')) && filesize(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id')) > 0) { $session_data = trim(file_get_contents(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id'))); } } $navigation = unserialize(osc_get_serialized_variable($session_data, 'osC_NavigationHistory_data', 'array')); $last_page = end($navigation); $last_page_url = $last_page['page']; if (isset($last_page['get']['osCsid'])) { unset($last_page['get']['osCsid']); } if (sizeof($last_page['get']) > 0) { $last_page_url .= '?' . osc_array_to_string($last_page['get']); } $currency = unserialize(osc_get_serialized_variable($session_data, 'currency', 'string')); $cart = unserialize(osc_get_serialized_variable($session_data, 'osC_ShoppingCart_data', 'array')); ?>
</th> </tr> </tfoot> <tbody> <?php while ($Qwho->next()) { if (STORE_SESSIONS == 'database') { $Qsession = $osC_Database->query('select value from :table_sessions where id = :id'); $Qsession->bindTable(':table_sessions', TABLE_SESSIONS); $Qsession->bindValue(':id', $Qwho->value('session_id')); $Qsession->execute(); $session_data = trim($Qsession->value('value')); } else { if (file_exists(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $Qwho->value('session_id')) && filesize(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $Qwho->value('session_id')) > 0) { $session_data = trim(file_get_contents(OSCOM_Registry::get('Session')->getSavePath() . '/sess_' . $Qwho->value('session_id'))); } } $navigation = unserialize(osc_get_serialized_variable($session_data, 'osC_NavigationHistory_data', 'array')); $last_page = end($navigation); $currency = unserialize(osc_get_serialized_variable($session_data, 'currency', 'string')); $cart = unserialize(osc_get_serialized_variable($session_data, 'osC_ShoppingCart_data', 'array')); ?> <tr onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);"> <td align="center"> <?php if ($osC_GeoIP->isActive() && $osC_GeoIP->isValid($Qwho->value('ip_address'))) { echo osc_image('../images/worldflags/' . $osC_GeoIP->getCountryISOCode2($Qwho->value('ip_address')) . '.png', $osC_GeoIP->getCountryName($Qwho->value('ip_address')) . ', ' . $Qwho->value('ip_address'), 18, 12); } else {
public static function delete($id) { global $osC_Database; $Qcheck = $osC_Database->query('select session_id from :table_whos_online where customer_id = :customer_id'); $Qcheck->bindTable(':table_whos_online', TABLE_WHOS_ONLINE); $Qcheck->bindInt(':customer_id', $id); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { OSCOM_Registry::get('Session')->delete($Qcheck->value('session_id')); } $Qcustomers = $osC_Database->query('delete from :table_customers where customers_id = :customers_id'); $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcustomers->bindInt(':customers_id', $id); $Qcustomers->setLogging($_SESSION['module'], $id); $Qcustomers->execute(); return !$osC_Database->isError(); }
public static function restore($filename = false) { global $osC_Database; osc_set_time_limit(0); if ($filename !== false) { if (file_exists(DIR_FS_BACKUP . $filename)) { $restore_file = DIR_FS_BACKUP . $filename; $extension = substr($filename, -3); if ($extension == 'sql' || $extension == '.gz' || $extension == 'zip') { switch ($extension) { case 'sql': $restore_from = $restore_file; $remove_raw = false; break; case '.gz': $restore_from = substr($restore_file, 0, -3); exec(CFG_APP_GUNZIP . ' ' . $restore_file . ' -c > ' . $restore_from); $remove_raw = true; break; case 'zip': $restore_from = substr($restore_file, 0, -4); exec(CFG_APP_UNZIP . ' ' . $restore_file . ' -d ' . DIR_FS_BACKUP); $remove_raw = true; break; } if (isset($restore_from) && file_exists($restore_from)) { $fd = fopen($restore_from, 'rb'); $restore_query = fread($fd, filesize($restore_from)); fclose($fd); } } } } else { $sql_file = new upload('sql_file'); if ($sql_file->parse()) { $restore_query = fread(fopen($sql_file->tmp_filename, 'r'), filesize($sql_file->tmp_filename)); $filename = $sql_file->filename; } } if (isset($restore_query) && !empty($restore_query)) { $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_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 (preg_match('/create/i', $next) || preg_match('/insert/i', $next) || preg_match('/drop t/i', $next)) { $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; } } } // drop all tables defined in oscommerce/includes/database_tables.php $tables_array = array(); foreach (get_defined_constants() as $key => $value) { if (substr($key, 0, 6) == 'TABLE_') { $tables_array[] = $value; } } if (!empty($tables_array)) { $Qdrop = $osC_Database->query('drop table if exists :tables'); $Qdrop->bindRaw(':tables', implode(', ', $tables_array)); $Qdrop->execute(); } for ($i = 0, $n = sizeof($sql_array); $i < $n; $i++) { $osC_Database->simpleQuery($sql_array[$i]); } OSCOM_Registry::get('Session')->close(); // empty the sessions table $Qsessions = $osC_Database->query('delete from :table_sessions'); $Qsessions->bindTable(':table_sessions', TABLE_SESSIONS); $Qsessions->execute(); // empty the who's online table $Qwho = $osC_Database->query('delete from :table_whos_online'); $Qwho->bindTable(':table_whos_online', TABLE_WHOS_ONLINE); $Qwho->execute(); $Qcfg = $osC_Database->query('delete from :table_configuration where configuration_key = :configuration_key'); $Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION); $Qcfg->bindValue(':configuration_key', 'DB_LAST_RESTORE'); $Qcfg->execute(); $Qcfg = $osC_Database->query('insert into :table_configuration values ("", "Last Database Restore", "DB_LAST_RESTORE", :filename, "Last database restore file", "6", "", "", now(), "", "")'); $Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION); $Qcfg->bindValue(':filename', $filename); $Qcfg->execute(); osC_Cache::clear('configuration'); if (isset($remove_raw) && $remove_raw === true) { unlink($restore_from); } return true; } return false; }