当前位置: 首页>>代码示例>>PHP>>正文


PHP trim_script函数代码示例

本文整理汇总了PHP中trim_script函数的典型用法代码示例。如果您正苦于以下问题:PHP trim_script函数的具体用法?PHP trim_script怎么用?PHP trim_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了trim_script函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 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;
 }
开发者ID:RocherKong,项目名称:518ESHOP,代码行数:58,代码来源:content_input.class.php

示例2: get

 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;
 }
开发者ID:baowzh,项目名称:fulianweb,代码行数:56,代码来源:content_input.class.php

示例3: get

 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;
 }
开发者ID:shenhua4286,项目名称:gxw,代码行数:51,代码来源:formguide_input.class.php

示例4: get

 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;
 }
开发者ID:WALES7CH,项目名称:TP-Admin,代码行数:50,代码来源:content_input.class.php

示例5: get

 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;
 }
开发者ID:pondyond,项目名称:phpcmsv9,代码行数:48,代码来源:member_input.class.php

示例6: register

 /**
  *	申请友情链接 
  */
 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');
     }
 }
开发者ID:ahmatjan,项目名称:huluphp,代码行数:46,代码来源:index.php

示例7: addContent

 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);
 }
开发者ID:shenhua4286,项目名称:gxw,代码行数:48,代码来源:indexs.php

示例8: _show_result

 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)) . ')');
 }
开发者ID:klj123wan,项目名称:czsz,代码行数:7,代码来源:index.php

示例9: trim_script

/**
 * 转义 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;
}
开发者ID:hw18708118867,项目名称:htmlmoban,代码行数:20,代码来源:global.func.php

示例10: ajax_gettopparent

/**
 * 获取地区顶级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;
    }
}
开发者ID:panhongsheng,项目名称:zl_cms,代码行数:23,代码来源:get_linkage.php

示例11: add_content

	/**
	 * 添加内容
	 * 
	 * @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);
		
		//发布到审核列表中
//.........这里部分代码省略.........
开发者ID:panhongsheng,项目名称:zl_cms,代码行数:101,代码来源:content_model.class.php

示例12: get

 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;
 }
开发者ID:shenhua4286,项目名称:gxw,代码行数:69,代码来源:content_input.class.php

示例13: add_content

 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;
//.........这里部分代码省略.........
开发者ID:RocherKong,项目名称:518ESHOP,代码行数:101,代码来源:ContentModel.class.php

示例14: ajax_gettopparent

/**
 * 获取地区顶级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;
    }
}
开发者ID:jiangwuzhang,项目名称:phpcms,代码行数:23,代码来源:get_menu.php

示例15: edit

 /**
  * 编辑内容
  */
 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");
     }
 }
开发者ID:boylzj,项目名称:omguitar,代码行数:91,代码来源:content.php


注:本文中的trim_script函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。