[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * special application_top for Paypal IPN payment method 4 * 5 * @package paymentMethod 6 * @copyright Copyright 2003-2007 Zen Cart Development Team 7 * @copyright Portions Copyright 2003 osCommerce 8 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 9 * @version $Id: ipn_application_top.php 6528 2007-06-25 23:25:27Z drbyte $ 10 */ 11 12 /** 13 * boolean used to see if we are in the admin script, obviously set to false here. 14 */ 15 define('IS_ADMIN_FLAG', false); 16 error_reporting(0); 17 $show_all_errors = false; 18 $current_page_base = 'paypalipn'; 19 @ini_set("arg_separator.output","&"); 20 21 // Set the local configuration parameters - mainly for developers 22 if (file_exists('includes/local/configure.php')) { 23 include('includes/local/configure.php'); 24 } 25 // include server parameters 26 if (file_exists('includes/configure.php')) { 27 include('includes/configure.php'); 28 } 29 30 require ('includes/classes/class.base.php'); 31 require ('includes/classes/class.notifier.php'); 32 require ('includes/classes/class.phpmailer.php'); 33 require ('includes/classes/class.smtp.php'); 34 $zco_notifier = new notifier(); 35 36 require('includes/classes/db/' .DB_TYPE . '/query_factory.php'); 37 $db = new queryFactory(); 38 if ( !$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false) ) { 39 die('Cannot connect to database. Please notify webmaster.'); 40 exit; 41 } 42 43 44 // set the type of request (secure or not) 45 $request_type = (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == '1' || strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_BY']),'SSL') || strstr(strtoupper($_SERVER['HTTP_X_FORWARDED_HOST']),'SSL')) ? 'SSL' : 'NONSSL'; 46 47 // set php_self in the local scope 48 if (!isset($PHP_SELF)) $PHP_SELF = $_SERVER['PHP_SELF']; 49 50 // include the list of project filenames 51 require(DIR_WS_INCLUDES . 'filenames.php'); 52 53 // include the list of project database tables 54 require(DIR_WS_INCLUDES . 'database_tables.php'); 55 56 // include the list of compatibility issues 57 require(DIR_WS_FUNCTIONS . 'compatibility.php'); 58 59 // include the list of extra database tables and filenames 60 // include(DIR_WS_MODULES . 'extra_datafiles.php'); 61 if ($za_dir = @dir(DIR_WS_INCLUDES . 'extra_datafiles')) { 62 while ($zv_file = $za_dir->read()) { 63 if (preg_match('/\.php$/', $zv_file) > 0) { 64 require(DIR_WS_INCLUDES . 'extra_datafiles/' . $zv_file); 65 } 66 } 67 $za_dir->close(); 68 } 69 70 // include the cache class 71 require(DIR_WS_CLASSES . 'cache.php'); 72 $zc_cache = new cache; 73 74 $configuration = $db->Execute('select configuration_key as cfgkey, configuration_value as cfgvalue 75 from ' . TABLE_CONFIGURATION, '', true, 150); 76 77 while (!$configuration->EOF) { 78 // define($configuration->fields['cfgkey'], $configuration->fields['cfgvalue']); 79 define($configuration->fields['cfgkey'], $configuration->fields['cfgvalue']); 80 // echo $configuration->fields['cfgkey'] . '#'; 81 $configuration->MoveNext(); 82 } 83 // Load the database dependant query defines 84 if (file_exists(DIR_WS_CLASSES . 'db/' . DB_TYPE . '/define_queries.php')) { 85 include(DIR_WS_CLASSES . 'db/' . DB_TYPE . '/define_queries.php'); 86 } 87 88 if ( (defined('MODULE_PAYMENT_PAYPALWPP_DEBUGGING') && strstr(MODULE_PAYMENT_PAYPALWPP_DEBUGGING, 'Log')) || 89 (defined('MODULE_PAYMENT_PAYPAL_IPN_DEBUG') && strstr(MODULE_PAYMENT_PAYPAL_IPN_DEBUG, 'Log')) || 90 ($_POST['ppdebug'] == 'on' && strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) ) { 91 @ini_set('display_errors', E_ALL ^ E_NOTICE); 92 error_reporting(E_ALL ^ E_NOTICE); 93 $show_all_errors = true; 94 } 95 96 // define general functions used application-wide 97 require(DIR_WS_FUNCTIONS . 'functions_general.php'); 98 require(DIR_WS_FUNCTIONS . 'html_output.php'); 99 require(DIR_WS_FUNCTIONS . 'functions_email.php'); 100 require(DIR_WS_FUNCTIONS . 'functions_ezpages.php'); 101 102 // load extra functions 103 include(DIR_WS_MODULES . 'extra_functions.php'); 104 105 106 // set the top level domains 107 $http_domain = zen_get_top_level_domain(HTTP_SERVER); 108 $https_domain = zen_get_top_level_domain(HTTPS_SERVER); 109 $current_domain = (($request_type == 'NONSSL') ? $http_domain : $https_domain); 110 if (SESSION_USE_FQDN == 'False') $current_domain = '.' . $current_domain; 111 112 113 // include shopping cart class 114 require(DIR_WS_CLASSES . 'shopping_cart.php'); 115 116 117 // include navigation history class 118 require(DIR_WS_CLASSES . 'navigation_history.php'); 119 120 // define how the session functions will be used 121 require(DIR_WS_FUNCTIONS . 'sessions.php'); 122 123 // set the session name and save path 124 zen_session_name('zenid'); 125 zen_session_save_path(SESSION_WRITE_DIRECTORY); 126 127 // set the session cookie parameters 128 session_set_cookie_params(0, '/', (zen_not_null($current_domain) ? $current_domain : '')); 129 130 // set the session ID if it exists 131 if (isset($_POST[zen_session_name()])) { 132 zen_session_id($_POST[zen_session_name()]); 133 } elseif ( ($request_type == 'SSL') && isset($_GET[zen_session_name()]) ) { 134 zen_session_id($_GET[zen_session_name()]); 135 } 136 137 // start the session 138 $session_started = false; 139 if (SESSION_FORCE_COOKIE_USE == 'True') { 140 zen_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, '/', (zen_not_null($current_domain) ? $current_domain : '')); 141 142 if (isset($_COOKIE['cookie_test'])) { 143 zen_session_start(); 144 $session_started = true; 145 } 146 } elseif (SESSION_BLOCK_SPIDERS == 'True') { 147 $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); 148 $spider_flag = false; 149 150 if (zen_not_null($user_agent)) { 151 $spiders = file(DIR_WS_INCLUDES . 'spiders.txt'); 152 153 for ($i=0, $n=sizeof($spiders); $i<$n; $i++) { 154 if (zen_not_null($spiders[$i])) { 155 if (is_integer(strpos($user_agent, trim($spiders[$i])))) { 156 $spider_flag = true; 157 break; 158 } 159 } 160 } 161 } 162 163 if ($spider_flag == false) { 164 zen_session_start(); 165 $session_started = true; 166 } 167 } else { 168 zen_session_start(); 169 $session_started = true; 170 } 171 172 /** 173 * Begin processing. Add notice to log if logging enabled. 174 */ 175 ipn_debug_email('IPN PROCESSING INITIATED. ' . "\n" . '*** Originating IP: ' . $_SERVER['REMOTE_ADDR'] . ' ' . (SESSION_IP_TO_HOST_ADDRESS == 'true' ? @gethostbyaddr($_SERVER['REMOTE_ADDR']) : '') . ($_SERVER['HTTP_USER_AGENT'] == '' ? '' : "\n" . '*** Browser/User Agent: ' . $_SERVER['HTTP_USER_AGENT'])); 176 177 // need to see if we are in test mode. If so then the data is going to come in as a GET string 178 if (MODULE_PAYMENT_PAYPAL_TESTING == 'Test') { 179 foreach ($_GET as $key=>$value) { 180 $_POST[$key] = $value; 181 } 182 } 183 if (!$_POST) { 184 ipn_debug_email('IPN FATAL ERROR :: No POST data available -- Most likely initiated by browser and not PayPal.' . "\n\n\n" . ' *** The rest of this log report can most likely be ignored !! ***' . "\n\n\n\n"); 185 } 186 187 188 $session_post = isset($_POST['custom']) ? $_POST['custom'] : '='; 189 $session_stuff = explode('=', $session_post); 190 $ipnFoundSession = true; 191 if (!$isECtransaction && !isset($_POST['parent_txn_id']) && ipn_get_stored_session($session_stuff) === false) { 192 ipn_debug_email('IPN FATAL ERROR :: No saved session data available to build order from IPN. Cannot process this as an IPN-only transaction.'); 193 $ipnFoundSession = false; 194 } 195 // create the shopping cart & fix the cart if necesary 196 if (!$_SESSION['cart']) { 197 $_SESSION['cart'] = new shoppingCart; 198 } 199 200 201 // include currencies class and create an instance 202 require (DIR_WS_CLASSES . 'currencies.php'); 203 $currencies = new currencies(); 204 205 206 // set the language 207 if (!$_SESSION['language'] || isset($_GET['language'])) { 208 209 require(DIR_WS_CLASSES . 'language.php'); 210 211 $lng = new language(); 212 213 if (isset($_GET['language']) && zen_not_null($_GET['language'])) { 214 $lng->set_language($_GET['language']); 215 } else { 216 $lng->get_browser_language(); 217 $lng->set_language(DEFAULT_LANGUAGE); 218 } 219 220 $_SESSION['language'] = $lng->language['directory']; 221 $_SESSION['languages_id'] = $lng->language['id']; 222 223 } 224 225 // Set theme related directories 226 $sql = "select template_dir 227 from " . TABLE_TEMPLATE_SELECT . 228 " where template_language = '0'"; 229 230 $template_query = $db->Execute($sql); 231 232 $template_dir = $template_query->fields['template_dir']; 233 234 $sql = "select template_dir 235 from " . TABLE_TEMPLATE_SELECT . 236 " where template_language = '" . $_SESSION['languages_id'] . "'"; 237 238 $template_query = $db->Execute($sql); 239 240 if ($template_query->RecordCount() > 0) { 241 $template_dir = $template_query->fields['template_dir']; 242 } 243 //if (template_switcher_available=="YES") $template_dir = templateswitch_custom($current_domain); 244 define('DIR_WS_TEMPLATE', DIR_WS_TEMPLATES . $template_dir . '/'); 245 246 define('DIR_WS_TEMPLATE_IMAGES', DIR_WS_TEMPLATE . 'images/'); 247 define('DIR_WS_TEMPLATE_ICONS', DIR_WS_TEMPLATE_IMAGES . 'icons/'); 248 249 require(DIR_WS_CLASSES . 'template_func.php'); 250 $template = new template_func(DIR_WS_TEMPLATE); 251 252 // include the language translations 253 // include template specific language files 254 if (file_exists(DIR_WS_LANGUAGES . $template_dir . '/' . $_SESSION['language'] . '.php')) { 255 $template_dir_select = $template_dir . '/'; 256 //die('Yes ' . DIR_WS_LANGUAGES . $template_dir . '/' . $_SESSION['language'] . '.php'); 257 } else { 258 //die('NO ' . DIR_WS_LANGUAGES . $template_dir . '/' . $_SESSION['language'] . '.php'); 259 $template_dir_select = ''; 260 } 261 262 263 include(DIR_WS_LANGUAGES . $template_dir_select . $_SESSION['language'] . '.php'); 264 ipn_debug_email('IPN NOTICE :: ipn_application_top -> language files okay'); 265 266 // include the extra language translations 267 include(DIR_WS_MODULES . 'extra_definitions.php'); 268 269 // currency 270 if (!$_SESSION['currency'] || isset($_GET['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $_SESSION['currency']) ) ) { 271 if (isset($_GET['currency'])) { 272 if (!$_SESSION['currency'] = zen_currency_exists($_GET['currency'])) $_SESSION['currency'] = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; 273 } else { 274 $_SESSION['currency'] = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; 275 } 276 } 277 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |