Ejemplo n.º 1
0
function &get_db()
{
    global $g_db;
    if (!is_object($g_db)) {
        $g_db = new database_connection_mssql_class();
    }
    if ($g_db->connected) {
        return $g_db;
    }
    $servername = get_config('db_server_name');
    $dbname = get_config('db_database_name');
    $username = get_config('db_user_name');
    $password = get_config('db_password');
    $code = get_config('db_code');
    $note_emails = "chenlong@xun-ao.com, sunyoujie@xun-ao.com, shengzhifeng@xun-ao.com, zhanghao@xun-ao.com";
    if ($g_db->connect($servername, $dbname, $username, $password, $code) === false) {
        $last_time = file_get_contents(dirname(__FILE__) . '/config/last_disconnect.txt');
        if ($last_time == '') {
            write_to_file(dirname(__FILE__) . '/config/last_disconnect.txt', now(), 'w');
            @mail($note_emails, '数据库连接失败', '主备数据库均无法连接,请立即检查' . $this->servername);
        }
        $servername = get_config('db_server_name_bak');
        $dbname = get_config('db_database_name_bak');
        $username = get_config('db_user_name_bak');
        $password = get_config('db_password_bak');
        $code = get_config('db_code_bak');
        if ($g_db->connect($servername, $dbname, $username, $password, $code) === false) {
        }
    }
    return $g_db;
}
Ejemplo n.º 2
0
 public function saveGCMDeviceID($device_id)
 {
     write_to_file($this->assets_devices_data . $device_id, '');
     $api['err_no'] = "0";
     $api['err_msg'] = "Device ID success included";
     return json_encode($api);
 }
Ejemplo n.º 3
0
 public function config_url_add($data)
 {
     include_once TOA_ROOT . 'include/class_Utility.php';
     $httpurl = $this->confgi_url() . '/office/' . $this->config_oaurl($data) . '?uid=' . $this->config_data('com_userid') . '&number=' . $this->config_data('com_number');
     $re_user = Utility::HttpRequest($httpurl);
     $content = array();
     $content['version'] = array('copyright' => $re_user);
     write_to_file('version', $content);
     return $re_user;
 }
Ejemplo n.º 4
0
function codo_get_translation($index, $count)
{
    global $CODOT;
    if (!isset($CODOT[$index])) {
        $CODOT[$index] = $index;
        //add translation if does not exist
        if (MODE == 'DEVELOPMENT') {
            asort($CODOT);
            write_to_file($CODOT);
        }
    }
    return str_replace("%s", $count, $CODOT[$index]);
}
Ejemplo n.º 5
0
    alert('页面名称不能为空!');
    redirect($redirect_url);
    return;
}
if ($view_id == 0 && !$view->identity) {
    alert('页面标识不能为空!');
    redirect($redirect_url);
    return;
}
if ($view_id == 0) {
    if (is_file('../../view/' . $view->identity . '.php')) {
        alert('页面标识已存在,请重新制定!');
        redirect($redirect_url);
        return;
    } else {
        if (!write_to_file('../../view/' . $view->identity . '.php', implode("", file('../../view_templet/' . $view->templet_name . '/index.php')))) {
            alert('创建页面失败!');
            redirect($redirect_url);
            return;
        }
    }
}
if (!$view->save()) {
    alert('创建页面失败!');
    redirect($redirect_url);
    return;
}
if ($optype == 'add') {
    //copy templet files
    //copy_dir('../../view_templet/' .$view->templet_name,'../../view/' .$view->identity,true);
}
Ejemplo n.º 6
0
<?php

session_start();
require_once 'functions.php';
$content = $_POST['textarea'];
write_to_file($_SESSION['file_path'], $content);
session_destroy();
header("HTTP/1.1 301 Moved Permanently");
header("Location: index.php");
function generate($HTTP_GET_VARS)
{
    global $languages_id, $all_categories, $currency, $currencies, $categories_audio, $customer_discount, $cart, $breadcrumb;
    $customer_discount = $cart->get_customer_discount();
    if (!is_array($customer_discount)) {
        $customer_discount = array();
    }
    $content = FILENAME_PRICELIST;
    $page = tep_db_query_fetch_array("\n\t\t\tSELECT pages_id, \n\t\t\tpages_name, \n\t\t\tpages_additional_description, \n\t\t\tpages_description \n\t\t\tFROM " . TABLE_PAGES . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    define('ADDITIONAL_DESCRIPTION', $page['pages_additional_description']);
    $translation_query = tep_db_query("\n\t\t\tSELECT pages_translation_key, \n\t\t\tpages_translation_value \n\t\t\tFROM " . TABLE_PAGES_TRANSLATION . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    while ($translation = tep_db_fetch_array($translation_query)) {
        define($translation['pages_translation_key'], $translation['pages_translation_value']);
    }
    $breadcrumb->add($page['pages_name'], tep_href_link(FILENAME_PRICELIST));
    $fields_array = array();
    $fields_array['products_model'] = TEXT_CHOOSE_MODEL;
    $fields_array['products_name'] = TEXT_CHOOSE_NAME;
    $fields_array['categories_name'] = TEXT_CHOOSE_CATEGORY;
    $fields_array['authors_name'] = TEXT_CHOOSE_AUTHOR;
    $fields_array['manufacturers_name'] = TEXT_CHOOSE_MANUFACTURER;
    $fields_array['series_name'] = TEXT_CHOOSE_SERIE;
    $fields_array['products_description'] = TEXT_CHOOSE_DESCRIPTION;
    $fields_array['products_price'] = TEXT_CHOOSE_PRICE;
    $fields_array['products_year'] = TEXT_CHOOSE_YEAR;
    $fields_array['products_pages_count'] = TEXT_CHOOSE_PAGES_COUNT;
    $fields_array['products_copies'] = TEXT_CHOOSE_COPIES;
    $fields_array['products_covers_name'] = TEXT_CHOOSE_COVER;
    $fields_array['products_formats_name'] = TEXT_CHOOSE_FORMAT;
    $fields_array['products_image'] = TEXT_CHOOSE_IMAGE;
    $fields_array['products_url'] = TEXT_CHOOSE_URL;
    $fileds_required = array('products_model', 'products_name', 'authors_name', 'products_price', 'manufacturers_name');
    $specials_array = array();
    $specials_types_query = tep_db_query("\n\t\t\tSELECT specials_types_id, \n\t\t\tspecials_types_name \n\t\t\tFROM " . TABLE_SPECIALS_TYPES . " \n\t\t\tWHERE specials_types_status = '1' \n\t\t\tAND specials_types_path <> '' \n\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($specials_types = tep_db_fetch_array($specials_types_query)) {
        $specials_type_check = tep_db_query_fetch_array("\n\t\t\t\tSELECT count(*) as total \n\t\t\t\tFROM " . TABLE_SPECIALS . " \n\t\t\t\tWHERE specials_types_id = '" . (int) $specials_types['specials_types_id'] . "' \n\t\t\t\tAND status = '1'");
        if ($specials_type_check['total'] > 0) {
            $specials_array[$specials_types['specials_types_id']] = $specials_types['specials_types_name'];
        }
    }
    $specials_periods_array = array(array('id' => 'w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_WEEK), array('id' => '2w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_2_WEEK), array('id' => 'm', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_MONTH), array('id' => 'h', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_HALF_YEAR));
    $fields = array();
    //здесь была проверка на выдачу определенных полей
    $categories = array();
    //здесь была проверка на выдачу определенных категорий
    $manufacturers = array();
    //здесь была проверка на выдачу определенных издательств
    $specials = array();
    $specials_periods = array();
    ////здесь была проверка на выдачу определенных типов
    $ff = 'xml';
    $status = 'active';
    $compression_method = '';
    //проверить наличие переменной далее
    $type_info_query = tep_db_query("SELECT products_types_id, products_last_modified FROM " . TABLE_PRODUCTS_TYPES . " WHERE products_types_status = '1'" . (tep_not_null($HTTP_GET_VARS['type']) ? " and products_types_path = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['type'])) . "'" : " and products_types_default_status = '1'") . " limit 1");
    if (tep_db_num_rows($type_info_query) < 1) {
        tep_exit();
    } else {
        $type_info = tep_db_fetch_array($type_info_query);
        $products_types_id = $type_info['products_types_id'];
        $products_last_modified = strtotime($type_info['products_last_modified']);
    }
    $select_string_select = "SELECT distinct p.products_id";
    $select_string_from = " FROM " . TABLE_PRODUCTS_INFO . " p";
    $select_string_where = " WHERE p.products_types_id = '" . (int) $products_types_id . "' and p.categories_id <> '4990' and p.products_status = '1'" . ($status == 'active' ? " and p.products_listing_status = '1'" : "") . " and p.products_price > '0'";
    if (sizeof($categories) > 0) {
        $subcategories_array = array();
        reset($categories);
        while (list(, $category_id) = each($categories)) {
            $subcategories_array[] = $category_id;
            tep_get_subcategories($subcategories_array, $category_id);
        }
        $select_string_where .= " and p.categories_id in ('" . implode("', '", $subcategories_array) . "')";
    } else {
        $disabled_categories = array();
        $type_categories_check_query = tep_db_query("SELECT categories_id FROM " . TABLE_CATEGORIES . " WHERE products_types_id = '" . (int) $products_types_id . "'");
        $type_categories_check = tep_db_fetch_array($type_categories_check_query);
        if ($type_categories_check['categories_id'] > 0) {
            $active_categories = array();
        } else {
            $active_categories = array('0');
        }
        $categories_query = tep_db_query("SELECT categories_id, categories_xml_status FROM " . TABLE_CATEGORIES . " WHERE products_types_id = '" . (int) $products_types_id . "' and categories_status = '1' order by parent_id");
        while ($categories = tep_db_fetch_array($categories_query)) {
            if ($categories['categories_xml_status'] < 1 && !in_array($categories['categories_id'], $disabled_categories)) {
                $disabled_categories[] = $categories['categories_id'];
                tep_get_subcategories($disabled_categories, $categories['categories_id']);
            } elseif (!in_array($categories['categories_id'], $disabled_categories)) {
                if (!in_array($categories['categories_id'], $active_categories)) {
                    $active_categories[] = $categories['categories_id'];
                }
            }
        }
        $select_string_where .= " and p.categories_id > '0'";
        if (sizeof($disabled_categories) > 0) {
            $select_string_where .= " and p.categories_id not in ('" . implode("', '", $disabled_categories) . "')";
        }
    }
    //	if ($customer_id==2) { echo $select_string_where; die; }
    $manufacturers_array = array();
    unset($manufacturers_string);
    if (sizeof($manufacturers) > 0) {
        $manufacturers_string = '';
        reset($manufacturers);
        while (list(, $manufacturer_name) = each($manufacturers)) {
            $manufacturer_name = tep_db_prepare_input(preg_replace('/\\s+/', ' ', $manufacturer_name));
            if (tep_not_null($manufacturer_name)) {
                $manufacturers_string .= (tep_not_null($manufacturers_string) ? " or " : "") . "(manufacturers_name like '%" . str_replace(' ', "%' and manufacturers_name like '%", $manufacturer_name) . "%')";
            }
        }
        unset($manufacturers_products);
        if ($products_types_id == 1) {
            $manufacturers_query = tep_db_query("SELECT distinct manufacturers_id FROM " . TABLE_MANUFACTURERS_INFO . " WHERE " . $manufacturers_string . "");
            while ($manufacturers_row = tep_db_fetch_array($manufacturers_query)) {
                $manufacturers_array[] = $manufacturers_row['manufacturers_id'];
            }
            //		$select_string_where .= " and p.manufacturers_id in ('" . implode("', '", $manufacturers_array) . "')";
            $manufacturers_products_query = tep_db_query("SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_status = '1' and manufacturers_id in ('" . implode("', '", $manufacturers_array) . "')");
            while ($manufacturers_products_array = tep_db_fetch_array($manufacturers_products_query)) {
                $manufacturers_products[] = $manufacturers_products_array['products_id'];
            }
            $select_string_where .= " and p.products_id in ('" . implode("', '", $manufacturers_products) . "')";
        } else {
            $select_string_where .= " and (" . str_replace('manufacturers_name', 'p.manufacturers_name', $manufacturers_string) . ")";
        }
    }
    if (sizeof($specials) > 0) {
        $specials_products = array();
        reset($specials);
        while (list($j, $specials_type_id) = each($specials)) {
            if ($specials_periods[$j] == 'h') {
                $period = time() - 60 * 60 * 24 * 183;
            } elseif ($specials_periods[$j] == 'm') {
                $period = time() - 60 * 60 * 24 * 30;
            } elseif ($specials_periods[$j] == '2w') {
                $period = time() - 60 * 60 * 24 * 14;
            } else {
                $period = time() - 60 * 60 * 24 * 7;
            }
            //		$select_string_from .= ", " . TABLE_SPECIALS . " s" . $j . "";
            //		$select_string_where .= " and p.products_id = s" . $j . ".products_id and s" . $j . ".status = '1' and s" . $j . ".specials_types_id = '" . $specials_type_id . "' and date_format(s" . $j . ".specials_date_added, '%Y-%m-%d') >= '" . date('Y-m-d', $period) . "'";
            $specials_products_query = tep_db_query("SELECT products_id FROM " . TABLE_SPECIALS . " WHERE status = '1' and specials_types_id = '" . $specials_type_id . "' and date_format(specials_date_added, '%Y-%m-%d') >= '" . date('Y-m-d', $period) . "'");
            while ($specials_products_array = tep_db_fetch_array($specials_products_query)) {
                $specials_products[] = $specials_products_array['products_id'];
            }
            $select_string_where .= " and p.products_id in ('" . implode("', '", $specials_products) . "')";
        }
    }
    if (strpos($for, 'amazon') !== false) {
        $select_string_where .= " and p.products_covers_id > '0' and p.products_year > '0' and p.products_image_exists = '1' and p.products_formats_id > '0'";
    } elseif ($for == 'ebay' || $for == 'nur_kz') {
        $select_string_where .= " and p.products_image_exists = '1'";
    }
    $all_categories = array();
    if ($for == 'shopmania') {
        $separator = '|';
    } elseif (strpos($for, 'amazon') !== false) {
        $separator = "\t";
    } elseif ($for == 'ebay') {
        $separator = ',';
    } else {
        $separator = ';';
    }
    $limit_string = "";
    $select_string = $select_string_select . $select_string_from . $select_string_where;
    if (tep_not_null($HTTP_GET_VARS['limit'])) {
        $limit_query = urldecode($HTTP_GET_VARS['limit']);
        list($limit_from, $limit_to) = explode(',', $limit_query);
        $limit_from = (double) trim($limit_from);
        $limit_to = (double) trim($limit_to);
        if ($limit_from >= 0 && $limit_from < 1 && $limit_to > 0 && $limit_to <= 1) {
            $products_count_query_raw = str_replace('SELECT distinct p.products_id FROM', 'SELECT count(distinct p.products_id) as total FROM', $select_string);
            $products_count_query_raw = str_replace("FROM " . TABLE_PRODUCTS . " p", "FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
            $products_count_query = tep_db_query($products_count_query_raw);
            //		$products_count_row = tep_db_fetch_array($products_count_query);
            $products_count = tep_db_num_rows($products_count_query);
            $limit_from = ceil($products_count * $limit_from);
            $limit_to = ceil($products_count * $limit_to);
            $limit_string = " limit " . $limit_from . ", " . ($limit_to - $limit_from);
            $select_string .= " group by p.products_id" . $limit_string;
        } else {
            $select_string .= " group by p.products_id";
        }
    } else {
        $select_string .= " group by p.products_id";
    }
    //	if ( (tep_not_null($eval_string) && sizeof($products_to_load)==0) || $products_query_numrows==0) {
    //	  $messageStack->add('header', ENTRY_CORPORATE_FORM_PRODUCTS_FOUND_ERROR);
    //	} else {
    set_time_limit(0);
    $pricelist_link = tep_href_link(FILENAME_PRICELIST, tep_get_all_get_params(array('result_uri', 'overwrite_existing_file')), 'NONSSL', false);
    if (substr($pricelist_link, -5) == '&amp;') {
        do {
            $pricelist_link = substr($pricelist_link, 0, -5);
        } while (substr($pricelist_link, -5) != '&amp;');
    }
    if (strpos($pricelist_link, '&amp;&amp;') !== false) {
        do {
            $pricelist_link = str_replace('&amp;&amp;', '&amp;;', $pricelist_link);
        } while (strpos($pricelist_link, '&amp;&amp;') == false);
    }
    $pricelist_check_query = tep_db_query("SELECT pricelists_id, pricelists_filename FROM " . TABLE_PRICELISTS . " WHERE pricelists_url = '" . tep_db_input($pricelist_link) . "'");
    if (tep_db_num_rows($pricelist_check_query) > 0) {
        $pricelist_check = tep_db_fetch_array($pricelist_check_query);
        $pricelist_filename = $pricelist_check['pricelists_filename'];
    } else {
        tep_db_query("insert into " . TABLE_PRICELISTS . " (pricelists_url, date_added) values ('" . tep_db_input($pricelist_link) . "', now())");
        $pricelist_id = tep_db_insert_id();
        $pricelist_filename = 'prices/price' . $pricelist_id . '.' . ($ff == 'csv' && strpos($for, 'amazon') !== false ? 'txt' : $ff);
        tep_db_query("update " . TABLE_PRICELISTS . " set pricelists_filename = '" . tep_db_input($pricelist_filename) . "' WHERE pricelists_id = '" . (int) $pricelist_id . "'");
    }
    if ($HTTP_GET_VARS['file'] !== '') {
        $pricelist_filename = $HTTP_GET_VARS['file'];
    }
    $name = basename($pricelist_filename);
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
        $name = str_replace('.', '%2e', $name);
    }
    //	  tep_session_close();
    //	  ob_end_clean();
    /*
    	  header('HTTP/1.1 200 OK');
    	  header('Expires: Mon, 26 Nov 1962 00:00:00 GMT');
    	  header('Last-Modified: ' . gmdate('D,d M Y H:i:s', $products_last_modified) . ' GMT');
    	  if ($_SERVER['REQUEST_METHOD'] =='HEAD') { tep_exit(); }
    	  header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
    	  header('Pragma: no-cache');
    	  header('Content-Description: File Transfer');
    	  header('Content-Type: application/force-download');
    	  header('Content-Type: application/octet-stream');
    	  header('Content-Type: application/download');
    	  header('Content-Disposition: attachment; filename="' . $name . '"');
    	  header('Content-Transfer-Encoding: binary');
    	  header('Connection: Keep-Alive');
    	  header('Keep-Alive: timeout=60, max=300'); 
    */
    if (file_exists($pricelist_filename) && $HTTP_GET_VARS['overwrite_existing_file'] != 'yes' && $customer_discount['type'] != 'purchase') {
        clearstatcache();
        if (filemtime($pricelist_filename) >= $products_last_modified) {
            tep_db_query("update " . TABLE_PRICELISTS . " set last_modified = now(), pricelists_downloads_count = pricelists_downloads_count + 1 WHERE pricelists_id = '" . (int) $pricelist_check['pricelists_id'] . "'");
            //header('Content-Length: ' . (string)(filesize($pricelist_filename)));
            $fp = fopen($pricelist_filename, 'r');
            while (($line = fgets($fp, 65536)) !== false) {
                echo $line;
            }
            fclose($fp);
            //		  readfile($pricelist_filename);
            die;
        } else {
            unlink($pricelist_filename);
        }
    }
    /*
    	  if (!isset($argv)) {
    		system('php ' . DIR_FS_CATALOG . FILENAME_PRICELIST . ' ' . implode(' ', explode('&', tep_get_all_get_params(array(tep_session_name())))) . ' > /dev/null &');
    		do {
    		  sleep(10);
    		} while (!is_readable($pricelist_filename));
    
    		  sleep(5);
    		  readfile($pricelist_filename);
    
    //		if ($ff = fopen($pricelist_filename, 'r')) {
    //		  fpassthru($fp);
    //		  $k = 0;
    //		  while( (!feof($ff)) && (connection_status()==0) ) {
    //			echo fread($ff, 1024*8);
    //			flush();
    //		  }
    //		  fclose($ff);
    //		}
    		die();
    	  }
    */
    //создаем массив символов которые будем менять
    $from = array('<', '>', '&', '"', '&#34;', '&#60;', '&#62;', '&#034;', '&#060;', '&#062;', "\r\n");
    $from1 = array('&amp;lt;', '&amp;gt;', '&amp;amp;', '&amp;quot;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', ' ');
    //создаем массив символов на которые будем менять
    $to = array('&lt;', '&gt;', '&amp;', '&quot;', '&quot;', '&lt;', '&gt;', '&quot;', '&lt;', '&gt;', '&#039;', ' ');
    unset($pricelist_currency);
    $categories_audio = array();
    tep_get_subcategories($categories_audio, 1104);
    if ($customer_discount['type'] == 'purchase' && empty($for)) {
        $fp = false;
    } else {
        $fp = fopen($pricelist_filename, 'wb');
    }
    if ($ff == 'csv') {
        if ($for == 'shopmania') {
            $fields_array = array('categories_name' => 'Категория', 'manufacturers_name' => 'Изготовитель', 'products_model' => 'Модель', 'products_id' => 'Торговый Код', 'products_name' => 'Имя продукта', 'products_description' => 'Описание продукции', 'products_url' => 'URL продукта', 'products_image' => 'URL изображения продукта', 'products_price' => 'Цена', 'products_currency' => 'Валюта');
            $fields = array_keys($fields_array);
        } elseif ($for == 'nur_kz') {
            //		Категория	Название товара	Производитель	Цена	Количество на складе	Ссылка на фотографию	Ссылка для покупки товара	Краткое описание	Полное описание	Ссылка на фотографию (уменьшенное фото)	Активность(товар активен если поле не пустое)
            $fields_array = array('categories_name' => 'Категория', 'products_name' => 'Название товара', 'manufacturers_name' => 'Производитель', 'products_price' => 'Цена', 'value::100' => 'Количество на складе', 'products_image_big' => 'Ссылка на фотографию', 'products_url' => 'Ссылка для покупки товара', 'products_description_short' => 'Краткое описание', 'products_description' => 'Полное описание', 'products_image' => 'Ссылка на фотографию (уменьшенное фото)', 'value::1' => 'Активность(товар активен если поле не пустое)');
            $fields = array_keys($fields_array);
            reset($fields);
            $temp_array = array();
            while (list(, $field_id) = each($fields)) {
                //			if ($field_id=='products_price') $temp_array[] = $fields_array[$field_id] . ' (' . DEFAULT_CURRENCY . ')';
                //			else
                $temp_array[] = $fields_array[$field_id];
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } elseif (strpos($for, 'amazon') !== false) {
            if ($for == 'amazon_uk') {
                $fields_array = array('products_id' => 'sku', 'authors_name' => 'Author', 'products_name' => 'Title', 'manufacturers_name' => 'publisher', 'products_year' => 'pub-date', 'products_covers_name' => 'Binding', 'products_price' => 'Price', 'products_model' => 'product-id', 'value::"2"' => 'Product-id-type', 'value::100' => 'Quantity', 'value::1' => 'Item-condition', 'value::"In fact it\'s a new product! NOTE: The book is in Russian!!! Will be delivered within 2-3 weeks over Europe and within 3-4 weeks elsewhere. Please note that ordered books are shipped out from our warehouse in Moscow to our warehouse in Germany and then they are dispatched from Germany to the customers. Because we have to clear customs, some orders may take longer to reach the customers."' => 'Item-note', 'value::6' => 'Will-ship-internationally', 'value::N' => 'Expedited-shipping', 'products_image' => 'Main-image-url', '09' => 'Package-height', '10' => 'Package-width', '11' => 'Package-length', '12' => 'Package-length-unit-of-measure', 'products_weight' => 'Package-weight', 'value::kg' => 'Package-weight-unit-of-measure', 'value::russian' => 'Language', '13' => 'Illustrator', '14' => 'Edition', '15' => 'Subject', 'value::a' => 'Add-delete', '17' => 'fulfillment-center-id');
            } else {
                $fields_array = array('products_id' => 'sku', 'authors_name' => 'Author', 'products_name' => 'Title', 'manufacturers_name' => 'publisher', 'products_year' => 'pub-date', 'products_covers_name' => 'Binding', 'products_price' => 'Price', 'products_model' => 'product-id', 'value::"2"' => 'Product-id-type', 'value::100' => 'Quantity', 'value::11' => 'Item-condition', '02' => 'Item-note', '03' => 'Expedited-shipping', 'value::2' => 'Will-ship-internationally', 'products_image' => 'Main-image-url', '04' => 'main-offer-image', '05' => 'offer-image1', '06' => 'offer-image2', '07' => 'offer-image3', '08' => 'offer-image4', '09' => 'Package-height', '10' => 'Package-width', '11' => 'Package-length', '12' => 'Package-length-unit-of-measure', 'products_weight' => 'Package-weight', 'value::kg' => 'Package-weight-unit-of-measure', 'value::russian' => 'Language', '13' => 'Illustrator', '14' => 'Edition', '15' => 'Subject', 'value::a' => 'Add-delete', '17' => 'fulfillment-center-id', '18' => 'Dust-jacket', '19' => 'Signed-by');
            }
            $fields = array_keys($fields_array);
            reset($fields_array);
            $temp_array = array();
            while (list($field_id, $field_name) = each($fields_array)) {
                $temp_array[] = $field_name;
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } elseif ($for == 'ebay') {
            $fields_array = array('value::Add' => '*Action(SiteID=US|Country=US|Currency=USD|Version=403|CC=UTF-8)', '20' => 'Product:UPC', 'products_model' => 'Product:ISBN', '00' => 'Product:ProductReferenceID', '01' => 'Product:IncludePreFilledItemInformation', '02' => 'Product:IncludeStockPhotoURL', '03' => 'Product:ReturnSearchResultsOnDuplicates', 'products_name' => 'Title', 'products_description' => 'Description', 'value::1000' => '*ConditionID', 'products_image' => 'PicURL', 'value::100' => '*Quantity', 'value::StoresFixedPrice' => '*Format', 'products_price' => '*StartPrice', '04' => 'BuyItNowPrice', '05' => 'ReservePrice', 'value::30' => '*Duration', '06' => 'ImmediatePayRequired', 'value::Boston,MA,USA' => '*Location', '07' => 'GalleryType', 'value::1' => 'PayPalAccepted', 'value::claudia.lokshina@gmail.com' => 'PayPalEmailAddress', 'value::- Book must be returned within 3 days. - Refund will be given as MoneyBack. - Seller pays for return shipping.' => 'PaymentInstructions', 'categories_name' => 'StoreCategory', '09' => 'ShippingDiscountProfileID', '10' => 'ShippingService-1:Option', '11' => 'ShippingService-1:Cost', '12' => 'ShippingService-1:Priority', '13' => 'ShippingService-1:ShippingSurcharge', '14' => 'ShippingService-2:Option', '15' => 'ShippingService-2:Cost', '16' => 'ShippingService-2:Priority', '17' => 'ShippingService-2:ShippingSurcharge', 'value::10' => '*DispatchTimeMax', '18' => 'CustomLabel', 'value::ReturnsAccepted' => '*ReturnsAcceptedOption', 'value::MoneyBack' => 'RefundOption', 'value::Days_3' => 'ReturnsWithinOption', 'value::Seller' => 'ShippingCostPaidBy', '19' => 'AdditionalDetails');
            $fields = array_keys($fields_array);
            reset($fields_array);
            $temp_array = array();
            while (list($field_id, $field_name) = each($fields_array)) {
                $temp_array[] = $field_name;
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } else {
            reset($fields);
            $temp_array = array();
            while (list(, $field_id) = each($fields)) {
                if ($field_id == 'products_price') {
                    $temp_array[] = $fields_array[$field_id] . ' (' . DEFAULT_CURRENCY . ')';
                } else {
                    $temp_array[] = $fields_array[$field_id];
                }
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        }
        $products_query = tep_db_query($select_string);
        $products_query_numrows = tep_db_num_rows($products_query);
        while ($products = tep_db_fetch_array($products_query)) {
            $product_info = tep_get_full_product_info($products['products_id']);
            if (strpos($for, 'amazon') !== false) {
                if (strlen($product_info['products_model']) > 14 || strlen($product_info['products_model']) < 9) {
                    $product_info = array();
                }
            }
            if (sizeof($product_info) > 0) {
                reset($fields);
                $temp_array = array();
                while (list(, $field_id) = each($fields)) {
                    switch ($field_id) {
                        case 'products_currency':
                            $temp_array[] = str_replace('RUR', 'RUB', $product_info['products_currency']);
                            break;
                        case 'products_id':
                            $temp_array[] = $product_info['products_id'];
                            break;
                        case 'products_model':
                            $temp_array[] = $product_info['products_model'];
                            break;
                        case 'products_name':
                            $temp_array[] = $product_info['products_name'];
                            break;
                        case 'products_description':
                            $temp_array[] = $product_info['products_description'];
                            break;
                        case 'products_description_short':
                            $temp_array[] = $product_info['products_description_short'];
                            break;
                        case 'categories_name':
                            $temp_array[] = $product_info['categories_name'];
                            break;
                        case 'authors_name':
                            $temp_array[] = $product_info['authors_name'];
                            break;
                        case 'products_price':
                            $temp_array[] = $product_info['products_price'];
                            break;
                        case 'manufacturers_name':
                            $temp_array[] = $product_info['manufacturers_name'];
                            break;
                        case 'series_name':
                            $temp_array[] = $product_info['series_name'];
                            break;
                        case 'products_pages_count':
                            $temp_array[] = $product_info['products_pages_count'];
                            break;
                        case 'products_year':
                            $temp_array[] = $product_info['products_year'];
                            break;
                        case 'products_copies':
                            $temp_array[] = $product_info['products_copies'];
                            break;
                        case 'products_covers_name':
                            $temp_array[] = $product_info['products_covers_name'];
                            break;
                        case 'products_formats_name':
                            $temp_array[] = $product_info['products_formats_name'];
                            break;
                        case 'products_url':
                            $temp_array[] = $product_info['products_url'];
                            break;
                        case 'products_image':
                            $temp_array[] = $product_info['products_image'];
                            break;
                        case 'products_image_big':
                            $temp_array[] = $product_info['products_image_big'];
                            break;
                        case 'products_buy_now':
                            $temp_array[] = $product_info['products_buy'];
                            break;
                        case 'products_quantity':
                            $temp_array[] = $product_info['products_quantity'];
                            break;
                        case 'products_weight':
                            $temp_array[] = $product_info['products_weight'];
                            break;
                        case 'products_width':
                            $temp_array[] = $product_info['products_width'];
                            break;
                        case 'products_height':
                            $temp_array[] = $product_info['products_height'];
                            break;
                        case 'products_width_height_measure':
                            $temp_array[] = $product_info['products_width_height_measure'];
                            break;
                        default:
                            $field_value = '';
                            if (substr($field_id, 0, 7) == 'value::') {
                                list(, $field_value) = explode('value::', $field_id);
                                $field_value = preg_replace('/^"2"$/', '2', $field_value);
                            }
                            $temp_array[] = $field_value;
                            break;
                    }
                }
                if ($for == 'shopmania') {
                    $string = implode($separator, $temp_array) . "\n";
                    echo $string;
                    fwrite($fp, $string);
                } elseif (strpos($for, 'amazon') !== false) {
                    clearstatcache();
                    $string = implode($separator, $temp_array) . "\n";
                    echo $string;
                    fwrite($fp, $string);
                } elseif ($for == 'ebay') {
                    clearstatcache();
                    if (filesize($pricelist_filename) > '1500000') {
                        fclose($fp);
                        tep_exit();
                    } else {
                        write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
                    }
                } else {
                    if ($for == 'nur_kz' && empty($temp_array[8])) {
                    } else {
                        write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
                    }
                }
            }
        }
    } else {
        if ($for == 'cenometr') {
            $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '<!DOCTYPE cenometr SYSTEM "cenometr.dtd">' . "\n" . '<cenometr date="' . date('Y-m-d H:i', $products_last_modified) . '">' . "\n" . '  <shop>' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . '	<logo>' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_TEMPLATES . 'images/logo.gif</logo>' . "\n" . '	<offers>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
            $products_currency = 'RUR';
        } else {
            $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '<!DOCTYPE yml_catalog SYSTEM "shops.dtd">' . "\n" . '<yml_catalog date="' . date('Y-m-d H:i', $products_last_modified) . '">' . "\n" . '  <shop>' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<company>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_OWNER)) . '</company>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . '	<currencies>' . "\n";
            if ($currency == 'UAH') {
                $products_currency = 'UAH';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('" . $currency . "')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="1" />' . "\n";
                }
            } elseif (!in_array($currency, array('RUR', 'EUR', 'USD', 'UAH'))) {
                $products_currency = 'RUR';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('RUR')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="1" />' . "\n";
                }
            } else {
                $products_currency = 'RUR';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('RUR', '" . $currency . "')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="' . str_replace(',', '.', round(1 / $curs['value'], 4)) . '" />' . "\n";
                }
            }
            $content .= '	</currencies>' . "\n" . '	<categories>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
            $xml_categories_query = tep_db_query("SELECT concat_ws('', '<category id=\"', c.categories_id, '\" parentId=\"', c.parent_id, '\">', cd.categories_name, '</category>') as categories_string FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.products_types_id = '" . (int) $products_types_id . "' and c.categories_status = '1' and c.categories_xml_status = '1' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
            while ($xml_categories = tep_db_fetch_array($xml_categories_query)) {
                write_to_file($pricelist_filename, $fp, $xml_categories['categories_string'] . "\n");
                $COUNTER['Categories']++;
            }
            $content = '	</categories>' . "\n" . '	<offers>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
        }
        $temp_filename = UPLOAD_DIR . 'csv/products_' . substr(uniqid(rand()), 0, 10) . '.xml';
        $currency_decimal_places = $currencies->get_decimal_places($products_currency);
        $currency_value = $currencies->get_value($products_currency);
        if ($products_types_id == 1) {
            if ($for == 'cenometr') {
                $xml_string = "concat_ws('', '<offer><name>', p.products_name, '</name><url>', '" . HTTP_SERVER . "', p.products_url, '</url><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><barcode>', replace(group_concat(p2m.products_model_1), ',', '</barcode><barcode>'), '</barcode></offer>') as products_string";
                $select_string = str_replace(" FROM " . TABLE_PRODUCTS_INFO . " p", " FROM " . TABLE_PRODUCTS_INFO . " p, " . TABLE_PRODUCTS_TO_MODELS . " p2m", $select_string);
                $select_string = str_replace(" and p.products_status = '1'", " and p.categories_id > '0' and p.products_status = '1' and p.products_id = p2m.products_id", $select_string);
            } else {
                //			if ($languages_id!=DEFAULT_LANGUAGE_ID) {
                //			  $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" type=\"book\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','" . HTTP_SERVER . DIR_WS_IMAGES . "thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', a.authors_name, '</author><name>', pd.products_name, '</name><publisher>', mi.manufacturers_name, '</publisher><series>', s.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(pd.products_description,'\n',if((locate(pd.products_description, '<br')>0 or locate(pd.products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></offer>') as products_string";
                //			} else {
                $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" type=\"book\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', p.authors_name, '</author><name>', p.products_name, '</name><publisher>', p.manufacturers_name, '</publisher><series>', p.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></offer>') as products_string";
                //			}
            }
        } else {
            $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><name>', p.products_name, '</name><vendor>', p.manufacturers_name, '</vendor><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>', if((p.products_filename is null), 'false', 'true'), '</downloadable></offer>') as products_string";
        }
        $xml_query_row = str_replace("SELECT distinct p.products_id FROM " . TABLE_PRODUCTS_INFO . " p", "SELECT " . $xml_string . " FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
        $xml_query_row = str_replace("WHERE ", "WHERE 1 and p.categories_id not in ('" . implode("','", $categories_audio) . "') and ", $xml_query_row);
        if (strpos($xml_query_row, 'order by') !== false) {
            $xml_query_row = substr($xml_query_row, 0, strpos($xml_query_row, 'order by'));
        }
        if (strpos($xml_query_row, ' limit ') === false) {
            $xml_query_row .= $limit_string;
        }
        //		write_to_file($pricelist_filename, $fp,  $xml_query_row . " into outfile '" . $temp_filename . "'"); die;
        //		if ($customer_id==2) { echo $xml_query_row; die; }
        //		echo $xml_query_row; die;
        $query = tep_db_query($xml_query_row);
        while ($row = tep_db_fetch_array($query)) {
            $t_str = $row['products_string'];
            $t_str = preg_replace('/<series>(.*)<\\/series>/ie', "'<series>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</series>'", $t_str);
            $t_str = preg_replace('/<description>(.*)<\\/description>/ie', "'<description>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</description>'", $t_str);
            $t_str = preg_replace('/<name>(.*)<\\/name>/ie', "'<name>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</name>'", $t_str);
            write_to_file($pricelist_filename, $fp, $t_str . "\n");
            $COUNTER['Offers']++;
        }
        if ($for == 'cenometr') {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</cenometr>' . "\n";
        } else {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</yml_catalog>' . "\n";
        }
        write_to_file($pricelist_filename, $fp, $content);
    }
    if ($fp) {
        fclose($fp);
    }
    return $COUNTER;
}
Ejemplo n.º 8
0
        if (strpos($xml_query_row, 'order by') !== false) {
            $xml_query_row = substr($xml_query_row, 0, strpos($xml_query_row, 'order by'));
        }
        if (strpos($xml_query_row, ' limit ') === false) {
            $xml_query_row .= $limit_string;
        }
        //		write_to_file($pricelist_filename, $fp,  $xml_query_row . " into outfile '" . $temp_filename . "'"); die;
        //		if ($customer_id==2) { echo $xml_query_row; die; }
        //		echo $xml_query_row; die;
        $query = tep_db_query($xml_query_row);
        while ($row = tep_db_fetch_array($query)) {
            $t_str = $row['products_string'];
            $t_str = preg_replace('/<series>(.*)<\\/series>/ie', "'<series>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</series>'", $t_str);
            $t_str = preg_replace('/<description>(.*)<\\/description>/ie', "'<description>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</description>'", $t_str);
            $t_str = preg_replace('/<name>(.*)<\\/name>/ie', "'<name>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</name>'", $t_str);
            write_to_file($pricelist_filename, $fp, $t_str . "\n");
        }
        if ($for == 'cenometr') {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</cenometr>' . "\n";
        } else {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</yml_catalog>' . "\n";
        }
        write_to_file($pricelist_filename, $fp, $content);
    }
    if ($fp) {
        fclose($fp);
    }
    tep_exit();
    //	}
}
require DIR_WS_INCLUDES . 'application_bottom.php';
Ejemplo n.º 9
0
<?php

// define variable and set to empty value
$temp = NULL;
ini_set('display_errors', 1);
// set to 0 for production version
error_reporting(E_ALL);
//echo $_POST["query_input"];
//echo "<br />";
$temp = test_input($_POST["query_input"]);
write_to_file($temp);
if (empty($temp)) {
    echo "Welcome to Toybox";
} else {
    /**
    						./toybox returns either of the following:
    						>> Successful parsing!
    						>> ERROR: <message here>
    					**/
    exec('./toybox "' . $temp . '"', $out);
    //print_r($out);
    $arrSize = sizeof($out);
    for ($i = 0; $i < $arrSize; $i++) {
        //echo("&nbsp"."&nbsp".$out[$i]."<br>");
        $temp_out = substr($out[0], 0, 5);
        //echo($temp_out);
        if ($temp_out != "ERROR") {
            $shell_output = shell_exec('gcc -save-temps -fverbose-asm translated.c');
            $shell_output2 = shell_exec('gcc -o run translated.s');
            $shell_output3 = shell_exec('./run');
            //echo("\nToybox >>\n\t");
Ejemplo n.º 10
0
function get_rightscale_data($server_cfg, $game_cfg, $current_timestamp)
{
    $api_prefix = $server_cfg["api_href_prefix"];
    $user = $server_cfg["rightscale_user"];
    $pass = $server_cfg["rightscale_passwd"];
    $ips = array();
    // to hold the iplist with their corresponding array ids
    $prefetch = new Curl_Prefetch(array(CURLOPT_HTTPHEADER => array('X-API-VERSION: 1.0'), CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "{$user}:{$pass}"));
    $logger = new Logger($server_cfg, $game_cfg);
    $game_cfg['logger'] = $logger;
    error_log("=====>Fetching Rightscale Data =====>\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
    foreach ($game_cfg["deployIDs"] as $deployID) {
        $prefetch->add("deploy_{$deployID}", "{$api_prefix}/deployments/{$deployID}.xml");
        // To get array ids
        $prefetch->add("deploy_arrays_{$deployID}", "{$api_prefix}/server_arrays");
        // append "?server_settings=true" if you want MachineDetail
    }
    if (isset($game_cfg["arrayIDs"])) {
        $arrayIDs = $game_cfg["arrayIDs"];
    }
    if (empty($arrayIDs)) {
        $arrayIDs = array();
    }
    $allMachines = array();
    foreach ($game_cfg["deployIDs"] as $deployID) {
        $allMachines = array_merge($allMachines, getAllDeployedMachines($server_cfg, $game_cfg, $prefetch, $deployID));
        if (empty($game_cfg["arrayIDs"])) {
            $arrayIDs = array_merge($arrayIDs, getAllArrayId($server_cfg, $game_cfg, $prefetch, $deployID));
        }
    }
    $game_cfg["arrayIDs"] = $arrayIDs;
    foreach ($game_cfg["arrayIDs"] as $arrayID) {
        $prefetch->add("array_{$arrayID}", "{$api_prefix}/server_arrays/{$arrayID}/instances");
    }
    foreach ($game_cfg["arrayIDs"] as $arrayID) {
        $allMachines = array_merge($allMachines, getAllArrayMachines($server_cfg, $game_cfg, $prefetch, $arrayID, $current_timestamp, $ips));
    }
    //print("test");
    //create_games_for_arrays($server_cfg, $game_cfg["name"], $arrayIDs);
    $machine_split = array('web' => array(), 'mc' => array(), 'db' => array(), "mb" => array(), 'admin' => array(), 'proxy' => array(), 'queue' => array());
    $pregmatch = null;
    foreach ($allMachines as $machine) {
        if (preg_match('%-(web|db|mc|mb|admin|proxy|queue)%', $machine->nickName, $pregmatch)) {
            $machine_split[$pregmatch[1]][] = $machine;
        }
    }
    $game_dir = sprintf($server_cfg['root_upload_directory'], $game_cfg['name']);
    $file_name = $server_cfg['bd_metrics_file'];
    $machine_counts = getMachineCount($machine_split);
    if (($marker_dir = write_to_file($server_cfg, $game_cfg, $file_name, $current_timestamp, $machine_counts)) !== false) {
        touch($marker_dir . "/.machine_counts");
    }
    $file_name = $server_cfg['iplist_file'];
    if (($marker_dir = write_to_file($server_cfg, $game_cfg, $file_name, $current_timestamp, json_encode($ips))) !== false) {
        // top level profile
        $top_iplist = "{$game_dir}/../iplist.json";
        # timeslots/../iplist.json
        if (file_exists($top_iplist)) {
            unlink($top_iplist);
        }
        symlink("{$marker_dir}/{$file_name}", $top_iplist);
    }
}
Ejemplo n.º 11
0
function execute_php($code, $output_needed)
{
    if (!get_php_ini("suhosin.executor.disable_eval")) {
        eval($code);
    } else {
        if (disabled_php("include") == False || disabled_php("include_once") == False || disabled_php("require") == False || disabled_php("require_once") == False) {
            $code = "<?php\n" . $code . "\n?>";
            $filename = $_SESSION["daws_directory"] . "/" . rand(1, 1000) . ".php";
            write_to_file($filename, $code);
            include_php($filename);
        } else {
            $code = "<?php\n" . $code . "\n?>";
            echo execute_script($code, $_SESSION["php"], "php", $output_needed);
        }
    }
}
Ejemplo n.º 12
0
function SendAllMail($dailytest_id)
{
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $dailytest_id . "\n");
    //打印表格的css
    $message .= PrintCss();
    //fullsmoketest 的地址链接
    $message .= PrintDetailLink($dailytest_id);
    $message .= "<br/>\n";
    //打印testdeail表格和 issuse描述
    $message .= PrintTestDetailandIssue($dailytest_id);
    $message .= "<br/>\n";
    //FAIL 状态的统计表
    $message .= "<h3 style=font-family:arial>Fail Testcase:</h3>\n";
    $message .= PrintFailStateTable($dailytest_id, 0);
    $message .= "<br/>\n";
    //统计每个状态个数
    //$message .= PrintStateStatisticsTable($dailytest_id, 0);
    //所有状态的统计表,全部的表格,分模块 打印
    $message .= "<h3 style=font-family:arial>Feature Status:</h3>\n";
    $sql = "select st_testsuite.testsuite_id as testsuite_id, st_testsuite.testsuite as testsuite from st_testsuite,st_stateresult,st_dailytest,st_testcase\n        where st_dailytest.dailytest_id=st_stateresult.dailytest_id and\n        st_stateresult.testcase_id=st_testcase.testcase_id and\n        st_testcase.testsuite_id=st_testsuite.testsuite_id and\n        st_testsuite.testsuite_online = '1' and\n        st_dailytest.dailytest_id='{$dailytest_id}'\n        group by st_testsuite.testsuite_id";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
    $testsuite = Dosql($sql);
    $num_suite = $testsuite->num_rows;
    for ($tables = 0; $tables < $num_suite; $tables++) {
        $row = $testsuite->fetch_assoc();
        //利用一个循环,把每个模块对应的表格打印出来
        $message .= PrintTestsuiteTable($dailytest_id, $row['testsuite_id'], $row['testsuite']);
    }
    $testsuite->free();
    $sql = "select st_tester.testerdescription, st_tester.email,testdate,platform,branch,product,imageinfo\n        from st_tester,st_dailytest\n        where\n        st_dailytest.tester=st_tester.tester\n        and st_dailytest.dailytest_id='{$dailytest_id}'";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
    $testerresult = Dosql($sql);
    $num_tester = $testerresult->num_rows;
    for ($i = 0; $i < $num_tester; $i++) {
        $row = $testerresult->fetch_assoc();
        $testername = $row['testerdescription'];
        $testeremail = $row['email'];
        $reportdate = $row['testdate'];
        $platform = $row['platform'];
        $branch = $row['branch'];
        $product = $row['product'];
        $imageinfo = stripslashes($row['imageinfo']);
    }
    $testerresult->free();
    $message .= "<br/>\n";
    $to = $testeremail;
    $sql = "select alldepartment_email from st_alldepartment where alldepartment_online='1' and (belongto='all' or belongto='{$platform}')";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $sql . "\n");
    $emailresult = Dosql($sql);
    $num_email = $emailresult->num_rows;
    for ($i = 0; $i < $num_email; $i++) {
        $row = $emailresult->fetch_assoc();
        $to = $to . "," . $row['alldepartment_email'];
    }
    $emailresult->free();
    $smoketest_imagedate = get_imageinfo_imagedate($imageinfo);
    echo "smoketest_imagedate =  {$smoketest_imagedate}<br/> ";
    if ($smoketest_imagedate) {
        $subject = "[Daily Smoke Test][" . stripslashes($product) . "][{$smoketest_imagedate}]";
    } else {
        $subject = "[Daily Smoke Test] - " . stripslashes($reportdate) . "_" . stripslashes($platform) . "_" . stripslashes($branch) . " _ " . stripslashes($product);
    }
    echo "subject:{$subject}<br/> ";
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $subject . "\n");
    //$to = "*****@*****.**";
    $to = "mamh@marvell.com," . $to;
    $from = "{$testername}<{$testeremail}>";
    $headers = "Content-type:text/html; charset=utf-8\n";
    $headers .= "From:{$from}";
    $sendmailresult = mail($to, $subject, $message, $headers);
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $to . "\n");
    Debug("\n[" . __FILE__ . "][" . __LINE__ . "]:\n" . $from . "\n");
    echo "<font color=\"red\">SendAllMail</font>:sendmailresult = {$sendmailresult}<br/>\n";
    echo "From = {$from}<br/>\n";
    echo "To = {$to}<br/>\n";
    echo "<br/>\n";
    write_to_file($platform, $subject, $message, $imageinfo);
    $message = "";
}
Ejemplo n.º 13
0
 $date = strftime("%F");
 $date = strftime("%F", strtotime("-1 day", strtotime($date)));
 $tweets = 1;
 $data_file = $query . ".txt";
 $json_file = $query . ".json";
 var_dump($date);
 echo "<br><br>";
 while (!empty($tweets) && $count < 10) {
     $tweets = searchResults($query, $date);
     echo count($tweets);
     echo "<br><br>";
     if (!empty($tweets)) {
         $sentimentized = assignSentiment($tweets);
         echo count($sentimentized);
         echo "<br><br>";
         write_to_file($data_file, $sentimentized);
         //break;
     }
     sleep(0.5);
     $date = strftime("%F", strtotime("-1 day", strtotime($date)));
     echo $date;
     echo "<br><br>";
     $count++;
 }
 $data = get_data_from_file($data_file);
 echo count($data);
 $result = binData($data);
 convert2Json($json_file, $result);
 foreach ($result as $row) {
     print_r($row);
     echo "<br>";
$query = "SELECT * from class where sub IN (select sub from handles where name like '{$teacher}')";
$result = mysqli_query($con, $query);
if ($result === FALSE) {
    die(mysql_error());
    // TODO: better error handling
} else {
    if (isset($result) and $result != FALSE) {
        $num_rows = $result->num_rows;
        if ($num_rows > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $start_time = date('g:i', strtotime($row['start_time']));
                $end_time = date('g:i', strtotime($row['end_time']));
                $subject = $row['sub'];
                $day = $row['day'];
                $sem = $row['sem'];
                write_to_file($start_time, $end_time, $day, $subject, $sem);
                //to define a function for this
            }
            //end while
        }
        //end num_rows >0 condition
    }
}
//end set of result
//function to write to Excel file and sheet
function write_to_file($start, $end, $day, $matter, $sem)
{
    $teacher = $_GET['teacher'];
    $fname = "PersonalTT/" . $teacher . ".xlsx";
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $objPHPExcel = $objReader->load($fname);
Ejemplo n.º 15
0
 function execute($sqlstr)
 {
     if ($this->echo_sql) {
         echo $sqlstr;
     }
     if ($this->connected === false) {
         $this->_debug_info('database connection has not been established!');
         return false;
     }
     global $g_db_log_file;
     if ($g_db_log_file) {
         $f_start = get_microtime();
     }
     $this->_qresult = mysql_query($sqlstr, $this->_db);
     if ($g_db_log_file) {
         $f_length = get_microtime() - $f_start;
         $str = chr(13) . chr(10) . now() . " " . $_SERVER['SCRIPT_NAME'] . " execute sql: ({$f_length}ms)" . $sqlstr;
         write_to_file($g_db_log_file, $str);
     }
     if ($this->_qresult === FALSE) {
         $this->_debug_info('fail to execute sql!' . $this->get_error() . ";query string = " . $sqlstr);
         write_log('fail to execute sql!' . $this->get_error() . ";query string = " . $sqlstr);
         return FALSE;
     } else {
         return true;
     }
 }
Ejemplo n.º 16
0
 function _save_table_struct_to_file()
 {
     $data = json_encode($this->fields);
     write_to_file($this->map_file, $data, 'w');
 }
Ejemplo n.º 17
0
function oa_where_recache($table, $id, $nums, $where, $value)
{
    global $db;
    $content = array();
    $query = $db->query("SELECT * FROM " . DB_TABLEPRE . "" . $table . " where " . $where . " ORDER BY " . $nums . " ASC");
    while ($row = $db->fetch_array($query)) {
        $content[$row[$id]] = $row;
    }
    write_to_file($table . '_' . $value, $content);
}
Ejemplo n.º 18
0
function refresh_course_xml()
{
    $db = get_db();
    $db->query("select id from eb_category where category_type='image' and name='课程flash'");
    if ($db->record_count < 0) {
        return false;
    }
    $cate_id = $db->field_by_name('id');
    $items = $db->query("select * from eb_images where category_id = {$cate_id} and is_adopt=1 order by priority,created_at asc limit 4");
    $out = '<?xml version="1.0" encoding="UTF-8"?>';
    $out .= '<settings';
    $out .= ' autoRotate="1"';
    $out .= ' autoRotateSpeed="2"';
    $out .= ' useSubtitle="0"';
    $out .= ' useTooltip="1"';
    $out .= ' useSecondCaption="1"';
    $out .= ' spanX="170"';
    $out .= ' spanY="20"';
    $out .= ' centerX="260"';
    $out .= ' centerY="280"';
    $out .= ' distanceValue="0"';
    $out .= ' perspectiveRatio="0.85"';
    $out .= ' minimumscale="0.99"';
    $out .= ' turningspeed="4"';
    $out .= ' rotationKind="1"';
    $out .= '/>';
    $out .= '<photos>';
    for ($i = 0; $i < 4; $i++) {
        $out .= '<photo imageURL="' . $items[$i]->src . '" linkData="' . $items[$i]->url . '" linkType="URL" linkTarget="_blank" captionText="" captionText2="" enableButtonWhenInFront="1"/>';
    }
    $out .= "</photos>";
    return write_to_file(dirname(__FILE__) . '/../course/data.xml', $out, 'w');
}
Ejemplo n.º 19
0
function static_news($news, $symbol = 'fck_pageindex', $en = false)
{
    if (!$news) {
        return false;
    }
    global $static_dir;
    global $static_url;
    $url = "{$static_url}/news/news.php?id={$news->id}&page_type=static";
    if ($en) {
        $url .= "&lang=en";
    }
    $content = file_get_contents($url);
    $date = date('Ym', strtotime($news->created_at));
    $dir = "{$static_dir}/review/{$date}";
    if (!is_dir($dir)) {
        mkdir($dir);
    }
    $news_id = str_pad($news->id, 7, '0', STR_PAD_LEFT);
    if ($en) {
        $news_id .= "_en";
    }
    $file = $dir . "/{$news_id}.shtml";
    if (!write_to_file($file, $content, 'w')) {
        return false;
    }
    $page_count = get_fck_page_count($news->content);
    if ($page_count > 1) {
        for ($i = 2; $i <= $page_count; $i++) {
            $url = "{$static_url}/news/news.php?id={$news->id}&{$symbol}={$i}&page_type=static";
            if ($en) {
                $url .= "&lang=en";
            }
            $content = file_get_contents($url);
            $file = "{$dir}/{$news_id}_{$i}.shtml";
            if (!write_to_file($file, $content, 'w')) {
                return false;
            }
        }
    }
    //handle the english article
    if (!$en) {
        $db = get_db();
        $db->query("select * from fb_news_relationship where chinese_news_id = {$news->id}");
        if ($db->move_first()) {
            $news->find($news->id);
            return static_news($news, $symbol, true);
        }
    }
    return true;
}
Ejemplo n.º 20
0
/**
 * @desc Remove some old stuff
 */
function task_remove_old()
{
    write_to_file('o');
    taskman_sysmsg("Remove uselles files from '" . taskman_prop('PROJECT_DIR') . "'...\n");
}
function get_gui_trans_status($cvsbranch, $searchpattern, $lastupdatedstring, $almostdonestring, $completestring)
{
    global $stable_KDE_BRANCH;
    global $almostdone;
    global $complete;
    $local_prefix = strtr($cvsbranch, '/.', '__');
    if ($searchpattern == "desktop_kdevelop.po") {
        $status_filename = "dynamic/" . $local_prefix . "_dsk_po_status.ihtml";
        $lastupdate_filename = "dynamic/" . $local_prefix . "_dsk_po_status_lastupdate.ihtml";
        $almostdone_filename = "dynamic/" . $local_prefix . "_dsk_po_status_almostdone.ihtml";
        $complete_filename = "dynamic/" . $local_prefix . "_dsk_po_status_complete.ihtml";
    } else {
        $status_filename = "dynamic/" . $local_prefix . "_po_status.ihtml";
        $lastupdate_filename = "dynamic/" . $local_prefix . "_po_status_lastupdate.ihtml";
        $almostdone_filename = "dynamic/" . $local_prefix . "_po_status_almostdone.ihtml";
        $complete_filename = "dynamic/" . $local_prefix . "_po_status_complete.ihtml";
    }
    // If the file does not exist or if it is older than 24H
    $time = time();
    $min_time = $time - 24 * 60 * 59;
    if ((!file_exists($status_filename) || filemtime($status_filename) <= $min_time) && ($cvsbranch == $stable_KDE_BRANCH || $cvsbranch == 'HEAD')) {
        $outputfile = fopen($status_filename, 'w');
        if (!$outputfile) {
            echo "<p>Unable to open local output file file \"{$status_filename}\" for write.</p>\n";
            exit;
        }
        // Init these strings
        $almostdone = '';
        $complete = '';
        switch ($cvsbranch) {
            case $stable_KDE_BRANCH:
                $cvsbranch = 'stable';
                break;
            case 'HEAD':
                $cvsbranch = 'trunk';
                break;
        }
        get_lang_trans_status($cvsbranch, $searchpattern, "af", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ar", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "az", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "be", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "bg", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "bn", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "bo", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "br", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "bs", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ca", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "cs", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "cy", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "da", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "de", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "el", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "en_GB", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "eo", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "es", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "et", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "eu", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "fa", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "fi", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "fo", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "fr", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "fy", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ga", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "gl", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "gu", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "he", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "hi", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "hr", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "hu", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "id", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "is", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "it", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ja", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ko", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "ku", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "ky", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "lo", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "lt", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "lv", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "mi", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "mk", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "mn", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ms", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "mt", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "nb", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "nds", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "nl", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "nn", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "nso", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "oc", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "pl", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "pt", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "pt_BR", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ro", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ru", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "se", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "sk", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "sl", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "sq", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "sr", $outputfile);
        //  get_lang_trans_status($cvsbranch, $searchpattern, "ss", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "sv", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ta", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "tg", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "th", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "tr", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "uk", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "uz", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "ven", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "vi", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "wa", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "xh", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "zh_CN", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "zh_TW", $outputfile);
        get_lang_trans_status($cvsbranch, $searchpattern, "zu", $outputfile);
        fclose($outputfile);
        write_to_file($lastupdate_filename, get_trans_timestamp($cvsbranch, $searchpattern, "af"));
        if ($almostdone != "") {
            // If not empty replace the trailing ',' with a '.'
            $almostdone[strrpos($almostdone, ",")] = ".";
        }
        write_to_file($almostdone_filename, $almostdone);
        if ($complete != "") {
            // If not empty replace the trailing ',' with a '.'
            $complete[strrpos($complete, ",")] = ".";
        }
        write_to_file($complete_filename, $complete);
    }
    include $status_filename;
    echo "<tr><td align=\"left\" colspan=10><font size=\"2\">{$lastupdatedstring}";
    include $lastupdate_filename;
    echo "</td></tr>\n";
    echo "<tr><td align=\"left\" colspan=10><font size=\"2\">{$almostdonestring}";
    include $almostdone_filename;
    echo "</td></tr>\n";
    echo "<tr><td align=\"left\" colspan=10><font size=\"2\">{$completestring}";
    include $complete_filename;
    echo "</td></tr>\n";
}
Ejemplo n.º 22
0
function execute_php($code, $output_needed)
{
    //eval and its substitutes
    if (!get_php_ini("suhosin.executor.disable_eval")) {
        //we use eval since it's not blocked by suhosin
        eval($code);
    } else {
        if (disabled_php("include") == False || disabled_php("include_once") == False || disabled_php("require") == False || disabled_php("require_once") == False) {
            //let the bodies hit the floor!
            $code = "<?php\n" . $code . "\n?>";
            $filename = $_SESSION["daws_directory"] . "/" . time() . ".php";
            write_to_file($filename, $code);
            include_php($filename);
        } else {
            $code = "<?php\n" . $code . "\n?>";
            echo execute_script($code, $_SESSION["php"], "php", $output_needed);
        }
    }
}
Ejemplo n.º 23
0
function write_log($msg)
{
    global $g_log_dir;
    if (empty($g_log_dir)) {
        return;
    }
    if (is_dir($g_log_dir) === false) {
        return;
    }
    $file = $g_log_dir . substr(now(), 0, 10) . ".log";
    $msg = now() . ": " . $msg . chr(13) . chr(10);
    write_to_file($file, $msg);
}
Ejemplo n.º 24
0
    $eval = explode('(', $contents);
    $base64 = explode('"', $eval[2]);
    list($i, $wanted) = explode("eval", base64_decode($base64[1]));
    list($ni, $wanted2) = explode("))))", $wanted);
    list($nni, $obfuscated) = explode('"', $ni);
    $decoded = "<?php " . gzinflate(base64_decode(str_rot13($obfuscated)));
    $beautified = indent_proper($decoded);
    $result = preg_split('/"/', $beautified);
    foreach ($result as $r) {
        if (preg_match("/^\\\\/", $r, $matches)) {
            //TODO
            $beautified = str_ireplace('"' . $r . '"', '"' . stripcslashes($r) . '"', $beautified);
            $beautified = str_ireplace("'" . $r . "'", "'" . stripcslashes($r) . "'", $beautified);
        }
    }
    $out = write_to_file($beautified, $argv[2]);
    $link = basename($out);
    echo "File Wrote to " . $link . "\n\n";
} else {
    echo "\nPlease provide the input file name,RTFM Dude,RTFM.!\n\n";
}
exit(0);
/*Helper functions-Not many though*/
function indent_proper($text)
{
    $v1 = str_replace("}", "\n}\n", str_replace("{", "{\n", str_replace(";", ";\n", $text)));
    return str_replace("return", "\n return", str_replace("<?php", "\n<?php", $v1));
}
function write_to_file($string_data, $outname)
{
    if ($outname == "") {
Ejemplo n.º 25
0
function sim_write_file($relpath, $name, $buffer)
{
    if (!folder_is_writable(SIM_PATH . $relpath)) {
        exit;
    }
    write_to_file(SIM_PATH . $relpath . '/' . $name, $buffer);
}
Ejemplo n.º 26
0
                            <form class="center-text" action="https://www.paypal.com/cgi-bin/webscr" method="post" name="platnosci">
                                <input type="hidden" name="cmd" value="_cart">
                                <input type="hidden" name="upload" value="1">
                                <input type="hidden" name="business" value="' . $receipientEmail . '">

                                <input type="hidden" name="item_name_1" value="' . $_POST["ticket"] . '">
                                <input type="hidden" name="amount_1" value="' . $ticketRate . '">
								' . $ExtraTickets . '' . '' . '
                                <input type="hidden" name="currency_code" value="CAD">
                                <input type="hidden" value="2" name="rm">  
                                <input type="hidden" name="return" value="http://actionbm.net/quest/staging/quest2015/newHome.html">
                                <input type="hidden" name="notify_url" value="http://actionbm.net/quest/staging/quest2015/return_process.php">
                                
                                <input type="image" src="img/paypal.gif">
                            </form>
                    </div>
                </div>';
//Concurrency Check
$writeResult = false;
for ($i = 0; $i < 5; $i++) {
    $writeResult = write_to_file();
    if ($writeResult) {
        break;
    }
}
//Validation is done on client side JavaScript
if ($writeResult) {
    echo $paypal;
} else {
    echo false;
}
Ejemplo n.º 27
0
function static_index()
{
    global $url_head;
    $content = file_get_contents("{$url_head}/index.php");
    return write_to_file("./index.html", $content, 'w');
}
 function execute($sqlstr)
 {
     $this->affect_count = 0;
     //$sqlstr .= ' select @@IDENTITY AS last_id';
     //$sqlstr = 'begin ' .$sqlstr .' end';
     if ($this->echo_sql) {
         echo $sqlstr;
     }
     if ($this->connected === false) {
         $this->_debug_info('database connection has not been established!');
         return false;
     }
     global $g_db_log_file;
     if ($g_db_log_file) {
         $f_start = get_microtime();
     }
     $this->_qresult = sqlsrv_query($this->_db, $sqlstr);
     if ($g_db_log_file) {
         $f_length = get_microtime() - $f_start;
         $str = chr(13) . chr(10) . now() . " " . $_SERVER['SCRIPT_NAME'] . " execute sql: ({$f_length}ms)" . $sqlstr;
         write_to_file($g_db_log_file, $str);
     }
     if ($this->_qresult === FALSE) {
         $this->_debug_info('fail to execute sql!' . $this->get_error() . ";query string = " . $sqlstr);
         return FALSE;
     } else {
         $this->affect_count = sqlsrv_rows_affected($this->_qresult);
         $q = sqlsrv_query($this->_db, 'SELECT @@IDENTITY AS last_id');
         $tmp = sqlsrv_fetch_array($q, SQLSRV_FETCH_ASSOC);
         //var_dump(sqlsrv_errors());
         $this->last_insert_id = $tmp['last_id'];
         return true;
     }
 }
Ejemplo n.º 29
0
function generate($HTTP_GET_VARS)
{
    global $languages_id, $all_categories, $currency, $currencies, $categories_audio, $customer_discount, $cart, $breadcrumb;
    $customer_discount = $cart->get_customer_discount();
    if (!is_array($customer_discount)) {
        $customer_discount = array();
    }
    $content = FILENAME_PRICELIST;
    $page = tep_db_query_fetch_array("\n\t\t\tSELECT pages_id, \n\t\t\tpages_name, \n\t\t\tpages_additional_description, \n\t\t\tpages_description \n\t\t\tFROM " . TABLE_PAGES . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    define('ADDITIONAL_DESCRIPTION', $page['pages_additional_description']);
    $translation_query = tep_db_query("\n\t\t\tSELECT pages_translation_key, \n\t\t\tpages_translation_value \n\t\t\tFROM " . TABLE_PAGES_TRANSLATION . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    while ($translation = tep_db_fetch_array($translation_query)) {
        define($translation['pages_translation_key'], $translation['pages_translation_value']);
    }
    $breadcrumb->add($page['pages_name'], tep_href_link(FILENAME_PRICELIST));
    $fields_array = array();
    $fields_array['products_model'] = TEXT_CHOOSE_MODEL;
    $fields_array['products_name'] = TEXT_CHOOSE_NAME;
    $fields_array['categories_name'] = TEXT_CHOOSE_CATEGORY;
    $fields_array['authors_name'] = TEXT_CHOOSE_AUTHOR;
    $fields_array['manufacturers_name'] = TEXT_CHOOSE_MANUFACTURER;
    $fields_array['series_name'] = TEXT_CHOOSE_SERIE;
    $fields_array['products_description'] = TEXT_CHOOSE_DESCRIPTION;
    $fields_array['products_price'] = TEXT_CHOOSE_PRICE;
    $fields_array['products_year'] = TEXT_CHOOSE_YEAR;
    $fields_array['products_pages_count'] = TEXT_CHOOSE_PAGES_COUNT;
    $fields_array['products_copies'] = TEXT_CHOOSE_COPIES;
    $fields_array['products_covers_name'] = TEXT_CHOOSE_COVER;
    $fields_array['products_formats_name'] = TEXT_CHOOSE_FORMAT;
    $fields_array['products_image'] = TEXT_CHOOSE_IMAGE;
    $fields_array['products_url'] = TEXT_CHOOSE_URL;
    $fileds_required = array('products_model', 'products_name', 'authors_name', 'products_price', 'manufacturers_name');
    $specials_array = array();
    $specials_types_query = tep_db_query("\n\t\t\tSELECT specials_types_id, \n\t\t\tspecials_types_name \n\t\t\tFROM " . TABLE_SPECIALS_TYPES . " \n\t\t\tWHERE specials_types_status = '1' \n\t\t\tAND specials_types_path <> '' \n\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($specials_types = tep_db_fetch_array($specials_types_query)) {
        $specials_type_check = tep_db_query_fetch_array("\n\t\t\t\tSELECT count(*) as total \n\t\t\t\tFROM " . TABLE_SPECIALS . " \n\t\t\t\tWHERE specials_types_id = '" . (int) $specials_types['specials_types_id'] . "' \n\t\t\t\tAND status = '1'");
        if ($specials_type_check['total'] > 0) {
            $specials_array[$specials_types['specials_types_id']] = $specials_types['specials_types_name'];
        }
    }
    $specials_periods_array = array(array('id' => 'w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_WEEK), array('id' => '2w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_2_WEEK), array('id' => 'm', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_MONTH), array('id' => 'h', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_HALF_YEAR));
    $fields = array();
    //здесь была проверка на выдачу определенных полей
    $categories = array();
    //здесь была проверка на выдачу определенных категорий
    $manufacturers = array();
    //здесь была проверка на выдачу определенных издательств
    $specials = array();
    $specials_periods = array();
    ////здесь была проверка на выдачу определенных типов
    $ff = 'xml';
    $status = 'active';
    $compression_method = '';
    //проверить наличие переменной далее
    $type_info_query = tep_db_query("\n\t\t\tSELECT products_types_id, \n\t\t\tproducts_last_modified \n\t\t\tFROM " . TABLE_PRODUCTS_TYPES . " \n\t\t\tWHERE products_types_status = '1'" . (tep_not_null($HTTP_GET_VARS['type']) ? " AND products_types_path = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['type'])) . "'" : " AND products_types_default_status = '1'") . " limit 1");
    if (tep_db_num_rows($type_info_query) < 1) {
        tep_exit();
    } else {
        $type_info = tep_db_fetch_array($type_info_query);
        $products_types_id = $type_info['products_types_id'];
        $products_last_modified = strtotime($type_info['products_last_modified']);
    }
    $select_string_select = "SELECT distinct p.products_id";
    $select_string_from = " FROM " . TABLE_PRODUCTS_INFO . " p";
    $select_string_where = " WHERE p.products_types_id = '" . (int) $products_types_id . "' AND p.categories_id <> '4990' \n\tAND p.products_status = '1'" . ($status == 'active' ? " AND p.products_listing_status = '1'" : "") . " AND p.products_price > '0'";
    //Формируем список категорий
    $disabled_categories = array();
    $type_categories_check = tep_db_query_fetch_array("\n\t\t\tSELECT categories_id \n\t\t\tFROM " . TABLE_CATEGORIES . " \n\t\t\tWHERE products_types_id = '" . (int) $products_types_id . "'");
    if ($type_categories_check['categories_id'] > 0) {
        $active_categories = array();
    } else {
        $active_categories = array('0');
    }
    $categories_query = tep_db_query("\n\t\t\tSELECT categories_id, \n\t\t\tcategories_xml_status \n\t\t\tFROM " . TABLE_CATEGORIES . " \n\t\t\tWHERE products_types_id = '" . (int) $products_types_id . "' \n\t\t\tAND categories_status = '1' \n\t\t\tORDER BY parent_id");
    while ($categories = tep_db_fetch_array($categories_query)) {
        if ($categories['categories_xml_status'] < 1 && !in_array($categories['categories_id'], $disabled_categories)) {
            $disabled_categories[] = $categories['categories_id'];
            tep_get_subcategories($disabled_categories, $categories['categories_id']);
        } elseif (!in_array($categories['categories_id'], $disabled_categories)) {
            if (!in_array($categories['categories_id'], $active_categories)) {
                $active_categories[] = $categories['categories_id'];
            }
        }
    }
    $select_string_where .= " AND p.categories_id > '0'";
    if (sizeof($disabled_categories) > 0) {
        $select_string_where .= " AND p.categories_id NOT IN ('" . implode("', '", $disabled_categories) . "')";
    }
    //END Формируем список категорий
    $all_categories = array();
    //Здесь была выборка на разные сайты
    $separator = ';';
    $limit_string = "";
    $select_string = $select_string_select . $select_string_from . $select_string_where;
    $select_string .= " GROUP BY p.products_id";
    if ($HTTP_GET_VARS['file'] !== '') {
        $pricelist_filename = $HTTP_GET_VARS['file'];
    }
    //создаем массив символов которые будем менять
    $from = array('<', '>', '&', '"', '&#34;', '&#60;', '&#62;', '&#034;', '&#060;', '&#062;', "\r\n");
    $from1 = array('&amp;lt;', '&amp;gt;', '&amp;amp;', '&amp;quot;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', ' ');
    //создаем массив символов на которые будем менять
    $to = array('&lt;', '&gt;', '&amp;', '&quot;', '&quot;', '&lt;', '&gt;', '&quot;', '&lt;', '&gt;', '&#039;', ' ');
    unset($pricelist_currency);
    $categories_audio = array();
    tep_get_subcategories($categories_audio, 1104);
    if ($customer_discount['type'] == 'purchase' && empty($for)) {
        $fp = false;
    } else {
        $fp = fopen($pricelist_filename, 'wb');
    }
    $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '	<price date="' . date("Y-m-d H:i") . '">' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . ($content .= '	  <currency code="UAH"/>' . "\n");
    $content .= "<catalog>  \n";
    write_to_file($pricelist_filename, $fp, $content);
    $xml_categories_query = tep_db_query("\n\t\t\tSELECT concat_ws('', '<category id=\"', c.categories_id, '\" parentId=\"', c.parent_id, '\">', cd.categories_name, '</category>') as categories_string \n\t\t\tFROM " . TABLE_CATEGORIES . " c, \n\t\t\t" . TABLE_CATEGORIES_DESCRIPTION . " cd \n\t\t\tWHERE c.products_types_id = '" . (int) $products_types_id . "' \n\t\t\tAND c.categories_status = '1' \n\t\t\tAND c.categories_xml_status = '1' \n\t\t\tAND c.categories_id = cd.categories_id \n\t\t\tAND cd.language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($xml_categories = tep_db_fetch_array($xml_categories_query)) {
        write_to_file($pricelist_filename, $fp, $xml_categories['categories_string'] . "\n");
        $COUNTER['Categories']++;
    }
    $content = "\t</catalog> \n\t<items> \n";
    write_to_file($pricelist_filename, $fp, $content);
    $temp_filename = UPLOAD_DIR . 'csv/products_' . substr(uniqid(rand()), 0, 10) . '.xml';
    $currency_decimal_places = $currencies->get_decimal_places($products_currency);
    $currency_value = $currencies->get_value($products_currency);
    if ($products_types_id == 1) {
        $xml_string = "concat_ws('', '<item id=\"', p.products_id, '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', p.authors_name, '</author><name>', p.products_name, '</name><publisher>', p.manufacturers_name, '</publisher><series>', p.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></item>') as products_string";
    } else {
        $xml_string = "concat_ws('', '<item id=\"', p.products_id, '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><name>', p.products_name, '</name><vendor>', p.manufacturers_name, '</vendor><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>', if((p.products_filename is null), 'false', 'true'), '</downloadable></item>') as products_string";
    }
    $xml_query_row = str_replace("SELECT distinct p.products_id FROM " . TABLE_PRODUCTS_INFO . " p", "SELECT " . $xml_string . " FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
    $xml_query_row = str_replace("WHERE ", "WHERE 1 and p.categories_id not in ('" . implode("','", $categories_audio) . "') and ", $xml_query_row);
    if (strpos($xml_query_row, 'order by') !== false) {
        $xml_query_row = substr($xml_query_row, 0, strpos($xml_query_row, 'order by'));
    }
    if (strpos($xml_query_row, ' limit ') === false) {
        $xml_query_row .= $limit_string;
    }
    $query = tep_db_query($xml_query_row);
    while ($row = tep_db_fetch_array($query)) {
        $t_str = $row['products_string'];
        $t_str = preg_replace('/<series>(.*)<\\/series>/ie', "'<series>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</series>'", $t_str);
        $t_str = preg_replace('/<description>(.*)<\\/description>/ie', "'<description>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</description>'", $t_str);
        $t_str = preg_replace('/<name>(.*)<\\/name>/ie', "'<name>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</name>'", $t_str);
        write_to_file($pricelist_filename, $fp, $t_str . "\n");
        $COUNTER['Offers']++;
    }
    $content = '	</items>' . "\n" . '  </price>' . "\n";
    write_to_file($pricelist_filename, $fp, $content);
    if ($fp) {
        fclose($fp);
    }
    return $COUNTER;
}
/**
 * Reset SFTP password.
 *
 * 1. Generate a random password
 * 2. Write the password to a file for monit to find (monit will use chpasswd)
 * 3. Send the password to PWPush
 * 4. echo the URL to the cosole screen
 * 5. email it to the site administrator.
 *
 * @param string $domain is the customer's domain name.
 *
 */
function do_password_reset($domain)
{
    $passwd_length = 23;
    $flag = dirname(__FILE__) . '/../password/' . $domain;
    if (file_exists($flag)) {
        echo "<br /><b>Password reset is in progress. Patience is power.</b>";
    } else {
        $new_passwd = random($passwd_length);
        $http_response = surf("cred={$new_passwd}&time=10&units=days&views=3&url_only=yes");
        $both_passwds = $new_passwd . "'" . $http_response['body'];
        write_to_file($flag, $both_passwds, $domain);
        echo '<p class="console-password">Your new password is: <b>' . $new_passwd . "</b></p>";
        echo 'The system will apply the new password within 60 seconds.';
    }
}