Uploadinstallincludesauto_init.php source code analysis

Source: Internet
Author: User
Uploadinstallincludesauto_init.php source code analysis
1
 Caching = true; 23} 24 $ ua = strtolower ($ _ SERVER ['http _ USER_AGENT ']); 25 26 $ uachar = "/(nokia | sony | ericsson | mot | samsung | sgh | lg | philips | panasonic | alcatel | lenovo | cldc | midp | mobile)/I "; 27 28 if ($ ua = ''| preg_match ($ uachar, $ ua ))&&! Strpos (strtolower ($ _ SERVER ['request _ URI ']), 'wap') 29 {30 $ Loaction = 'mobile/'; 31 32 if (! Empty ($ Loaction) 33 {34 ecs_header ("Location: $ Loaction \ n"); 35 36 exit; 37} 38 39} 40/* ---------------------------------------------------- */41 // -- Shopex system address conversion 42/* blank */43 if (! Empty ($ _ GET ['goo']) 44 {45 if (! Empty ($ _ GET ['gcat']) 46 {47/* item category. */48 $ Loaction = 'Category. php? Id = '. $ _ GET ['gcat']; 49} 50 elseif (! Empty ($ _ GET ['acat']) 51 {52/* document category. */53 $ Loaction = 'article _ cat. php? Id = '. $ _ GET ['acat']; 54} 55 elseif (! Empty ($ _ GET ['goodsid ']) 56 {57/* product details. */58 $ Loaction = 'goods. php? Id = '. $ _ GET ['goodsid']; 59} 60 elseif (! Empty ($ _ GET ['articleid']) 61 {62/* article details. */63 $ Loaction = 'article. php? Id = '. $ _ GET ['articleid']; 64} 65 66 if (! Empty ($ Loaction) 67 {68 ecs_header ("Location: $ Loaction \ n"); 69 70 exit; 71} 72} 73 74 // determine whether an ajax request exists 75 $ act =! Empty ($ _ GET ['AC'])? $ _ GET ['AC']: ''; 76 if ($ act = 'cat _ rec ') 77 {78 $ rec_array = array (1 => 'best ', 2 => 'new', 3 => 'Hot '); 79 $ rec_type =! Empty ($ _ REQUEST ['rec _ type'])? Intval ($ _ REQUEST ['rec _ type']): '1'; 80 $ cat_id =! Empty ($ _ REQUEST ['CID'])? Intval ($ _ REQUEST ['CID']): '0'; 81 include_once ('includes/cls_json.php '); 82 $ json = new JSON; 83 $ result = array ('error' => 0, 'content' => '', 'type' => $ rec_type, 'Cat _ id' => $ cat_id ); 84 85 $ children = get_children ($ cat_id); 86 $ smarty-> assign ($ rec_array [$ rec_type]. '_ goods', get_category_recommend_goods ($ rec_array [$ rec_type], $ children); // recommended products 87 $ smarty-> assign ('cat _ rec_sign ', 1 ); 88 $ re Sult ['content'] = $ smarty-> fetch ('Library/recommend _'. $ rec_array [$ rec_type]. '. lbi '); 89 die ($ json-> encode ($ result); 90} 91 92/* -------------------------------------------------- */93 // -- determines whether a cache exists, if yes, call the cache. otherwise, read 94/* ---------------------------------------------------- */95/* cache number */96 $ cache_id = sprintf ('% X ', crc32 ($ _ SESSION ['User _ rank ']. '-'. $ _ CFG ['Lang ']); 97 98 if (! $ Smarty-> is_cached ('index. dwt ', $ cache_id) 99 {100 assign_template (); 101 102 $ position = assign_ur_here (); 103 $ smarty-> assign ('page _ title ', $ position ['title']); // page title 104 $ smarty-> assign ('Ur _ here ', $ position ['Ur _ here']); // Current location 105 106/* meta information */107 $ smarty-> assign ('keyword', htmlspecialchars ($ _ CFG ['shop _ keyword']); 108 $ smarty-> assign ('Description', htmlspecialchars ($ _ CFG ['shop _ des C ']); 109 $ smarty-> assign ('flash _ theme', $ _ CFG ['flash _ theme ']); // Flash carousel image template 110 111 $ smarty-> assign ('feed _ url', ($ _ CFG ['rewrite'] = 1 )? 'Feed. xml ': 'Feed. php '); // RSS URL112 113 $ smarty-> assign ('category', get_categories_tree (); // category tree 114 $ smarty-> assign ('helps ', get_shop_help (); // online shop help 115 $ smarty-> assign ('top _ goods ', get_top10 ()); // sales ranking: 116 $ smarty-> assign ('best _ goods ', get_recommend_goods ('best ')); // Recommended Product 118 $ smarty-> assign ('New _ goods ', get_recommend_goods ('New ')); // latest product 119 $ smarty-> assign ('hot _ goods ', get_recomme Nd_goods ('Hot '); // hot Article 120 $ smarty-> assign ('promotion _ goods', get_promote_goods ()); // special offer 121 $ smarty-> assign ('brand _ list', get_brands (); 122 $ smarty-> assign ('promotion _ info', get_promotion_info ()); // add a label bar 123 124 $ smarty-> assign ('Invoice _ list', index_get_invoice_query () that dynamically displays all promotion information ()); // shipping query 125 $ smarty-> assign ('New _ articles ', index_get_new_articles (); // The latest article 126 $ smarty-> assign ('group _ buy_g Oods ', index_get_group_buy (); // group buying product 127 $ smarty-> assign ('Auction _ list', index_get_auction ()); // auction activity 128 $ smarty-> assign ('shop _ notice ', $ _ CFG ['shop _ notice']); // Store announcement 129 130/* homepage main ad settings */131 $ smarty-> assign ('index _ ad', $ _ CFG ['index _ ad']); 132 if ($ _ CFG ['index _ ad'] = 'cu') 133 {134 $ SQL = 'SELECT ad_type, content, url FROM '. $ ecs-> table ("ad_custom "). 'Where ad_status = 1'; 135 $ ad = $ db-> getRo W ($ SQL, true); 136 $ smarty-> assign ('AD', $ ad); 137} 138 139/* links */140 $ links = index_get_links (); 141 $ smarty-> assign ('IMG _ links ', $ links ['IMG']); 142 $ smarty-> assign ('txt _ links ', $ links ['txt ']); 143 $ smarty-> assign ('data _ dir', DATA_DIR ); // data directory 144 145/* homepage recommendation category */146 $ cat_recommend_res = $ db-> getAll ("SELECT c. cat_id, c. cat_name, cr. recommend_type FROM ". $ ecs-> table ("cat_recommend "). "AS cr I Nner join ". $ ecs-> table (" category ")." AS c ON cr. cat_id = c. cat_id "); 147 if (! Empty ($ cat_recommend_res) 148 {149 $ cat_rec_array = array (); 150 foreach ($ cat_recommend_res as $ cat_recommend_data) 151 {152 $ cat_rec [$ cat_recommend_data ['recommend _ type'] [] = array ('cat _ id' => $ cat_recommend_data ['cat _ id'], 'cat _ name' => $ cat_recommend_data ['cat _ name']); 153} 154 $ smarty-> assign ('cat _ rec ', $ cat_rec ); 155} 156 157/* dynamic content on the page */158 assign_dynamic ('index'); 159} 160 161 $ smarty-> display ('Index. dwt ', $ cache_id ); 162 163/* latest */164 // -- PRIVATE FUNCTIONS165/* latest */166 167/** 168 * call the invoice query 169*170 * @ access private171 * @ return array172 * /173 function index_get_invoice_query () 174 {175 $ SQL = 'SELECT o. order_sn, o. invoice_no, s. shipping_code FROM '. $ GLOBALS ['ecs']-> table ('Order _ I Nfo '). 'As O '. 176 'left join '. $ GLOBALS ['ecs']-> table ('shipping '). AS s ON s. shipping_id = o. shipping_id '. 177 "WHERE invoice_no>'' AND shipping_status = ". SS_SHIPPED. 178 'Order BY shipping_time desc limit 10'; 179 $ all = $ GLOBALS ['DB']-> getAll ($ SQL ); 180 181 foreach ($ all AS $ key => $ row) 182 {183 $ plugin = ROOT_PATH. 'Des/modules/shipping /'. $ row ['shipping _ Code']. '. php'; 184 185 if (file_exists ($ plugin) 186 {187 export de_once ($ plugin); 188 189 $ shipping = new $ row ['shipping _ Code']; 190 $ all [$ key] ['Invoice _ no'] = $ shipping-> query (string) $ row ['Invoice _ no']); 191} 192} 193 194 clearstatcache (); 195 196 return $ all; 197} 198 199/** 200 * Get the latest article list. 201*202 * @ access private203 * @ return array204 */205 function index_get_new_articles () 206 {207 $ SQL = 'SELECT. article_id,. title, ac. cat_name,. add_time,. file_url,. open_type, ac. cat_id, ac. cat_name '. 208 'from '. $ GLOBALS ['ecs']-> table ('article '). AS ,'. 209 $ GLOBALS ['ecs']-> table ('article _ cat '). 'As AC '. 210 'Where. is_open = 1 AND. cat_id = ac. cat_id AND ac. cat_type = 1 '. 2 11 'Order BY. article_type DESC,. add_time desc limit '. $ GLOBALS ['_ CFG'] ['article _ number']; 212 $ res = $ GLOBALS ['DB']-> getAll ($ SQL ); 213 214 $ arr = array (); 215 foreach ($ res AS $ idx => $ row) 216 {217 $ arr [$ idx] ['id'] = $ row ['article _ id']; 218 $ arr [$ idx] ['title'] = $ row ['title']; 219 $ arr [$ idx] ['short _ title'] = $ GLOBALS ['_ CFG'] ['article _ title_length ']> 0? 220 sub_str ($ row ['title'], $ GLOBALS ['_ CFG'] ['article _ title_length ']): $ row ['title']; 221 $ arr [$ idx] ['cat _ name'] = $ row ['cat _ name']; 222 $ arr [$ idx] ['add _ time'] = local_date ($ GLOBALS ['_ CFG'] ['date _ format'], $ row ['add _ time']); 223 $ arr [$ idx] ['URL'] = $ row ['open _ type']! = 1? 224 build_uri ('article', array ('aid '=> $ row ['article _ id']), $ row ['title']): trim ($ row ['File _ url']); 225 $ arr [$ idx] ['cat _ url'] = build_uri ('article _ cat ', array ('acid '=> $ row ['cat _ id']), $ row ['cat _ name']); 226} 227 return $ arr; 229} 230 231/** 232 * Get the latest group buying activity 233*234 * @ access private235 * @ return array236 */237 function index_get_group_buy () 238 {239 $ time = gmtime (); 240 $ limit = get_library_numb Er ('group _ buy', 'index'); 241 242 $ group_buy_list = array (); 243 if ($ limit> 0) 244 {245 $ SQL = 'SELECT gb. act_id AS group_buy_id, gb. goods_id, gb. ext_info, gb. goods_name, g. goods_thumb, g. goods_img '. 246 'from '. $ GLOBALS ['ecs']-> table ('goods _ active '). 'As gb ,'. 247 $ GLOBALS ['ecs']-> table ('Goods '). 'As G '. 248 "WHERE gb. act_type = '". GAT_GROUP_BUY. "'". 249 "AND g. goods_id = gb. goods _ Id ". 250 "AND gb. start_time <= '". $ time. "'". 251 "AND gb. end_time> = '". $ time. "'". 252 "AND g. is_delete = 0 ". 253 "order by gb. act_id DESC ". 254 "LIMIT $ limit"; 255 $ res = $ GLOBALS ['DB']-> query ($ SQL ); 256 257 while ($ row = $ GLOBALS ['DB']-> fetchRow ($ res) 258 {259/* If the thumbnail is empty, use the default image */260 $ row ['goods _ img '] = get_image_path ($ row ['goods _ id'], $ row ['goods _ img']); 261 $ row ['thumb'] = get_image _ Path ($ row ['goods _ id'], $ row ['goods _ thumb'], true); 262 263/* based on the price tier, calculate the lowest price */264 $ ext_info = unserialize ($ row ['ext _ info']); 265 $ price_ladder = $ ext_info ['price _ ladder']; 266 if (! Is_array ($ price_ladder) | empty ($ price_ladder) 267 {268 $ row ['last _ price'] = price_format (0 ); 269} 270 else271 {272 foreach ($ price_ladder AS $ amount_price) 273 {274 $ price_ladder [$ amount_price ['amount '] = $ amount_price ['price']; 275} 276} 277 ksort ($ price_ladder); 278 $ row ['last _ price'] = price_format (end ($ price_ladder )); 279 $ row ['URL'] = build_uri ('group _ buy', array ('gbid' => $ row ['group _ buy_id ']); 280 $ row ['short _ name'] = $ GLOBALS ['_ CFG'] ['goods _ name_length ']> 0? 281 sub_str ($ row ['goods _ name'], $ GLOBALS ['_ CFG'] ['goods _ name_length ']): $ row ['goods _ name']; 282 $ row ['short _ style_name '] = add_style ($ row ['short _ name'], ''); 283 $ group_buy_list [] = $ row; 284} 285} 286 287 return $ group_buy_list; 288} 289 290/** 291 * get the auction list 292 * @ return array293 */294 function index_get_auction () 295 {296 $ now = gmtime (); 297 $ limit = get_library_number ('Audio', 'index'); 298 $ SQL = "SELECT. act_id,. goods_id,. goods_name,. ext_info, g. goods_thumb ". 299 "FROM ". $ GLOBALS ['ecs']-> table ('goods _ active '). "AS ,". 300 $ GLOBALS ['ecs']-> table ('Goods '). "AS g ". 301 "WHERE. goods_id = g. goods_id ". 302 "AND. act_type = '". GAT_AUCTION. "'". 303 "AND. is_finished = 0 ". 304 "AND. start_time <= '$ now '". 305 "AND. end_time> = '$ now '". 306 "AND g. is_delete = 0 ". 307 "Order by. start_time DESC ". 308 "LIMIT $ limit"; 309 $ res = $ GLOBALS ['DB']-> query ($ SQL); 310 311 $ list = array (); 312 while ($ row = $ GLOBALS ['DB']-> fetchRow ($ res) 313 {314 $ ext_info = unserialize ($ row ['ext _ info']); 315 $ arr = array_merge ($ row, $ ext_info); 316 $ arr ['formated _ start_price '] = price_format ($ arr ['start _ price']); 317 $ arr ['formated _ end_price '] = price_format ($ arr ['end _ price']); 318 $ arr [' t Humb'] = get_image_path ($ row ['goods _ id'], $ row ['goods _ thumb'], true ); 319 $ arr ['URL'] = build_uri ('Auction ', array ('auid' => $ arr ['act _ id']); 320 $ arr ['short _ name'] = $ GLOBALS ['_ CFG'] ['goods _ name_length ']> 0? 321 sub_str ($ arr ['goods _ name'], $ GLOBALS ['_ CFG'] ['goods _ name_length ']): $ arr ['goods _ name']; 322 $ arr ['short _ style_name '] = add_style ($ arr ['short _ name'], ''); 323 $ list [] = $ arr; 324} 325 326 return $ list; 327} 328 329/** 330 * get all links 331*332 * @ access private333 * @ return array334 */335 function index_get_links () 336 {337 $ SQL = 'SELECT link_logo, link_name, link_url FROM '. $ GLOBALS ['ecs']-> table (' Friend_link '). 'order BY show_order '; 338 $ res = $ GLOBALS ['DB']-> getAll ($ SQL ); 339 340 $ links ['IMG '] = $ links ['txt'] = array (); 341 342 foreach ($ res AS $ row) 343 {344 if (! Empty ($ row ['link _ logo ']) 345 {346 $ links ['IMG '] [] = array ('name' => $ row ['link _ name'], 347 'URL' => $ row ['link _ url'], 348 'logo '=> $ row ['link _ logo']); 349} 350 else351 {352 $ links ['txt '] [] = array ('name' => $ row ['link _ name'], 353 'URL' => $ row ['link _ url']); 354} 355} 356 357 return $ links; 358} 359 360?>

Call structure level

  • \ Upload \ index. php
  • \ Upload \ uplodes \ init. php
  • \ Upload \ install \ index. php
  • \ Upload \ install \ auto_index.php
  • \ Upload \ install \ des \ auto_init.php
  • @ Ini_set ('display _ errors ', 1); // Set the display error

    Error_reporting (E_ALL ^ E_NOTICE); // report all errors and notifications, where notifications are the places where scripts may find errors.

    Clearstatcache (); // clear the cache

    Define ('root _ path', str_replace ('Install/repldes/auto_init.php ', '', str_replace ('\\','/', _ FILE _); // defines the constant 'root _ path' as the website ROOT Directory upload/

    If(Isset($ _ SERVER ['php _ SELF ']) // defines the constant 'php _ SELF', $ _ SERVER ['php _ SELF '] (file NAME of the SCRIPT currently being executed) or $ _ SERVER ['script _ name'] (path of the folder where the SCRIPT is currently executed)

    {

    Define ('php _ SELF ', $ _ SERVER ['php _ SELF']);

    }

    Else

    {

    Define ('php _ SELF ', $ _ SERVER ['script _ name']);

    }

    Define ('EC _ charset', 'utf-8'); // defines the constants 'EC _ charset' and 'EC _ db_charset' as UTF8.

    Define ('EC _ DB_CHARSET ', 'utf8 ');

    Require(ROOT_PATH. 'mongodes/lib_base.php '); // reference the basic function library, public function library, and time function library, so that you can call the function later.

    Require(ROOT_PATH. 'Des/lib_common.php ');

    Require(ROOT_PATH. 'Des/lib_time.php ');

    Require(ROOT_PATH. 'Des/cls_error.php '); // generate an error class object. the template is message. dwt. the dwt file is not imported here, but the class member object $ _ template is assigned a value.

    $ Err =NewEcs_error ('message. dwt ');

    Require(ROOT_PATH. 'Install/includes/cls_template.php '); // Generate a template class object and assign a value to the class member object path $ path.

    $ Smarty =NewTemplate (ROOT_PATH. 'Install/templates /');

    Require(ROOT_PATH. 'Install/uplodes/lib_auto_installer.php '); // call lib_auto_installer.php without actually doing anything. lib_auto_installer.php provides a series of library functions for calling.

    Header ('content-type: text/html; charset = '. EC_CHARSET); // informs the browser of the text type and encoding format. EC_CHARSET is defined before and its value is 'utf-8 '.

    @ Set_time_limit (360); // sets the maximum execution time of the script to 360 seconds. if the time limit is exceeded, the program ends.

    Summary:

    This php initializes the automatic installation program, including generating an error class ecs_error object (execute the constructor to set the value of the public member variable $ _ template to 'message. (execute the constructor to set the $ path value of the public member variable to '/upload/install/templates /'; tells the browser that the text type is text/html, and the encoding format is utf8. sets the maximum script execution time to 360 seconds.

    I have some questions about the last statement @ set_time_limit (360.

    The set_time_limit function works the same way as modifying max_execution_time in php. ini. Here, the maximum execution time of the script is set to 360 seconds. at first, I saw this statement fall into a misunderstanding: due to the index from the top layer. php sends require all the way to this php, and The require statement will be directly replaced by the file contained in it during execution, so the 360 s limit the execution time of which php is used. When I was puzzled, I saw the word "script". then I suddenly thought that this function was not used to limit the execution time of the PHP file, and the PHP file was not a script file, this function is used to limit the execution time of js and other scripts used in ecshop. forgive me for being unliterate and I am so arrogant.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.