/** * 更新数据表数据 */ private function _updateData($data) { if (XUtils::method() == 'POST') { if (!empty($_FILES['site_logo']['name'])) { $this->_getLogo('site_logo', SITE_PATH . 'static/', $data['site_logo']); } else { unset($data['site_logo']); } foreach ((array) $data as $key => $row) { $row = XUtils::addslashes($row); Yii::app()->db->createCommand("REPLACE INTO {{config}}(`variable`, `value`) VALUES('{$key}', '{$row}') ")->execute(); } XXcache::refresh('_config', 3600); parent::_backendLogger(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id)); XUtils::message('success', '更新完成', $this->createUrl($this->action->id)); } }
/** * 缓存更新 */ public function actionCacheUpdate() { $scope = $this->_gets->getParam('scope'); try { if (is_array($scope)) { foreach ($scope as $key => $row) { XXcache::refresh($row, 3600); } $var['state'] = 'success'; $var['message'] = '操作完成'; } else { throw new Exception('请选择要更新的内容'); } } catch (Exception $e) { $var['state'] = 'error'; $var['message'] = '操作失败:' . $e->getMessage(); } exit(CJSON::encode($var)); }
/** * 单页更新 * * @param $id */ public function actionUpdate($id) { parent::_acl(); $model = parent::_dataLoad(new Page(), $id); if (isset($_POST['Page'])) { $model->attributes = $_POST['Page']; $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(200, 180))); if (is_array($file)) { $model->attach_file = $file['pathname']; $model->attach_thumb = $file['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if ($model->save()) { XXcache::refresh('_link'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑单页,ID:' . $id)); $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); }
/** * 编辑 * * @param $id */ public function actionUpdate($id) { parent::_acl('catalog_update'); $model = new Catalog(); $parentId = intval($_POST['Catalog']['parent_id']); $model = parent::_dataLoad(new Catalog(), $id); if (isset($_POST['Catalog'])) { self::parentTrue($id, $parentId); $model->attributes = $_POST['Catalog']; $file = XUpload::upload($_FILES['attach']); if (is_array($file)) { $model->image = $file['pathname']; @unlink($_POST['oAttach']); } if ($model->save()) { XXcache::refresh('_catalog'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑类别,ID:' . $id . ',名称:' . $model->catalog_name)); $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); }
/** * 更新广告 */ public function actionAdUpdate($id) { parent::_acl('ad_update'); $model = parent::_dataLoad(new Ad(), $id); if (isset($_POST['Ad'])) { $file = XUpload::upload($_FILES['attach']); if (is_array($file)) { $model->attach_file = $file['pathname']; @unlink($_POST['oAttach']); } $model->attributes = $_POST['Ad']; $model->expired_time = intval(strtotime($model->expired_time)); $model->start_time = intval(strtotime($model->start_time)); if ($model->save()) { XXcache::refresh('_ad'); AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑广告,ID:' . $id)); $this->redirect(array('ad')); } } $model->expired_time = date('Y-m-d', $model->expired_time); $model->start_time = date('Y-m-d', $model->start_time); $this->render('ad_update', array('model' => $model)); }
private function doTb($tid, $cid = 0) { if ($tid == 2610) { //彩票部分 $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://www.114la.com/icai.json'; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } $fcurl = substr($fcurl, 17, -1); $data_arr = json_decode($fcurl, TRUE); if (!empty($data_arr)) { //对应关系 $dy = array('ssq' => array(220, 221, 222), 'dlt' => array(223, 224, 225), 'fc3d' => array(226, 227, 228), 'jx_11x5' => array(229, 230, 231)); foreach ($data_arr as $tp => $v) { $va = $v[0]; $fdata[$dy[$tp][0]] = array(0 => array('title' => '上期开奖号码', 'link' => $va['url'][0], 'opt_a' => implode(',', $va['result']), 'opt_b' => $va['phase'], 'opt_c' => $va['date'])); $fdata[$dy[$tp][1]] = array(0 => array('title' => '立即投注', 'link' => $va['url'][1]), 1 => array('title' => $va['chain'][0], 'link' => $va['chain'][1])); foreach ($va['link'] as $vl => $tu) { $tu['link'] = $tu['url']; unset($tu['url']); $va['link'][$vl] = $tu; } $fdata[$dy[$tp][2]] = $va['link']; } } if (!empty($fdata)) { foreach ($fdata as $cid => $cinfo) { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); foreach ($cinfo as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link']; $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1caipiao'; } } } } return 'ok'; // ppr($fdata,1); } elseif ($tid == 1114) { //实时热点部分 $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://api4.114la.com/1114_2.json'; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } $fcurl = substr($fcurl, 20, -1); // ppr($fcurl,1); if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) { //先将对应的旧数据处理 $old = reqPost('old'); if (empty($old)) { Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'"); } else { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); } // ppr(Links::model()->findAll("`catalog_id`='$cid'")); foreach ($fcurl as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['url']) || $info['url'] == '#' ? 'http://www.114la.com/' : $info['url']; unset($info['url']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1'; } } $cacheId = '_catalogAllNum'; $catalogAllNum = XXcache::refresh($cacheId); return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok'; } else { return 'error2'; } ppr($data_arr, 1); } elseif ($tid > 1000 && $tid < 10000) { $tid = (int) $tid; $data = $re = 0; $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://www.114la.com/api/ky.php?id=' . $tid . '&' . time(); // $url = 'http://www.114la.com/api/ky.php?id='.$tid; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) { //先将对应的旧数据处理 $old = reqPost('old'); if (empty($old)) { Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'"); } else { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); } // ppr(Links::model()->findAll("`catalog_id`='$cid'")); foreach ($fcurl as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link']; $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1'; } } $cacheId = '_catalogAllNum'; $catalogAllNum = XXcache::refresh($cacheId); return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok'; } else { return 'error2'; } } else { return 'error3'; } }
private function groupEdite($data = null) { if (XUtils::method() == 'POST') { if (!empty($_POST['gname']) && !empty($_POST['auth'])) { $gid = reqPost('gid', null); $auth = '|' . implode('|', array_keys($_POST['auth'])) . '|'; $sis = !empty($_POST['sis']) && $_POST['sis'] == 'Y' ? 'Y' : 'N'; $attr = array('group_name' => $_POST['gname'], 'acl' => $auth, 'status_is' => $_POST['sis']); if (!empty($gid)) { $attr['id'] = $gid; } else { $attr['create_time'] = time(); } empty($data) && ($data = new AdminGroup()); $data->attributes = $attr; // ppr($data); // ppr($attr); // ppr($_POST,1); if ($data->save()) { //更新权限缓存 !empty($gid) && cacheDelete('_backendAcl' . $gid, ''); parent::_backendLogger(array('catalog' => 'create', 'intro' => '编辑管理员组及权限' . $data->group_name)); XXcache::refresh('_adminGroup'); $this->redirect(array('group')); } } else { $gid = reqPostNum('gid'); if ($gid > 0) { XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/groupCreate', array('id' => $gid))); } else { XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/group')); } } } }
/** * 刷新内置缓存 * @param $model */ protected function _refreshCache($model) { if (is_object($model)) { $modelx = get_class($model); } else { $modelx = $model; } switch (strtolower($modelx)) { case 'link': XXcache::refresh('_link', 86400); break; case 'ad': XXcache::refresh('_ad', 86400); break; case 'catalog': XXcache::refresh('_catalog', 86400); break; case 'UserGroup': XXcache::refresh('_userGroup', 86400); break; } }
/** * 自定义字段 */ public function actionCustom() { parent::_acl(); if (XUtils::method() == 'POST') { foreach ((array) $_POST['attr'] as $key => $row) { $val = is_array($row['val']) ? implode(',', $row['val']) : $row['val']; $var = $row["name"]; $config = Config::model()->find('scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var)); if ($config) { Config::model()->updateAll(array('value' => $val), 'scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var)); } else { $config = new Config(); $config->scope = 'custom'; $config->variable = $var; $config->value = $val; $config->save(); } } XXcache::refresh('_config', 3600); AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id)); XUtils::message('success', '更新完成', $this->createUrl($this->action->id)); } $attrModel = Attr::lists(0, 'config'); $this->render('custom', array('attrData' => self::loadData(), 'attrModel' => $attrModel)); }
public function actionDelete() { parent::_acl(); $catalogId = reqGet('catalogId', null); // ppr($_REQUEST,1); if (!empty($catalogId)) { $catalogId = intval($catalogId); $model = Catalog::model()->findByPk($catalogId); $name = $model->catalog_name; $model->delete(); XXcache::refresh('_catalog'); XXcache::refresh('_catalogAll'); $model = Links::model()->deleteAll('catalog_id=:cid', array(':cid' => $catalogId)); parent::_backendLogger(array('catalog' => 'delete', 'intro' => '删除分类 ' . $name . '(' . $catalogId . ') 及该分类所有链接')); XUtils::message('success', '已删除分类 ' . $name . ' 及该分类所有链接'); } $this->redirect(Yii::app()->request->urlReferrer); }