/** * Adds a new section to use custom controls in the WordPress customiser * * @param Obj $wp_manager - WP Manager * * @return Void */ private function custom_sections($wp_manager) { $wp_manager->add_section('customiser_demo_custom_section', array('title' => 'Custom Controls Demo', 'priority' => 36)); // Add A Date Picker require_once dirname(__FILE__) . '/date/date-picker-custom-control.php'; $wp_manager->add_setting('date_picker_setting', array('default' => '')); $wp_manager->add_control(new Date_Picker_Custom_Control($wp_manager, 'date_picker_setting', array('label' => 'Date Picker Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'date_picker_setting', 'priority' => 1))); // Add A Layout Picker require_once dirname(__FILE__) . '/layout/layout-picker-custom-control.php'; $wp_manager->add_setting('layout_picker_setting', array('default' => '')); $wp_manager->add_control(new Layout_Picker_Custom_Control($wp_manager, 'layout_picker_setting', array('label' => 'Layout Picker Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'layout_picker_setting', 'priority' => 2))); // Add a category dropdown control require_once dirname(__FILE__) . '/select/category-dropdown-custom-control.php'; $wp_manager->add_setting('category_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Category_Dropdown_Custom_Control($wp_manager, 'category_dropdown_setting', array('label' => 'Category Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'category_dropdown_setting', 'priority' => 3))); // Add a menu dropdown control require_once dirname(__FILE__) . '/select/menu-dropdown-custom-control.php'; $wp_manager->add_setting('menu_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Menu_Dropdown_Custom_Control($wp_manager, 'menu_dropdown_setting', array('label' => 'Menu Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'menu_dropdown_setting', 'priority' => 4))); // Add a post dropdown control require_once dirname(__FILE__) . '/select/post-dropdown-custom-control.php'; $wp_manager->add_setting('post_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Post_Dropdown_Custom_Control($wp_manager, 'post_dropdown_setting', array('label' => 'Post Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'post_dropdown_setting', 'priority' => 5))); // Add a post type dropdown control require_once dirname(__FILE__) . '/select/post-type-dropdown-custom-control.php'; $wp_manager->add_setting('post_type_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Post_Type_Dropdown_Custom_Control($wp_manager, 'post_type_dropdown_setting', array('label' => 'Post Type Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'post_type_dropdown_setting', 'priority' => 6))); // Add a tags dropdown control require_once dirname(__FILE__) . '/select/tags-dropdown-custom-control.php'; $wp_manager->add_setting('tags_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Tags_Dropdown_Custom_Control($wp_manager, 'tags_dropdown_setting', array('label' => 'Tags Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'tags_dropdown_setting', 'priority' => 7))); // Add a taxonomy dropdown control require_once dirname(__FILE__) . '/select/taxonomy-dropdown-custom-control.php'; $wp_manager->add_setting('taxonomy_dropdown_setting', array('default' => '')); $wp_manager->add_control(new Taxonomy_Dropdown_Custom_Control($wp_manager, 'taxonomy_dropdown_setting', array('label' => 'Taxonomy Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'taxonomy_dropdown_setting', 'priority' => 8))); // Add a user dropdown control require_once dirname(__FILE__) . '/select/user-dropdown-custom-control.php'; $wp_manager->add_setting('user_dropdown_setting', array('default' => '')); $wp_manager->add_control(new User_Dropdown_Custom_Control($wp_manager, 'user_dropdown_setting', array('label' => 'User Dropdown Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'user_dropdown_setting', 'priority' => 9))); // Add a textarea control require_once dirname(__FILE__) . '/text/textarea-custom-control.php'; $wp_manager->add_setting('textarea_text_setting', array('default' => '')); $wp_manager->add_control(new Textarea_Custom_Control($wp_manager, 'textarea_text_setting', array('label' => 'Textarea Text Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'textarea_text_setting', 'priority' => 10))); // Add a text editor control require_once dirname(__FILE__) . '/text/text-editor-custom-control.php'; $wp_manager->add_setting('text_editor_setting', array('default' => '')); $wp_manager->add_control(new Text_Editor_Custom_Control($wp_manager, 'text_editor_setting', array('label' => 'Text Editor Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'text_editor_setting', 'priority' => 11))); // Add a Google Font control require_once dirname(__FILE__) . '/select/google-font-dropdown-custom-control.php'; $wp_manager->add_setting('google_font_setting', array('default' => '')); $wp_manager->add_control(new Google_Font_Dropdown_Custom_Control($wp_manager, 'google_font_setting', array('label' => 'Google Font Setting', 'section' => 'customiser_demo_custom_section', 'settings' => 'google_font_setting', 'priority' => 12))); }
function MasterObject(&$config) { if (!$config['widget_enable']) { $msg = 'Widget功能没有启用'; if (get_param('in_ajax')) { widget_error($msg); } else { exit($msg); } } $this->Config = $config; $this->Get =& $_GET; $this->Post =& $_POST; $this->Module = get_param('mod'); $this->Code = get_param('code'); $this->DatabaseHandler =& Obj::registry('DatabaseHandler'); $this->MemberHandler = jclass('member'); $this->MemberHandler->init(); if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) { widget_error($this->MemberHandler->GetError(), 203); } Obj::register("MemberHandler", $this->MemberHandler); define("FORMHASH", substr(md5(substr(time(), 0, -4) . $this->Config['auth_key']), 0, 16)); if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($this->Post["FORMHASH"] != FORMHASH) { } } }
function initMemberHandler() { $this->MemberHandler = jclass('member'); $member = $this->MemberHandler->init(); Obj::register("MemberHandler", $this->MemberHandler); return $member; }
function MTagLogic() { Load::logic('topic'); $this->TopicLogic = new TopicLogic(); $this->Config = jconf::get(); $this->DatabaseHandler =& Obj::registry('DatabaseHandler'); }
function MasterObject(&$config, $auto_run = false) { if (!$config['wap']) { include ROOT_PATH . 'wap/include/error_wap.php'; exit; } $this->Config = $config; require_once ROOT_PATH . 'wap/include/func/wap_global.func.php'; $this->Get =& $_GET; $this->Post =& $_POST; $this->Module = get_param('mod'); $this->Code = get_param('code'); $this->DatabaseHandler =& Obj::registry('DatabaseHandler'); $this->MemberHandler = jclass('member'); $this->MemberHandler->init(); if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) { $member_error = $this->MemberHandler->GetError(); $member_error = array_iconv($this->Config['charset'], 'utf-8', $member_error); $this->Messager($member_error, null); } if (!in_array($this->Module, array('member', 'login', 'other'))) { $visit_rets = $this->MemberHandler->visit(); if ($visit_rets['error']) { $this->Messager(null, 'index.php?mod=login&referer=' . urlencode('index.php?' . $_SERVER['QUERY_STRING'])); } } $this->Title = $this->MemberHandler->CurrentAction['name']; Obj::register("MemberHandler", $this->MemberHandler); if ($this->auto_run || $auto_run) { $this->auto_run(); } }
function MiscLogic() { $this->Config = jconf::get(); $this->DatabaseHandler =& Obj::registry('DatabaseHandler'); Load::logic('other'); $this->OtherLogic = new OtherLogic(); }
/** * A section to show how you use the default customizer controls in WordPress * * @param Obj $wp_manager - WP Manager * * @return Void */ private function demo_section($wp_manager) { $wp_manager->add_section('featured_content_section', array('title' => 'Featured Content Section', 'priority' => 35)); // Dropdown pages control $wp_manager->add_setting('featured_content', array('default' => '1')); $wp_manager->add_control('featured_content', array('label' => 'Featured Content', 'section' => 'featured_content_section', 'type' => 'dropdown-pages', 'priority' => 5)); $wp_manager->add_section('homepage_section', array('title' => 'Home Page Content Section', 'priority' => 35)); // Dropdown pages control $wp_manager->add_setting('work_page_dropdown', array('default' => '1')); $wp_manager->add_control('work_page_dropdown', array('label' => 'Work Section Page', 'section' => 'homepage_section', 'type' => 'dropdown-pages', 'priority' => 5)); // Dropdown pages control $wp_manager->add_setting('about_page_dropdown', array('default' => '1')); $wp_manager->add_control('about_page_dropdown', array('label' => 'About Section Page', 'section' => 'homepage_section', 'type' => 'dropdown-pages', 'priority' => 5)); }
public function __construct($model, Position $position, Position $rotation, $sight) { $this->id = Obj::MakeID(); $this->model = $model; $this->position = $position; $this->rotation = $rotation; $this->ids = array_fill(0, MAX_PLAYERS, 0); $this->sight = $sight; }
public function testIsString() { $this->assertFalse(Obj::isString(10)); $this->assertFalse(Obj::isString(10.5)); $this->assertFalse(Obj::isString(true)); $this->assertTrue(Obj::isString('var')); $this->assertTrue(Obj::isString('10')); $this->assertFalse(Obj::isString([10])); $this->assertFalse(Obj::isInt($this->object)); }
/** * Find latest entry in $string after $delimiter * @param string $string * @param string $delimiter * @param bool $withoutDelimiter * @return string|bool */ public static function lastIn($string, $delimiter, $withoutDelimiter = false) { $pos = strrpos($string, $delimiter); // if entry is not founded return false if (!Obj::isInt($pos)) { return false; } // remove delimiter pointer if (true === $withoutDelimiter) { ++$pos; } return self::sub($string, $pos); }
function request($url) { $config=&Obj::registry('config'); if(strpos($url,':/'.'/')===false) { $url=$config['site_url'].'/'.$url; } if ((defined('ROBOT_NAME') && false!==ROBOT_NAME) || ('remote_script' == $_REQUEST['request_from']) || (!$_SERVER['HTTP_USER_AGENT']) || (!$_COOKIE)) { @dfopen($url,-1,$post,$cookie,true,3); @usleep(rand(10000,100000)); } else { $GLOBALS['iframe'] .="<iframe src='{$url}' border=0 width=0 height=0></iframe>"; } }
function save() { $this->success = false; if ($this->get('value')) { if (!$this->saved()) { $this->set('date', 'now()'); } parent::save(); } else { $this->throwError("No value!"); $this->error_code = 500; } return $this; }
function TagLogic($item) { $this->tconf = jconf::get('tag'); if (false == $this->tconf) { exit("tag的配制文件不存在,请检查SETTING目录下的tag.php文件是否存在。"); } $this->Item = trim($item); $this->iconf = $this->tconf['item_list'][$this->Item]; if (false == $this->iconf) { exit("{$item}的配制文件不存在,请检查SETTING目录下的tag.php文件。"); } $this->DatabaseHandler =& Obj::registry("DatabaseHandler"); $this->_setItem(); }
function authcode ($string, $operation, $key = '') { $config=Obj::registry('config'); $key = md5($key ? $key : md5($config['auth_key'].(isset($_POST['HTTP_USER_AGENT']) ? base64_decode($_POST['HTTP_USER_AGENT']) : $_SERVER['HTTP_USER_AGENT']))); $key_length = strlen($key); $string = $operation == 'DECODE' ? base64_decode($string) : substr(md5($string.$key), 0, 8).$string; $string_length = strlen($string); $rndkey = $box = array(); $result = ''; for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($key[$i % $key_length]); $box[$i] = $i; } for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); } if($operation == 'DECODE') { if(substr($result, 0, 8) == substr(md5(substr($result, 8).$key), 0, 8)) { return substr($result, 8); } else { return ''; } } else { return str_replace('=', '', base64_encode($result)); } }
public static function get() { global $_CONFIG; $func_num_args=func_num_args(); if($func_num_args===0) { Return Obj::registry('config'); } else { $func_args=func_get_args(); $type=$func_args[0]; if(isset($_CONFIG[$type])===false) { $file = ConfigHandler::file($type); if (!is_file($file)) return null; include($file); if(isset($config[$type])) { $_CONFIG[$type]=$config[$type]; } else { $config=isset(${$type})?${$type}: $_CONFIG[$type]=${$type}; } } if($func_num_args===1)Return $_CONFIG[$type]; foreach($func_args as $arg) { $path_str.="['$arg']"; } $config=eval('return $_CONFIG'.$path_str.";"); Return $config; } }
/** * Get the fields for this page type by merging the default template fields * with page specific ones * @return array The array of fields */ public function getFields() { // First figure out what template we're on to get the correct fields // If this is the user facing page, then _wp_page_template will be populated // and that can be used as the template. // // If this is the admin facing page, then loadPost() is run to figure out // the page ID and the template is determined that way if (!empty($this->_wp_page_template)) { $template = $this->_wp_page_template; } else { if (!$this->loadPost() || !Obj::iterable($this->loaded_post)) { return []; } $template = get_page_template_slug($this->loaded_post->ID); $this->_wp_page_template = $template; } $fields_by_template = []; if (!empty($template)) { $fields_by_template = $this->getFieldsByPageTemplate($template); } return array_merge($this->getDefaultFields(), $fields_by_template); }
echo __METHOD__, "\n"; } function die() { echo __METHOD__, "\n"; } function self() { echo __METHOD__, "\n"; } function parent() { echo __METHOD__, "\n"; } } $obj = new Obj(); $obj->empty(); $obj->callable(); $obj->trait(); $obj->extends(); $obj->implements(); $obj->const(); $obj->enddeclare(); $obj->endfor(); $obj->endforeach(); $obj->endif(); $obj->endwhile(); $obj->and(); $obj->global(); $obj->goto(); $obj->instanceof();
public static function ®istry($name=null) { Return Obj::_share($name,$null,'get'); }
function output($template = 'output', $backup_path = null) { if ($this->hasMethod(__FUNCTION__)) { return $this->override(__FUNCTION__, array($template, $backup_path)); } parent::output($template, array('group' => $this), 'groups', $backup_path); }
function PmLogic() { $this->DatabaseHandler =& Obj::registry("DatabaseHandler"); }
/** * printVideoEntry * * DEV ONLY: Echos out data from video entry object * * @param Obj $videoEntry * @access private * @author Ben Moody */ private function printVideoEntry($videoEntry) { // the videoEntry object contains many helper functions // that access the underlying mediaGroup object echo 'Video: ' . $videoEntry->getVideoTitle() . "\n"; echo 'Video ID: ' . $videoEntry->getVideoId() . "\n"; echo 'Updated: ' . $videoEntry->getUpdated() . "\n"; echo 'Description: ' . $videoEntry->getVideoDescription() . "\n"; echo 'Category: ' . $videoEntry->getVideoCategory() . "\n"; echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "\n"; echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "\n"; echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "\n"; echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n"; echo 'View count: ' . $videoEntry->getVideoViewCount() . "\n"; echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "\n"; echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "\n"; echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "\n"; // see the paragraph above this function for more information on the // 'mediaGroup' object. in the following code, we use the mediaGroup // object directly to retrieve its 'Mobile RSTP link' child foreach ($videoEntry->mediaGroup->content as $content) { if ($content->type === "video/3gpp") { echo 'Mobile RTSP link: ' . $content->url . "\n"; } } echo "Thumbnails:\n"; $videoThumbnails = $videoEntry->getVideoThumbnails(); foreach ($videoThumbnails as $videoThumbnail) { echo $videoThumbnail['time'] . ' - ' . $videoThumbnail['url']; echo ' height=' . $videoThumbnail['height']; echo ' width=' . $videoThumbnail['width'] . "\n"; } }
function initMemberHandler() { include_once LIB_PATH.'member.han.php'; list($password,$secques,$uid)=explode("\t",authcode($this->CookieHandler->GetVar('auth'),'DECODE')); $this->MemberHandler=new MemberHandler($this); $member=$this->MemberHandler->FetchMember($uid,$password,$secques); Obj::register("MemberHandler",$this->MemberHandler); return $member; }
private function _init_user($init_user = 0) { if (($this->init_user || $init_user) && !isset($this->var['object_user'])) { $this->var['object_user'] = jclass('member'); $this->var['object_user']->init(); Obj::register('MemberHandler', $this->var['object_user']); } }
/** ** AddOBject ** Adds a dynamic object to this location. If sight is -1, then objects are always shown. ** ** Parameters: ** - modelid: Model of the object ** - position: Position of the object ** - rotation: Rotation of the object **/ public function AddObject($modelid, Position $position, Position $rotation = null, $sight = 0) { /* Create the object */ if ($sight == 0) { $sight = $this->sight; } if ($rotation == null) { $rotation = new Position(0, 0, 0, 0); } $obj = new Obj($modelid, $position, $rotation, $sight); /* Find this object nearest objects */ if ($sight != -1) { foreach ($this->objects as $o) { if ($position->DistanceTo($o->position) < $sight) { $obj->SetNear($o); $o->SetNear($obj); } } } /* This object is also near itself */ $obj->SetNear($obj); /* Add the object to this location objects list */ $this->objects[] = $obj; /* Add the object to its sector objects */ $sector = $this->area->Locate($position); if ($sight != -1) { $sectors = $sector->FindSectors($position, $sight); foreach ($sectors as $sector) { $sector->AddObject($obj); } } else { $sector->AddObject($obj); } }
/** * 得到页面配置值 * * @param String $name 页面属性变量 * @return Boolean */ function getValue($name) { return $this->configObj->getValue($name); }
public function getAdd3() { echo parent::getAdd2(); return self::$a += 3; }
function MeLogic() { $this->CookieHandler = handler('cookie'); $this->DatabaseHandler = dbc(); $this->Config = &Obj::registry("config"); }
function RegistryObj($objName) { $this->DatabaseHandler=&Obj::registry($objName); }
function Msg($POD, $type, $object_definition) { parent::Obj($POD, $type, $object_definition); $this->success = true; return $this; }
function Add($datas, $totid = 0, $imageid = 0, $attachid = 0, $from = 'web', $type = "first", $uid = 0, $item = '', $item_id = 0, $from_queue = false) { if ($GLOBALS['_J']['config']['wqueue_enabled'] && !$from_queue) { isset($datas['content']) && ($datas['content'] = base64_encode($datas['content'])); $wq_data = array('datas' => $datas, 'totid' => $totid, 'imageid' => $imageid, 'attachid' => $attachid, 'from' => $from, 'type' => $type, 'uid' => $uid ? $uid : (isset($datas['uid']) ? $datas['uid'] : MEMBER_ID), 'item' => $item ? $item : (isset($datas['item']) ? $datas['item'] : ''), 'item_id' => $item_id ? $item_id : (isset($datas['item_id']) ? $datas['item_id'] : 0)); $wq_ds = base64_encode(serialize($wq_data)); $wq_url = 'http:/' . '/' . $GLOBALS['_J']['config']['wqueue']['host'] . '/?name=' . $GLOBALS['_J']['config']['wqueue']['name'] . '&opt=put&auth=' . $GLOBALS['_J']['config']['wqueue']['auth'] . '&data=' . $wq_ds; $wq_r = dfopen($wq_url); if (strstr($wq_r, 'HTTPSQS_PUT_OK')) { return array(); } } elseif ($from_queue) { } if (is_array($datas) && count($datas)) { $ks = array('tid' => 1, 'uid' => 1, 'content' => 1, 'imageid' => 1, 'attachid' => 1, 'videoid' => 1, 'musicid' => 1, 'longtextid' => 1, 'totid' => 1, 'touid' => 1, 'dateline' => 1, 'from' => 1, 'type' => 1, 'item_id' => 1, 'item' => 1, 'postip' => 1, 'timestamp' => 1, 'managetype' => 1, 'checkfilter' => 1, 'verify' => 1, 'design' => 1, 'xiami_id' => 1, 'is_reward' => 1); foreach ($datas as $k => $v) { if (isset($ks[$k])) { ${$k} = $v; } } $pverify = $datas['pverify']; } else { $content = $datas; } $is_verify = $pverify || $GLOBALS['_J']['config']['verify'] ? true : false; $content = $this->_content_strip($content); $content_length = strlen($content); if ($content_length < 2) { return "内容不允许为空"; } if ($this->_len2 > 0 && $content_length > $this->_len2) { $content = cut_str($content, $this->_len2, ''); } if (!$checkfilter) { $f_rets = filter($content); if ($f_rets) { if ($f_rets['verify']) { $is_verify = true; } elseif ($f_rets['error']) { return $f_rets['msg']; } } } else { if ($is_verify && 'verify' == $verify && true === IN_JISHIGOU_ADMIN) { $is_verify = false; } } $totid = max(0, (int) $totid); $data = array(); if ($managetype) { $data['managetype'] = $managetype; } $is_new = 1; if ($tid) { $is_new = 0; $data['tid'] = $tid; } $parents = ''; $_froms = array('web' => 1, 'wap' => 1, 'mobile' => 1, 'sms' => 1, 'qq' => 1, 'msn' => 1, 'api' => 1, 'sina' => 1, 'qqwb' => 1, 'vote' => 1, 'qun' => 1, 'wechat' => 1, 'fenlei' => 1, 'event' => 1, 'android' => 1, 'iphone' => 1, 'ipad' => 1, 'pad' => 1, 'androidpad' => 1, 'reward' => 1); $from = $from && $_froms[$from] ? $from : 'web'; if (empty($item) || $item_id < 0) { if (!is_numeric($type)) { $_types = array('first' => 1, 'forward' => 1, 'reply' => 1, 'both' => 1); $type = $totid < 1 && $type && isset($_types[$type]) ? 'first' : $type; if (empty($type)) { $type = 'first'; } } } $data['from'] = $from; if (($type == 'forward' || $type == 'both') && $item == 'qun') { $data['type'] = $item; } else { $data['type'] = $type; } if ($item == 'channel' && $item_id > 0) { $channeldata = jlogic('channel')->id2category($item_id); if ($channeldata) { if ($channeldata['purpostview']) { $data['type'] = 'channel'; } if ($channeldata['topictype']) { $data['managetype'] = $channeldata['topictype']; } unset($channeldata); } } $data['uid'] = $uid = max(0, (int) ($uid ? $uid : MEMBER_ID)); $data['videoid'] = $videoid = max(0, (int) $videoid); $data['longtextid'] = $longtextid = max(0, (int) $longtextid); $timestamp = (int) ($timestamp ? $timestamp : $dateline); $data['dateline'] = $data['lastupdate'] = $timestamp = $dateline = $timestamp > 0 ? $timestamp : TIMESTAMP; $data['totid'] = $totid; $data['touid'] = $touid; $data['anonymous'] = $GLOBALS['_J']['config']['anonymous_enable'] ? $datas['anonymous'] : 0; $data['item'] = $item; $data['item_id'] = $item_id; $member = $this->GetMember($data['uid']); if (!$member) { return "用户不存在"; } if ($item == 'qun' && $item_id > 0) { $qun_closed = DB::result_first("SELECT closed FROM " . DB::table('qun') . " WHERE qid='{$item_id}'"); if ($qun_closed) { return "当前" . $GLOBALS['_J']['config']['changeword']['weiqun'] . "已经关闭,你无法发布内容"; } $r = $this->is_qun_member($item_id, $uid); if (!$r) { return "你没有权限进行当前操作"; } } if ($item == 'channel' && $item_id > 0) { $can_pub_topic = jlogic('channel')->can_pub_topic($item_id); if (!$can_pub_topic) { return "你没有权限进行当前操作"; } } if ($item == 'company' && $item_id > 0) { if ($GLOBALS['_J']['config']['company_enable']) { $my_companyid = $GLOBALS['_J']['member']['companyid']; $can_pub_cp_topic = false; if ($item_id == $my_companyid) { $can_pub_cp_topic = true; } elseif (@is_file(ROOT_PATH . 'include/logic/cp.logic.php') && $member['companyid'] > 0) { $is_my_cpid = jlogic('cp')->is_cp_company($item_id); if ($is_my_cpid) { $can_pub_cp_topic = true; } } if (!$can_pub_cp_topic) { return "你没有权限进行当前操作"; } } else { $item = ''; $item_id = 0; $data['type'] = 'first'; } } if ($GLOBALS['_J']['config']['add_topic_need_face'] && !$member['__face__']) { return "本站需上传头像才可互动。"; } $MemberHandler =& Obj::registry('MemberHandler'); if ($MemberHandler) { if (!in_array($type, array('both', 'reply', 'forward'))) { if (!$MemberHandler->HasPermission('topic', 'add', 0, $member)) { if (true !== IN_JISHIGOU_SMS) { return $MemberHandler->GetError(); } } } else { if (('reply' == $type || 'both' == $type) && !$MemberHandler->HasPermission('topic', 'reply', 0, $member)) { return $MemberHandler->GetError(); } elseif (('forward' == $type || 'both' == $type) && !$MemberHandler->HasPermission('topic', 'forward', 0, $member)) { return $MemberHandler->GetError(); } } } if (MEMBER_ROLE_TYPE != 'admin') { if ($GLOBALS['_J']['config']['topic_vip'] == 1) { if (!$member['validate']) { return "非V认证用户无法发布信息"; } } elseif ($GLOBALS['_J']['config']['topic_vip'] == 2) { $to_verify = 1; if (!$member['validate']) { $f_rets['vip'] = 1; $f_rets['msg'] = '非V认证用户发言内容进入<a href="index.php?mod=' . $member['uid'] . '&type=my_verify" target="_blank">待审核</a>, <a href="' . $GLOBALS['_J']['config']['site_url'] . '/index.php?mod=other&code=vip_intro" target="_blank">点击申请认证</a>'; $is_verify = true; } } } $data['username'] = $username = $member['username']; $topic_content_id = abs(crc32(md5($content))); if (!$verify) { if ($GLOBALS['_J']['config']['lastpost_time'] > 0 && !in_array($data['from'], array('sina', 'qqwb')) && $timestamp - $member['lastpost'] < $GLOBALS['_J']['config']['lastpost_time']) { return "您发布的太快了,请在<b>{$GLOBALS['_J']['config']['lastpost_time']}</b>秒后再发布"; } } #if NEDU if (defined('NEDU_MOYO')) { if (false != ($deny = nlogic('feeds.app.jsg')->topic_publish_denied($data))) { return $deny; } } #endif if ($imageid) { if ($verify) { $data['imageid'] = $imageid; } else { $data['imageid'] = $imageid = jlogic('image')->get_ids($imageid, $data['uid']); } } if ($attachid) { if ($verify) { $data['attachid'] = $attachid; } else { $data['attachid'] = $attachid = jlogic('attach')->get_ids($attachid, $data['uid']); } } $data['musicid'] = $musicid; if ($xiami_id > 0) { $musicid = $data['musicid'] = jtable('topic_music')->insert(array('uid' => $data['uid'], 'username' => $data['username'], 'dateline' => $timestamp, 'xiami_id' => $xiami_id), true); } $topic_more = array(); $parents = ''; $data['roottid'] = 0; if ($totid > 0) { $content = $this->GetForwardContent($content); $_type_names = array('both' => '转发和评论', 'forward' => '转发', 'reply' => '评论'); $_type_name = $_type_names[$type]; $to_topic = $row = $this->Get($totid); if (!$to_topic) { return "对不起,由于原微博已删除,不能{$_type_name}"; } if (('reply' == $type || 'both' == $type) && ($rets = jsg_role_check_allow('topic_reply', $row['uid'], $data['uid']))) { return $rets['error']; } elseif (('forward' == $type || 'both' == $type) && ($rets = jsg_role_check_allow('topic_forward', $row['uid'], $data['uid']))) { return $rets['error']; } $topic_more = $this->GetMore($totid); $data['totid'] = $row['tid']; $data['touid'] = $row['uid']; $data['tousername'] = $row['nickname']; $parents = $topic_more['parents'] ? $topic_more['parents'] . ',' . $totid : $totid; $data['roottid'] = $topic_more['parents'] ? substr($parents, 0, strpos($parents, ',')) : $totid; $root_topic = $this->Get($data['roottid']); if ($root_topic['item'] == 'qun' && $root_topic['item_id'] > 0) { $qun_closed = DB::result_first("SELECT closed FROM " . DB::table('qun') . " WHERE qid='{$root_topic['item_id']}'"); if ($qun_closed) { return "当前" . $GLOBALS['_J']['config'][changeword][weiqun] . "已经关闭,你无法发布内容"; } } if ($data['totid'] != $data['roottid']) { $rrow = $this->Get($data['roottid']); if (!$rrow) { return "对不起,由于原始微博已删除,不能{$_type_name}"; } if (('reply' == $type || 'both' == $type) && ($rets = jsg_role_check_allow('topic_reply', $rrow['uid'], $data['uid']))) { return $rets['error']; } elseif (('forward' == $type || 'both' == $type) && ($rets = jsg_role_check_allow('topic_forward', $rrow['uid'], $data['uid']))) { return $rets['error']; } if ('forward' == $type || 'both' == $type) { $content .= $this->ForwardSeprator . "{$row['nickname']} : " . addslashes($this->_content_strip($row['raw_content'])); } } } $_process_result = $this->_process_content($content, $data); $longtext = $_content = $_process_result['content']; $at_uids = $_process_result['at_uids']; $tags = $_process_result['tags']; $urls = $_process_result['urls']; unset($data['longtextid']); if (jstrlen($_content) > $this->_len) { $_content = cut_str($_content, $this->_len, ''); $_content = $this->_content_end($_content); if (strlen($longtext) > strlen($_content)) { $longtextid = 0; if ($is_verify) { $longtextid = jlogic('longtext')->Add($longtext, $data['uid']); } $longtextid = $longtextid > 0 ? $longtextid : TIMESTAMP; $data['longtextid'] = $longtextid; } } if (!$GLOBALS['_J']['config']['clear_format_open']) { $_content = $this->clearFormat($_content); } else { $_content = preg_replace('/\\n{3,}/', '\\n\\n', $_content); $_content = nl2br($_content); } if (strlen($_content) > 255) { $_content = cut_str($_content, 254 * 2, ''); $data['content'] = cut_str($_content, 255, ''); $data['content2'] = substr($_content, strlen($data['content'])); } else { $data['content'] = $_content; } $data['postip'] = $postip ? $postip : $GLOBALS['_J']['client_ip']; $data['post_ip_port'] = $GLOBALS['_J']['client_ip_port']; if ($is_verify) { $sql = "insert into `" . TABLE_PREFIX . "topic_verify` (`" . implode("`,`", array_keys($data)) . "`) values ('" . implode("','", $data) . "')"; DB::query($sql); $topic_id = $data['tid'] = $tid = DB::insert_id(); if ($imageid) { DB::query("update " . TABLE_PREFIX . "topic_image set `tid`='-1' where `id` in ({$imageid})"); } if ($attachid) { DB::query("update " . TABLE_PREFIX . "topic_attach set `tid`='-1' where `id` in ({$attachid})"); } if ($urls) { $date = $data; $date['id'] = $data['tid']; $date['tid'] = -1; $this->_process_urls($date, $urls, false, 'topic_verify'); } if ($notice_to_admin = $GLOBALS['_J']['config']['notice_to_admin']) { $pm_post = array('message' => $member['nickname'] . "有一条微博进入待审核状态,<a href='admin.php?jump_url=admin.php?mod=topic&code=verify' target='_blank'>点击</a>进入审核。", 'to_user' => str_replace('|', ',', $notice_to_admin)); $admin_info = DB::fetch_first('select `uid`,`username`,`nickname` from `' . TABLE_PREFIX . 'members` where `uid` = 1'); load::logic('pm'); $PmLogic = new PmLogic(); $PmLogic->pmSend($pm_post, $admin_info['uid'], $admin_info['username'], $admin_info['nickname']); } if ($f_rets['verify'] || $f_rets['vip']) { return array($f_rets['msg']); } } else { $tid = jtable('topic')->insert($data, true); if ($tid < 1) { return "未知的错误"; } $topic_id = $data['tid'] = $tid; if (is_array($datas) && isset($datas['relateid'])) { $relateid = $datas['relateid'] ? $datas['relateid'] : 0; $featureid = $datas['featureid'] ? $datas['featureid'] : 0; if ($relateid) { DB::query("update `" . TABLE_PREFIX . "topic` set `relateid`='{$tid}',`featureid`='{$featureid}' where `tid`='{$relateid}'"); $pmtoinfo = jlogic('topic')->Get($relateid, '`uid`,`item_id`,`relateid`,`featureid`', ''); $ch_typeinfo = jlogic('channel')->get_channel_typeinfo_byid($pmtoinfo['item_id']); $msg = '您提出的'; $msg .= $ch_typeinfo['channel_type'] == 'ask' ? '问题' : '建议'; $msg .= $pmtoinfo['relateid'] == 0 ? ',已经有了答复' : '重新给予了答复'; if ($featureid != $pmtoinfo['featureid']) { $msg .= ',状态变更为“' . ($ch_typeinfo['feature'][$featureid] ? $ch_typeinfo['feature'][$featureid] : '等待处理') . '”'; } postpmsms($pmtoinfo['uid'], $relateid, $msg); } } if ($is_new) { if (!empty($item) && $item_id > 0 && !($design == 'design' || $design == 'btn_wyfx')) { jfunc('app'); $param = array('item' => $item, 'item_id' => $item_id, 'tid' => $tid, 'uid' => $data['uid']); if ($item == 'talk') { $param['touid'] = $touid; $param['totid'] = $totid; } app_add_relation($param); unset($param); } jtable('topic_more')->add($tid, $parents, $longtext); } jtable('member_topic')->add($tid); if ($parents && 'first' != $data['type']) { jtable('topic_relation')->add($tid, $parents); } $p = array('uid' => $data['uid'], 'lastactivity' => $data['lastupdate'], 'lastpost' => $data['lastupdate'], 'last_topic_content_id' => $topic_content_id); if ('reply' != $data['type']) { $p['+@topic_count'] = 1; } jtable('members')->update($p); if ($at_uids) { $this->_process_at_uids($data, $at_uids); ios_push_msg($at_uids, '你有新消息:1条@我'); } if ($totid > 0 && $parents) { $this->_process_reply($data); ios_push_msg($totid, '你有新消息:1条评论'); } if ($urls) { $this->_process_urls($data, $urls); } if ($imageid) { jlogic('image')->set_tid($imageid, $tid); } if ($attachid) { jlogic('attach')->set_tid($attachid, $tid); } if ($musicid) { $sql = "update `" . TABLE_PREFIX . "topic_music` set `tid` = '{$tid}' where `id` = '{$musicid}' "; DB::query($sql); } if ($data['videoid'] > 0) { $sql = "update `" . TABLE_PREFIX . "topic_video` set `tid`='{$tid}' where `id`='{$data['videoid']}'"; DB::query($sql); } #有奖转发判断 if ($is_reward) { $allowed_reward = 1; $reward_info = jlogic('reward')->getRewardInfo($is_reward); if ($reward_info['rules']) { foreach ($reward_info['rules'] as $key => $val) { if ($allowed_reward == 0) { break; } switch ($key) { case 'at_num': if ($val > count($at_uids)) { $allowed_reward = 0; } break; case 'user': $my_buddyids = get_buddyids($data['uid']); if (!$my_buddyids) { $allowed_reward = 0; break; } foreach ($val as $re_uid => $re_name) { if ($re_uid == $data['uid']) { continue; } if (!in_array($re_uid, $my_buddyids)) { $allowed_reward = 0; break; } } break; case 'tag': foreach ($val as $re_tag) { if (!$tags) { $allowed_reward = 0; break; } if (!in_array($re_tag, $tags)) { $allowed_reward = 0; break; } } break; default: break; } } } #超时转发也不可进入有奖转发名单 if (TIMESTAMP > $reward_info['tot']) { $allowed_reward = 0; } #记录有奖转发 DB::query(" insert into `" . TABLE_PREFIX . "reward_user` (`uid`,`tid`,`rid`,`on`,`dateline`) values('{$data['uid']}','{$tid}','{$is_reward}','{$allowed_reward}','" . TIMESTAMP . "')"); DB::query(" update `" . TABLE_PREFIX . "reward` set `f_num` = `f_num`+1,`a_num`=`a_num`+{$allowed_reward} where `id` = '{$is_reward}' "); } if ($item == 'qun' && ($data['type'] == 'qun' || $data['type'] == 'first')) { if (!empty($item_id)) { $query = DB::query("SELECT uid FROM " . DB::table('qun_user') . " WHERE qid='{$item_id}'"); $uids = array(); while ($value = DB::fetch($query)) { if ($value['uid'] != $uid) { $uids[$value['uid']] = $value['uid']; } } if (!empty($uids)) { DB::query("UPDATE " . DB::table('members') . "\r\n\t \t\t\t\t\t SET qun_new=qun_new+1\r\n\t \t\t\t\t\t WHERE uid IN(" . jimplode($uids) . ")"); } } } if ($item == 'channel' && $item_id > 0 && ($data['type'] == 'first' || $data['type'] == 'channel')) { if (!empty($item_id)) { $query = DB::query("SELECT uid FROM " . DB::table('buddy_channel') . " WHERE ch_id='{$item_id}'"); $uids = array(); while ($value = DB::fetch($query)) { if ($value['uid'] != $uid) { $uids[$value['uid']] = $value['uid']; } } if (!empty($uids)) { DB::query("UPDATE " . DB::table('members') . "\r\n\t \t\t\t\t\t SET channel_new=channel_new+1\r\n\t \t\t\t\t\t WHERE uid IN(" . jimplode($uids) . ")"); } } if ($GLOBALS['_J']['config']['extcredits_enable'] && $data['uid'] > 0) { $credits_itemid = jlogic('channel')->is_update_credits_byid($item_id); if ($credits_itemid) { update_credits_by_action('_C' . crc32($credits_itemid), $data['uid']); } } } if ($item == 'company' && $item_id > 0 && $data['type'] == 'company') { $query = DB::query("SELECT uid FROM " . DB::table('members') . " WHERE companyid='{$item_id}'"); $uids = array(); while ($value = DB::fetch($query)) { if ($value['uid'] != $uid) { $uids[$value['uid']] = $value['uid']; } } $query = DB::query("SELECT uid FROM " . DB::table('cp_user') . " WHERE companyid='{$item_id}'"); while ($value = DB::fetch($query)) { if ($value['uid'] != $uid) { $uids[$value['uid']] = $value['uid']; } } if (!empty($uids)) { DB::query("UPDATE " . DB::table('members') . " SET company_new=company_new+1 WHERE uid IN(" . jimplode($uids) . ")"); } } $update_credits = false; if ($tags) { Load::logic('tag'); $TagLogic = new TagLogic('topic'); $TagLogic->Add(array('item_id' => $tid, 'tag' => $tags), false); if ($GLOBALS['_J']['config']['extcredits_enable'] && $data['uid'] > 0) { if (is_array($tags) && count($tags)) { if ($GLOBALS['_J']['config']['sign']['sign_enable'] && jtable('sign_tag')->is_sign_tag($tags)) { $sign_credits = update_credits_by_action('_S', $data['uid']); } if (!$sign_credits['updatecredit']) { foreach ($tags as $_t) { if ($_t) { $update_credits = update_credits_by_action('_T' . crc32($_t), $data['uid']) || $update_credits; } } } } } jlogic('tag_favorite')->topic_new($tags, $data['uid']); } if ($GLOBALS['_J']['config']['extcredits_enable']) { if (!$update_credits && !$sign_credits && $data['uid'] > 0) { if ($totid > 0) { update_credits_by_action('reply', $data['uid']); } else { update_credits_by_action('topic', $data['uid']); } } } if ($GLOBALS['_J']['config']['imjiqiren_enable'] && imjiqiren_init()) { $to_admin_robot = jconf::get('imjiqiren', 'admin_qq_robots'); if ($to_admin_robot) { imjiqiren_send_message($to_admin_robot, 'to_admin_robot', array('site_url' => $GLOBALS['_J']['config']['site_url'], 'username' => $data['username'], 'content' => $data['content'], 'topic_id' => $topic_id)); } } if ($GLOBALS['_J']['config']['sms_enable'] && sms_init()) { $to_admin_mobile = jconf::get('sms', 'admin_mobile'); if ($to_admin_mobile) { sms_send_message($to_admin_mobile, 'to_admin_mobile', array('site_url' => $GLOBALS['_J']['config']['site_url'], 'username' => $data['username'], 'content' => $data['content'], 'topic_id' => $topic_id)); } } if (@is_file(ROOT_PATH . 'include/logic/cp.logic.php') && $GLOBALS['_J']['config']['company_enable'] && $member['companyid'] > 0) { $CpLogic = jlogic('cp'); $update_companyid = $member['companyid']; $update_departmentid = $member['departmentid']; if ($item = 'company' && $item_id > 0 && $update_companyid != $item_id) { $cp_company_info = $CpLogic->get_cp_row_bycompany($item_id); if ($cp_company_info) { $update_companyid = $member['companyid']; $update_departmentid = $member['departmentid']; } } $CpLogic->update('company', $update_companyid, 0, 1); if ($update_departmentid > 0) { $CpLogic->update('department', $update_departmentid, 0, 1); } } $feed_action = ''; if (in_array($data['type'], array('first', 'reply', 'forward', 'both'))) { $feed_action = $data['type']; if ($feed_action == 'first') { $feed_action = 'post'; } elseif ($feed_action == 'both') { $feed_action = 'reply'; } } if ($feed_action) { $feed_msg = cut_str($data['content'], 30, ''); feed_msg('channel', $feed_action, $tid, $feed_msg, $item_id, $data['anonymous']); } $this->_syn_to($data); } if ($GLOBALS['_J']['plugins']['func']['posttopic']) { hookscript('posttopic', 'funcs', array('param' => array($data['tid']), 'step' => 'post'), 'posttopic'); } if ('reply' != $data['type']) { cache_db('rm', "{$data['uid']}-topic-%", 1); jtable('topic')->archive($data['tid']); } $this->cache_rm($data['tid']); #if NEDU defined('NEDU_MOYO') && nfevent('jsg.logic.topic.add', null, $data); #endif return $data; }