Esempio n. 1
0
 function clear()
 {
     $lDate = get_date_add('m', -1, date('Y-m-d H:i:s'));
     $where = 'addTime <' . strtotime($lDate);
     $this->where($where)->delete();
     return result_data(1, '一个月前的数据清除成功');
 }
 /**
  * 批量更新缓存
  */
 public function updateAct()
 {
     $cacheList = C('CACHE_LIST');
     $errMsg = '';
     if (!IS_POST) {
         $this->assign('listHtml', $this->getComboBox($cacheList, 'id', array('nullText' => '全部缓存')));
         $this->display();
     } else {
         $id = I('post.id', '');
         if (!empty($id)) {
             if (!isset($cacheList[$id])) {
                 $this->showResult(result_data(0, '请选择您要更新的缓存!'));
             }
             $cacheList = array($id => $cacheList[$id]);
         }
         foreach ($cacheList as $key => $c) {
             $obj = D($key);
             if (method_exists($obj, 'updateCache')) {
                 $obj->updateCache();
                 $msg .= $c . '缓存更新成功<br/>';
             } else {
                 $msg .= '<font color=red>' . $c . '缓存更新失败</font><br/>';
             }
         }
         $this->showResult(result_data(1, $msg));
     }
 }
 public function indexAct()
 {
     if (!IS_POST) {
         $this->assign(array('dataTypeHtml' => $this->getComboBox($this->dataType, 'dataType', array('selVal' => -1, 'width' => 120))));
         $this->display();
     } else {
         $postDataType = $_POST['dataType'];
         $checkField = $_POST['checkField'];
         if (!in_array($postDataType, array_keys($this->dataType))) {
             $this->showResult(result_data(0, '请选择导入对象!'));
         }
         if (empty($checkField)) {
             $this->showResult(result_data(0, '头部字段不能为空!'));
         }
         $file = $_FILES['importFile'];
         if ($file['type'] != 'application/vnd.ms-excel') {
             $this->showResult(result_data(0, '文件格式错误'));
         }
         $data = new \Org\Util\Spreadsheet_Excel_Reader();
         $data->setOutputEncoding('utf-8');
         //编码
         $data->read($file['tmp_name']);
         $firstRow = $data->sheets[0]['cells'][1];
         //第一行的数据
         $fieldArr = explode(',', strtolower($checkField));
         if (count($fieldArr) != count($fieldArr)) {
             $this->showResult(result_data(0, '核对字段和文件里头部字段不一致'));
         }
         //print_r($firstRow);
         $allField = array();
         foreach ($firstRow as $value) {
             if (!in_array($value, $fieldArr)) {
                 $this->showResult(result_data(0, '文件里缺少 ' . $value . '字段'));
             } else {
                 $allField[] = $value;
             }
         }
         for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
             if ($postDataType == 1) {
                 //课程
             } else {
                 if ($postDataType == 2) {
                     //视频
                 }
             }
             if ($i % 1000 == 0) {
                 //每插入1000条数据 让数据库休息
                 sleep(5);
             }
         }
     }
 }
 /**
  * 更新/保存配置项内容
  */
 public function updateConfig($data)
 {
     $record = D('ProConfig')->find($data['id']);
     if (empty($record)) {
         return result_data(0, '配置记录不存在!');
     }
     unset($data['id']);
     //解析页面传递的数据
     $record['content'] = $this->parsePageData($data, $record['templete']);
     //保存配置内容
     $rows = D('ProConfig')->saveData($record);
     return result_data(1, '配置更新成功!', array('rows' => $rows));
 }
Esempio n. 5
0
 /**
  * 保存数据
  * @param array $data
  */
 public function saveData($data)
 {
     if ($data['adClass']) {
         if (!$data['apId']) {
             return result_data(0, '广告商不能为空!');
         }
         if (!$data['adId']) {
             return result_data(0, '外部广告ID不能为空!');
         }
     } else {
         $data['apId'] = '';
         $data['adId'] = '';
     }
     return parent::saveData($data);
 }
Esempio n. 6
0
 /**
  * 获取配置文件模版
  * @param unknown_type $cnfKey
  */
 public function getConfigTpl($cnfKey)
 {
     //判断参数是完整的文件名还是关键字
     if (strpos($cnfKey, '.php') === false) {
         $r = D('ProConfig')->selectOne(array('cKey' => $cnfKey));
         $filename = $r['templete'];
     } else {
         $filename = $cnfKey;
     }
     if (!is_file(CONF_PATH . $filename)) {
         return result_data(0, '配置模版' . $filename . '不存在!', '');
     }
     $configTpl = (include CONF_PATH . $filename);
     return result_data(1, '读取模版文件成功!', $configTpl);
 }
 public function delData($data)
 {
     if (!$data['id']) {
         return result_data(0, '活动不存在!');
     }
     $result = parent::delData($data['id']);
     if ($result['status'] == 1) {
         if ($data['delTable'] == 'on') {
             //删除表
             $result2 = D('ActBase', 'Logic')->delActTable($data['id']);
             if ($result2['status'] == 0) {
                 return result_data(0, $result2['info']);
             }
         }
     }
     return $result;
 }
Esempio n. 8
0
 /**
  * 保存数据
  * @param array $data
  * @return Ambigous <multitype:, multitype:boolean unknown mixed >
  */
 public function saveData($data)
 {
     $data = get_array_data($data, 'name,isSuper,auth', 'id');
     $data['auth'] = serialize($data['auth']);
     $data['isSuper'] = $data['isSuper'] == 1 ? 1 : 0;
     if ($this->create($data)) {
         if (empty($data['id'])) {
             $id = $this->add();
         } else {
             $id = $this->save();
         }
         $this->updateCache();
         return result_data(1, '数据保存成功!', array('id' => $id));
     } else {
         return result_data(0, $this->getError());
     }
 }
Esempio n. 9
0
 public function delData($data)
 {
     if (!$data['id']) {
         return result_data(0, '附件不存在!');
     }
     $result = parent::delData($data['id']);
     if ($result['status'] == 1) {
         if ($data['delFile'] == 'on') {
             //删除本身附件
             $url = get_upfile_url($data['url']);
             $result2 = unlink($url);
             if (!$result2) {
                 return result_data(0, '本身文件删除失败!');
             }
         }
     }
     return $result;
 }
Esempio n. 10
0
 public function countAct()
 {
     $where = array();
     $beginTime = I('beginTime', '');
     if (!empty($beginTime)) {
         $beginTime = $beginTime . ' 00:00:00';
         $where['where']['addTime'] = array('egt', $beginTime);
     }
     $endTime = I('endTime', '');
     if (!empty($endTime)) {
         $endTime = $endTime . ' 23:23:59';
         $where['where']['addTime2'] = array('elt', $endTime);
     }
     $userId = I('userId', '');
     if (!empty($userId)) {
         $where['where']['$userId'] = $userId;
     }
     $userCount = D('User')->selectPage($where);
     $this->ajaxReturn(result_data(1, '<div style="text-align:center;">用户个数:' . $userCount['total'] . '</div>'));
 }
 /**
  * 保存上传记录到数据库中
  * @param arr $infos
  * @param int $fileType
  * @param arr $thumb
  * @param string $memo
  * @return array 上传的文件名列表
  */
 private function saveData($infos, $fileType, $thumb, $memo)
 {
     $Upfile = D('Upfile');
     foreach ($infos as $info) {
         $data = array('fileType' => $fileType, 'url' => $info['savename'], 'size' => $info['size'], 'thumb' => $thumb, 'memo' => $memo);
         if ($Upfile->create($data)) {
             $Upfile->add();
         } else {
             $this->showResult(result_data(0, $Upfile->getError()));
         }
         $files[] = $info['savename'];
     }
     return $files;
 }
Esempio n. 12
0
 /**
  * 删除数据
  * @param int|array $id
  */
 public function delData($id)
 {
     if (!$id) {
         return result_data(0, '没有数据被删除!');
     }
     if (is_array($id)) {
         $id = $id[0];
     }
     //$id = implode ($id,',');
     $num = $this->delete($id);
     if ($num === false) {
         return result_data(0, '数据删除失败:' . $this->getError(), $num);
     } else {
         if ($num > 0) {
             if (method_exists($this, 'updateCache')) {
                 $this->updateCache();
             }
             if (!empty($this->sync)) {
                 $this->syncSend($this->sync);
             }
         }
         return result_data(1, '数据记录(' . $num . '条)删除成功!', $num);
     }
 }
Esempio n. 13
0
 /**
  * 增加或减少某项值
  * @param int $userId
  * @param array $data
  */
 public function SetIncOrDec($userId, $data)
 {
     $rows = $this->where(array('userId' => $userId))->setField($this->getIncOrDecData($data));
     return result_data(1, '数据更新成功!', array('rows' => $rows));
 }
Esempio n. 14
0
 /**
  * 修改密码
  * @param string $oldPassword
  * @param string $password
  * @param string $rePassword
  */
 public function editpwd($id, $oldPassword, $password, $rePassword)
 {
     if (empty($oldPassword)) {
         return result_data(0, '请输入旧密码!');
     }
     if (empty($password)) {
         return result_data(0, '请输入新密码!');
     }
     if ($password != $rePassword) {
         return result_data(0, '两次输入的密码不一致!');
     }
     $user = $this->field('id,password')->find($id);
     if (!$user) {
         return result_data(0, '发生未知的错误!');
     }
     if ($user['password'] != md5($oldPassword)) {
         return result_data(0, '您输入的旧密码错误!');
     }
     $this->data(array('id' => $id, 'password' => md5($password)))->save();
     return result_data(1, '密码修改成功!');
 }