public static function sendUaStat() { $access_id = TwigmoConnector::getAccessID('A'); if (!$access_id) { return; } $query = db_quote('FROM ?:twigmo_ua_stat WHERE month<?s LIMIT ?i', date('Y-m-1'), 100); $needToSend = db_get_array('SELECT *, ?s as access_id ' . $query, $access_id); if (!count($needToSend)) { return; } $responce = Http::post(TWG_UA_RULES_STAT, array('stat' => serialize($needToSend))); if ($responce == 'ok') { db_query('DELETE ' . $query); } }
/** * Get favicon's url for twigmo */ public static final function getFaviconUrl() { $local_jsurl = Registry::get('config.twg.jsurl'); $urls = TwigmoConnector::getMobileScriptsUrls($local_jsurl); return $urls['favicon']; }
function fn_twigmo_set_admin_notification() { if (!TwigmoConnector::anyFrontendIsConnected()) { $message = __('twgadmin_connect_notification', array('[addon_link]' => fn_url('addons.update&addon=twigmo'))); fn_set_notification('N', __('notice'), $message, 'S'); } if (fn_twg_is_on_saas()) { if (!isset($_SESSION['stats'])) { $_SESSION['stats'] = array(); } $_SESSION['stats'][] = fn_twg_get_ajax_reconnect_code('check_twigmo_for_upgrade'); } }
} return array(CONTROLLER_STATUS_REDIRECT, 'addons.update?addon=twigmo'); } if ($mode == 'tw_disconnect') { $stores = empty($_REQUEST['disconnect_stores']) ? array() : $_REQUEST['disconnect_stores']; TwigmoConnector::disconnect($stores, $_REQUEST['disconnect_admin'] == 'Y'); return array(CONTROLLER_STATUS_REDIRECT, 'addons.update?addon=twigmo&disconnect=Y'); } if ($mode == 'tw_svc_auth_cp') { $connector = new TwigmoConnector(); $action = 'cp'; $connector->authPage($action); exit; } if ($mode == 'tw_svc_auth_te') { $connector = new TwigmoConnector(); $action = 'te'; $connector->authPage($action); exit; } if ($mode == 'update' && $_REQUEST['addon'] == 'twigmo') { if (!empty($_REQUEST['tw_settings'])) { $company_id = fn_twg_get_current_company_id(); TwigmoSettings::set(array('customer_connections' => array($company_id => $_REQUEST['tw_settings']))); } return array(CONTROLLER_STATUS_REDIRECT, 'addons.update?addon=twigmo'); } } elseif ($mode == 'update') { if ($_REQUEST['addon'] == 'twigmo') { if (!empty($_REQUEST['selected_section']) and $_REQUEST['selected_section'] == 'twigmo_addon') { fn_delete_notification('twigmo_upgrade');
public static function restoreSettingsAndCSS($upgrade_dirs) { // Restore langvars - for all languages except EN and RU $languages = Lang::getLanguages(); $except_langs = array('en', 'ru'); foreach ($languages as $language) { $backup_file = $upgrade_dirs['backup_settings'] . 'lang_' . $language['lang_code'] . '.bak'; if (!in_array($language['lang_code'], $except_langs) and file_exists($backup_file)) { LanguageValues::updateLangVar(unserialize(fn_get_contents($backup_file)), $language['lang_code']); } } // Restore blocks $old_company_id = Registry::get('runtime.company_id'); foreach ($upgrade_dirs['backup_company_settings'] as $company_id => $dir) { Registry::set('runtime.company_id', $company_id); $backup_file = $dir . 'blocks.xml'; if (file_exists($backup_file)) { if (version_compare(PRODUCT_VERSION, '4.1.1', '>=')) { Registry::set('runtime.layout', Layout::instance()->getDefault()); } Exim::instance($company_id, fn_twg_get_default_layout_id())->importFromFile($backup_file); } } Registry::set('runtime.company_id', $old_company_id); // Restore settings if addon was connected $restored_settings = array('my_private_key', 'my_public_key', 'his_public_key', 'email', 'customer_connections', 'admin_connection'); $settings = array(); foreach ($_SESSION['twigmo_backup_settings'] as $setting => $value) { if (in_array($setting, $restored_settings)) { $settings[$setting] = $value; } } $settings['version'] = TWIGMO_VERSION; unset($_SESSION['twigmo_backup_settings']); TwigmoSettings::set($settings); $connector = new TwigmoConnector(); if (!$connector->updateConnections(true)) { $connector->disconnect(array(), true); } // Restore images self::copyFiles($upgrade_dirs['backup_files']['media_frontend'], $upgrade_dirs['installed']['media_frontend']); return true; }
public function returnResponse($xml_root_node = 'data') { $this->addPaymentNotifications(); $notifications = fn_get_notifications(); // Clear all the user notifications $_SESSION['notifications'] = array(); $this->setMeta(empty($notifications) ? array() : array_values($notifications), 'notifications'); $this->setMeta(TwigmoConnector::getAccessID(), 'access_id'); $this->setMeta(TWIGMO_VERSION, 'twigmo_version'); $this->setMeta(PRODUCT_VERSION, 'cart_version'); $this->setMeta(PRODUCT_EDITION, 'cart_edition'); $this->setMeta($this->getPageUrl($_REQUEST), 'page_url'); $doc = $this->getAsDoc($this->format, $xml_root_node); self::showResponse($doc, $this->format); }
} } elseif ($object == 'images' && $action == 'delete') { foreach ($data as $image) { if (empty($image['pair_id'])) { $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'images', __('twgadmin_wrong_api_object_data'))); continue; } fn_delete_image_pair($image['pair_id'], 'product'); } } $response->returnResponse(); } } if ($mode == 'post') { if ($action == 'auth.svc') { $connector = new TwigmoConnector(); $request = $connector->parseResponse($_REQUEST['data']); if (!$connector->responseIsOk($request) || empty($request['data']['user_login']) || empty($request['data']['password'])) { $connector->onError(); } $_POST = $_REQUEST = array_merge($_REQUEST, $request['data']); list($status, $user_data, $user_login, $password, $salt) = fn_auth_routines($_REQUEST, $auth); $redirect_to_mv_url = fn_twg_check_for_vendor_url($status, $user_data); if ($redirect_to_mv_url) { $status = true; } $is_ok = !empty($user_data) && !empty($password) && fn_generate_salted_password($password, $salt) == $user_data['password']; if ($status === false || !$is_ok) { $connector->onError(); } $response_data = array('redirect_to_mv_url' => $redirect_to_mv_url, 'company_id' => $user_data['company_id'], 'can_view_orders' => fn_check_user_access($user_data['user_id'], 'view_orders'));
} $request = $connector->parseResponse($_REQUEST['data']); if (empty($request['data']) or empty($request['data']['url'])) { $connector->onError(); } // Request is ok - check url if ($action == 'check.admin') { if ($request['data']['url'] != $connector->getAdminUrl()) { $connector->onError('Wrong admin url'); } } else { $stores = fn_twg_get_stores(); $store = reset($stores); $my_url = $connector->getCustomerUrl($store); if ($request['data']['url'] != $my_url) { $connector->onError('Wrong customer url'); } } $connector->respond(array('result' => 'ok')); } elseif ($action == 'repo.updated') { $connector = new TwigmoConnector(); $stores = fn_twg_get_stores(); $store = reset($stores); $all_stores = TwigmoSettings::get('customer_connections'); if (empty($store) || empty($all_stores) || !isset($all_stores[$store['company_id']])) { $connector->onError('store_not_found'); } $all_stores[$store['company_id']]['repo_revision'] = TIME; TwigmoSettings::set(array('customer_connections' => $all_stores)); $connector->respond(array('result' => 'ok')); }
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ if (!defined('BOOTSTRAP')) { die('Access denied'); } use Tygh\Registry; use Twigmo\Core\TwigmoConnector; require_once Registry::get('config.dir.addons') . 'twigmo/Twigmo/Core/phpqrcode/qrlib.php'; if ($mode == 'show_qr') { $access_id = fn_twg_get_connected_access_id($auth); if (!$access_id) { die; } $user_info = Registry::get('user_info'); $login = Registry::get('settings.General.use_email_as_login') == 'N' ? $user_info['user_login'] : $user_info['email']; // outputs image directly into browser, as PNG stream $url = TwigmoConnector::getAdminUrl(false); QRcode::png($url . '_' . $login . '_' . $access_id); die; } elseif ($mode == 'view') { $view = fn_twg_get_view_object(); $view->assign('connected_access_id', fn_twg_get_connected_access_id($auth)); }
/*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ if (!defined('BOOTSTRAP')) { die('Access denied'); } use Twigmo\Upgrade\TwigmoUpgrade; use Twigmo\Core\TwigmoConnector; if ($mode == 'auth' && !fn_twg_is_on_saas()) { TwigmoUpgrade::checkForUpgrade(); } elseif ($mode == 'check_twigmo_for_upgrade') { header('Content-Type: image/png'); echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlJJREFUeNqkUztoVEEUPfN5k7gf4q4J6yduxKDRQhBEUCQ2KbaJCiI2Wtgt0cJCUEGxshJs/EBSWCoWFhKxULtFDUYXBUFMjJFl1WVBVkX39/a9N96ZfbtuoYU4cLgz8+45986ZeUxrjf8ZMjfBTIxxjqzgyAiJpBT0Qf4ZXKDCGR4whhni/ZQ0ASE7mE4cH9qYGFYRpRhlciHATeyA1owQtFpurVgYbXwqmsKXJVU1AhlDrjerquU3IShREqkDhGRGbQrGVDQ9MkwCmbaAtAJJU9mQV1/4CFAMKh8QFB5Dv7kDXi2DE5kxe1xw1afIuqSd2/MK2DZN5ebcdbRe3QLqXyG3H4Vz+DbE1gNdsjG9DVjYDs03HrbtPr1iozbrwU3g46eBveeIyqAXZi0Zvt8V4F13w/PGTy1gxdQ8nMmrVhSPzgCll8Cuk9CxNcQlsuch+JtAkL8B/f4hWGobMDlNF5yCfnKJkvqBLQfhGTJBB0AQ9Aiw0AM9fw3IXQTuHmu/lJ0noCvL0NQFG9nTFfCJ7PcIuKZdIyCmKDGbB358Bgo5YO0O23bwZREsseG3gAeXABm+5FLnnjvDmlWvgDlRS5JujQr0tQVIsFpFyaSw14eMv5gZ2zd+RDZq0d6rMpUNoRdmT6lINX/v3U3yICuelYGJVUi7nh6NrxsaEPGoRD8ZphTgONSBA04QBIf2ghZvLL6oLBWX6/fPL+G5eR3p9RGkzo5h/+YYdkNjpXG347IfRgsfdHB8e/sdc9NlzJY9lI3AAIFKQvzjn0xyaPwSYACS4hG3ZjB6zgAAAABJRU5ErkJggg=='); TwigmoUpgrade::checkForUpgrade(); die; } elseif ($mode == 'update_twigmo_connection') { $connector = new TwigmoConnector(); if ($connector->updateConnections()) { $connector->displayServiceNotifications(); } }