首页 > 代码库 > 脚本转移
脚本转移
//1.主函数
/** * 通过API更新模板内容 * @tpl_id int 模板ID * @return bool */ function updateTemplateByAPI($tpl_id) { $data = $this->getTemplateByAPI($tpl_id); //JUMP02 liyuhs if ($data == false || !is_array($data) || count($data) == 0) return; $data[‘tpl_name‘] = $data[‘name‘]; $data[‘subject_check‘] = $this->_getSensitiveWord($data[‘subject‘]); $data[‘sender_nickname_check‘] = $this->_getSensitiveWord($data[‘sender_nickname‘]); $data[‘content_check‘] = $this->_getSensitiveWord(str_replace(array(‘,‘, "\n", "\r", ‘ ‘), array(‘,‘,‘‘,‘‘,‘‘), preg_replace(‘~<[^>]+>~‘, ‘‘, $data[‘content‘]))); $id = $this->db->getvalue("SELECT id FROM {$this->tablepre}project_task_tpl WHERE tpl_id=‘$tpl_id‘"); if ($id) $this->update(‘project_task_tpl‘,$data," WHERE id=‘$id‘"); else $this->add(‘project_task_tpl‘,$data); return true; }
/** * 通过API接口获取模板信息 * @tpl_id int 模板ID * @return array */ function getTemplateByAPI($tpl_id) { if ($tpl_id < 1) return array(); $api = $this->initAPI(); if ($api == false) return array(); $ch = $this->initCurl(); $post_data = array(); $post_data[‘id‘] = $tpl_id; // 必须项, 模板id $sign = md5($api[‘encrypt_key‘] . http_build_query($post_data)); $url = $api[‘api_url_prefix‘].‘tpl.php?do=getInfo&client_id=‘.$api[‘client_id‘].‘&sign=‘.$sign; curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data); curl_setopt($ch,CURLOPT_URL,$url); $content = curl_exec($ch); if(curl_errno($ch)!=CURLE_OK) { echo "\ndoing>>>>>do gettemplatebyapi,curl error:".curl_errno($ch).",tpl_id:".$tpl_id; curl_close($ch);return; } curl_close($ch); $mp = json_decode($content,true); if ($mp[‘code‘] > 1) return $mp[‘message‘]; $mp[‘data‘][‘tpl_id‘] = $mp[‘data‘][‘id‘]; unset($mp[‘data‘][‘id‘]); return $mp[‘data‘]; }
脚本转移
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。