示例#1
0
 public function saveConfig($arr)
 {
     $webid = ARR::get($arr, 'webid');
     foreach ($arr as $k => $v) {
         /* if(!get_magic_quotes_gpc())
            {
                $v = addslashes($v);
            }
            else
            {
                $v = $v;
            }*/
         if ($k !== 'webid') {
             $row = $this->where('webid', '=', $webid)->and_where('varname', '=', $k)->find();
             if (isset($row->id)) {
                 //$v = $k=='cfg_tongjicode' ? addslashes($v) : $v;
                 $row->value = $v;
                 $row->update();
             } else {
                 $row->varname = $k;
                 $row->value = $v;
                 $row->webid = $webid;
                 $row->create();
             }
             $row->clear();
         }
     }
     $this->writeConfig($webid);
     return true;
 }
示例#2
0
 public function action_ajax_get_attrchild()
 {
     $pid = ARR::get($_POST, 'pid');
     $typeid = ARR::get($_POST, 'typeid');
     $list = Model_Attrlist::getAttr($typeid, $pid);
     echo json_encode($list);
 }
示例#3
0
 public function action_index()
 {
     $action = $this->params['action'];
     if (empty($action)) {
         $this->display('stourtravel/tools/tagword_list');
     } else {
         if ($action == 'read') {
             $start = Arr::get($_GET, 'start');
             $limit = Arr::get($_GET, 'limit');
             $keyword = ARR::get($_GET, 'keyword');
             $channelid = ARR::get($_GET, 'channelid');
             $channelid = empty($channelid) ? 1 : $channelid;
             $type = ARR::get($_GET, 'type');
             $type = empty($type) ? 0 : $type;
             $fieldname = $this->channelArr[$channelid]['fieldname'];
             $tablename = $this->channelArr[$channelid]['table'];
             $w = "where id > 0 ";
             $w .= $type ? "and (tagword is  NULL or tagword = '')" : "";
             $w .= $keyword ? " and tagword like '%{$keyword}%'" : '';
             $sql = "select id, aid, {$fieldname} as title,tagword  from  {$tablename} {$w} limit {$start},{$limit}";
             $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num  from  {$tablename} {$w} ")->execute()->as_array();
             $list = DB::query(Database::SELECT, $sql)->execute()->as_array();
             $new_list = array();
             foreach ($list as $k => $v) {
                 $new_list[] = $v;
             }
             $result['total'] = $totalcount_arr[0]['num'];
             $result['lists'] = $new_list;
             $result['success'] = true;
             echo json_encode($result);
         } else {
             if ($action == 'save') {
             } else {
                 if ($action == 'update') {
                     $id = Arr::get($_POST, 'id');
                     $field = Arr::get($_POST, 'field');
                     $val = Arr::get($_POST, 'val');
                     $channelid = $this->params['channelid'];
                     $tablename = $this->channelArr[$channelid]['table'];
                     $modelname = str_replace('sline_', '', $tablename);
                     if (is_numeric($id)) {
                         $model = ORM::factory($modelname)->where('id', '=', $id)->find();
                     }
                     if ($model->id) {
                         $model->{$field} = $val;
                         $model->update();
                         if ($model->saved()) {
                             echo 'ok';
                         } else {
                             echo 'no';
                         }
                     }
                 }
             }
         }
     }
 }
示例#4
0
 public function save($data)
 {
     $webname = ARR::get($data, 'webname');
     $id = ARR::get($data, 'id');
     for ($i = 0; isset($webname[$i]); $i++) {
         $obj = $this->where('id', '=', $id[$i])->find();
         $obj->webname = $webname[$i];
         $obj->update();
         $obj->clear();
     }
 }
示例#5
0
 public function saveNav($data)
 {
     $servername = ARR::get($data, 'servername');
     $displayorder = ARR::get($data, 'displayorder');
     $id = ARR::get($data, 'id');
     $isdisplay = ARR::get($data, 'isdisplay');
     for ($i = 0; isset($servername[$i]); $i++) {
         $obj = $this->where('id', '=', $id[$i])->find();
         $obj->servername = $servername[$i];
         $obj->displayorder = $displayorder[$i];
         $obj->isdisplay = $isdisplay[$i];
         $obj->update();
         $obj->clear();
     }
 }
示例#6
0
 public function saveNav($data)
 {
     $shortname = ARR::get($data, 'shortname');
     $displayorder = ARR::get($data, 'displayorder');
     $linktitle = ARR::get($data, 'linktitle');
     $id = ARR::get($data, 'id');
     $kind = ARR::get($data, 'kind');
     $isopen = ARR::get($data, 'isopen');
     for ($i = 0; isset($shortname[$i]); $i++) {
         $obj = $this->where('id', '=', $id[$i])->find();
         $obj->shortname = $shortname[$i];
         $obj->displayorder = $displayorder[$i];
         $obj->kind = $kind[$i];
         $obj->linktitle = $linktitle[$i];
         $obj->isopen = $isopen[$i];
         $obj->update();
         $obj->clear();
     }
 }
示例#7
0
 public function action_ajax_check()
 {
     $field = $this->params['type'];
     $val = ARR::get($_POST, 'val');
     //值
     $id = ARR::get($_POST, 'id');
     //会员id
     $flag = Model_Tool_Link::checkExist($field, $val, $id);
     echo $flag;
 }
示例#8
0
 public function action_ajax_save()
 {
     $action = ARR::get($_POST, 'action');
     //当前操作
     $id = ARR::get($_POST, 'id');
     $status = false;
     //添加操作
     if ($action == 'add' && empty($id)) {
         $model = ORM::factory('icon');
     } else {
         $model = ORM::factory('icon')->where('id', '=', $id)->find();
     }
     $model->kind = ARR::get($_POST, 'kind');
     $model->picurl = ARR::get($_POST, 'litpic');
     if ($action == 'add' && empty($id)) {
         $model->create();
     } else {
         $model->update();
     }
     if ($model->saved()) {
         if ($action == 'add') {
             $productid = $model->id;
             //插入的产品id
         } else {
             $productid = null;
         }
         $status = true;
     }
     echo json_encode(array('status' => $status, 'productid' => $productid));
 }
示例#9
0
 public function commonSave($factory, $data)
 {
     $kindname = ARR::get($data, 'kindname');
     $displayorder = ARR::get($data, 'displayorder');
     $newname = ARR::get($data, 'newname');
     $newdisplayorder = ARR::get($data, 'newdisplayorder');
     $id = ARR::get($data, 'id');
     for ($i = 0; isset($kindname[$i]); $i++) {
         $obj = ORM::factory($factory)->where('id', '=', $id[$i])->find();
         $obj->kindname = $kindname[$i];
         $obj->displayorder = $displayorder[$i];
         $obj->update();
         $obj->clear();
     }
     for ($i = 0; isset($newname[$i]); $i++) {
         $model = ORM::factory($factory);
         $model->kindname = $newname[$i];
         $model->displayorder = $newdisplayorder[$i];
         $model->create();
         $model->clear();
     }
 }
示例#10
0
 public function action_ajax_updatesort()
 {
     $webid = ARR::get($_POST, 'webid');
     $pageid = ARR::get($_POST, 'pageid');
     $orderlist = ARR::get($_POST, 'orderlist');
     $model = ORM::factory('module_config')->where('webid', '=', $webid)->and_where('aid', '=', $pageid)->find();
     $model->moduleids = $orderlist;
     $model->save();
     echo $model->saved();
 }
示例#11
0
 public function action_ajax_page_save()
 {
     $flag = 0;
     $content = ARR::get($_POST, 'content');
     $filename = ARR::get($_POST, 'filename');
     $issline = $_POST['issline'];
     $content = stripslashes($content);
     $basefolder = $issline == 1 ? BASEPATH . '/templets/sline/uploadtemplets/' : BASEPATH . '/templets/smore/uploadtemplets/';
     $file = $basefolder . $filename;
     if (strpos(realpath($file), 'uploadtemplets') === false) {
         exit;
     }
     if (file_put_contents($file, $content)) {
         $flag = true;
     }
     echo json_encode(array('status' => $flag));
 }
示例#12
0
 public function action_ajax_upload_templet()
 {
     $basefolder = BASEPATH . '/templets/smore/uploadtemplets/';
     if (!file_exists($basefolder)) {
         mkdir($basefolder);
     }
     $zipfolder = $basefolder . 'zip/';
     if (!file_exists($zipfolder)) {
         mkdir($zipfolder);
     }
     $pageid = ARR::get($_POST, 'pageid');
     $filedata = ARR::get($_FILES, 'filedata');
     $storepath = $zipfolder . $filedata['name'];
     $out = array();
     if (move_uploaded_file($filedata['tmp_name'], $storepath)) {
         if (self::extractTemplet($storepath, $basefolder)) {
             $templetname = current(explode('.', $filedata['name']));
             //模板名称
             $model = ORM::factory('page_config')->where('path', '=', $templetname)->find();
             $model->pageid = $pageid;
             $model->path = $templetname;
             $model->isuse = 0;
             $model->save();
             if ($model->saved()) {
                 $out['status'] = true;
                 $out['id'] = $model->id;
                 $out['path'] = $model->path;
                 $out['isuse'] = 0;
             }
         }
     } else {
         $out['status'] = false;
     }
     echo json_encode($out);
 }
示例#13
0
 public function action_ajax_getfooternav()
 {
     $webid = ARR::get($_GET, 'webid');
     $model = new Model_FooterNav();
     $arr = $model->getFooterNav($webid);
     $out = array();
     foreach ($arr as $row) {
         $openstatus = $row['isdisplay'] ? Common::getIco('show') : Common::getIco('hide');
         $tr = '
               <tr>
               <td height="40" align="center"><input type="text"  name="displayorder[]" class="tb-text text_60 al" value="' . $row['displayorder'] . '" /></td>
               <td><input type="text"  name="servername[]" class="tb-text text_300 pl-5" value="' . $row['servername'] . '" /></td>
               <td align="center" onclick="changeShow(this)">' . $openstatus . '<input type="hidden" name="isdisplay[]" value=' . $row['isdisplay'] . '></td>
               <td align="center"><a href="javascript:;" class="row-mod-btn" onclick="edit(' . $row['id'] . ')" title="修改"></a></td>
               <td align="center"><a href="javascript:;" class="row-del-btn" onclick="del(' . $row['id'] . ',this)" title="删除"></a><input type="hidden" name="id[]" value="' . $row['id'] . '"/></td>
             </tr>
         ';
         array_push($out, $tr);
     }
     echo json_encode(array('trlist' => $out));
 }
示例#14
0
 public function action_ajax_config_save()
 {
     $typeid = ARR::get($_POST, 'typeid');
     //$table = self::$table_arr[$typeid];
     $table = Model_Attrlist::getAttrTable($typeid);
     $id = ARR::get($_POST, 'attrid');
     $desc = ARR::get($_POST, 'description');
     $litpic = ARR::get($_POST, 'litpic');
     $model = ORM::factory($table, $id);
     $model->litpic = $litpic;
     $model->description = $desc;
     $model->update();
     if ($model->saved()) {
         echo json_encode(array('status' => true));
     }
 }
示例#15
0
 public function action_uploaddoc()
 {
     $basefolder = BASEPATH . '/uploads/main/doc/';
     $filedata = ARR::get($_FILES, 'Filedata');
     $path_info = pathinfo($filedata['name']);
     $filename = date('YmdHis');
     $filepath = $basefolder . $filename . '.' . $path_info['extension'];
     //文件上传路径
     $out = array();
     if (move_uploaded_file($filedata['tmp_name'], $filepath)) {
         $out = array('status' => true, 'path' => $GLOBALS['cmsurl'] . '/uploads/main/doc/' . $filename . '.' . $path_info['extension']);
     }
     echo json_encode($out);
 }
示例#16
0
 /**
  * Get the value of a field.
  *
  * @throws  Mango_Exception  field does not exist
  * @param   string  field name
  * @return  mixed
  */
 public function __get($name)
 {
     if (!$this->_init) {
         $this->init();
     }
     if (isset($this->_fields[$name])) {
         $field = $this->_fields[$name];
         if (isset($this->_clean[$name])) {
             // lazy load - field hasn't been loaded yet
             // move value from _clean to _object
             $this->_object[$name] = $this->load_field($name, $this->_clean[$name], TRUE);
             unset($this->_clean[$name]);
         }
         $value = isset($this->_object[$name]) ? $this->_object[$name] : NULL;
         switch ($field['type']) {
             case 'enum':
                 $value = isset($value) && isset($field['values'][$value]) ? $field['values'][$value] : NULL;
                 break;
             case 'set':
             case 'array':
             case 'has_one':
             case 'has_many':
                 if ($value === NULL) {
                     // 'secretly' create value - access _object directly, not recorded as change
                     $value = $this->_object[$name] = $this->load_field($name, array());
                 }
                 break;
             case 'counter':
                 if ($value === NULL) {
                     // 'secretly' create counter - access _object directly, not recorded as change
                     $value = $this->_object[$name] = $this->load_field($name, 0);
                 }
                 break;
         }
         if ($value === NULL && isset($field['default'])) {
             $value = $field['default'];
         }
         return $value;
     } elseif (isset($this->_relations[$name])) {
         if (!isset($this->_related[$name])) {
             $relation = $this->_relations[$name];
             switch ($relation['type']) {
                 case 'has_one':
                     $criteria = array($this->_model . '_id' => $this->_id);
                     $limit = 1;
                     break;
                 case 'belongs_to':
                     $id = isset($this->_clean[$name . '_id']) ? $this->_clean[$name . '_id'] : $this->_object[$name . '_id'];
                     $criteria = array('_id' => $id);
                     $limit = 1;
                     break;
                 case 'has_many':
                     $criteria = array(ARR::get($relation, 'relation_name', $this->_model) . '_id' => $this->_id);
                     $limit = FALSE;
                     break;
                 case 'has_and_belongs_to_many':
                     $criteria = array('_id' => array('$in' => $this->__get($name . '_ids')->as_array()));
                     $limit = FALSE;
                     break;
             }
             $parameters = array('limit' => $limit, 'criteria' => $criteria);
             $this->_related[$name] = Mango::factory($relation['model'])->load($parameters);
         }
         return $this->_related[$name];
     } else {
         throw new Mango_Exception(':name model does not have a field :field', array(':name' => $this->_model, ':field' => $name));
     }
 }
示例#17
0
 public function action_index()
 {
     $action = $this->params['action'];
     if (empty($action)) {
         $this->display('stourtravel/tools/visit_list');
     } else {
         if ($action == 'read') {
             $start = Arr::get($_GET, 'start');
             $limit = Arr::get($_GET, 'limit');
             $keyword = Arr::get($_GET, 'keyword');
             $sttime = ARR::get($_GET, 'sttime');
             $engine = ARR::get($_GET, 'searchengine');
             $order = 'order by a.access_time desc';
             $w = "where a.id is not null";
             if (!empty($keyword)) {
                 $w .= " and a.keywords like '%{$keyword}%'";
             }
             if (!empty($sttime)) {
                 $sttime = strtotime($sttime);
                 $w .= " and a.access_time >= {$sttime} ";
             }
             if (!empty($ettime)) {
                 $ettime = strtotime($ettime);
                 $w .= " and a.access_time <= {$sttime} ";
             }
             if (!empty($engine)) {
                 $w .= " and a.searchengine = '{$engine}'";
             }
             $sql = "select a.*  from sline_stats as a {$w} {$order} limit {$start},{$limit}";
             $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_stats a {$w} ")->execute()->as_array();
             $list = DB::query(Database::SELECT, $sql)->execute()->as_array();
             $new_list = array();
             foreach ($list as $k => $v) {
                 $v['access_time'] = Common::myDate('Y-m-d H:i:s', $v['access_time']);
                 $v['searchengine'] = $this->getSearchEngine($v['searchengine']);
                 $new_list[] = $v;
             }
             $result['total'] = $totalcount_arr[0]['num'];
             $result['lists'] = $new_list;
             $result['success'] = true;
             echo json_encode($result);
         } else {
             if ($action == 'save') {
             } else {
                 if ($action == 'delete') {
                     $rawdata = file_get_contents('php://input');
                     $data = json_decode($rawdata);
                     $id = $data->id;
                     if (is_numeric($id)) {
                         $model = ORM::factory('stats', $id);
                         $model->delete();
                     }
                 } else {
                     if ($action == 'update') {
                         $id = Arr::get($_POST, 'id');
                         $field = Arr::get($_POST, 'field');
                         $val = Arr::get($_POST, 'val');
                         if (is_numeric($id)) {
                             $model = ORM::factory('stats')->where('id', '=', $id)->find();
                         }
                         if ($model->id) {
                             $model->{$field} = $val;
                             $model->update();
                             if ($model->saved()) {
                                 echo 'ok';
                             } else {
                                 echo 'no';
                             }
                         }
                     }
                 }
             }
         }
     }
 }