【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“fun.cache.php”一文,供大家参考学习
<?php
/*----------------------------------------------------
[dzsw] admin/cache.php
----------------------------------------------------*/
if(!defined('IN_dzsw')) {
exit('Access Denied');
}
function updatecache($cachefile_name = '') {
switch($cachefile_name){
case 'styles':
cache_styles();
break;
case 'index':
cache_index();
break;
case 'usergroup':
cache_usergroup();
break;
case 'admingroup':
cache_admingroup();
break;
case 'settings':
cache_settings();
break;
case 'categories':
cache_categories();
break;
case 'classes':
cache_classes();
break;
case 'news':
cache_news();
break;
case 'links':
cache_links();
break;
case 'email':
cache_email();
break;
case 'area':
cache_area();
break;
case 'shipping':
cache_shipping();
break;
case 'shipping_define':
cache_shipping_define();
break;
case 'payment':
cache_payment();
break;
case 'area':
cache_area();
break;
default:
cache_styles();
cache_usergroup();
cache_admingroup();
cache_settings();
cache_classes();
cache_news();
cache_links();
cache_index();
cache_email();
cache_area();
cache_shipping();
cache_shipping_define();
cache_payment();
break;
}
}
function cache_index() {
global $db, $table_products, $table_specials, $table_source, $table_news, $settings;
$num_a_row = (is_numeric($settings['index_productnumarow']) && $settings['index_productnumarow']>0) ? $settings['index_productnumarow'] : 3;
$query_and = $settings['stock_limitshow'] != true ? "and p.available = '1'" : '';
$total = $num_a_row * ((is_numeric($settings['index_newproductnumofrow']) && $settings['index_newproductnumofrow']>0) ? $settings['index_newproductnumofrow'] : '0');
$index_new_product_array = explode(',',$settings['index_new_productid']);
$index_new_productids = get_strings($index_new_product_array);
if($index_new_productids){
$product_data = $db->get_one("select count(*) as count from $table_products p where p.products_id in ($index_new_productids) and p.status = '1' ".$query_and);
if($product_data['count'] == '0'){
$define_total = "0";
$leave_num = $total;
}elseif($product_data['count'] < $total){
$define_total = $product_data['count'];
$leave_num = $total - $product_data['count'];
}elseif($product_data['count'] >= $total){
$define_total = $product_data['count'];
$leave_num = "0";
}
}
$nproducts = array();
if($define_total){
$query = $db->query("select p.products_id, p.price, p.name, p.s_p, p.image, if(p.s_p>0, sp.s_price, NULL) from $table_products as p left join $table_specials sp on p.products_id = sp.pid where p.products_id in ($index_new_productids) and p.status = '1' ".$query_and." order by p.date_added desc limit $define_total");
while ($new_products = $db->fetch_array($query)) {
$image_data = $db->get_one("select path,name,extension from $table_source where id='".$new_products['image']."' order by id limit 1");
$new_products['imagesrc'] = get_image_src($image_data);
$nproducts[$new_products['products_id']] = $new_products;
}
$index_new_products = array();
if(is_array($index_new_product_array)){
foreach($index_new_product_array as $v){
if(is_array($nproducts[$v])){
$index_new_products[] = $nproducts[$v];
}
}
}
$query_and_new .= " and p.products_id not in ($index_new_productids) ";
}
if($leave_num){
$query = $db->query("select p.products_id, p.price, p.name, p.s_p, p.image, IF(p.s_p>0 , sp.s_price, NULL) from $table_products p left join $table_specials sp on p.products_id = sp.pid where p.status = '1' ".$query_and_new." order by p.date_added desc limit $leave_num");
while ($new_products = $db->fetch_array($query)) {
$image_data = $db->get_one("select path,name,extension from $table_source where id='".$new_products['image']."' order by id limit 1");
$new_products['imagesrc'] = get_image_src($image_data);
$index_new_products[] = $new_products;
}
}
$date_value = "\$INDEX_NEW_CACHE = ".arraydate_more($index_new_products).";\n\n";
$total = $num_a_row * ((is_numeric($settings['index_sproductnumofrow']) && $settings['index_sproductnumofrow']>0) ? $settings['index_sproductnumofrow'] : '0');
$index_s_product_a