예제 #1
0
function zen_create_random_value($length, $type = 'mixed')
{
    if ($type != 'mixed' && $type != 'chars' && $type != 'digits') {
        return false;
    }
    $rand_value = '';
    while (strlen($rand_value) < $length) {
        if ($type == 'digits') {
            $char = zen_rand(0, 9);
        } else {
            $char = chr(zen_rand(0, 255));
        }
        if ($type == 'mixed') {
            if (eregi('^[a-z0-9]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'chars') {
            if (eregi('^[a-z]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'digits') {
            if (ereg('^[0-9]$', $char)) {
                $rand_value .= $char;
            }
        }
    }
    return $rand_value;
}
function zen_create_random_value($length, $type = 'mixed')
{
    if ($type != 'mixed' && $type != 'chars' && $type != 'digits') {
        return false;
    }
    $rand_value = '';
    while (strlen($rand_value) < $length) {
        if ($type == 'digits') {
            $char = zen_rand(0, 9);
        } else {
            $char = chr(zen_rand(0, 255));
        }
        if ($type == 'mixed') {
            if (preg_match('/^[a-z0-9]$/i', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'chars') {
            if (preg_match('/^[a-z]$/i', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'digits') {
            if (preg_match('/^[0-9]$/', $char)) {
                $rand_value .= $char;
            }
        }
    }
    if ($type == 'mixed' && !preg_match('/^(?=.*[\\w]+.*)(?=.*[\\d]+.*)[\\d\\w]{' . $length . ',}$/', $rand_value)) {
        $rand_value .= zen_rand(0, 9);
    }
    return $rand_value;
}
예제 #3
0
function zen_encrypt_password($plain)
{
    $password = '';
    for ($i = 0; $i < 10; $i++) {
        $password .= zen_rand();
    }
    $salt = substr(md5($password), 0, 2);
    $password = md5($salt . $plain) . ':' . $salt;
    return $password;
}
예제 #4
0
function zen_random_name()
{
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(zen_rand(16, 20));
    for ($i = 1; $i <= $length; $i++) {
        $q = floor(zen_rand(1, 26));
        $dirname .= $letters[$q];
    }
    return $dirname;
}
function zen_random_charcode($length)
{
    $arraysize = 34;
    $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
    $code = '';
    for ($i = 1; $i <= $length; $i++) {
        $j = floor(zen_rand(0, $arraysize));
        $code .= $chars[$j];
    }
    return $code;
}
예제 #6
0
function zen_random_name()
{
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    if (defined('DOWNLOADS_SKIP_DOT_PREFIX_ON_REDIRECT') && DOWNLOADS_SKIP_DOT_PREFIX_ON_REDIRECT === TRUE) {
        $dirname = '';
    }
    $length = floor(zen_rand(16, 20));
    for ($i = 1; $i <= $length; $i++) {
        $q = floor(zen_rand(1, 26));
        $dirname .= $letters[$q];
    }
    return $dirname;
}
예제 #7
0
 function ExecuteRandom($zf_sql, $zf_limit = 0, $zf_cache = false, $zf_cachetime = 0)
 {
     //    if ($zf_limit) {
     //      $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit;
     //    }
     //echo $zf_sql . '<br />';
     $time_start = explode(' ', microtime());
     $obj = new queryFactoryResult();
     $obj->result = array();
     if (!$this->db_connected) {
         $this->set_error('0', DB_ERROR_NOT_CONNECTED);
     }
     $zp_db_resource = @pg_query($this->link, $zf_sql);
     if (!$zp_db_resource) {
         $this->set_error(pg_last_error());
     }
     $obj->resource = $zp_db_resource;
     $obj->cursor = 0;
     $obj->Limit = $zf_limit;
     if ($obj->RecordCount() > 0) {
         $obj->EOF = false;
         $zp_Start_row = 0;
         if ($zf_limit) {
             $zp_start_row = zen_rand(0, $obj->RecordCount() - $zf_limit);
         }
         $obj->Move($zp_start_row);
         $obj->Limit = $zf_limit;
         $zp_ii = 0;
         while (!$obj->EOF) {
             $zp_result_array = @pg_fetch_array($zp_db_resource, NULL, PGSQL_ASSOC);
             if ($zp_ii == $zf_limit) {
                 $obj->EOF = true;
             }
             if ($zp_result_array) {
                 while (list($key, $value) = each($zp_result_array)) {
                     if (!ereg('^[0-9]', $key)) {
                         //              echo $key . '=' . $value . '<br />';
                         $obj->result[$zp_ii][$key] = $value;
                     }
                 }
             } else {
                 $obj->Limit = $zp_ii;
                 $obj->EOF = true;
             }
             $zp_ii++;
         }
         $obj->result_random = array_rand($obj->result, sizeof($obj->result));
         //      echo sizeof($obj->result) . " result array ";
         //      print_r($obj->result);
         //      echo '<br /><br />';
         //      echo 'random array ';
         //      print_r($obj);
         if (is_array($obj->result_random)) {
             $zp_ptr = $obj->result_random[$obj->cursor];
         } else {
             $zp_ptr = $obj->result_random;
         }
         while (list($key, $value) = each($obj->result[$zp_ptr])) {
             if (!ereg('^[0-9]', $key)) {
                 $obj->fields[$key] = $value;
             }
         }
         $obj->EOF = false;
     } else {
         $obj->EOF = true;
     }
     $time_end = explode(' ', microtime());
     $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
     $this->total_query_time += $query_time;
     $this->count_queries++;
     return $obj;
 }
예제 #8
0
function zen_random_select($query)
{
    global $db;
    $random_product = '';
    $random_query = $db->Execute($query);
    $num_rows = $random_query->RecordCount();
    if ($num_rows > 1) {
        $random_row = zen_rand(0, $num_rows - 1);
        $random_query->Move($random_row);
    }
    return $random_query;
}
예제 #9
0
 function ExecuteRandomMulti($zf_sql, $zf_limit = 0, $zf_cache = false, $zf_cachetime = 0)
 {
     $this->zf_sql = $zf_sql;
     $time_start = explode(' ', microtime());
     $obj = new queryFactoryResult();
     $obj->result = array();
     if (!$this->db_connected) {
         if (!$this->connect($this->host, $this->user, $this->password, $this->database, $this->pConnect, $this->real)) {
             $this->set_error('0', DB_ERROR_NOT_CONNECTED);
         }
     }
     $zp_db_resource = @mysql_query($zf_sql, $this->link);
     if (!$zp_db_resource) {
         $this->set_error(mysql_errno(), mysql_error());
     }
     if (!is_resource($zp_db_resource)) {
         $obj = null;
         return true;
     }
     $obj->resource = $zp_db_resource;
     $obj->cursor = 0;
     $obj->Limit = $zf_limit;
     if ($obj->RecordCount() > 0 && $zf_limit > 0) {
         $obj->EOF = false;
         $zp_Start_row = 0;
         if ($zf_limit) {
             $zp_start_row = zen_rand(0, $obj->RecordCount() - $zf_limit);
         }
         $obj->Move($zp_start_row);
         $obj->Limit = $zf_limit;
         $zp_ii = 0;
         while (!$obj->EOF) {
             $zp_result_array = @mysql_fetch_array($zp_db_resource);
             if ($zp_ii == $zf_limit) {
                 $obj->EOF = true;
             }
             if ($zp_result_array) {
                 while (list($key, $value) = each($zp_result_array)) {
                     $obj->result[$zp_ii][$key] = $value;
                 }
             } else {
                 $obj->Limit = $zp_ii;
                 $obj->EOF = true;
             }
             $zp_ii++;
         }
         $obj->result_random = array_rand($obj->result, sizeof($obj->result));
         if (is_array($obj->result_random)) {
             $zp_ptr = $obj->result_random[$obj->cursor];
         } else {
             $zp_ptr = $obj->result_random;
         }
         while (list($key, $value) = each($obj->result[$zp_ptr])) {
             if (!preg_match('/^[0-9]/', $key)) {
                 $obj->fields[$key] = $value;
             }
         }
         $obj->EOF = false;
     } else {
         $obj->EOF = true;
     }
     $time_end = explode(' ', microtime());
     $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
     $this->total_query_time += $query_time;
     $this->count_queries++;
     return $obj;
 }
예제 #10
0
function session_start()
{
    global $session, $SID, $_COOKIE, $_GET, $_POST;
    // Define the global variable $SID?
    $define_sid = true;
    // Send the session cookie?
    $send_cookie = true;
    // Is track_vars enabled?
    $track_vars = isset($_COOKIE) || isset($_GET) || isset($_POST) ? true : false;
    // Check if session_start() has been called once already
    if ($session->nr_open_sessions != 0) {
        return false;
    }
    // If our only resource is the global symbol_table, then check it.
    // If track_vars are enabled, we prefer these, because they are more
    // reliable, and we always know whether the user has accepted the
    // cookie.
    if (isset($GLOBALS[$session->name]) && !empty($GLOBALS[$session->name]) && !$track_vars) {
        $session->id = $GLOBALS[$session->name];
        $send_cookie = false;
    }
    // Now check the track_vars. Cookies are preferred, because initially
    // cookie and get variables will be available.
    if (empty($session->id) && $track_vars) {
        if (isset($_COOKIE[$session->name])) {
            $session->id = $_COOKIE[$session->name];
            $define_sid = false;
            $send_cookie = false;
        }
        if (isset($_GET[$session->name])) {
            $session->id = $_GET[$session->name];
        }
        if (isset($_POST[$session->name])) {
            $session->id = $_POST[$session->name];
        }
    }
    /*
    // Check the REQUEST_URI symbol for a string of the form
    // '<session-name>=<session-id>' to allow URLs of the form
    // http://yoursite/<session-name>=<session-id>/script.php 
        if (empty($session->id)) {
          eregi($session->name . '=([^/]+)', $GLOBALS['REQUEST_URI'], $regs);
          $regs[1] = trim($regs[1]);
          if (!empty($regs[1])) {
            $session->id = $regs[1];
          }
        }
    */
    // Check whether the current request was referred to by
    // an external site which invalidates the previously found ID
    if (!empty($session->id) && $session->referer_check) {
        $url = parse_url($GLOBALS['HTTP_REFERER']);
        if (trim($url['host']) != $GLOBALS['SERVER_NAME']) {
            unset($session->id);
            $send_cookie = true;
            $define_sid = true;
        }
    }
    // Do we have an existing session ID?
    if (empty($session->id)) {
        // Create new session ID
        $session->id = _session_create_id();
    }
    // Is use_cookies set to false?
    if (!$session->use_cookies && $send_cookie) {
        $define_sid = true;
        $send_cookie = false;
    }
    // Should we send a cookie?
    if ($send_cookie) {
        setcookie($session->name, $session->id, $session->cookie_lifetime, $session->cookie_path, $session->cookie_domain);
    }
    // Should we define the SID?
    if ($define_sid) {
        $SID = $session->name . '=' . $session->id;
    }
    $session->nr_open_sessions++;
    // Send caching headers
    // Start session
    $mod = $GLOBALS[$session->mod_name];
    if (!$mod->open($session->save_path, $session->name)) {
        die('Failed to initialize session module.');
    }
    // Read session data
    if ($val = $mod->read($session->id)) {
        // Decode session data
        session_decode($val);
    }
    // Send HTTP cache headers
    _session_cache_limiter();
    // Check if we should clean up (call the garbage collection routines)
    if ($session->gc_probability > 0) {
        $randmax = getrandmax();
        $nrand = (int) (100 * zen_rand() / $randmax);
        if ($nrand < $session->gc_probability) {
            $mod->gc($session->gc_maxlifetime);
        }
    }
    if ($define_sid) {
        define('SID', $SID);
    } else {
        define('SID', '');
    }
    return true;
}
예제 #11
0
파일: mime.php 프로젝트: bitweaver/commerce
 /**
  * encode()
  * 
  * Encodes and returns the email. Also stores
  * it in the encoded member variable
  *
  * @return An associative array containing two elements,
  *         body and headers. The headers element is itself
  *         an indexed array.
  * @access public
  */
 function encode()
 {
     /* HPDL PHP3 */
     //      $encoded =& $this->_encoded;
     $encoded = $this->_encoded;
     if (zen_not_null($this->_subparts)) {
         $boundary = '=_' . md5(uniqid(zen_rand()) . microtime());
         $this->_headers['Content-Type'] .= ';' . $this->lf . chr(9) . 'boundary="' . $boundary . '"';
         // Add body parts to $subparts
         for ($i = 0; $i < count($this->_subparts); $i++) {
             $headers = array();
             /* HPDL PHP3 */
             //          $tmp = $this->_subparts[$i]->encode();
             $_subparts = $this->_subparts[$i];
             $tmp = $_subparts->encode();
             reset($tmp['headers']);
             while (list($key, $value) = each($tmp['headers'])) {
                 $headers[] = $key . ': ' . $value;
             }
             $subparts[] = implode($this->lf, $headers) . $this->lf . $this->lf . $tmp['body'];
         }
         $encoded['body'] = '--' . $boundary . $this->lf . implode('--' . $boundary . $this->lf, $subparts) . '--' . $boundary . '--' . $this->lf;
     } else {
         $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . $this->lf;
     }
     // Add headers to $encoded
     /* HPDL PHP3 */
     //      $encoded['headers'] =& $this->_headers;
     $encoded['headers'] = $this->_headers;
     return $encoded;
 }
예제 #12
0
 /**
  * Install the payment module and its configuration settings
  *
  */
 function install()
 {
     global $db;
     // javascript
     $script = '<script type="text/javascript">' . "\n" . "<!--\n" . "window.onload = function() {\n" . "  init();\n" . "  var radio = document.getElementsByName('configuration[MODULE_PAYMENT_PAYPAL_SETTLEMENT_TYPE]');\n" . "  for (var i=0; i<radio.length; i++) {\n" . "    if (radio[i].value == 'ExpressCheckout')\n" . "      radio[i].onclick = function() { config_show('EC_div'); config_hide('WPP_div'); }\n" . "    else\n" . "      radio[i].onclick = function() { config_show('WPP_div'); config_hide('EC_div'); }\n" . "  }\n" . "}\n" . "function config_hide(div_id) {\n" . "  var element = document.getElementById(div_id);\n" . "  if (!element) return;\n" . "  element.style.display = 'none';\n" . "}\n" . "\n" . "function config_show(div_id) {\n" . "  var element = document.getElementById(div_id);\n" . "  if (!element) return;\n" . "  element.style.display = 'block';\n" . "}\n" . "// -->\n" . "</script>\n";
     $script = str_replace("'", "\\'", $script);
     $script = str_replace('"', '\\"', $script);
     define('MODULE_PAYMENT_PAYPAL_TEXT_STATUS', 'PayPal を有効にする');
     define('MODULE_PAYMENT_PAYPAL_DESC_STATUS', 'PayPal を有効にする');
     define('MODULE_PAYMENT_PAYPAL_TEXT_SETTLEMENT_TYPE', '処理タイプ');
     define('MODULE_PAYMENT_PAYPAL_DESC_SETTLEMENT_TYPE', '処理タイプを選択してください' . $script);
     define('MODULE_PAYMENT_PAYPAL_TEXT_ZONE', '適用地域');
     define('MODULE_PAYMENT_PAYPAL_DESC_ZONE', '適用地域を選択すると、選択した地域のみで利用可能となります。');
     define('MODULE_PAYMENT_PAYPAL_TEXT_ORDER_STATUS_ID', '初期注文ステータス');
     define('MODULE_PAYMENT_PAYPAL_DESC_ORDER_STATUS_ID', '設定したステータスが受注時に適用されます。');
     define('MODULE_PAYMENT_PAYPAL_TEXT_SORT_ORDER', '表示の整列順');
     define('MODULE_PAYMENT_PAYPAL_DESC_SORT_ORDER', '表示の整列順を設定できます。数字が小さいほど上位に表示されます');
     define('MODULE_PAYMENT_PAYPAL_TEXT_SELECTOPTION', '');
     define('MODULE_PAYMENT_PAYPAL_DESC_SELECTOPTION', 'WebPaymentPlusは、決済画面のカスタマイズ、PayPal/クレジットカード決済の利用可能です。');
     // for Express Checkout
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_ID', 'PayPal ビジネスアカウントのID');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_ID', 'PayPal ビジネスアカウントのIDを入力してください。');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_PASS', 'PayPal ビジネスアカウントのパスワード');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_PASS', 'PayPal ビジネスアカウントのパスワードを入力してください。');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_SIGNATURE', 'API署名');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_SIGNATURE', '上記アカウントのAPI署名を設定してください。');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_SETTLEMENT_TYPE', '決済方式');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_SETTLEMENT_TYPE', 'Sale(売上)もしくはAuthorization(与信)を選択してください');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_CURRENCY', '通貨');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_CURRENCY', '通貨を選択してください');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_REFERENCE', 'Reference Transactionを利用');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_REFERENCE', '事前合意によるPayPal口座引き落としを有効にする<br/>※ Reference Transactionを利用するためには事前に審査が必要です。<br/>→ <a href="https://www.paypal.com/jp/cgi-bin/helpscr?cmd=_help&t=escalateTab" target="_blank">審査のご依頼はフォーム</a>');
     define('MODULE_PAYMENT_PAYPAL_EC_TEXT_TEST', 'Test環境');
     define('MODULE_PAYMENT_PAYPAL_EC_DESC_TEST', 'テスト時はTrue、そうでなければFalseとしてください。');
     // for Web Payment Plus
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_LINK', 'WebPaymentPlusを利用するにはお申し込みが必要です。');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_LINK', '<p>下記のURLから申し込みが可能です。<br><a href="https://www.paypal-japan.com/wpp/">ウェブペイメントプラスのご紹介</a></p>' . '<b>WebPaymentPlusの設定:</b><br>' . '<p>設定方法は<a href="...">WPP設定マニュアル</a>をご覧ください。</p>' . '<b>設定値:</b><br>' . '<p>(A)IPNへのURL:<br>' . str_replace('index.php?main_page=index', 'paypal_ipn.php', zen_catalog_href_link(FILENAME_DEFAULT, '', 'SSL')) . '<br><br>' . '(B)zen-cartへの戻りURL:<br>' . zen_catalog_href_link(FILENAME_CHECKOUT_SUCCESS_PAYPAL_IPN_WAITING, '', 'SSL', false) . '</p>');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_MERCHANT_ID', 'PayPal ビジネスアカウントの「セキュアなマーチャントID」');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_MERCHANT_ID', 'PayPalへログインして「個人設定」のページ上部に書いてあります。');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_SETTLEMENT_TYPE', '決済方式');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_SETTLEMENT_TYPE', '注文後、即売上となります(sale)');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_CURRENCY', '通貨');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_CURRENCY', 'お支払い通貨。');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_TEST', 'テスト環境 (Sandboxの利用有無)');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_TEST', 'テスト時はTrue、そうでなければFalseとしてください。');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_CUSTOM_KEY', 'パススルー変数の正当性チェックキー');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_CUSTOM_KEY', 'パススルー変数が正しいことをチェックするキーを入力してください。');
     define('MODULE_PAYMENT_PAYPAL_WPP_TEXT_EMAIL', 'エラー発生時の通知先メールアドレス');
     define('MODULE_PAYMENT_PAYPAL_WPP_DESC_EMAIL', 'エラー発生時の通知先メールアドレスを入力してください。');
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_STATUS . "',          'MODULE_PAYMENT_PAYPAL_STATUS',          'True',            '" . MODULE_PAYMENT_PAYPAL_DESC_STATUS . "',          '6', '0', 'zen_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_SETTLEMENT_TYPE . "', 'MODULE_PAYMENT_PAYPAL_SETTLEMENT_TYPE', 'ExpressCheckout', '" . MODULE_PAYMENT_PAYPAL_DESC_SETTLEMENT_TYPE . "', '6', '1', 'zen_cfg_select_option(array(\\'ExpressCheckout\\', \\'WebPaymentPlus\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_SELECTOPTION . "',    'MODULE_PAYMENT_PAYPAL_SELECTOPTION',    '',                '" . MODULE_PAYMENT_PAYPAL_DESC_SELECTOPTION . "',    '6', '2', 'zen_cfg_null(', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_ZONE . "',            'MODULE_PAYMENT_PAYPAL_ZONE',            '0',               '" . MODULE_PAYMENT_PAYPAL_DESC_ZONE . "',            '6', '3', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_ORDER_STATUS_ID . "', 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID', '0',               '" . MODULE_PAYMENT_PAYPAL_DESC_ORDER_STATUS_ID . "', '6', '4', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,                             date_added) values ('" . MODULE_PAYMENT_PAYPAL_TEXT_SORT_ORDER . "',      'MODULE_PAYMENT_PAYPAL_SORT_ORDER',      '0',               '" . MODULE_PAYMENT_PAYPAL_DESC_SORT_ORDER . "',      '6', '5', now())");
     // for Express Checkout
     $curencies = array('USER' => '[User Selected Currency]', 'AUD' => 'Australian Dollar', 'BRL' => 'Brazilian Real', 'CAD' => 'Canadian Dollar', 'CZK' => 'Czech Koruna', 'DKK' => 'Danish Krone', 'EUR' => 'Euro', 'HKD' => 'Hong Kong Dollar', 'HUF' => 'Hungarian Forint', 'ILS' => 'Israeli New Sheqel', 'JPY' => 'Japanese Yen', 'MYR' => 'Malaysian Ringgit', 'MXN' => 'Mexican Peso', 'NOK' => 'Norwegian Krone', 'NZD' => 'New Zealand Dollar', 'PHP' => 'Philippine Peso', 'PLN' => 'Polish Zloty', 'GBP' => 'Pound Sterling', 'SGD' => 'Singapore Dollar', 'SEK' => 'Swedish Krona', 'CHF' => 'Swiss Franc', 'TWD' => 'Taiwan New Dollar', 'THB' => 'Thai Baht', 'TRY' => 'Turkish Lira', 'USD' => 'U.S. Dollar');
     $option = array();
     foreach ($curencies as $k => $v) {
         $option[] = "array(\\'id\\' => \\'{$k}\\', \\'text\\' => \\'{$v}\\')";
     }
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('</b><div id=\"EC_div\"><b>',                           'MODULE_PAYMENT_PAYPAL_EC_START',              '',                              '',                                                     '6', '10', 'zen_cfg_null(', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_ID . "',        'MODULE_PAYMENT_PAYPAL_EC_BUSINESS_ID',        '" . STORE_OWNER_EMAIL_ADDRESS . "', '" . MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_ID . "',        '6', '11', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_PASS . "',      'MODULE_PAYMENT_PAYPAL_EC_BUSINESS_PASS',      '',                              '" . MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_PASS . "',      '6', '12', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_BUSINESS_SIGNATURE . "', 'MODULE_PAYMENT_PAYPAL_EC_BUSINESS_SIGNATURE', '',                              '" . MODULE_PAYMENT_PAYPAL_EC_DESC_BUSINESS_SIGNATURE . "', '6', '13', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_SETTLEMENT_TYPE . "',    'MODULE_PAYMENT_PAYPAL_EC_SETTLEMENT_TYPE',    'Sale',                          '" . MODULE_PAYMENT_PAYPAL_EC_DESC_SETTLEMENT_TYPE . "',    '6', '14', 'zen_cfg_select_option(array(\\'Sale\\', \\'Authorization\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_CURRENCY . "',           'MODULE_PAYMENT_PAYPAL_EC_CURRENCY',           'USER',                          '" . MODULE_PAYMENT_PAYPAL_EC_DESC_CURRENCY . "',           '6', '15', 'zen_cfg_select_drop_down_paypal(array(" . implode(",", $option) . "), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_REFERENCE . "',          'MODULE_PAYMENT_PAYPAL_EC_REFERENCE',          'True',                          '" . MODULE_PAYMENT_PAYPAL_EC_DESC_REFERENCE . "',          '6', '16', 'zen_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_EC_TEXT_TEST . "',               'MODULE_PAYMENT_PAYPAL_EC_TEST',               'True',                          '" . MODULE_PAYMENT_PAYPAL_EC_DESC_TEST . "',               '6', '17', 'zen_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('</b></div><b>',                                        'MODULE_PAYMENT_PAYPAL_EC_END',                '',                              '',                                                     '6', '19', 'zen_cfg_null(', now())");
     // for Web Payment Plus
     $customAvailableChars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz' . '01234567890123456789';
     $customAvailableCharCount = strlen($customAvailableChars);
     $customCharCount = zen_rand(20, 30);
     $customValue = '';
     for ($i = 0; $i < $customCharCount; $i++) {
         $pos = mt_rand(0, $customAvailableCharCount * 50) % $customAvailableCharCount;
         $customValue = $customValue . substr($customAvailableChars, $pos, 1);
     }
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('</b><div id=\"WPP_div\"><b>',                          'MODULE_PAYMENT_PAYPAL_WPP_START',             '',                              '',                                                     '6', '20', 'zen_cfg_null(', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_LINK . "',              'MODULE_PAYMENT_PAYPAL_WPP_LINK',              '',                              '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_LINK . "',              '6', '27', 'zen_cfg_null(', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_MERCHANT_ID . "',       'MODULE_PAYMENT_PAYPAL_WPP_MERCHANT_ID',       '',                              '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_MERCHANT_ID . "',       '6', '21', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_SETTLEMENT_TYPE . "',   'MODULE_PAYMENT_PAYPAL_WPP_SETTLEMENT_TYPE',   'sale',                          '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_SETTLEMENT_TYPE . "',   '6', '22', 'zen_cfg_select_option(array(\\'sale\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_CURRENCY . "',          'MODULE_PAYMENT_PAYPAL_WPP_CURRENCY',          'JPY',                           '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_CURRENCY . "',          '6', '23', 'zen_cfg_select_option(array(\\'User Selected Currency\\', \\'USD\\', \\'JPY\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_TEST . "',              'MODULE_PAYMENT_PAYPAL_WPP_TEST',              'True',                          '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_TEST . "',              '6', '24', 'zen_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_CUSTOM_KEY . "',        'MODULE_PAYMENT_PAYPAL_WPP_CUSTOM_KEY','" . $customValue . "',                      '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_CUSTOM_KEY . "',        '6', '25', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,               date_added) values ('" . MODULE_PAYMENT_PAYPAL_WPP_TEXT_EMAIL . "',             'MODULE_PAYMENT_PAYPAL_WPP_EMAIL',             '',                              '" . MODULE_PAYMENT_PAYPAL_WPP_DESC_EMAIL . "',             '6', '26', now())");
     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('</b></div><b>',                                        'MODULE_PAYMENT_PAYPAL_WPP_END',               '',                              '',                                                     '6', '29', 'zen_cfg_null(', now())");
     // customers(paypal_express_checkout_billing_agreement_id)
     $find = false;
     $result = $db->Execute("desc " . TABLE_CUSTOMERS);
     while (!$result->EOF) {
         if ($result->fields['Field'] == "paypal_express_checkout_billing_agreement_id") {
             $find = true;
             break;
         }
         $result->MoveNext();
     }
     if ($find == false) {
         $db->Execute("alter table " . TABLE_CUSTOMERS . " add column paypal_express_checkout_billing_agreement_id varchar(255) NULL default NULL");
     }
     // payment_ec_log
     $query = "create table if not exists " . TABLE_PAYPAL_LOG . " (\n                paypal_log_id int(11)      not null auto_increment,\n                customers_id  int(11)      not null default 0,\n                method        varchar(255) not null default '',\n                request       text         not null default '',\n                response      text         not null default '',\n                ack           varchar(255) not null default '',\n                created       datetime         null,\n                updated       datetime         null,\n                primary key(paypal_log_id)\n              )";
     $db->Execute($query);
     // payment_wpp_log
     $query = "create table if not exists " . TABLE_PAYPAL_WPP_LOG . " (\n                paypal_wpp_log_id int(11)      not null auto_increment,\n                post_base64       text,\n                session_id        text,\n                saved_session     blob,\n                expiry            int(17),\n                customers_id      int(11),\n                reject_reason     text,\n                created           datetime     null,\n                updated           datetime     null,\n                primary key(paypal_wpp_log_id)\n              )";
     $db->Execute($query);
     $this->notify('NOTIFY_PAYMENT_PAYPAL_INSTALLED');
 }