/** * 提供给控制器的 接口 函数。每个版本类必须有该函数。 */ function update_files() { $result = file_mode_info(ROOT_PATH . 'data/'); if ($result < 2) { die('ERROR, ' . ROOT_PATH . 'data/ isn\'t a writeable directory.'); } if (!file_exists(ROOT_PATH . 'data/config.php')) { if (file_exists(ROOT_PATH . 'includes/config.php')) { copy(ROOT_PATH . 'includes/config.php', ROOT_PATH . 'data/config.php'); //unlink(ROOT_PATH . 'includes/config.php'); } else { die("ERROR, can't find config.php."); } } if (!file_exists(ROOT_PATH . 'data/install.lock')) { if (file_exists(ROOT_PATH . 'includes/install.lock')) { copy(ROOT_PATH . 'includes/install.lock', ROOT_PATH . 'data/install.lock'); //unlink(ROOT_PATH . 'includes/install.lock'); } else { die("ERROR, can't find install.lock."); } } }
/* 供货商名 */ $suppliers_list_name = suppliers_list_name(); $suppliers_exists = 1; if (empty($suppliers_list_name)) { $suppliers_exists = 0; } $smarty->assign('suppliers_exists', $suppliers_exists); $smarty->assign('suppliers_list_name', $suppliers_list_name); unset($suppliers_list_name, $suppliers_exists); /* 如果是安全模式,检查目录是否存在 */ if (ini_get('safe_mode') == 1 && (!file_exists('../' . IMAGE_DIR . '/' . date('Ym')) || !is_dir('../' . IMAGE_DIR . '/' . date('Ym')))) { if (@(!mkdir('../' . IMAGE_DIR . '/' . date('Ym'), 0777))) { $warning = sprintf($_LANG['safe_mode_warning'], '../' . IMAGE_DIR . '/' . date('Ym')); $smarty->assign('warning', $warning); } } elseif (file_exists('../' . IMAGE_DIR . '/' . date('Ym')) && file_mode_info('../' . IMAGE_DIR . '/' . date('Ym')) < 2) { $warning = sprintf($_LANG['not_writable_warning'], '../' . IMAGE_DIR . '/' . date('Ym')); $smarty->assign('warning', $warning); } /* 取得商品信息 */ if ($is_add) { /* 默认值 */ $last_choose = array(0, 0); if (!empty($_COOKIE['ECSCP']['last_choose'])) { $last_choose = explode('|', $_COOKIE['ECSCP']['last_choose']); } $goods = array('goods_id' => 0, 'goods_desc' => '', 'goods_shipai' => '', 'cat_id' => $last_choose[0], 'brand_id' => $last_choose[1], 'is_on_sale' => '1', 'is_alone_sale' => '1', 'is_shipping' => '0', 'other_cat' => array(), 'goods_type' => 0, 'shop_price' => 0, 'promote_price' => 0, 'market_price' => 0, 'integral' => 0, 'goods_number' => $_CFG['default_storage'], 'warn_number' => 1, 'promote_start_date' => local_date('Y-m-d'), 'promote_end_date' => local_date('Y-m-d', local_strtotime('+1 month')), 'goods_weight' => 0, 'give_integral' => -1, 'rank_integral' => -1); /* 设置商品的默认库存数量 add by zenghd for date 2014-08-28 */ $agency_user_id = check_url(); if ($agency_user_id) { //如果是代理商,商品的默认库存数量为0,主站默认为0
/** * 载入库项目内容 * * @access public * @param string $curr_template 模版名称 * @param string $lib_name 库项目名称 * @return array */ function load_library($curr_template, $lib_name) { $lib_name = str_replace("0xa", '', $lib_name); // 过滤 0xa 非法字符 $lib_file = '../themes/' . $curr_template . '/library/' . $lib_name . '.lbi'; $arr['mark'] = file_mode_info($lib_file); $arr['html'] = str_replace("", '', file_get_contents($lib_file)); return $arr; }
/** * 检查数组中目录权限 * * @access public * @param array $arr 要检查的文件列表数组 * @param array $err_msg 错误信息回馈数组 * * @return int $mark 文件权限掩码 */ function check_file_in_array($arr, &$err_msg) { $read = true; $writen = true; $modify = true; foreach ($arr as $val) { $mark = file_mode_info(ROOT_PATH . $val); if (($mark & 1) < 1) { $read = false; $err_msg['r'][] = $val; } if (($mark & 2) < 1) { $writen = false; $err_msg['w'][] = $val; } if (($mark & 4) < 1) { $modify = false; $err_msg['m'][] = $val; } } $mark = 0; if ($read) { $mark ^= 1; } if ($writen) { $mark ^= 2; } if ($modify) { $mark ^= 4; } return $mark; }
$info = cls_sql_dump::get_head($path . $file); $list[] = array('name' => $file, 'ver' => $info['ecs_ver'], 'add_time' => $info['date'], 'vol' => $info['vol'], 'file_size' => num_bitunit($file_size), 'mark' => $mark); } } assign_query_info(); $smarty->assign('action_link', array('text' => $_LANG['02_db_manage'], 'href' => 'database.php?act=backup')); $smarty->assign('ur_here', $_LANG['restore']); $smarty->assign('list', $list); $smarty->display('db_restore.htm'); } if ($_REQUEST['act'] == 'dumpsql') { /* 权限判断 */ admin_priv('db_backup'); /* 检查目录权限 */ $path = ROOT_PATH . DATA_DIR . '/sqldata'; $mask = file_mode_info($path); if ($mask === false) { $warning = sprintf($_LANG['dir_not_exist'], $path); sys_msg($warning, 1); } elseif ($mask != 15) { $warning = sprintf($_LANG['dir_priv'], $path); if (($mask & 1) < 1) { $warning .= $_LANG['cannot_read']; } if (($mask & 2) < 1) { $warning .= $_LANG['cannot_write']; } if (($mask & 4) < 1) { $warning .= $_LANG['cannot_add']; } if (($mask & 8) < 1) {
/** * 妫€鏌ョ壒瀹氱洰褰曟槸鍚︽湁鎵ц?rename鍑芥暟鏉冮檺 * * @access public * @param void * * @return void */ function check_rename_priv() { /* 鑾峰彇瑕佹?鏌ョ殑鐩?綍 */ $dir_list = array(); $dir_list[] = 'templates/caches'; $dir_list[] = 'templates/compiled'; $dir_list[] = 'templates/compiled/admin'; /* 鑾峰彇images鐩?綍涓嬪浘鐗囩洰褰 */ $folder = opendir(ROOT_PATH . 'images'); while ($dir = readdir($folder)) { if (is_dir(ROOT_PATH . 'images/' . $dir) && preg_match('/^[0-9]{6}$/', $dir)) { $dir_list[] = 'images/' . $dir; } } closedir($folder); /* 妫€鏌ョ洰褰曟槸鍚︽湁鎵ц?rename鍑芥暟鐨勬潈闄 */ $msgs = array(); foreach ($dir_list as $dir) { $mask = file_mode_info(ROOT_PATH . $dir); if (($mask & 2) > 0 && ($mask & 8) < 1) { /* 鍙?湁鍙?啓鏃舵墠妫€鏌?ename鏉冮檺 */ $msgs[] = $dir . ' ' . $GLOBALS['_LANG']['cannt_modify']; } } return $msgs; }
/** * 检查某个目录的文件是否可读(不包括子目录) * 前提:$dirname 是目录且存在且可读 * * @param string $dirname 目录名:以 / 结尾,以 / 分隔 * @return mix 如果所有文件可读,返回true;否则,返回第一个不可读的文件名 */ function check_files_readable($dirname) { /* 遍历文件,检查文件是否可读 */ if ($dh = opendir($dirname)) { while (($file = readdir($dh)) !== false) { if (filetype($dirname . $file) == 'file' && strtolower($file) != 'thumbs.db') { if (file_mode_info($dirname . $file) & 1 != 1) { return $dirname . $file; } } } closedir($dh); } /* 全部可读的返回值 */ return true; }
} } $result = file_mode_info(saestor('images')); if ($result < 2) { // $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['images_cannt_write']); } else { $result = file_mode_info(saestor(IMAGE_DIR . '/upload')); if ($result < 2) { // $warning[] = sprintf($_LANG['not_writable'], IMAGE_DIR . '/upload', $_LANG['imagesupload_cannt_write']); } } $result = file_mode_info(saestor('temp')); if ($result < 2) { // $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['tpl_cannt_write']); } $result = file_mode_info(saestor('/temp/backup')); if ($result < 2) { // $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['tpl_backup_cannt_write']); } if (!is_writeable(DATA_DIR . '/order_print.html')) { // $warning[] = $_LANG['order_print_canntwrite']; } clearstatcache(); $smarty->assign('warning_arr', $warning); /* 管理员留言信息 */ $sql = 'SELECT message_id, sender_id, receiver_id, sent_time, readed, deleted, title, message, user_name ' . 'FROM ' . $ecs->table('admin_message') . ' AS a, ' . $ecs->table('admin_user') . ' AS b ' . "WHERE a.sender_id = b.user_id AND a.receiver_id = '{$_SESSION['admin_id']}' AND " . "a.readed = 0 AND deleted = 0 ORDER BY a.sent_time DESC"; $admin_msg = $db->GetAll($sql); $smarty->assign('admin_msg', $admin_msg); /* 取得支持货到付款和不支持货到付款的支付方式 */ $ids = get_pay_ids(); /* 已完成的订单 */
/** * 设置语言项 * @access public * @param string $file_path 存放语言项列表的文件的绝对路径 * @param array $src_items 替换前的语言项 * @param array $dst_items 替换后的语言项 * @return void 成功就把结果写入文件,失败返回false */ function set_language_items($file_path, $src_items, $dst_items) { /* 检查文件是否可写(修改) */ if (file_mode_info($file_path) < 2) { return false; } /* 获取文件内容 */ $line_array = file($file_path); if (!$line_array) { return false; } else { $file_content = implode('', $line_array); } $snum = count($src_items); $dnum = count($dst_items); if ($snum != $dnum) { return false; } /* 对索引进行排序,防止错位替换 */ ksort($src_items); ksort($dst_items); for ($i = 0; $i < $snum; $i++) { $file_content = str_replace($src_items[$i], $dst_items[$i], $file_content); } /* 写入修改后的语言项 */ $f = fopen($file_path, 'wb'); if (!$f) { return false; } if (!fwrite($f, $file_content)) { return false; } else { return true; } }
function update_files() { $config_path = ROOT_PATH . 'data/config.php'; @chmod($config_path, 0777); if (file_mode_info($config_path) < 7) { die('Config file isn\'t writable!'); } else { $ori_content = implode('', file($config_path)); $fp = @fopen($config_path, 'wb+'); if (!$fp) { die('Open config file failed!'); } $timezone = $this->get_local_timezone(); $content = "\n\n\$timezone = \"{$timezone}\";\n\n"; $content .= "\$cookie_path = \"/\";\n\n"; $content .= "\$cookie_domain = \"\";\n\n"; $content .= "\$admin_dir = \"admin\";\n\n"; $content .= "\$session = \"1440\";\n"; $new_content = preg_replace('/(\\$prefix\\s*=[^;]+;).*(\\?\\>)/is', '\\1' . $content . "\r\n\r\n\\2", $ori_content); if (!@fwrite($fp, $new_content)) { die('Write config file failed!'); } @fclose($fp); } return $this->handle_plugins(); }
/* 如果 open_basedir 不为空,则检查是否包含了 upload_tmp_dir */ $open_basedir = str_replace(array("\\", "\\\\"), array("/", "/"), $open_basedir); $upload_tmp_dir = ini_get('upload_tmp_dir'); if (empty($upload_tmp_dir)) { if (stristr(PHP_OS, 'win')) { $upload_tmp_dir = getenv('TEMP') ? getenv('TEMP') : getenv('TMP'); $upload_tmp_dir = str_replace(array("\\", "\\\\"), array("/", "/"), $upload_tmp_dir); } else { $upload_tmp_dir = getenv('TMPDIR') === false ? '/tmp' : getenv('TMPDIR'); } } if (!stristr($open_basedir, $upload_tmp_dir)) { $warning[] = sprintf($_LANG['temp_dir_cannt_read'], $upload_tmp_dir); } } $result = file_mode_info('../' . DATA_DIR); if ($result < 2) { $warning[] = sprintf($_LANG['not_writable'], 'data', $_LANG['data_cannt_write']); } clearstatcache(); $smarty->assign('warning_arr', $warning); /* 管理员留言信息 */ $sql = 'SELECT message_id, sender_id, receiver_id, sent_time, readed, deleted, title, message, user_name ' . 'FROM ' . $ecs->table('admin_message') . ' AS a, ' . $ecs->table('admin_user') . ' AS b ' . "WHERE a.sender_id = b.user_id AND a.receiver_id = '{$_SESSION['admin_id']}' AND " . "a.readed = 0 AND deleted = 0 ORDER BY a.sent_time DESC"; $admin_msg = $db->GetAll($sql); $smarty->assign('admin_msg', $admin_msg); /* 取得支持货到付款和不支持货到付款的支付方式 */ $ids = get_pay_ids(); /* 已完成的订单 */ $order['finished'] = $db->GetOne('SELECT COUNT(*) FROM ' . $ecs->table('order_info') . " WHERE 1 " . order_query_sql('finished')); $status['finished'] = CS_FINISHED; /* 待发货的订单: */
},200); } function test_dir(){ setTimeout(function(){ html=''; <?php $dir = array('data', 'inc', 'upload'); foreach ($dir as $value) { ?> html+='<div class="list">'; html+='<div class="name"><?php echo $value; ?> </div>'; <?php if (file_mode_info('../' . $value . '/') > 11) { ?> html+='<div class="value"><font color=green><b>√</b></font></div>'; <?php } else { ?> html+='<div class="value"><font color=red><b>x</b></font></div>'; <?php } ?> html+='</div>'; <?php } ?> $('#dir').html(html);
/** * ÔØÈë¿âÏîÄ¿ÄÚÈÝ. * * @param string $curr_template Ä£°æÃû³Æ * @param string $lib_name ¿âÏîÄ¿Ãû³Æ * * @return array */ function load_library($curr_template, $lib_name) { $lib_name = str_replace('0xa', '', $lib_name); // ¹ýÂË 0xa ·Ç·¨×Ö·û $lib_file = '../themes/' . $curr_template . '/library/' . $lib_name . '.lbi'; $arr['mark'] = file_mode_info($lib_file); $arr['html'] = str_replace("", '', file_get_contents($lib_file)); return $arr; }
/** * 检查特定目录是否有执行rename函数权限 * * @access public * @param void * * @return void */ function check_rename_priv() { /* 获取要检查的目录 */ $dir_list = array(); $dir_list[] = 'temp/caches'; $dir_list[] = 'temp/compiled'; $dir_list[] = 'temp/compiled/admin'; /* 获取images目录下图片目录 */ $folder = opendir(ROOT_PATH . 'images'); while ($dir = readdir($folder)) { if (is_dir(ROOT_PATH . 'images/' . $dir) && preg_match('/^[0-9]{6}$/', $dir)) { $dir_list[] = 'images/' . $dir; } } closedir($folder); /* 检查目录是否有执行rename函数的权限 */ $msgs = array(); foreach ($dir_list as $dir) { $mask = file_mode_info(ROOT_PATH . $dir); if (($mask & 2) > 0 && ($mask & 8) < 1) { /* 只有可写时才检查rename权限 */ $msgs[] = $dir . ' ' . $GLOBALS['_LANG']['cannt_modify']; } } return $msgs; }
} $allow_set_points = $_CFG['integrate_code'] == 'ecshop' ? 0 : 1; $smarty->assign('allow_set_points', $allow_set_points); $smarty->assign('ur_here', $_LANG['06_list_integrate']); $smarty->assign('modules', $modules); assign_query_info(); $smarty->display('integrates_list.htm'); } /*------------------------------------------------------ */ //-- 安装会员数据整合插件 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'install') { admin_priv('integrate_users', ''); /* 增加ucenter设置时先检测uc_client与uc_client/data是否可写 */ if ($_GET['code'] == 'ucenter') { $uc_client_dir = file_mode_info(ROOT_PATH . 'uc_client/data'); if ($uc_client_dir === false) { sys_msg($_LANG['uc_client_not_exists'], 0); } if ($uc_client_dir < 7) { sys_msg($_LANG['uc_client_not_write'], 0); } } if ($_GET['code'] == 'ecshop') { $sql = "UPDATE " . $ecs->table('touch_shop_config') . " SET value = 'ecshop' WHERE code = 'integrate_code'"; $db->query($sql); $sql = "UPDATE " . $GLOBALS['ecs']->table('touch_shop_config') . " SET value = '' WHERE code = 'points_rule'"; $GLOBALS['db']->query($sql); /* 清除shopconfig表的sql的缓存 */ clear_cache_files(); $links[0]['text'] = $_LANG['go_back'];
} } $result = file_mode_info('../images'); if ($result < 2) { $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['images_cannt_write']); } else { $result = file_mode_info('../' . IMAGE_DIR . '/upload'); if ($result < 2) { $warning[] = sprintf($_LANG['not_writable'], IMAGE_DIR . '/upload', $_LANG['imagesupload_cannt_write']); } } $result = file_mode_info('../temp'); if ($result < 2) { $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['tpl_cannt_write']); } $result = file_mode_info('../temp/backup'); if ($result < 2) { $warning[] = sprintf($_LANG['not_writable'], 'images', $_LANG['tpl_backup_cannt_write']); } if (!is_writeable('../' . DATA_DIR . '/order_print.html')) { $warning[] = $_LANG['order_print_canntwrite']; } clearstatcache(); $smarty->assign('warning_arr', $warning); /* 管理员留言信息 */ $sql = 'SELECT message_id, sender_id, receiver_id, sent_time, readed, deleted, title, message, user_name ' . 'FROM ' . $ecs->table('admin_message') . ' AS a, ' . $ecs->table('admin_user') . ' AS b ' . "WHERE a.sender_id = b.user_id AND a.receiver_id = '{$_SESSION['admin_id']}' AND " . "a.readed = 0 AND deleted = 0 ORDER BY a.sent_time DESC"; $admin_msg = $db->GetAll($sql); $smarty->assign('admin_msg', $admin_msg); /* 取得支持货到付款和不支持货到付款的支付方式 */ $ids = get_pay_ids(); /* 已完成的订单 */
//是否复制 $code = empty($_REQUEST['extension_code']) ? '' : trim($_REQUEST['extension_code']); if ($code == 'virual_card') { admin_priv('virualcard'); // 检查权限 } else { admin_priv('goods_manage'); // 检查权限 } /* 如果是安全模式,检查目录是否存在 */ if (ini_get('safe_mode') == 1 && (!file_exists('../images/' . date('Ym')) || !is_dir('../images/' . date('Ym')))) { if (@(!mkdir('../images/' . date('Ym'), 0777))) { $warning = sprintf($_LANG['safe_mode_warning'], '../images/' . date('Ym')); $smarty->assign('warning', $warning); } } elseif (file_exists('../images/' . date('Ym')) && file_mode_info('../images/' . date('Ym')) < 2) { $warning = sprintf($_LANG['not_writable_warning'], '../images/' . date('Ym')); $smarty->assign('warning', $warning); } /* 取得商品信息 */ if ($is_add) { /* 默认值 */ $goods = array('goods_id' => 0, 'goods_desc' => '', 'cat_id' => 0, 'is_on_sale' => '1', 'is_alone_sale' => '1', 'other_cat' => array(), 'goods_type' => 0, 'shop_price' => 0, 'promote_price' => 0, 'market_price' => 0, 'integral' => 0, 'goods_number' => $_CFG['default_storage'], 'warn_number' => 1, 'promote_start_date' => local_date('Y-m-d'), 'promote_end_date' => local_date('Y-m-d', local_strtotime('+1 month')), 'goods_weight' => 0, 'give_integral' => -1); if ($code != '') { $goods['goods_number'] = 0; } /* 关联商品 */ $link_goods_list = array(); $sql = "DELETE FROM " . $ecs->table('link_goods') . " WHERE (goods_id = 0 OR link_goods_id = 0)" . " AND admin_id = '{$_SESSION['admin_id']}'"; $db->query($sql); /* 组合商品 */