public function update() { $conf_res = M("Conf")->where("is_effect = 1 and is_conf = 1")->findAll(); foreach ($conf_res as $k => $v) { conf($v['name'], $_REQUEST[$v['name']]); if ($v['name'] == 'URL_MODEL' && $v['value'] != $_REQUEST[$v['name']]) { clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_compiled/"); clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/data/page_static_cache/"); clear_dir_file(get_real_path() . "public/runtime/data/dynamic_avatar_cache/"); } } //开始写入配置文件 $sys_configs = M("Conf")->findAll(); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; $filename = get_real_path() . "public/sys_config.php"; if (!($handle = fopen($filename, 'w'))) { $this->error(l("OPEN_FILE_ERROR") . $filename); } if (fwrite($handle, $config_str) === FALSE) { $this->error(l("WRITE_FILE_ERROR") . $filename); } fclose($handle); save_log(l("CONF_UPDATED"), 1); //clear_cache(); write_timezone(); $this->success(L("UPDATE_SUCCESS")); }
/** * 前端全运行函数,生成系统前台使用的全局变量 * 1. 定位城市 GLOBALS['city']; * 2. 加载会员 GLOBALS['user_info']; * 3. 生成语言包 * 4. 加载推荐人与来路 * 5. 更新购物车 */ function global_run() { if (app_conf("SHOP_OPEN") == 0) { app_redirect(url("index", "close")); } //输出语言包的js if (!file_exists(get_real_path() . "public/runtime/app/lang.js")) { $str = "var LANG = {"; foreach ($GLOBALS['lang'] as $k => $lang_row) { $str .= "\"" . $k . "\":\"" . str_replace("nbr", "\\n", addslashes($lang_row)) . "\","; } $str = substr($str, 0, -1); $str .= "};"; @file_put_contents(get_real_path() . "public/runtime/app/lang.js", $str); } //会员信息 global $user_info; $user_info = es_session::get('user_info'); //商户信息 global $account_info; require_once APP_ROOT_PATH . "system/libs/biz_user.php"; $account_info = es_session::get('account_info'); if (empty($account_info)) { // $cookie_aname = es_cookie::get("account_name")?es_cookie::get("account_name"):''; // $cookie_apwd = es_cookie::get("account_pwd")?es_cookie::get("account_pwd"):''; // if($cookie_aname!=''&&$cookie_apwd!=''&&!es_session::get("account_info")) // { // $cookie_aname = strim($cookie_aname); // $cookie_apwd = strim($cookie_apwd); // auto_do_login_biz($cookie_aname,$cookie_apwd); // $account_info = es_session::get('account_info'); // } app_redirect(url("biz", "user#login")); } //实时刷新会员数据 if ($account_info) { $account_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_account where is_delete = 0 and is_effect = 1 and id = " . intval($account_info['id'])); if ($account_info['is_main'] == 1) { //主账户取所有门店 $account_locations = $GLOBALS['db']->getAll("select id as location_id from " . DB_PREFIX . "supplier_location where supplier_id = " . $account_info['supplier_id']); } else { $account_locations = $GLOBALS['db']->getAll("select location_id from " . DB_PREFIX . "supplier_account_location_link where account_id = " . $account_info['id']); } $account_location_ids = array(); foreach ($account_locations as $row) { $account_location_ids[] = $row['location_id']; } $account_info['location_ids'] = $account_location_ids; $GLOBALS['account_info']['location_ids'] = $account_location_ids; es_session::set('account_info', $account_info); } }
function write_timezone($zone = '') { if ($zone == '') { $zone = conf('TIME_ZONE'); } $var = array('0' => 'UTC', '8' => 'PRC'); $timezone_config_str = "<?php\r\n"; $timezone_config_str .= "return array(\r\n"; $timezone_config_str .= "'DEFAULT_TIMEZONE'=>'" . $var[$zone] . "',\r\n"; $timezone_config_str .= ");\r\n"; $timezone_config_str .= "?>"; @file_put_contents(get_real_path() . "public/timezone_config.php", $timezone_config_str); }
public function clear_image() { set_time_limit(0); es_session::close(); $path = APP_ROOT_PATH . "public/attachment/"; $this->clear_image_file($path); $path = APP_ROOT_PATH . "public/images/"; $this->clear_image_file($path); $qrcode_path = APP_ROOT_PATH . "public/images/qrcode/"; $this->clear_qrcode($qrcode_path); clear_dir_file(get_real_path() . "public/runtime/app/tpl_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_compiled/"); header("Content-Type:text/html; charset=utf-8"); exit("<div style='line-height:50px; text-align:center; color:#f30;'>" . L('CLEAR_SUCCESS') . "</div><div style='text-align:center;'><input type='button' onclick='\$.weeboxs.close();' class='button' value='关闭' /></div>"); }
public function deleteImg() { B('FilterString'); $ajax = intval($_REQUEST['ajax']); $file = $_REQUEST['file']; $file = explode("..", $file); $file = $file[4]; $file = substr($file, 1); @unlink(get_real_path() . $file); if (app_conf("PUBLIC_DOMAIN_ROOT") != '') { $syn_url = app_conf("PUBLIC_DOMAIN_ROOT") . "/es_file.php?username="******"IMAGE_USERNAME") . "&password="******"IMAGE_PASSWORD") . "&path=" . $file . "&act=1"; @file_get_contents($syn_url); } save_log(l("DELETE_SUCCESS"), 1); $this->success(l("DELETE_SUCCESS"), $ajax); }
private function updateRegionJS() { $jsStr = "var regionConf = " . $this->getRegionJS(); $path = get_real_path() . "public/region.js"; @file_put_contents($path, $jsStr); }
filter_injection($_REQUEST); if (!file_exists(APP_ROOT_PATH . 'public/runtime/app/')) { mkdir(APP_ROOT_PATH . 'public/runtime/app/', 0777); } $GLOBALS['tmpl']->assign("site_info", get_site_info()); //输出根路径 $GLOBALS['tmpl']->assign("APP_ROOT", APP_ROOT); //输出语言包的js if (!file_exists(get_real_path() . "public/runtime/app/lang.js")) { $str = "var LANG = {"; foreach ($lang as $k => $lang_row) { $str .= "\"" . $k . "\":\"" . str_replace("nbr", "\\n", addslashes($lang_row)) . "\","; } $str = substr($str, 0, -1); $str .= "};"; @file_put_contents(get_real_path() . "public/runtime/app/lang.js", $str); } //会员自动登录及输出 $cookie_uname = es_cookie::get("user_name") ? es_cookie::get("user_name") : ''; $cookie_upwd = es_cookie::get("user_name") ? es_cookie::get("user_pwd") : ''; if ($cookie_uname != '' && $cookie_upwd != '' && !es_session::get("user_info")) { require_once APP_ROOT_PATH . "system/libs/user.php"; auto_do_login_user($cookie_uname, $cookie_upwd); } if (strim($_REQUEST['ctl']) == "uc_invest" || strim($_REQUEST['ctl']) == "uc_deal") { $r_user_name = strim($_REQUEST['user_name']); $r_user_pwd = strim($_REQUEST['user_pwd']); if ($r_user_name != '' && $r_user_pwd != '') { require_once APP_ROOT_PATH . "system/libs/user.php"; auto_do_login_user($r_user_name, $r_user_pwd); }
/** * 上传图片的通公基础方法 * * @return array */ protected function uploadImage() { if (conf("WATER_MARK") != "") { $water_mark = get_real_path() . conf("WATER_MARK"); } else { $water_mark = ""; } $alpha = conf("WATER_ALPHA"); //水印透明 $place = conf("WATER_POSITION"); //水印位置 $upload = new UploadFile(); //设置上传文件大小 $upload->maxSize = conf('MAX_IMAGE_SIZE'); /* 配置于config */ //设置上传文件类型 $upload->allowExts = explode(',', conf('ALLOW_IMAGE_EXT')); /* 配置于config */ $dir_name = to_date(get_gmtime(), "Ym"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $dir_name = $dir_name . "/" . to_date(get_gmtime(), "d"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $dir_name = $dir_name . "/" . to_date(get_gmtime(), "H"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $save_rec_Path = "/public/attachment/" . $dir_name . "/origin/"; //上传时先存放原图 $savePath = APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/"; //绝对路径 if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/")) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/"); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/", 0777); } $domain_path = get_domain() . APP_ROOT . $save_rec_Path; $upload->saveRule = "uniqid"; //唯一 $upload->savePath = $savePath; if ($upload->upload()) { $uploadList = $upload->getUploadFileInfo(); foreach ($uploadList as $k => $fileItem) { $file_name = $fileItem['savepath'] . $fileItem['savename']; //上图原图的地址 //水印图 $big_save_path = str_replace("origin/", "", $savePath); //大图存放图径 $big_file_name = str_replace("origin/", "", $file_name); // Image::thumb($file_name,$big_file_name,'',$big_width,$big_height); @file_put_contents($big_file_name, @file_get_contents($file_name)); if (file_exists($water_mark)) { Image::water($big_file_name, $water_mark, $big_file_name, $alpha, $place); } $big_save_rec_Path = str_replace("origin/", "", $save_rec_Path); //上传的图存放的相对路径 $uploadList[$k]['recpath'] = $save_rec_Path; $uploadList[$k]['bigrecpath'] = $big_save_rec_Path; // if(app_conf("PUBLIC_DOMAIN_ROOT")!='') // { // $origin_syn_url = app_conf("PUBLIC_DOMAIN_ROOT")."/es_file.php?username="******"IMAGE_USERNAME")."&password="******"IMAGE_PASSWORD")."&file=".get_domain().APP_ROOT."/public/attachment/".$dir_name."/origin/".$fileItem['savename']."&path=attachment/".$dir_name."/origin/&name=".$fileItem['savename']."&act=0"; // $big_syn_url = app_conf("PUBLIC_DOMAIN_ROOT")."/es_file.php?username="******"IMAGE_USERNAME")."&password="******"IMAGE_PASSWORD")."&file=".get_domain().APP_ROOT."/public/attachment/".$dir_name."/".$fileItem['savename']."&path=attachment/".$dir_name."/&name=".$fileItem['savename']."&act=0"; // @file_get_contents($origin_syn_url); // @file_get_contents($big_syn_url); // } } return array("status" => 1, 'data' => $uploadList, 'info' => L("UPLOAD_SUCCESS")); } else { return array("status" => 0, 'data' => null, 'info' => $upload->getErrorMsg()); } }
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0) { global $xoopsModuleConfig, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL; global $xoopsDB, $xoopsUser, $picinID, $_SERVER; $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $image = $xoopsModuleConfig['fullpath'] . $filepath . $filename; $normal = $xoopsModuleConfig['fullpath'] . $filepath . $xoopsModuleConfig['normal_pfx'] . $filename; $thumb = $xoopsModuleConfig['fullpath'] . $filepath . $xoopsModuleConfig['thumb_pfx'] . $filename; $imagesize = getimagesize($image); if (!$imagesize) { if (is_movie($image)) { $filename_wo_ext = substr($filename, 0, strrpos($filename, '.')); $thm_image = get_real_path() . $filepath . $filename_wo_ext . ".thm"; if (file_exists($thm_image)) { copy($thm_image, $thumb); copy($thm_image, $normal); } else { copy(XOOPS_ROOT_PATH . "/modules/xcgal/images/thumb_avi.jpg", $thumb); copy(XOOPS_ROOT_PATH . "/modules/xcgal/images/thumb_avi.jpg", $normal); } $imagesize[0] = 320; $imagesize[1] = 240; } elseif (is_audio($image)) { $filename_wo_ext = substr($filename, 0, strrpos($filename, '.')); $thm_image = get_real_path() . $filepath . $filename_wo_ext . ".thm"; if (file_exists($thm_image)) { copy($thm_image, $thumb); copy($thm_image, $normal); } else { copy(XOOPS_ROOT_PATH . "/modules/xcgal/images/thumb_mp3.jpg", $thumb); copy(XOOPS_ROOT_PATH . "/modules/xcgal/images/thumb_mp3.jpg", $normal); } $imagesize[0] = 320; $imagesize[1] = 240; } } else { if (!file_exists($thumb)) { if (!resize_image($image, $thumb, $xoopsModuleConfig['thumb_width'], $xoopsModuleConfig['thumb_method'])) { return false; } } if (max($imagesize[0], $imagesize[1]) > $xoopsModuleConfig['picture_width'] && $xoopsModuleConfig['make_intermediate'] && !file_exists($normal)) { if (!resize_image($image, $normal, $xoopsModuleConfig['picture_width'], $xoopsModuleConfig['thumb_method'])) { return false; } } } $image_filesize = filesize($image); $total_filesize = $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb); // Test if disk quota exceeded if (!USER_IS_ADMIN && $USER_DATA['group_quota']) { if (is_object($xoopsUser)) { $quota_opt = "owner_id = '" . USER_ID . "'"; } else { $quota_opt = "ip = '" . $_SERVER['REMOTE_ADDR'] . "'"; } $result = $xoopsDB->query("SELECT sum(total_filesize) FROM " . $xoopsDB->prefix("xcgal_pictures") . " WHERE {$quota_opt}"); $record = $xoopsDB->fetchArray($result); $total_space_used = $record['sum(total_filesize)']; //echo $total_space_used; $xoopsDB->freeRecordSet($result); if ($total_space_used + $total_filesize > $USER_DATA['group_quota'] << 10) { @unlink($image); @unlink($normal); @unlink($thumb); $msg = strtr(_MD_QUOTA_EXCEEDED, array('[quota]' => $USER_DATA['group_quota'], '[space]' => $total_space_used >> 10)); redirect_header('index.php', 2, $msg); } } // Test if picture requires approval if (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) { $approved = 'YES'; } elseif (!$USER_DATA['pub_upl_need_approval']) { $approved = 'YES'; } else { $approved = 'NO'; } $PIC_NEED_APPROVAL = $approved == 'NO'; // User ID is not recorded when in admin mode (ie. for batch uploads) $user_id = USER_ID; $user_name = USER_NAME; $query = "INSERT INTO " . $xoopsDB->prefix("xcgal_pictures") . " (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, mtime, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, ip) VALUES ('{$aid}', '" . $myts->makeTboxData4Save($filepath) . "', '" . $myts->makeTboxData4Save($filename) . "', '{$image_filesize}', '{$total_filesize}', '{$imagesize[0]}', '{$imagesize[1]}','" . time() . "', '" . time() . "', '{$user_id}','{$user_name}', '{$title}', '{$caption}', '{$keywords}', '{$approved}', '{$user1}', '{$user2}', '{$user3}', '{$user4}','" . $_SERVER['REMOTE_ADDR'] . "')"; $result = $xoopsDB->queryf($query); if ($approved == 'YES') { $picinID = $xoopsDB->getInsertId(); } if ($approved == 'YES' && is_object($xoopsUser)) { $xoopsUser->incrementPost(); } return $result; }
public function set_default() { $adm_id = intval($_REQUEST['id']); $admin = M("Admin")->getById($adm_id); if ($admin) { M("Conf")->where("name = 'DEFAULT_ADMIN'")->setField("value", $admin['adm_name']); //开始写入配置文件 $sys_configs = M("Conf")->findAll(); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; $filename = get_real_path() . "public/sys_config.php"; if (!($handle = fopen($filename, 'w'))) { $this->error(l("OPEN_FILE_ERROR") . $filename); } if (fwrite($handle, $config_str) === FALSE) { $this->error(l("WRITE_FILE_ERROR") . $filename); } fclose($handle); save_log(l("CHANGE_DEFAULT_ADMIN"), 1); clear_cache(); $this->success(L("SET_DEFAULT_SUCCESS")); } else { $this->error(L("NO_ADMIN")); } }
/** * 上传图片的通公基础方法 * * @return array */ protected function uploadImage() { if (conf("WATER_MARK") != "") { $water_mark = get_real_path() . conf("WATER_MARK"); } else { $water_mark = ""; } $alpha = conf("WATER_ALPHA"); //水印透明 $place = conf("WATER_POSITION"); //水印位置 $upload = new UploadFile(); //设置上传文件大小 $upload->maxSize = conf('MAX_IMAGE_SIZE'); /* 配置于config */ //设置上传文件类型 $upload->allowExts = explode(',', conf('ALLOW_IMAGE_EXT')); /* 配置于config */ $dir_name = to_date(NOW_TIME, "Ym"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $dir_name = $dir_name . "/" . to_date(NOW_TIME, "d"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $dir_name = $dir_name . "/" . to_date(NOW_TIME, "H"); if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name)) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name, 0777); } $save_rec_Path = "/public/attachment/" . $dir_name . "/origin/"; //上传时先存放原图 $savePath = APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/"; //绝对路径 if (!is_dir(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/")) { @mkdir(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/"); @chmod(APP_ROOT_PATH . "public/attachment/" . $dir_name . "/origin/", 0777); } $domain_path = SITE_DOMAIN . APP_ROOT . $save_rec_Path; $upload->saveRule = "uniqid"; //唯一 $upload->savePath = $savePath; if ($upload->upload()) { $uploadList = $upload->getUploadFileInfo(); foreach ($uploadList as $k => $fileItem) { $file_name = $fileItem['savepath'] . $fileItem['savename']; //上图原图的地址 //水印图 $big_save_path = str_replace("origin/", "", $savePath); //大图存放图径 $big_file_name = str_replace("origin/", "", $file_name); // Image::thumb($file_name,$big_file_name,'',$big_width,$big_height); @file_put_contents($big_file_name, @file_get_contents($file_name)); if (file_exists($water_mark)) { Image::water($big_file_name, $water_mark, $big_file_name, $alpha, $place); } $big_save_rec_Path = str_replace("origin/", "", $save_rec_Path); //上传的图存放的相对路径 $uploadList[$k]['recpath'] = $save_rec_Path; $uploadList[$k]['bigrecpath'] = $big_save_rec_Path; if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != 'NONE') { syn_to_remote_image_server("./public/attachment/" . $dir_name . "/origin/" . $fileItem['savename']); syn_to_remote_image_server("./public/attachment/" . $dir_name . "/" . $fileItem['savename']); } } return array("status" => 1, 'data' => $uploadList, 'info' => L("UPLOAD_SUCCESS")); } else { return array("status" => 0, 'data' => null, 'info' => $upload->getErrorMsg()); } }
public function deleteImg() { B('FilterString'); $ajax = intval($_REQUEST['ajax']); $file = $_REQUEST['file']; $file = explode("..", $file); $file = $file[4]; $file = substr($file, 1); @unlink(get_real_path() . $file); if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] == 'ES_FILE') { $syn_url = $GLOBALS['distribution_cfg']['OSS_DOMAIN'] . "/es_file.php?username="******"&password="******"&path=" . $file . "&act=1"; @file_get_contents($syn_url); } save_log(l("DELETE_SUCCESS"), 1); $this->success(l("DELETE_SUCCESS"), $ajax); }
public function update() { B('FilterString'); $data = M(MODULE_NAME)->create(); //开始验证有效性 $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id']))); if (!check_empty($data['name'])) { $this->error(L("YOUHUI_NAME_EMPTY_TIP")); } if (file_exists(get_real_path() . $_REQUEST['image_3'])) { list($image_3_w, $image_3_h) = getimagesize(get_real_path() . $_REQUEST['image_3']); $data['image_3_w'] = intval($image_3_w); $data['image_3_h'] = intval($image_3_h); } $data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']); $data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']); $log_info = $data['name']; // 更新数据 $data['publish_wait'] = 0; $list = M(MODULE_NAME)->save($data); if (false !== $list) { M("DealCateTypeYouhuiLink")->where("youhui_id=" . $data['id'])->delete(); foreach ($_REQUEST['deal_cate_type_id'] as $type_id) { $link_data = array(); $link_data['deal_cate_type_id'] = $type_id; $link_data['youhui_id'] = $data['id']; M("DealCateTypeYouhuiLink")->add($link_data); } M("YouhuiLocationLink")->where("youhui_id=" . $data['id'])->delete(); foreach ($_REQUEST['location_id'] as $location_id) { $link_data = array(); $link_data['location_id'] = $location_id; $link_data['youhui_id'] = $data['id']; M("YouhuiLocationLink")->add($link_data); recount_supplier_data_count($location_id, "youhui"); } //成功提示 syn_youhui_match($data['id']); save_log($log_info . L("UPDATE_SUCCESS"), 1); $this->success(L("UPDATE_SUCCESS")); } else { //错误提示 $DBerr = M()->getDbError(); save_log($log_info . L("UPDATE_FAILED") . $DBerr, 0); $this->error(L("UPDATE_FAILED") . $DBerr, 0); } }
public function update() { B('FilterString'); $data = M(MODULE_NAME)->create(); //对于商户请求操作 if (intval($_REQUEST['edit_type']) == 2 && intval($_REQUEST['youhui_id']) > 0) { //商户提交修改审核 $youhui_submit_id = intval($_REQUEST['id']); $data['id'] = intval($_REQUEST['youhui_id']); } //开始验证有效性 $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id']))); if (!check_empty($data['name'])) { $this->error(L("YOUHUI_NAME_EMPTY_TIP")); } if ($data['city_id'] == 0) { $this->error(L("DEAL_CITY_EMPTY_TIP")); } $city_info = M("DealCity")->where("id=" . intval($data['city_id']))->find(); if ($city_info['pid'] == 0) { $this->error("只能选择城市,不能选择省份"); } if (file_exists(get_real_path() . $_REQUEST['image_3'])) { list($image_3_w, $image_3_h) = getimagesize(get_real_path() . $_REQUEST['image_3']); $data['image_3_w'] = intval($image_3_w); $data['image_3_h'] = intval($image_3_h); } $data['begin_time'] = strim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']); $data['end_time'] = strim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']); $log_info = $data['name']; // 更新数据 $data['publish_wait'] = 0; $list = M(MODULE_NAME)->save($data); if (false !== $list) { M("DealCateTypeYouhuiLink")->where("youhui_id=" . $data['id'])->delete(); foreach ($_REQUEST['deal_cate_type_id'] as $type_id) { $link_data = array(); $link_data['deal_cate_type_id'] = $type_id; $link_data['youhui_id'] = $data['id']; M("DealCateTypeYouhuiLink")->add($link_data); } M("YouhuiLocationLink")->where("youhui_id=" . $data['id'])->delete(); foreach ($_REQUEST['location_id'] as $location_id) { $link_data = array(); $link_data['location_id'] = $location_id; $link_data['youhui_id'] = $data['id']; M("YouhuiLocationLink")->add($link_data); recount_supplier_data_count($location_id, "youhui"); } //对于商户请求操作 if (intval($_REQUEST['edit_type']) == 2 && $youhui_submit_id > 0) { //商户提交修改审核 /*同步商户发布表状态*/ $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_biz_submit", array("admin_check_status" => 1), "UPDATE", "id=" . $youhui_submit_id); // 1 通过 2 拒绝', } //成功提示 syn_youhui_match($data['id']); save_log($log_info . L("UPDATE_SUCCESS"), 1); $this->success(L("UPDATE_SUCCESS")); } else { //错误提示 $DBerr = M()->getDbError(); save_log($log_info . L("UPDATE_FAILED") . $DBerr, 0); $this->error(L("UPDATE_FAILED") . $DBerr, 0); } }
/** * 前端全运行函数,生成系统前台使用的全局变量 * 1. 定位城市 GLOBALS['city']; * 2. 加载会员 GLOBALS['user_info']; * 3. 生成语言包 * 4. 加载推荐人与来路 * 5. 更新购物车 */ function global_run() { if (app_conf("SHOP_OPEN") == 0) { app_redirect(url("index", "close")); } //处理城市 global $city; require_once APP_ROOT_PATH . "system/model/city.php"; $city = City::locate_city(); global $geo; $geo = City::locate_geo(floatval($_REQUEST['xpoint']), floatval($_REQUEST['ypoint'])); //输出语言包的js if (!file_exists(get_real_path() . "public/runtime/app/lang.js")) { $str = "var LANG = {"; foreach ($GLOBALS['lang'] as $k => $lang_row) { $str .= "\"" . $k . "\":\"" . str_replace("nbr", "\\n", addslashes($lang_row)) . "\","; } $str = substr($str, 0, -1); $str .= "};"; @file_put_contents(get_real_path() . "public/runtime/app/lang.js", $str); } //会员自动登录及输出 global $user_info; global $user_logined; require_once APP_ROOT_PATH . "system/model/user.php"; $user_info = es_session::get('user_info'); if (empty($user_info)) { $cookie_uname = es_cookie::get("user_name") ? es_cookie::get("user_name") : ''; $cookie_upwd = es_cookie::get("user_pwd") ? es_cookie::get("user_pwd") : ''; if ($cookie_uname != '' && $cookie_upwd != '' && !es_session::get("user_info")) { $cookie_uname = strim($cookie_uname); $cookie_upwd = strim($cookie_upwd); auto_do_login_user($cookie_uname, $cookie_upwd); $user_info = es_session::get('user_info'); } } refresh_user_info(); //刷新购物车 require_once APP_ROOT_PATH . "system/model/cart.php"; refresh_cart_list(); global $ref_uid; //保存返利的cookie if ($_REQUEST['r']) { $rid = intval(base64_decode($_REQUEST['r'])); $ref_uid = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where id = " . intval($rid))); es_cookie::set("REFERRAL_USER", intval($ref_uid)); } else { //获取存在的推荐人ID if (intval(es_cookie::get("REFERRAL_USER")) > 0) { $ref_uid = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where id = " . intval(es_cookie::get("REFERRAL_USER")))); } } global $referer; //保存来路 // es_cookie::delete("referer_url"); if (!es_cookie::get("referer_url")) { if (!preg_match("/" . urlencode(SITE_DOMAIN . APP_ROOT) . "/", urlencode($_SERVER["HTTP_REFERER"]))) { $ref_url = $_SERVER["HTTP_REFERER"]; if (substr($ref_url, 0, 7) == "http://" || substr($ref_url, 0, 8) == "https://") { preg_match("/http[s]*:\\/\\/[^\\/]+/", $ref_url, $ref_url); $referer = $ref_url[0]; if ($referer) { es_cookie::set("referer_url", $referer); } } } } else { $referer = es_cookie::get("referer_url"); } $referer = strim($referer); }
public function uninstall() { $class_name = $_REQUEST['class_name']; $directory = APP_ROOT_PATH . "system/integrate/"; $file = $directory . $class_name . "_integrate.php"; if (file_exists($file)) { require_once $file; $integrate_class = $class_name . "_integrate"; $integrate_item = new $integrate_class(); $integrate_item->uninstall(); } M("Conf")->where("name='INTEGRATE_CODE'")->setField("value", ''); M("Conf")->where("name='INTEGRATE_CFG'")->setField("value", ''); //开始写入配置文件 $sys_configs = M("Conf")->findAll(); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; $filename = get_real_path() . "public/sys_config.php"; if (!($handle = fopen($filename, 'w'))) { $this->error(l("OPEN_FILE_ERROR") . $filename); } if (fwrite($handle, $config_str) === FALSE) { $this->error(l("WRITE_FILE_ERROR") . $filename); } fclose($handle); clear_cache(); write_timezone(); $this->assign("jumpUrl", u(MODULE_NAME . "/index")); save_log(l("UNINSTALL_SUCCESS"), 1); $this->success(l("UNINSTALL_SUCCESS"), 0); }
/** * 恢复列表的备份 * * @param array $filelist * @return string */ public function restore($filelist) { set_time_limit(0); $filepath = get_real_path() . "public/db_backup/"; //导出的目录 foreach ($filelist as $fileItem) { $sql = file_get_contents($filepath . $fileItem['filename']); $sql = $this->remove_comment($sql); $sql = trim($sql); $sql = str_replace("\r", '', $sql); $segmentSql = explode(";\n", $sql); foreach ($segmentSql as $itemSql) { if ($itemSql != '') { $itemSql = str_replace("%DB_PREFIX%", conf('DB_PREFIX'), $itemSql); $this->db->query($itemSql); if ($this->db->getError() != "") { return $this->db->getError(); } } } } return ""; }
function check_install() { if (!file_exists(get_real_path() . "public/install.lock")) { clear_cache(); header('Location:' . APP_ROOT . '/install'); exit; } }
public function restore() { set_time_limit(0); es_session::close(); $groupname = $_REQUEST['file']; $vol = intval($_REQUEST['vol']); $db_back_dir = get_real_path() . "public/db_backup/" . $groupname . "/"; $sql_list = $this->dirFileInfo($db_back_dir, ".sql"); $sql_list = $sql_list[$groupname]; $fileItem = $sql_list[$vol]; $sql = file_get_contents($db_back_dir . $fileItem['filename']); $sql = $this->remove_comment($sql); $sql = trim($sql); $sql = str_replace("\r", '', $sql); $segmentSql = explode(";\n", $sql); foreach ($segmentSql as $itemSql) { if ($itemSql != '') { $itemSql = str_replace("%DB_PREFIX%", conf('DB_PREFIX'), $itemSql); $this->db->query($itemSql); } } if ($vol == count($sql_list)) { $result['done'] = 1; $result['status'] = 1; } else { $vol++; $result['filename'] = $groupname; $result['vol'] = $vol; $result['status'] = 1; } ajax_return($result); }
public function update_commossion() { $conf_res = M("Conf")->where("is_effect = 1 and name in ('INVESTORS_COMMISSION_RATIO','BORROWER_COMMISSION_RATIO')")->findAll(); foreach ($conf_res as $k => $v) { conf($v['name'], floatval(strim($_REQUEST[$v['name']]))); if ($v['name'] == 'URL_MODEL' && $v['value'] != $_REQUEST[$v['name']]) { clear_auto_cache("byouhui_filter_nav_cache"); clear_auto_cache("cache_shop_acate_tree"); clear_auto_cache("cache_shop_cate_tree"); clear_auto_cache("cache_youhui_cate_tree"); clear_auto_cache("city_list_result"); clear_auto_cache("fyouhui_filter_nav_cache"); clear_auto_cache("get_help_cache"); clear_auto_cache("page_image"); clear_auto_cache("tuan_filter_nav_cache"); clear_auto_cache("youhui_page_recommend_youhui_list"); clear_auto_cache("ytuan_filter_nav_cache"); clear_auto_cache("store_filter_nav_cache"); clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_compiled/"); clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/data/page_static_cache/"); clear_dir_file(get_real_path() . "public/runtime/data/dynamic_avatar_cache/"); } } //开始写入配置文件 $sys_configs = M("Conf")->findAll(); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; $filename = get_real_path() . "public/sys_config.php"; if (!($handle = fopen($filename, 'w'))) { $this->error(l("OPEN_FILE_ERROR") . $filename); } if (fwrite($handle, $config_str) === FALSE) { $this->error(l("WRITE_FILE_ERROR") . $filename); } fclose($handle); save_log(l("CONF_UPDATED"), 1); //clear_cache(); write_timezone(); $this->success(L("UPDATE_SUCCESS")); }