コード例 #1
0
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = $name . ' 不符合要求';
         }
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' 不得少于 ' . $minlength . ' 字符');
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' 不得多于 ' . $maxlength . ' 字符');
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         // 唯一性判断,和附加函数验证
         /*$MODEL = getcache('model', 'commons');
         		$this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre.$MODEL[$this->modelid]['tablename'] : $this->db_pre.$MODEL[$this->modelid]['tablename'].'_data';
         		if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage($name.L('the_value_must_not_repeat'));*/
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         // var_dump($this->fields);
         if ($this->fields[$field]['issystem']) {
             $info['system'][$field] = $value;
         } else {
             $info['model'][$field] = $value;
         }
     }
     //颜色选择为隐藏域 在这里进行取值
     $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : '';
     if ($_POST['style_font_weight']) {
         $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
     }
     return $info;
 }
コード例 #2
0
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         //if(!isset($this->fields[$field]) || check_in($_roleid, $this->fields[$field]['unsetroleids']) || check_in($_groupid, $this->fields[$field]['unsetgroupids'])) continue;
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = $name . ' ' . L('not_meet_the_conditions');
         }
         $length = empty($value) ? 0 : strlen($value);
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' ' . L('not_less_than') . ' ' . $minlength . L('characters'));
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' ' . L('not_more_than') . ' ' . $maxlength . L('characters'));
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         $MODEL = getcache('model', 'commons');
         $this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre . $MODEL[$this->modelid]['tablename'] : $this->db_pre . $MODEL[$this->modelid]['tablename'] . '_data';
         if ($this->fields[$field]['isunique'] && $this->db->get_one(array($field => $value), $field) && ROUTE_A != 'edit') {
             showmessage($name . L('the_value_must_not_repeat'));
         }
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         if ($this->fields[$field]['issystem']) {
             $info['system'][$field] = $value;
         } else {
             $info['model'][$field] = $value;
         }
         //颜色选择为隐藏域 在这里进行取值
         $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : '';
         if ($_POST['style_font_weight']) {
             $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
         }
     }
     return $info;
 }
コード例 #3
0
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($this->fields as $field) {
         //if(!isset($this->fields[$field]) || check_in($_roleid, $this->fields[$field]['unsetroleids']) || check_in($_groupid, $this->fields[$field]['unsetgroupids'])) continue;
         $name = $field['name'];
         $minlength = $field['minlength'];
         $maxlength = $field['maxlength'];
         $pattern = $field['pattern'];
         $errortips = $field['errortips'];
         $value = $data[$field['field']];
         //if(empty($errortips)) $errortips = $name.' '.L('not_meet_the_conditions');
         if (empty($errortips)) {
             $errortips = "请输入正确的{$name}";
         }
         $length = is_array($value) ? empty($value) ? 0 : 1 : strlen($value);
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' ' . L('not_less_than') . ' ' . $minlength . L('characters'));
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' ' . L('not_more_than') . ' ' . $maxlength . L('characters'));
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         $func = $field['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field['field'], $value);
         }
         $info[$field['field']] = $value;
         //颜色选择为隐藏域 在这里进行取值
         if ($_POST['style_color']) {
             $info['style'] = $_POST['style_color'];
         }
         if ($_POST['style_font_weight']) {
             $info['style'] = $info['style'] . ';' . strip_tags($_POST['style_font_weight']);
         }
     }
     return $info;
 }
コード例 #4
0
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = $name . ' 不符合要求';
         }
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' 不得少于 ' . $minlength . ' 字符');
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' 不得多于 ' . $maxlength . ' 字符');
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         // 附加函数验证
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         $info['system'][$field] = $value;
     }
     //颜色选择为隐藏域 在这里进行取值
     $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : '';
     if ($_POST['style_font_weight']) {
         $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
     }
     return $info;
 }
コード例 #5
0
 function get($data)
 {
     $this->data = $data = trim_script($data);
     $model_cache = getcache('member_model', 'commons');
     $this->db->table_name = $this->db_pre . $model_cache[$this->modelid]['tablename'];
     $info = array();
     $debar_filed = array('catid', 'title', 'style', 'thumb', 'status', 'islink', 'description');
     if (is_array($data)) {
         foreach ($data as $field => $value) {
             if ($data['islink'] == 1 && !in_array($field, $debar_filed)) {
                 continue;
             }
             $field = safe_replace($field);
             $name = $this->fields[$field]['name'];
             $minlength = $this->fields[$field]['minlength'];
             $maxlength = $this->fields[$field]['maxlength'];
             $pattern = $this->fields[$field]['pattern'];
             $errortips = $this->fields[$field]['errortips'];
             if (empty($errortips)) {
                 $errortips = "{$name} 不符合要求!";
             }
             $length = empty($value) ? 0 : strlen($value);
             if ($minlength && $length < $minlength && !$isimport) {
                 showmessage("{$name} 不得少于 {$minlength} 个字符!");
             }
             if (!array_key_exists($field, $this->fields)) {
                 showmessage('模型中不存在' . $field . '字段');
             }
             if ($maxlength && $length > $maxlength && !$isimport) {
                 showmessage("{$name} 不得超过 {$maxlength} 个字符!");
             } else {
                 str_cut($value, $maxlength);
             }
             if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
                 showmessage($errortips);
             }
             if ($this->fields[$field]['isunique'] && $this->db->get_one(array($field => $value), $field) && ROUTE_A != 'edit') {
                 showmessage("{$name} 的值不得重复!");
             }
             $func = $this->fields[$field]['formtype'];
             if (method_exists($this, $func)) {
                 $value = $this->{$func}($field, $value);
             }
             $info[$field] = $value;
         }
     }
     return $info;
 }
コード例 #6
0
ファイル: index.php プロジェクト: ahmatjan/huluphp
 /**
  *	申请友情链接 
  */
 public function register()
 {
     $siteid = SITEID;
     if (isset($_POST['dosubmit'])) {
         if ($_POST['name'] == "") {
             showmessage(L('sitename_noempty'), "?m=link&c=index&a=register&siteid={$siteid}");
         }
         if ($_POST['url'] == "" || !preg_match('/^http:\\/\\/(.*)/i', $_POST['url'])) {
             showmessage(L('siteurl_not_empty'), "?m=link&c=index&a=register&siteid={$siteid}");
         }
         if (!in_array($_POST['linktype'], array('0', '1'))) {
             $_POST['linktype'] = '0';
         }
         $link_db = pc_base::load_model(link_model);
         $_POST['logo'] = new_html_special_chars($_POST['logo']);
         $logo = safe_replace(strip_tags($_POST['logo']));
         if (!preg_match('/^http:\\/\\/(.*)/i', $logo)) {
             $logo = '';
         }
         $name = safe_replace(strip_tags($_POST['name']));
         $url = safe_replace(strip_tags($_POST['url']));
         $url = trim_script($url);
         if ($_POST['linktype'] == '0') {
             $sql = array('siteid' => $siteid, 'typeid' => intval($_POST['typeid']), 'linktype' => intval($_POST['linktype']), 'name' => $name, 'url' => $url);
         } else {
             $sql = array('siteid' => $siteid, 'typeid' => intval($_POST['typeid']), 'linktype' => intval($_POST['linktype']), 'name' => $name, 'url' => $url, 'logo' => $logo);
         }
         $link_db->insert($sql);
         showmessage(L('add_success'), "?m=link&c=index&siteid={$siteid}");
     } else {
         $setting = getcache('link', 'commons');
         $setting = $setting[$siteid];
         if ($setting['is_post'] == '0') {
             showmessage(L('suspend_application'), HTTP_REFERER);
         }
         $this->type = pc_base::load_model('type_model');
         $types = $this->type->get_types($siteid);
         //获取站点下所有友情链接分类
         pc_base::load_sys_class('form', '', 0);
         $SEO = seo(SITEID, '', L('application_links'), '', '');
         include template('link', 'register');
     }
 }
コード例 #7
0
ファイル: indexs.php プロジェクト: shenhua4286/gxw
 public function addContent()
 {
     //TODO
     $siteids = getcache('category_content', 'commons');
     $catid = intval($_POST['content']['catid']);
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     $category = $CATEGORYS[$catid];
     $modelid = $category['modelid'];
     if (!$modelid) {
         showmessage(L('illegal_parameters'), HTTP_REFERER);
     }
     $this->content_db = pc_base::load_model('content_model');
     $this->content_db->set_model($modelid);
     $table_name = $this->content_db->table_name;
     $fields_sys = $this->content_db->get_fields();
     $this->content_db->table_name = $table_name . '_data';
     $fields_attr = $this->content_db->get_fields();
     $fields = array_merge($fields_sys, $fields_attr);
     $fields = array_keys($fields);
     $content = array();
     foreach ($_POST['content'] as $_k => $_v) {
         if ($_k == 'content') {
             $content[$_k] = remove_xss(strip_tags($_v, '<p><a><br><img><ul><li><div>'));
         } elseif (in_array($_k, $fields)) {
             $content[$_k] = new_html_special_chars(trim_script($_v));
         }
     }
     $_POST['linkurl'] = str_replace(array('"', '(', ')', ",", ' ', '%'), '', new_html_special_chars(strip_tags($_POST['linkurl'])));
     $post_fields = array_keys($_POST['content']);
     $post_fields = array_intersect_assoc($fields, $post_fields);
     $setting = string2array($category['setting']);
     if ($setting['presentpoint'] < 0 && $membercontent['point'] < abs($setting['presentpoint'])) {
         showmessage(L('points_less_than', array('point' => $membercontent['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000);
     }
     // 判断企业组录入是否需要审核
     if ($grouplist[$membercontent['groupid']]['allowpostverify'] || !$setting['workflowid']) {
         $content['status'] = 99;
     } else {
         $content['status'] = -2;
     }
     $content['username'] = $membercontent['username'];
     if (isset($content['title'])) {
         $content['title'] = safe_replace($content['title']);
     }
     $this->content_db->siteid = $siteid;
     $id = $this->content_db->add_content($content);
 }
コード例 #8
0
ファイル: index.php プロジェクト: klj123wan/czsz
 protected function _show_result($status = 0, $msg = '')
 {
     if (CHARSET != 'utf-8') {
         $msg = iconv(CHARSET, 'utf-8', $msg);
     }
     exit(trim_script($_GET['callback']) . '(' . json_encode(array('status' => $status, 'data' => $msg)) . ')');
 }
コード例 #9
0
/**
 * 转义 javascript 代码标记
 *
 * @param $str
 * @return mixed
 */
function trim_script($str)
{
    if (is_array($str)) {
        foreach ($str as $key => $val) {
            $str[$key] = trim_script($val);
        }
    } else {
        $str = preg_replace('/\\<([\\/]?)script([^\\>]*?)\\>/si', '&lt;\\1script\\2&gt;', $str);
        $str = preg_replace('/\\<([\\/]?)iframe([^\\>]*?)\\>/si', '&lt;\\1iframe\\2&gt;', $str);
        $str = preg_replace('/\\<([\\/]?)frame([^\\>]*?)\\>/si', '&lt;\\1frame\\2&gt;', $str);
        $str = str_replace('javascript:', 'javascript:', $str);
    }
    return $str;
}
コード例 #10
0
ファイル: get_linkage.php プロジェクト: panhongsheng/zl_cms
/**
 * 获取地区顶级ID
 * Enter description here ...
 * @param  $linkageid 菜单id
 * @param  $keyid 菜单keyid
 * @param  $callback json生成callback变量
 * @param  $infos 递归返回结果数组
 */
function ajax_gettopparent($linkageid, $keyid, $callback, $infos = array())
{
    $keyid = intval($keyid);
    $linkageid = intval($linkageid);
    if (!$infos) {
        $datas = getcache($keyid, 'linkage');
        $infos = $datas['data'];
    }
    if ($infos[$linkageid]['parentid'] != 0) {
        return ajax_gettopparent($infos[$linkageid]['parentid'], $keyid, $callback, $infos);
    } else {
        echo trim_script($callback) . '(', $linkageid, ')';
        exit;
    }
}
コード例 #11
0
	/**
	 * 添加内容
	 * 
	 * @param $datas
	 * @param $isimport 是否为外部接口导入
	 */
	public function add_content($data,$isimport = 0) {
		if($isimport) $data = new_addslashes($data);
		$this->search_db = pc_base::load_model('search_model');
		$modelid = $this->modelid;
		require_once CACHE_MODEL_PATH.'content_input.class.php';
        require_once CACHE_MODEL_PATH.'content_update.class.php';
		$content_input = new content_input($this->modelid);
		$inputinfo = $content_input->get($data,$isimport);

		$systeminfo = $inputinfo['system'];
		$modelinfo = $inputinfo['model'];

		if($data['inputtime'] && !is_numeric($data['inputtime'])) {
			$systeminfo['inputtime'] = strtotime($data['inputtime']);
		} elseif(!$data['inputtime']) {
			$systeminfo['inputtime'] = SYS_TIME;
		} else {
			$systeminfo['inputtime'] = $data['inputtime'];
		}
		
		//读取模型字段配置中,关于日期配置格式,来组合日期数据
		$this->fields = getcache('model_field_'.$modelid,'model');
		$setting = string2array($this->fields['inputtime']['setting']);
		extract($setting);
		if($fieldtype=='date') {
			$systeminfo['inputtime'] = date('Y-m-d');
		}elseif($fieldtype=='datetime'){
 			$systeminfo['inputtime'] = date('Y-m-d H:i:s');
		}

		if($data['updatetime'] && !is_numeric($data['updatetime'])) {
			$systeminfo['updatetime'] = strtotime($data['updatetime']);
		} elseif(!$data['updatetime']) {
			$systeminfo['updatetime'] = SYS_TIME;
		} else {
			$systeminfo['updatetime'] = $data['updatetime'];
		}
		$systeminfo['username'] = $data['username'] ? $data['username'] : param::get_cookie('admin_username');
		$systeminfo['sysadd'] = defined('IN_ADMIN') ? 1 : 0;
		
		//自动提取摘要
		if(isset($_POST['add_introduce']) && $systeminfo['description'] == '' && isset($modelinfo['content'])) {
			$content = stripslashes($modelinfo['content']);
			$introcude_length = intval($_POST['introcude_length']);
			$systeminfo['description'] = str_cut(str_replace(array("'","\r\n","\t",'[page]','[/page]','&ldquo;','&rdquo;','&nbsp;'), '', strip_tags($content)),$introcude_length);
			$inputinfo['system']['description'] = $systeminfo['description'] = addslashes($systeminfo['description']);
		}
		//自动提取缩略图
		if(isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
			$content = $content ? $content : stripslashes($modelinfo['content']);
			$auto_thumb_no = intval($_POST['auto_thumb_no'])-1;
			if(preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
				$systeminfo['thumb'] = $matches[3][$auto_thumb_no];
			}
		}
		$systeminfo['description'] = str_replace(array('/','\\','#','.',"'"),' ',$systeminfo['description']);
		$systeminfo['keywords'] = str_replace(array('/','\\','#','.',"'"),' ',$systeminfo['keywords']);
		
		//主表
		$tablename = $this->table_name = $this->db_tablepre.$this->model_tablename;
		$id = $modelinfo['id'] = $this->insert($systeminfo,true);
		$this->update($systeminfo,array('id'=>$id));
		//更新URL地址
		if($data['islink']==1) {
			$urls[0] = trim_script($_POST['linkurl']);
			$urls[0] = remove_xss($urls[0]);
			
			$urls[0] = str_replace(array('select ',')','\\','#',"'"),' ',$urls[0]);
		} else {
			$urls = $this->url->show($id, 0, $systeminfo['catid'], $systeminfo['inputtime'], $data['prefix'],$inputinfo,'add');
		}
		$this->table_name = $tablename;
		$this->update(array('url'=>$urls[0]),array('id'=>$id));
		//附属表
		$this->table_name = $this->table_name.'_data';
		$this->insert($modelinfo);
		//添加统计
		$this->hits_db = pc_base::load_model('hits_model');
		$hitsid = 'c-'.$modelid.'-'.$id;
		$this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$systeminfo['catid'],'updatetime'=>SYS_TIME));
		if($data['status']==99) {
			//更新到全站搜索
			$this->search_api($id,$inputinfo);
		}
		//更新栏目统计数据
		$this->update_category_items($systeminfo['catid'],'add',1);
		//调用 update
		$content_update = new content_update($this->modelid,$id);
		//合并后,调用update
		$merge_data = array_merge($systeminfo,$modelinfo);
		$merge_data['posids'] = $data['posids'];
		$content_update->update($merge_data);
		
		//发布到审核列表中
		if(!defined('IN_ADMIN') || $data['status']!=99) {
			$this->content_check_db = pc_base::load_model('content_check_model');
			$check_data = array(
				'checkid'=>'c-'.$id.'-'.$modelid,
				'catid'=>$systeminfo['catid'],
				'siteid'=>$this->siteid,
				'title'=>$systeminfo['title'],
				'username'=>$systeminfo['username'],
				'inputtime'=>$systeminfo['inputtime'],
				'status'=>$data['status'],
				);
			$this->content_check_db->insert($check_data);
		}
		//END发布到审核列表中
		if(!$isimport) {
			$html = pc_base::load_app_class('html', 'content');
			$urls['data']['system']['id'] = $id;
			if($urls['content_ishtml'] && $data['status']==99) $html->show($urls[1],$urls['data']);
			$catid = $systeminfo['catid'];
		}
		//发布到其他栏目
		if($id && isset($_POST['othor_catid']) && is_array($_POST['othor_catid'])) {
			$linkurl = $urls[0];
			$r = $this->get_one(array('id'=>$id));
			foreach ($_POST['othor_catid'] as $cid=>$_v) {
				$this->set_catid($cid);
				$mid = $this->category[$cid]['modelid'];
				if($modelid==$mid) {
					//相同模型的栏目插入新的数据
					$inputinfo['system']['catid'] = $systeminfo['catid'] = $cid;
					$newid = $modelinfo['id'] = $this->insert($systeminfo,true);
					$this->table_name = $tablename.'_data';
					$this->insert($modelinfo);
					if($data['islink']==1) {
						$urls = $_POST['linkurl'];
						$urls = str_replace(array('select ',')','\\','#',"'"),' ',$urls);
					} else {
						$urls = $this->url->show($newid, 0, $cid, $systeminfo['inputtime'], $data['prefix'],$inputinfo,'add');
					}
					$this->table_name = $tablename;
					$this->update(array('url'=>$urls[0]),array('id'=>$newid));
					//发布到审核列表中
					if($data['status']!=99) {
						$check_data = array(
							'checkid'=>'c-'.$newid.'-'.$mid,
							'catid'=>$cid,
							'siteid'=>$this->siteid,
							'title'=>$systeminfo['title'],
							'username'=>$systeminfo['username'],
							'inputtime'=>$systeminfo['inputtime'],
							'status'=>1,
							);
						$this->content_check_db->insert($check_data);
					}
					if($urls['content_ishtml'] && $data['status']==99) $html->show($urls[1],$urls['data']);
				} else {
					//不同模型插入转向链接地址
					$newid = $this->insert(
					array('title'=>$systeminfo['title'],
						'style'=>$systeminfo['style'],
						'thumb'=>$systeminfo['thumb'],
						'keywords'=>$systeminfo['keywords'],
						'description'=>$systeminfo['description'],
						'status'=>$systeminfo['status'],
						'catid'=>$cid,'url'=>$linkurl,
						'sysadd'=>1,
						'username'=>$systeminfo['username'],
						'inputtime'=>$systeminfo['inputtime'],
						'updatetime'=>$systeminfo['updatetime'],
						'islink'=>1
					),true);
					$this->table_name = $this->table_name.'_data';
					$this->insert(array('id'=>$newid));
					//发布到审核列表中
					if($data['status']!=99) {
						$check_data = array(
							'checkid'=>'c-'.$newid.'-'.$mid,
							'catid'=>$systeminfo['catid'],
							'siteid'=>$this->siteid,
							'title'=>$systeminfo['title'],
							'username'=>$systeminfo['username'],
							'inputtime'=>$systeminfo['inputtime'],
							'status'=>1,
							);
						$this->content_check_db->insert($check_data);
					}
				}
				$hitsid = 'c-'.$mid.'-'.$newid;
				$this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$cid,'updatetime'=>SYS_TIME));
			}
		}
		//END 发布到其他栏目
		//更新附件状态
		if(pc_base::load_config('system','attachment_stat')) {
			$this->attachment_db = pc_base::load_model('attachment_model');
			$this->attachment_db->api_update('','c-'.$systeminfo['catid'].'-'.$id,2);
		}
		//生成静态
		if(!$isimport && $data['status']==99) {
			//在添加和修改内容处定义了 INDEX_HTML
			if(defined('INDEX_HTML')) $html->index();
			if(defined('RELATION_HTML')) $html->create_relation_html($catid);
		}
		return $id;
	}
コード例 #12
0
 function get($data, $isimport = 0)
 {
     $this->data = $data = trim_script($data);
     $info = array();
     foreach ($data as $field => $value) {
         if (!isset($this->fields[$field]) && !check_in($field, 'paytype,paginationtype,maxcharperpage,id')) {
             continue;
         }
         if (defined('IN_ADMIN')) {
             if (check_in($_SESSION['roleid'], $this->fields[$field]['unsetroleids'])) {
                 continue;
             }
         } else {
             $_groupid = param::get_cookie('_groupid');
             if (check_in($_groupid, $this->fields[$field]['unsetgroupids'])) {
                 continue;
             }
         }
         $name = $this->fields[$field]['name'];
         $minlength = $this->fields[$field]['minlength'];
         $maxlength = $this->fields[$field]['maxlength'];
         $pattern = $this->fields[$field]['pattern'];
         $errortips = $this->fields[$field]['errortips'];
         if (empty($errortips)) {
             $errortips = "请输入正确的{$name}";
         }
         //die;
         $length = empty($value) ? 0 : (is_string($value) ? strlen($value) : count($value));
         if ($minlength && $length < $minlength) {
             if ($isimport) {
                 return false;
             } else {
                 showmessage($name . ' ' . L('not_less_than') . ' ' . $minlength . L('characters'));
             }
         }
         if ($maxlength && $length > $maxlength) {
             if ($isimport) {
                 $value = str_cut($value, $maxlength, '');
             } else {
                 showmessage($name . ' ' . L('not_more_than') . ' ' . $maxlength . L('characters'));
             }
         } elseif ($maxlength) {
             $value = str_cut($value, $maxlength, '');
         }
         if ($pattern && $length && !preg_match($pattern, $value) && !$isimport) {
             showmessage($errortips);
         }
         $MODEL = getcache('model', 'commons');
         $this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre . $MODEL[$this->modelid]['tablename'] : $this->db_pre . $MODEL[$this->modelid]['tablename'] . '_data';
         if ($this->fields[$field]['isunique'] && $this->db->get_one(array($field => $value), $field) && ROUTE_A != 'edit') {
             showmessage($name . L('the_value_must_not_repeat'));
         }
         $func = $this->fields[$field]['formtype'];
         if (method_exists($this, $func)) {
             $value = $this->{$func}($field, $value);
         }
         if ($this->fields[$field]['issystem']) {
             $info['system'][$field] = $value;
         } else {
             $info['model'][$field] = $value;
         }
         //颜色选择为隐藏域 在这里进行取值
         $info['system']['style'] = $_POST['style_color'] && preg_match('/^#([0-9a-z]+)/i', $_POST['style_color']) ? $_POST['style_color'] : '';
         if ($_POST['style_font_weight'] == 'bold') {
             $info['system']['style'] = $info['system']['style'] . ';' . strip_tags($_POST['style_font_weight']);
         }
     }
     return $info;
 }
コード例 #13
0
 public function add_content()
 {
     // 主表
     $modelid = $this->modelid;
     $tablename = $this->trueTableName;
     $data = $_POST['info'];
     $data['relation'] = array2string($data['relation']);
     require FIELDS_PATH . 'content_input.class.php';
     $content_input = new \content_input($this->modelid);
     $inputinfo = $content_input->get($data);
     $systeminfo = $this->parse_field($inputinfo['system']);
     $systeminfo = array_merge($systeminfo, array('username' => $_SESSION['user_info']['account'], 'siteid' => get_siteid()));
     if ($data['inputtime'] && !is_numeric($data['inputtime'])) {
         $systeminfo['inputtime'] = strtotime($data['inputtime']);
     } elseif (!$data['inputtime']) {
         $systeminfo['inputtime'] = time();
     } else {
         $systeminfo['inputtime'] = $data['inputtime'];
     }
     $systeminfo['sysadd'] = defined('IN_ADMIN') ? 1 : 0;
     // $systeminfo = array_map('strip_tags', $systeminfo);
     $this->startTrans();
     if (($contentid = $this->add($systeminfo)) !== false) {
         // 更新URL地址
         if ($data['islink'] == 1) {
             $url = trim_script($_POST['linkurl']);
             $url = str_replace(array('select ', ')', '\\', '#', "'"), ' ', $urls[0]);
         } else {
             $siteinfo = get_site_info($systeminfo['siteid']);
             $url = U(C("DEFAULT_GROUP") . '/Content/show@' . $siteinfo['url'], 'catid=' . $systeminfo['catid'] . '&id=' . $contentid);
             // $url = U('Content/show','catid='.$systeminfo['catid'].'&id='.$contentid);
         }
         $this->where(array('id' => $contentid))->save(array('url' => $url));
         // 附表
         $this->trueTableName = $this->trueTableName . "_data";
         // $content_data = array('id' => $contentid ,'content' => $data['content'], 'relation' => $data['relation'], 'copyfrom' => $data['copyfrom'], 'allow_comment' => $data['allow_comment']);
         $this->set_field();
         $content_data = $this->parse_field($inputinfo['model']);
         $content_data['id'] = $contentid;
         if ($this->add($content_data) == false) {
             $this->rollback();
             return false;
         }
         // 发布到推荐位
         if ($systeminfo['posids']) {
             foreach ($data['posids'] as $key => $posid) {
                 if ($posid > 0) {
                     $position_data[] = array('id' => $contentid, 'catid' => $systeminfo['catid'], 'posid' => $posid, 'modelid' => $modelid, 'module' => 'content', 'thumb' => $systeminfo['thumb'], 'siteid' => $systeminfo['siteid'], 'listorder' => $contentid, 'data' => array2string(array('title' => $systeminfo['title'], 'url' => $url, 'description' => $systeminfo['description'], 'inputtime' => $systeminfo['inputtime']), true));
                 }
             }
             if (!empty($position_data)) {
                 if (D("PositionData")->addAll($position_data) === false) {
                     $this->rollback();
                     return false;
                 }
             }
         }
         // END 发布到推荐位
         //发布到其他栏目
         if ($contentid && isset($_POST['othor_catid']) && is_array($_POST['othor_catid'])) {
             $linkurl = $url;
             foreach ($_POST['othor_catid'] as $cid => $_v) {
                 $this->set_catid($cid);
                 $mid = $this->category[$cid]['modelid'];
                 echo $mid;
                 if ($modelid == $mid) {
                     //相同模型的栏目插入新的数据
                     $systeminfo['catid'] = $cid;
                     $this->set_field();
                     $content_data = $this->parse_field($systeminfo);
                     $newid = $content_data['id'] = $this->add($systeminfo);
                     if ($newid == false) {
                         $this->rollback();
                         echo '11' . $this->getLastSql();
                         exit;
                         return false;
                     }
                     // echo $this->getLastSql();
                     $this->trueTableName = $this->trueTableName . '_data';
                     $this->set_field();
                     $content_data = $this->parse_field($inputinfo['model']);
                     if ($this->add($content_data) == false) {
                         $this->rollback();
                         echo '22' . $this->getLastSql();
                         exit;
                         return false;
                     }
                     if ($data['islink'] == 1) {
                         $url = $_POST['linkurl'];
                         $url = str_replace(array('select ', ')', '\\', '#', "'"), ' ', $url);
                     } else {
                         $url = U(C("DEFAULT_GROUP") . '/Content/show', 'catid=' . $systeminfo['catid'] . '&id=' . $newid);
                     }
                     $this->trueTableName = $tablename;
                     $this->set_field();
                     $this->where(array('id' => $newid))->save(array('url' => $url));
                 } else {
                     //不同模型插入转向链接地址
                     $systeminfo['catid'] = $cid;
                     $systeminfo['url'] = $linkurl;
                     $systeminfo['sysadd'] = 1;
                     $systeminfo['islink'] = 1;
                     $this->set_field();
                     $content_data = $this->parse_field($systeminfo);
                     $newid = $this->add($systeminfo);
                     if ($newid == false) {
                         $this->rollback();
                         return false;
                     }
                     $this->trueTableName = $this->trueTableName . '_data';
                     if ($this->add(array('id' => $newid)) == fasle) {
                         $this->rollback();
                         return false;
                     }
                 }
             }
         }
         //END 发布到其他栏目
         $this->commit();
     } else {
         $this->rollback();
     }
     return $contentid;
 }
コード例 #14
0
ファイル: get_menu.php プロジェクト: jiangwuzhang/phpcms
/**
 * 获取地区顶级ID
 * Enter description here ...
 * @param  $linkageid 菜单id
 * @param  $keyid 菜单keyid
 * @param  $callback json生成callback变量
 * @param  $infos 递归返回结果数组
 */
function ajax_gettopparent($id, $keyid, $callback, $path, $infos = array())
{
    $path = str_replace(array('/', '//'), '', $path);
    $keyid = str_replace(array('/', '//'), '', $keyid);
    $id = intval($id);
    if (!$infos) {
        $infos = getcache($keyid, $path);
    }
    if ($infos[$id]['parentid'] != 0) {
        return ajax_gettopparent($infos[$id]['parentid'], $keyid, $callback, $path, $infos);
    } else {
        echo trim_script($callback) . '(', $id, ')';
        exit;
    }
}
コード例 #15
0
ファイル: content.php プロジェクト: boylzj/omguitar
 /**
  * 编辑内容
  */
 public function edit()
 {
     $_username = $this->memberinfo['username'];
     if (isset($_POST['dosubmit'])) {
         $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
         $siteids = getcache('category_content', 'commons');
         $siteid = $siteids[$catid];
         $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
         $category = $CATEGORYS[$catid];
         if ($category['type'] == 0) {
             $id = intval($_POST['id']);
             $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
             $this->content_db = pc_base::load_model('content_model');
             $modelid = $category['modelid'];
             $this->content_db->set_model($modelid);
             //判断会员组投稿是否需要审核
             $memberinfo = $this->memberinfo;
             $grouplist = getcache('grouplist');
             $setting = string2array($category['setting']);
             if (!$grouplist[$memberinfo['groupid']]['allowpostverify'] || $setting['workflowid']) {
                 $_POST['info']['status'] = 1;
             }
             $info = array();
             foreach ($_POST['info'] as $_k => $_v) {
                 if ($_k == 'content') {
                     $_POST['info'][$_k] = strip_tags($_v, '<p><a><br><img><ul><li><div>');
                 } elseif (in_array($_k, $fields)) {
                     $_POST['info'][$_k] = new_html_special_chars(trim_script($_v));
                 }
             }
             $_POST['linkurl'] = str_replace(array('"', '(', ')', ",", ' ', '%'), '', new_html_special_chars(strip_tags($_POST['linkurl'])));
             $this->content_db->edit_content($_POST['info'], $id);
             $forward = $_POST['forward'];
             showmessage(L('update_success'), $forward);
         }
     } else {
         $show_header = $show_dialog = $show_validator = '';
         $temp_language = L('news', '', 'content');
         //设置cookie 在附件添加处调用
         param::set_cookie('module', 'content');
         $id = intval($_GET['id']);
         if (isset($_GET['catid']) && $_GET['catid']) {
             $catid = $_GET['catid'] = intval($_GET['catid']);
             param::set_cookie('catid', $catid);
             $siteids = getcache('category_content', 'commons');
             $siteid = $siteids[$catid];
             $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
             $category = $CATEGORYS[$catid];
             if ($category['type'] == 0) {
                 $modelid = $category['modelid'];
                 $this->model = getcache('model', 'commons');
                 $this->content_db = pc_base::load_model('content_model');
                 $this->content_db->set_model($modelid);
                 $this->content_db->table_name = $this->content_db->db_tablepre . $this->model[$modelid]['tablename'];
                 $r = $this->content_db->get_one(array('id' => $id, 'username' => $_username, 'sysadd' => 0));
                 if (!$r) {
                     showmessage(L('illegal_operation'));
                 }
                 if ($r['status'] == 99) {
                     showmessage(L('has_been_verified'));
                 }
                 $this->content_db->table_name = $this->content_db->table_name . '_data';
                 $r2 = $this->content_db->get_one(array('id' => $id));
                 $data = array_merge($r, $r2);
                 require CACHE_MODEL_PATH . 'content_form.class.php';
                 $content_form = new content_form($modelid, $catid, $CATEGORYS);
                 $forminfos_data = $content_form->get($data);
                 $forminfos = array();
                 foreach ($forminfos_data as $_fk => $_fv) {
                     if ($_fv['isomnipotent']) {
                         continue;
                     }
                     if ($_fv['formtype'] == 'omnipotent') {
                         foreach ($forminfos_data as $_fm => $_fm_value) {
                             if ($_fm_value['isomnipotent']) {
                                 $_fv['form'] = str_replace('{' . $_fm . '}', $_fm_value['form'], $_fv['form']);
                             }
                         }
                     }
                     $forminfos[$_fk] = $_fv;
                 }
                 $formValidator = $content_form->formValidator;
                 include template('member', 'content_publish');
             }
         }
         header("Cache-control: private");
     }
 }
コード例 #16
0
ファイル: content.php プロジェクト: pondyond/phpcmsv9
 public function publish()
 {
     $memberinfo = $this->memberinfo;
     $grouplist = getcache('grouplist');
     //判断会员组是否允许投稿
     if (!$grouplist[$memberinfo['groupid']]['allowpost']) {
         showmessage(L('member_group') . L('publish_deny'), HTTP_REFERER);
     }
     //判断每日投稿数
     $this->content_check_db = pc_base::load_model('content_check_model');
     $todaytime = strtotime(date('y-m-d', SYS_TIME));
     $_username = $this->memberinfo['username'];
     $allowpostnum = $this->content_check_db->count("`inputtime` > {$todaytime} AND `username`='{$_username}'");
     if ($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) {
         showmessage(L('allowpostnum_deny') . $grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER);
     }
     $siteids = getcache('category_content', 'commons');
     header("Cache-control: private");
     if (isset($_POST['dosubmit'])) {
         $catid = intval($_POST['info']['catid']);
         $siteid = $siteids[$catid];
         $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
         $category = $CATEGORYS[$catid];
         $modelid = $category['modelid'];
         if (!$modelid) {
             showmessage(L('illegal_parameters'), HTTP_REFERER);
         }
         $this->content_db = pc_base::load_model('content_model');
         $this->content_db->set_model($modelid);
         $table_name = $this->content_db->table_name;
         $fields_sys = $this->content_db->get_fields();
         $this->content_db->table_name = $table_name . '_data';
         $fields_attr = $this->content_db->get_fields();
         $fields = array_merge($fields_sys, $fields_attr);
         $fields = array_keys($fields);
         $info = array();
         foreach ($_POST['info'] as $_k => $_v) {
             if (in_array($_k, $fields)) {
                 $info[$_k] = trim_script(htmlspecialchars($_v));
             }
         }
         $post_fields = array_keys($_POST['info']);
         $post_fields = array_intersect_assoc($fields, $post_fields);
         $setting = string2array($category['setting']);
         if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) {
             showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000);
         }
         //判断会员组投稿是否需要审核
         if ($grouplist[$memberinfo['groupid']]['allowpostverify'] || !$setting['workflowid']) {
             $info['status'] = 99;
         } else {
             $info['status'] = 1;
         }
         $info['username'] = $memberinfo['username'];
         if (isset($info['title'])) {
             $info['title'] = safe_replace($info['title']);
         }
         $this->content_db->siteid = $siteid;
         $id = $this->content_db->add_content($info);
         //检查投稿奖励或扣除积分
         if ($info['status'] == 99) {
             $flag = $catid . '_' . $id;
             if ($setting['presentpoint'] > 0) {
                 pc_base::load_app_class('receipts', 'pay', 0);
                 receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']);
             } else {
                 pc_base::load_app_class('spend', 'pay', 0);
                 spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
             }
         }
         //缓存结果
         $model_cache = getcache('model', 'commons');
         $infos = array();
         foreach ($model_cache as $modelid => $model) {
             if ($model['siteid'] == $siteid) {
                 $datas = array();
                 $this->content_db->set_model($modelid);
                 $datas = $this->content_db->select(array('username' => $memberinfo['username'], 'sysadd' => 0), 'id,catid,title,url,username,sysadd,inputtime,status', 100, 'id DESC');
                 if ($datas) {
                     $infos = array_merge($infos, $datas);
                 }
             }
         }
         setcache('member_' . $memberinfo['userid'] . '_' . $siteid, $infos, 'content');
         //缓存结果 END
         if ($info['status'] == 99) {
             showmessage(L('contributors_success'), APP_PATH . 'index.php?m=member&c=content&a=published');
         } else {
             showmessage(L('contributors_checked'), APP_PATH . 'index.php?m=member&c=content&a=published');
         }
     } else {
         $show_header = $show_dialog = $show_validator = '';
         $temp_language = L('news', '', 'content');
         $sitelist = getcache('sitelist', 'commons');
         if (!isset($_GET['siteid']) && count($sitelist) > 1) {
             include template('member', 'content_publish_select_model');
             exit;
         }
         //设置cookie 在附件添加处调用
         param::set_cookie('module', 'content');
         $siteid = intval($_GET['siteid']);
         if (!$siteid) {
             $siteid = 1;
         }
         $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
         $priv_db = pc_base::load_model('category_priv_model');
         //加载栏目权限表数据模型
         foreach ($CATEGORYS as $catid => $cat) {
             if ($cat['siteid'] == $siteid && $cat['child'] == 0 && $cat['type'] == 0 && $priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) {
                 break;
             }
         }
         $catid = $_GET['catid'] ? intval($_GET['catid']) : $catid;
         if (!$catid) {
             showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member');
         }
         //判断本栏目是否允许投稿
         if (!$priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) {
             showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member');
         }
         $category = $CATEGORYS[$catid];
         if ($category['siteid'] != $siteid) {
             showmessage(L('site_no_category'), '?m=member&c=content&a=publish');
         }
         $setting = string2array($category['setting']);
         if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) {
             showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000);
         }
         if ($category['type'] != 0) {
             showmessage(L('illegal_operation'));
         }
         $modelid = $category['modelid'];
         $model_arr = getcache('model', 'commons');
         $MODEL = $model_arr[$modelid];
         unset($model_arr);
         require CACHE_MODEL_PATH . 'content_form.class.php';
         $content_form = new content_form($modelid, $catid, $CATEGORYS);
         $forminfos_data = $content_form->get();
         $forminfos = array();
         foreach ($forminfos_data as $_fk => $_fv) {
             if ($_fv['isomnipotent']) {
                 continue;
             }
             if ($_fv['formtype'] == 'omnipotent') {
                 foreach ($forminfos_data as $_fm => $_fm_value) {
                     if ($_fm_value['isomnipotent']) {
                         $_fv['form'] = str_replace('{' . $_fm . '}', $_fm_value['form'], $_fv['form']);
                     }
                 }
             }
             $forminfos[$_fk] = $_fv;
         }
         $formValidator = $content_form->formValidator;
         //去掉栏目id
         unset($forminfos['catid']);
         $workflowid = $setting['workflowid'];
         header("Cache-control: private");
         $template = $MODEL['member_add_template'] ? $MODEL['member_add_template'] : 'content_publish';
         include template('member', $template);
     }
 }
コード例 #17
0
ファイル: add_favorite.php プロジェクト: cfhb/MIS
    $title = addslashes(urldecode($title));
    if (CHARSET != 'utf-8') {
        $title = iconv('utf-8', CHARSET, $title);
        $title = addslashes($title);
    }
    $title = htmlspecialchars($title);
    $url = safe_replace(addslashes(urldecode($_GET['url'])));
    $url = trim_script($url);
}
$_GET['callback'] = safe_replace($_GET['callback']);
//判断是否登录
$phpcms_auth = param::get_cookie('auth');
if ($phpcms_auth) {
    $auth_key = md5(pc_base::load_config('system', 'auth_key') . $_SERVER['HTTP_USER_AGENT']);
    list($userid, $password) = explode("\t", sys_auth($phpcms_auth, 'DECODE', $auth_key));
    if ($userid > 0) {
    } else {
        exit(trim_script($_GET['callback']) . '(' . json_encode(array('status' => -1)) . ')');
    }
} else {
    exit(trim_script($_GET['callback']) . '(' . json_encode(array('status' => -1)) . ')');
}
$favorite_db = pc_base::load_model('favorite_model');
$data = array('title' => $title, 'url' => $url, 'adddate' => SYS_TIME, 'userid' => $userid);
//根据url判断是否已经收藏过。
$is_exists = $favorite_db->get_one(array('url' => $url, 'userid' => $userid));
if (!$is_exists) {
    $favorite_db->insert($data);
}
exit(trim_script($_GET['callback']) . '(' . json_encode(array('status' => 1)) . ')');
コード例 #18
0
ファイル: LinkageController.php プロジェクト: hubs/yuncms
 /**
  * 获取地区父级路径路径
  * @param $parentid 父级ID
  * @param $keyid 菜单keyid
  * @param $callback json生成callback变量
  */
 private function get_path($parentid, $keyid, $callback)
 {
     $datas = S('linkage/' . $keyid);
     $infos = $datas['data'];
     $result = array();
     if (array_key_exists($parentid, $infos)) {
         $result[] = iconv(CHARSET, 'utf-8', $infos[$parentid]['name']);
         return $this->get_path($infos[$parentid]['parentid'], $keyid, $callback, $result, $infos);
     } else {
         if (count($result) > 0) {
             krsort($result);
             $jsonstr = json_encode($result);
             echo trim_script($callback) . '(', $jsonstr, ')';
             exit;
         } else {
             $result[] = iconv(CHARSET, 'utf-8', $datas['title']);
             $jsonstr = json_encode($result);
             echo trim_script($callback) . '(', $jsonstr, ')';
             exit;
         }
     }
 }
コード例 #19
0
ファイル: vote.php プロジェクト: ahmatjan/huluphp
 /**
  * 编辑投票
  */
 public function edit()
 {
     if (isset($_POST['dosubmit'])) {
         //验证数据正确性
         $subjectid = intval($_GET['subjectid']);
         if ($subjectid < 1) {
             return false;
         }
         if (!is_array($_POST['subject']) || empty($_POST['subject'])) {
             return false;
         }
         if (!$_POST['subject']['subject'] || empty($_POST['subject']['subject'])) {
             return false;
         }
         $post_data = trim_script($_POST);
         $this->db2->update_options($post_data['option']);
         //先更新已有 投票选项,再添加新增加投票选项
         if (is_array($_POST['newoption']) && !empty($_POST['newoption'])) {
             $siteid = $this->get_siteid();
             //新加选项站点ID
             $this->db2->add_options($post_data['newoption'], $subjectid, $siteid);
         }
         //模版
         $_POST['subject']['template'] = $_POST['vote_subject']['vote_tp_template'];
         $_POST['subject']['optionnumber'] = count($_POST['option']) + count($_POST['newoption']);
         $this->db->update($post_data['subject'], array('subjectid' => $subjectid));
         //更新投票选项总数
         $this->update_votejs($subjectid);
         //生成JS文件
         showmessage(L('operation_success'), '?m=vote&c=vote&a=edit', '', 'edit');
     } else {
         $show_validator = $show_scroll = $show_header = true;
         pc_base::load_sys_class('form', '', 0);
         //解出投票内容
         $info = $this->db->get_one(array('subjectid' => $_GET['subjectid']));
         if (!$info) {
             showmessage(L('operation_success'));
         }
         extract($info);
         //解出投票选项
         $this->db2 = pc_base::load_model('vote_option_model');
         $options = $this->db2->get_options($_GET['subjectid']);
         //模版
         pc_base::load_app_func('global', 'admin');
         $siteid = $this->get_siteid();
         $template_list = template_list($siteid, 0);
         $site = pc_base::load_app_class('sites', 'admin');
         $info = $site->get_by_id($siteid);
         foreach ($template_list as $k => $v) {
             $template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname'];
             unset($template_list[$k]);
         }
         include $this->admin_tpl('vote_edit');
     }
 }
コード例 #20
0
ファイル: index.php プロジェクト: hxzyzz/ddc
	protected function _show_msg($msg, $url = '', $status = 0) {
		
		switch ($this->format) {
			case 'json':
				$msg = pc_base::load_config('system', 'charset') == 'gbk' ? iconv('gbk', 'utf-8', $msg) : $msg;
				echo json_encode(array('msg'=>$msg, 'status'=>$status));
				exit;
			break;
			
			case 'jsonp':
				$msg = pc_base::load_config('system', 'charset') == 'gbk' ? iconv('gbk', 'utf-8', $msg) : $msg;
				echo trim_script($_GET['callback']).'('.json_encode(array('msg'=>$msg, 'status'=>$status)).')';
				exit;
			break;
			
			default:
				showmessage($msg, $url);
			break;
		}
	}