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


PHP e107::getEvent方法代码示例

本文整理汇总了PHP中e107::getEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP e107::getEvent方法的具体用法?PHP e107::getEvent怎么用?PHP e107::getEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在e107的用法示例。


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

示例1: registerEvents

 /**
  * Register core and plugin notification events.
  */
 public function registerEvents()
 {
     $active = e107::getConfig()->get('notify');
     if (empty($active) && e_PAGE == 'notify.php') {
         e107::getMessage()->addDebug('Notify is disabled!');
         return false;
     }
     $e_event = e107::getEvent();
     if (varset($this->notify_prefs['event'])) {
         foreach ($this->notify_prefs['event'] as $id => $status) {
             $include = null;
             if ($status['class'] != e_UC_NOBODY) {
                 if (varset($status['include'])) {
                     $include = e_PLUGIN . $status['include'] . "/e_notify.php";
                     if (varset($status['legacy']) != 1) {
                         $class = $status['include'] . "_notify";
                         $method = $id;
                         $e_event->register($id, array($class, $method), $include);
                     } else {
                         $e_event->register($id, 'notify_' . $id, $include);
                     }
                 } else {
                     if (method_exists($this, 'notify_' . $id)) {
                         $e_event->register($id, array('notify', 'notify_' . $id));
                     } else {
                         $e_event->register($id, array('notify', 'generic'));
                         // use generic notification.
                     }
                 }
             }
         }
     }
     //	e107::getEvent()->debug();
 }
开发者ID:armpit,项目名称:e107,代码行数:37,代码来源:notify_class.php

示例2: process

 function process($source = '')
 {
     global $_E107, $pref;
     e107::getCache()->CachePageMD5 = '_';
     e107::getCache()->set('emailLastBounce', time(), TRUE, FALSE, TRUE);
     $strEmail = !$source ? $this->mailRead(-1) : file_get_contents(e_HANDLER . "eml/" . $source);
     if (!$strEmail) {
         return;
     }
     $multiArray = Bouncehandler::get_the_facts($strEmail);
     $head = BounceHandler::parse_head($strEmail);
     $e107_userid = isset($head['X-e107-id']) ? intval($head['X-e107-id']) : $this->getHeader($strEmail, 'X-e107-id');
     if ($_E107['debug']) {
         require_once e_HANDLER . "mail.php";
         $message = "Your Bounce Handler is working. The data of the email you sent is displayed below.<br />";
         if ($e107_userid) {
             $message .= "A user-id was detected in the email you sent: <b>" . $e107_userid . "</b><br />";
         }
         $message .= "<br />";
         $message .= "<pre>" . print_r($multiArray, TRUE) . "</pre>";
         $message .= "<pre>" . $strEmail . "</pre>";
         sendemail($pref['siteadminemail'], SITENAME . " :: Bounce-Handler.", $message, $pref['siteadmin'], $pref['siteadminemail'], $pref['siteadmin']);
     }
     if ($e107_userid && $this->setUser_Bounced($e107_userid) == TRUE) {
         return;
     }
     /*		echo "<pre>";
     		print_r($multiArray);
     		echo "</pre>"; 
     */
     foreach ($multiArray as $the) {
         $the['user_id'] = $head['X-e107-id'];
         $the['user_email'] = $the['recipient'];
         unset($the['recipient']);
         switch ($the['action']) {
             case 'failed':
                 e107::getEvent()->trigger('email-bounce-failed', $the);
                 $this->setUser_Bounced($the['user_email']);
                 break;
             case 'transient':
                 //    $num_attempts  = delivery_attempts($the['user_email']);
                 e107::getEvent()->trigger('email-bounce-transient', $the);
                 if ($num_attempts > 10) {
                     $this->setUser_Bounced($the['user_email'], $the['user_id']);
                 } else {
                     //       insert_into_queue($the['user_email'], ($num_attempts+1));
                 }
                 break;
             case 'autoreply':
                 e107::getEvent()->trigger('email-bounce-autoreply', $the);
                 //  postpone($the['user_email'], '7 days');
                 break;
             default:
                 //don't do anything
                 break;
         }
     }
 }
开发者ID:notzen,项目名称:e107,代码行数:58,代码来源:bounce_handler.php

示例3: install_plugin_php

 function install_plugin_php($id)
 {
     $function = 'install';
     $sql = e107::getDb();
     $mes = e107::getMessage();
     $mySQLprefix = MPREFIX;
     // Fix for some plugin.php files.
     if (is_array($id)) {
         $plug = $id;
         $id = $plug['plugin_id'];
     } else {
         $plug = $this->getinfo($id);
     }
     $_path = e_PLUGIN . $plug['plugin_path'] . '/';
     $plug['plug_action'] = 'install';
     $this->parse_plugin_php($plug['plugin_path']);
     $plug_vars = $this->plug_vars;
     include $_path . 'plugin.php';
     $func = $eplug_folder . '_install';
     if (function_exists($func)) {
         $text .= call_user_func($func);
     }
     if (is_array($eplug_tables)) {
         $result = $this->manage_tables('add', $eplug_tables);
         if ($result === TRUE) {
             $text .= EPL_ADLAN_19 . '<br />';
             $mes->addSuccess(EPL_ADLAN_19);
         } else {
             $mes->addError(EPL_ADLAN_18);
         }
     }
     /*		if (is_array($eplug_prefs))
     		 {
     		 $this->manage_prefs('add', $eplug_prefs);
     		 $text .= EPL_ADLAN_8.'<br />';
     		 }*/
     if (varset($plug_vars['mainPrefs'])) {
         $this->XmlPrefs('core', $function, $plug_vars['mainPrefs']);
         $text .= EPL_ADLAN_8 . '<br />';
     }
     if (is_array($eplug_array_pref)) {
         foreach ($eplug_array_pref as $key => $val) {
             $this->manage_plugin_prefs('add', $key, $eplug_folder, $val);
         }
     }
     if (varset($plug_vars['siteLinks'])) {
         $this->XmlSiteLinks($function, $plug_vars);
     }
     if (varset($plug_vars['userClasses'])) {
         $this->XmlUserClasses($function, $plug_vars['userClasses']);
     }
     $this->manage_search('add', $eplug_folder);
     $this->manage_notify('add', $eplug_folder);
     $eplug_addons = $this->getAddons($eplug_folder);
     $sql->update('plugin', "plugin_installflag = 1, plugin_addons = '{$eplug_addons}' WHERE plugin_id = " . (int) $id);
     $p_installed = e107::getPref('plug_installed', array());
     // load preference;
     $p_installed[$plug['plugin_path']] = $plug['plugin_version'];
     e107::getConfig('core')->setPref('plug_installed', $p_installed);
     $this->rebuildUrlConfig();
     e107::getConfig('core')->save();
     $text .= isset($eplug_done) ? "<br />{$eplug_done}" : "<br />" . LAN_INSTALL_SUCCESSFUL;
     if ($eplug_conffile) {
         $text .= "<br /><a class='btn btn-primary' href='" . e_PLUGIN . $eplug_folder . "/" . $eplug_conffile . "'>" . LAN_CONFIGURE . "</a>";
     }
     // Event triggering after plugin installation.
     $event = e107::getEvent();
     $event->trigger('admin_plugin_install', $plug);
     return $text;
 }
开发者ID:armpit,项目名称:e107,代码行数:70,代码来源:plugin_class.php

示例4: submit_item

 function submit_item($news, $smessages = false)
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $admin_log = e107::getAdminLog();
     $pref = e107::getPref();
     $e_event = e107::getEvent();
     $e107cache = e107::getCache();
     $emessage = e107::getMessage();
     $error = false;
     if (empty($news['news_title'])) {
         $error = true;
         $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
         if (!empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     } else {
         // first format sef...
         if (empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::title2sef($news['news_title']);
         } else {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     }
     // ...then check it
     if (empty($news['news_sef'])) {
         $error = true;
         $emessage->add('Validation error: News SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     } elseif ($sql->db_Count('news', '(news_id)', ($news['news_sef'] ? 'news_id<>' . intval($news['news_id']) . ' AND ' : '') . "news_sef='" . $tp->toDB($news['news_sef']) . "'")) {
         $error = true;
         $emessage->add('Validation error: News SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR, $smessages);
     }
     if (empty($news['news_category'])) {
         $error = true;
         $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     }
     $data = array();
     //DB Array
     $data['data']['news_title'] = $news['news_title'];
     $data['_FIELD_TYPES']['news_title'] = 'todb';
     $data['data']['news_sef'] = $news['news_sef'];
     $data['_FIELD_TYPES']['news_sef'] = 'todb';
     $data['data']['news_body'] = $news['news_body'];
     $data['_FIELD_TYPES']['news_body'] = 'todb';
     $data['data']['news_extended'] = $news['news_extended'];
     $data['_FIELD_TYPES']['news_extended'] = 'todb';
     $data['data']['news_datestamp'] = $news['news_datestamp'];
     $data['_FIELD_TYPES']['news_datestamp'] = 'int';
     $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
     $data['_FIELD_TYPES']['news_author'] = 'int';
     $data['data']['news_category'] = $news['news_category'];
     $data['_FIELD_TYPES']['news_category'] = 'int';
     $data['data']['news_allow_comments'] = $news['news_allow_comments'];
     $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
     $data['data']['news_start'] = $news['news_start'];
     $data['_FIELD_TYPES']['news_start'] = 'int';
     $data['data']['news_end'] = $news['news_end'];
     $data['_FIELD_TYPES']['news_end'] = 'int';
     $data['data']['news_class'] = $news['news_class'];
     $data['_FIELD_TYPES']['news_class'] = 'todb';
     $data['data']['news_render_type'] = $news['news_render_type'];
     $data['_FIELD_TYPES']['news_render_type'] = 'todb';
     //news_comment_total
     $data['data']['news_summary'] = $news['news_summary'];
     $data['_FIELD_TYPES']['news_summary'] = 'todb';
     $data['data']['news_thumbnail'] = $news['news_thumbnail'];
     $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
     $data['data']['news_sticky'] = $news['news_sticky'];
     $data['_FIELD_TYPES']['news_sticky'] = 'int';
     $data['data']['news_meta_keywords'] = eHelper::formatMetaKeys($news['news_meta_keywords']);
     $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
     $data['data']['news_meta_description'] = eHelper::formatMetaDescription($news['news_meta_description']);
     //handle bbcodes
     $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
     if ($error) {
         $data['error'] = true;
         return $data;
     }
     // Calculate short strings for admin logging - no need to clog up the log with potentially long items
     $logData = $data['data'];
     if (isset($logData['news_body'])) {
         $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']), 300, '...');
     }
     if (isset($logData['news_extended'])) {
         $logData['news_extended'] = $tp->text_truncate($tp->toDB($logData['news_extended']), 300, '...');
     }
     //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
     if ($news['news_id']) {
         // Updating existing item
         $data['WHERE'] = 'news_id=' . intval($news['news_id']);
         //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
         if ($sql->db_Update('news', $data)) {
             e107::getAdminLog()->logArrayAll('NEWS_09', $logData);
             $data['data']['news_id'] = $news['news_id'];
             e107::getEvent()->trigger('newsupd', $data['data']);
             e107::getEvent()->trigger('admin_news_updated', $data['data']);
             $message = LAN_UPDATED;
             $emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //FIXME - triggerHook should return array(message, message_type)
//.........这里部分代码省略.........
开发者ID:KonzolozZ,项目名称:e107,代码行数:101,代码来源:news_class.php

示例5: signup


//.........这里部分代码省略.........
     if ($profile->identifier) {
         $sql = e107::getDb();
         $userMethods = e107::getUserSession();
         $plainPwd = $userMethods->generateRandomString('************');
         // auto plain passwords
         // TODO - auto login name, shouldn't be used if system set to user_email login...
         $userdata['user_loginname'] = $this->getProvider() . $userMethods->generateUserLogin(e107::getPref('predefinedLoginName', '_..#..#..#'));
         $userdata['user_email'] = $sql->escape($profile->emailVerified ? $profile->emailVerified : $profile->email);
         $userdata['user_name'] = $sql->escape($profile->displayName);
         $userdata['user_login'] = $userdata['user_name'];
         $userdata['user_customtitle'] = '';
         // not used
         $userdata['user_password'] = $userMethods->HashPassword($plainPwd, $userdata['user_loginname']);
         // pwd
         $userdata['user_sess'] = '';
         //
         $userdata['user_image'] = $profile->photoURL;
         // avatar
         $userdata['user_signature'] = '';
         // not used
         $userdata['user_hideemail'] = 1;
         // hide it by default
         $userdata['user_xup'] = $sql->escape($this->userId());
         $pref = e107::pref('core');
         if (!empty($pref['initial_user_classes'])) {
             $userdata['user_class'] = $pref['initial_user_classes'];
         } elseif (!empty($pref['user_new_period'])) {
             $userdata['user_class'] = e_UC_NEWUSER;
         } else {
             $userdata['user_class'] = '';
         }
         //		print_a($userdata);
         // user_name, user_xup, user_email and user_loginname shouldn't match
         $insert = !empty($userdata['user_email']) ? "OR user_email='" . $userdata['user_email'] . "' " : "";
         if ($sql->count("user", "(*)", "user_xup='" . $sql->escape($this->userId()) . "' " . $insert . " OR user_loginname='{$userdata['user_loginname']}' OR user_name='{$userdata['user_name']}'")) {
             // $this->login($redirectUrl); // auto-login
             e107::getUser()->loginProvider($this->userId());
             if ($redirectUrl) {
                 e107::getRedirect()->redirect($redirectUrl);
             }
             return false;
             // throw new Exception( "Signup failed! User already exists. Please use 'login' instead.", 3);
         }
         if (empty($userdata['user_email']) && e107::getPref('disable_emailcheck', 0) == 0) {
             throw new Exception("Signup failed! Can't access user email - registration without an email is impossible." . print_a($userdata, true), 4);
             // TODO lan
         }
         // other fields
         $now = time();
         $userdata['user_id'] = null;
         $userdata['user_join'] = $now;
         $userdata['user_lastvisit'] = 0;
         $userdata['user_currentvisit'] = 0;
         $userdata['user_comments'] = 0;
         $userdata['user_ip'] = e107::getIPHandler()->getIP(FALSE);
         $userdata['user_ban'] = USER_VALIDATED;
         $userdata['user_prefs'] = '';
         $userdata['user_visits'] = 0;
         $userdata['user_admin'] = 0;
         $userdata['user_perms'] = '';
         $userdata['user_realm'] = '';
         $userdata['user_pwchange'] = $now;
         $user = e107::getSystemUser(0, false);
         $user->setData($userdata);
         $user->getExtendedModel();
         // init
         //$user->setEditor(e107::getSystemUser(1, false));
         $user->save(true);
         // user model error
         if ($user->hasError()) {
             throw new Exception($user->renderMessages(), 5);
         }
         ### Successful signup!
         //$user->set('provider', $this->getProvider());
         $userdata = $user->getData();
         $userdata['provider'] = $this->getProvider();
         //	e107::getEvent()->trigger('userveri', $userdata);	 // Trigger New verified user.
         e107::getEvent()->trigger('user_xup_signup', $userdata);
         $ret = e107::getEvent()->trigger('usersupprov', $userdata);
         // XXX - it's time to pass objects instead of array?
         if (true === $ret) {
             return $this;
         }
         // send email
         if ($emailAfterSuccess) {
             $user->set('user_password', $plainPwd)->email('signup');
         }
         e107::getUser()->setProvider($this);
         // auto login
         if ($loginAfterSuccess) {
             e107::getUser()->loginProvider($this->userId());
             // if not proper after-login, return true so user can see login screen
         }
         if ($redirectUrl) {
             e107::getRedirect()->redirect($redirectUrl);
         }
         return true;
     }
     return false;
 }
开发者ID:armpit,项目名称:e107,代码行数:101,代码来源:user_handler.php

示例6: ListDeleteTrigger

 /**
  * Catch delete submit
  * @param string $batch_trigger
  * @return none
  */
 public function ListDeleteTrigger($posted)
 {
     if ($this->getPosted('etrigger_cancel')) {
         $this->setPosted(array());
         return;
         // always break on cancel!
     }
     $id = intval(key($posted));
     if ($this->deleteConfirmScreen && !$this->getPosted('etrigger_delete_confirm')) {
         // forward data to delete confirm screen
         $this->setPosted('delete_confirm_value', $id);
         return;
         // User confirmation expected
     }
     $this->setTriggersEnabled(false);
     $data = array();
     $model = $this->getTreeModel()->getNode($id);
     //FIXME - this has issues with being on a page other than the 1st.
     if ($model) {
         $data = $model->getData();
         if ($this->beforeDelete($data, $id)) {
             $eventData = array('oldData' => $data, 'id' => $id);
             if ($triggerName = $this->getEventTriggerName('delete')) {
                 if (E107_DBG_ALLERRORS > 0) {
                     $this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>' . $triggerName . '</b> with data ' . print_a($eventData, true));
                 }
                 if ($halt = e107::getEvent()->trigger($triggerName, $eventData)) {
                     $this->getTreeModel()->setMessages();
                     return;
                 }
             }
             $check = $this->getTreeModel()->delete($id);
             if ($this->afterDelete($data, $id, $check)) {
                 if ($triggerName = $this->getEventTriggerName('deleted')) {
                     if (E107_DBG_ALLERRORS > 0) {
                         $this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>' . $triggerName . '</b>');
                         //FIXME - Why doesn't this display?
                     }
                     e107::getEvent()->trigger($triggerName, $eventData);
                 }
                 $this->getTreeModel()->setMessages();
             }
         } else {
             $this->getTreeModel()->setMessages();
             // errors
         }
     } else {
         //echo "Couldn't get Node for ID: ".$id;
         // exit;
         e107::getMessage()->addDebug('Model Failure Fallback in use!! ID: ' . $id . ' file: ' . __FILE__ . " line: " . __LINE__, 'default', true);
         $check = $this->getTreeModel()->delete($id);
         return;
     }
 }
开发者ID:KonzolozZ,项目名称:e107,代码行数:59,代码来源:admin_ui.php

示例7: renderHooks

 /**
  * Render Table cells from hooks.
  * @param array $data 
  * @return string
  */
 function renderHooks($data)
 {
     $hooks = e107::getEvent()->triggerHook($data);
     $text = "";
     if (!empty($hooks)) {
         foreach ($hooks as $plugin => $hk) {
             $text .= "\n\n<!-- Hook : {$plugin} -->\n";
             if (!empty($hk)) {
                 foreach ($hk as $hook) {
                     $text .= "\t\t\t<tr>\n";
                     $text .= "\t\t\t<td>" . $hook['caption'] . "</td>\n";
                     $text .= "\t\t\t<td>" . $hook['html'] . "";
                     $text .= varset($hook['help']) ? "\n<span class='field-help'>" . $hook['help'] . "</span>" : "";
                     $text .= "</td>\n\t\t\t</tr>\n";
                 }
             }
         }
     }
     return $text;
 }
开发者ID:armpit,项目名称:e107,代码行数:25,代码来源:form_handler.php

示例8: clear

 /**
  * Deletes cache files. If $query is set, deletes files named {$CacheTag}*.cache.php, if not it deletes all cache files - (*.cache.php)
  *
  * @param string $CacheTag
  * @param boolean $syscache
  * @param boolean $related clear also 'nq_' and 'nomd5_' entries
  * @return bool
  *
  */
 public function clear($CacheTag = '', $syscache = false, $related = false)
 {
     $file = $CacheTag ? preg_replace("#\\W#", "_", $CacheTag) . "*.cache.php" : "*.cache.php";
     e107::getEvent()->triggerAdminEvent('cache_clear', "cachetag={$CacheTag}&file={$file}&syscache={$syscache}");
     $ret = self::delete(e_CACHE_CONTENT, $file, $syscache);
     if ($CacheTag && $related) {
         self::delete(e_CACHE_CONTENT, 'nq_' . $file, $syscache);
         self::delete(e_CACHE_CONTENT, 'nomd5_' . $file, $syscache);
         //ecache::delete(e_CACHE_CONTENT, 'nq_'.$file, $syscache);
         //ecache::delete(e_CACHE_CONTENT, 'nomd5_'.$file, $syscache);
     }
     return $ret;
 }
开发者ID:armpit,项目名称:e107,代码行数:22,代码来源:cache_handler.php

示例9: submit_download


//.........这里部分代码省略.........
     $dlInfo['download_sef'] = vartrue($_POST['download_sef']) ? eHelper::secureSef($_POST['download_sef']) : eHelper::title2sef($_POST['download_name']);
     $dlInfo['download_keywords'] = $tp->toDB($_POST['download_keywords']);
     $dlInfo['download_author'] = $tp->toDB($_POST['download_author']);
     $dlInfo['download_author_email'] = $tp->toDB($_POST['download_author_email']);
     $dlInfo['download_author_website'] = $tp->toDB($_POST['download_author_website']);
     $dlInfo['download_category'] = intval($_POST['download_category']);
     $dlInfo['download_active'] = intval($_POST['download_active']);
     $dlInfo['download_thumb'] = $tp->toDB($_POST['download_thumb']);
     $dlInfo['download_image'] = $tp->toDB($_POST['download_image']);
     $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']);
     $dlInfo['download_class'] = $tp->toDB($_POST['download_class']);
     $dlInfo['download_visible'] = $tp->toDB($_POST['download_visible']);
     $dlInfo['download_datestamp'] = e107::getDate()->convert($_POST['download_datestamp'], 'inputdate');
     if ($_POST['update_datestamp']) {
         $dlInfo['download_datestamp'] = time();
     }
     $mirrorStr = "";
     $mirrorFlag = FALSE;
     // See if any mirrors defined
     // Need to check all the possible mirror names - might have deleted the first one if we're in edit mode
     if (count($_POST['download_mirror_name'])) {
         foreach ($_POST['download_mirror_name'] as $mn) {
             if ($mn) {
                 $mirrorFlag = TRUE;
                 break;
             }
         }
     }
     if ($mirrorFlag) {
         $mirrors = count($_POST['download_mirror_name']);
         $mirrorArray = array();
         $newMirrorArray = array();
         if ($id && $sql->select('download', 'download_mirror', 'download_id = ' . $id)) {
             if ($row = $sql->fetch()) {
                 $mirrorArray = $this->makeMirrorArray($row['download_mirror'], TRUE);
             }
         }
         for ($a = 0; $a < $mirrors; $a++) {
             $mid = trim($_POST['download_mirror_name'][$a]);
             $murl = trim($_POST['download_mirror'][$a]);
             $msize = trim($_POST['download_mirror_size'][$a]);
             if ($mid && $murl) {
                 $newMirrorArray[$mid] = array('id' => $mid, 'url' => $murl, 'requests' => 0, 'filesize' => $msize);
                 if (DOWNLOAD_DEBUG && !$id) {
                     $newMirrorArray[$mid]['requests'] = intval($_POST['download_mirror_requests'][$a]);
                 }
             }
         }
         // Now copy across any existing usage figures
         foreach ($newMirrorArray as $k => $m) {
             if (isset($mirrorArray[$k])) {
                 $newMirrorArray[$k]['requests'] = $mirrorArray[$k]['requests'];
             }
         }
         $mirrorStr = $this->compressMirrorArray($newMirrorArray);
     }
     $dlMirrors['download_mirror'] = $mirrorStr;
     $dlMirrors['download_mirror_type'] = intval($_POST['download_mirror_type']);
     if ($id) {
         // Process triggers before calling admin_update so trigger messages can be shown
         $data = array('method' => 'update', 'table' => 'download', 'id' => $id, 'plugin' => 'download', 'function' => 'update_download');
         $hooks = $e107->e_event->triggerHook($data);
         $mes->add($hooks, E_MESSAGE_SUCCESS);
         $updateArray = array_merge($dlInfo, $dlMirrors);
         $updateArray['WHERE'] = 'download_id=' . intval($id);
         $mes->addAuto($sql->db_Update('download', $updateArray), 'update', DOWLAN_2 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $id . "'>" . $_POST['download_name'] . "</a>)");
         $dlInfo['download_id'] = $id;
         $this->downloadLog('DOWNL_06', $dlInfo, $dlMirrors);
         $dlInfo['download_datestamp'] = $time;
         // This is what 0.7 did, regardless of settings
         unset($dlInfo['download_class']);
         // Also replicating 0.7
         $e_event->trigger('dlupdate', $dlInfo);
         // @deprecated
         e107::getEvent()->trigger('admin_download_update', $dlInfo);
     } else {
         if ($download_id = $sql->insert('download', array_merge($dlInfo, $dlMirrors))) {
             // Process triggers before calling admin_update so trigger messages can be shown
             $data = array('method' => 'create', 'table' => 'download', 'id' => $download_id, 'plugin' => 'download', 'function' => 'create_download');
             $hooks = $e107->e_event->triggerHook($data);
             $mes->add($hooks, E_MESSAGE_SUCCESS);
             $mes->addAuto($download_id, 'insert', DOWLAN_1 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $download_id . "'>" . $_POST['download_name'] . "</a>)");
             $dlInfo['download_id'] = $download_id;
             $this->downloadLog('DOWNL_05', $dlInfo, $dlMirrors);
             $dlInfo['download_datestamp'] = $time;
             // This is what 0.7 did, regardless of settings
             unset($dlInfo['download_class']);
             // Also replicating 0.7
             $e_event->trigger("dlpost", $dlInfo);
             // @deprecated
             e107::getEvent()->trigger('admin_download_create', $dlInfo);
             if ($_POST['remove_upload']) {
                 $sql->db_Update("upload", "upload_active='1' WHERE upload_id='" . $_POST['remove_id'] . "'");
                 $mess = "<br/>" . $_POST['download_name'] . " " . DOWLAN_104;
                 $mess .= "<br/><br/><a href='" . e_ADMIN . "upload.php'>" . DOWLAN_105 . "</a>";
                 $this->show_message($mess);
             }
         }
     }
 }
开发者ID:armpit,项目名称:e107,代码行数:101,代码来源:admin.php

示例10: enter_comment


//.........这里部分代码省略.........
     $cuser_id = 0;
     $cuser_name = 'Anonymous';
     // Preset as an anonymous comment
     if (!$sql->select("comments", "*", "comment_comment='" . $comment . "' AND comment_item_id='" . intval($id) . "' AND comment_type='" . $tp->toDB($type, true) . "' ")) {
         if ($_POST['comment']) {
             if (USER == TRUE) {
                 $cuser_id = USERID;
                 $cuser_name = USERNAME;
                 $cuser_mail = USEREMAIL;
             } elseif ($_POST['author_name'] != '') {
                 if ($sql2->select("user", "*", "user_name='" . $tp->toDB($_POST['author_name']) . "' ")) {
                     if ($sql2->select("user", "*", "user_name='" . $tp->toDB($_POST['author_name']) . "' AND user_ip='" . $tp->toDB($ip, true) . "' ")) {
                         //list($cuser_id, $cuser_name) = $sql2->db_Fetch();
                         $tmp = $sql2->fetch();
                         $cuser_id = $tmp['user_id'];
                         $cuser_name = $tmp['user_name'];
                         $cuser_mail = $tmp['user_email'];
                     } else {
                         define("emessage", COMLAN_310);
                     }
                 } else {
                     $cuser_name = $tp->toDB($author_name);
                 }
             }
             if (!defined("emessage")) {
                 $ip = $e107->getip();
                 // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form
                 $_t = time();
                 if ($editpid) {
                     $comment .= "\n[ " . COMLAN_319 . " [time=short]" . time() . "[/time] ]";
                     $sql->update("comments", "comment_comment='{$comment}' WHERE comment_id='" . intval($editpid) . "' ");
                     e107::getCache()->clear("comment");
                     return;
                 }
                 //FIXME - don't sanitize, pass raw data to e_event, use DB array (inner db sanitize)
                 $edata_li = array('comment_pid' => intval($pid), 'comment_item_id' => $id, 'comment_subject' => $subject, 'comment_author_id' => $cuser_id, 'comment_author_name' => $cuser_name, 'comment_author_email' => $tp->toDB($cuser_mail), 'comment_datestamp' => $_t, 'comment_comment' => $comment, 'comment_blocked' => $this->moderateComment($pref['comments_moderate']) ? 2 : 0, 'comment_ip' => $ip, 'comment_type' => $tp->toDB($type, true), 'comment_lock' => 0, 'comment_share' => $comment_share);
                 //SecretR: new event 'prepostcomment' - allow plugin hooks - e.g. Spam Check
                 $edata_li_hook = array_merge($edata_li, array('comment_nick' => $cuser_id . '.' . $cuser_name, 'comment_time' => $_t));
                 if (e107::getEvent()->trigger("prepostcomment", $edata_li_hook)) {
                     return false;
                     //3rd party code interception
                 }
                 //allow 3rd party code to modify insert data
                 if (is_array($edata_li_hook)) {
                     foreach (array_keys($edata_li) as $k) {
                         if (isset($edata_li_hook[$k])) {
                             $edata_li[$k] = $edata_li_hook[$k];
                             //sanitize?
                             continue;
                         }
                         if ($k === 'break') {
                             $break = $edata_li_hook[$k];
                         }
                     }
                 }
                 unset($edata_li_hook);
                 if (!($inserted_id = $sql->insert("comments", $edata_li))) {
                     //echo "<b>".COMLAN_323."</b> ".COMLAN_11;
                     if (e_AJAX_REQUEST) {
                         return "Error";
                     }
                     e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
                 } else {
                     if (USER == true) {
                         $sql->update("user", "user_comments=user_comments+1, user_lastpost='" . time() . "' WHERE user_id='" . USERID . "' ");
                     }
                     // Next item for backward compatibility
                     $edata_li["comment_nick"] = $cuser_id . '.' . $cuser_name;
                     $edata_li["comment_time"] = $_t;
                     $edata_li["comment_id"] = $inserted_id;
                     //Why?
                     /*unset($edata_li['comment_pid']);
                     		unset($edata_li['comment_author_email']);
                     		unset($edata_li['comment_ip']);*/
                     e107::getEvent()->trigger("postcomment", $edata_li);
                     e107::getCache()->clear("comment");
                     if ((empty($type) || $type == "news") && !$this->moderateComment($pref['comments_moderate'])) {
                         $sql->update("news", "news_comment_total=news_comment_total+1 WHERE news_id=" . intval($id));
                     }
                     //if rateindex is posted, enter the rating from this user
                     //	if ($rateindex)
                     //	{
                     //		$rater->enterrating($rateindex);
                     //	}
                     return $inserted_id;
                     // return the ID number so it can be used. true;
                 }
             }
         }
     } else {
         define("emessage", COMLAN_312);
     }
     if (defined("emessage")) {
         if (e_AJAX_REQUEST) {
             return emessage;
         }
         message_handler("ALERT", emessage);
     }
     return false;
 }
开发者ID:gitye,项目名称:e107,代码行数:101,代码来源:comment_class.php

示例11: invalidLogin

 /**
  * called to log the reason for a failed login.
  * @param string $plugname
  * @return boolean Currently always returns false - could return some other value
  */
 protected function invalidLogin($username, $reason, $extra_text = '')
 {
     global $pref, $sql;
     $doCheck = FALSE;
     // Flag set if need to ban check
     switch ($reason) {
         case LOGIN_ABORT:
             // alt_auth reject
             $message = LAN_LOGIN_21;
             $this->genNote($this->userIP, $username, 'Alt_auth: ' . LAN_LOGIN_14);
             $this->logNote('LAN_ROLL_LOG_04', 'Alt_Auth: ' . $username);
             $doCheck = true;
             break;
         case LOGIN_DB_ERROR:
             // alt_auth couldn't add valid user
             $message = LAN_LOGIN_31;
             $this->genNote($username, 'Alt_auth: ' . LAN_LOGIN_30);
             //				$this->logNote('LAN_ROLL_LOG_04', 'Alt_Auth: '.$username);	// Added in alt_auth login
             $doCheck = true;
             break;
         case LOGIN_BAD_PW:
             $message = LAN_LOGIN_21;
             $this->logNote('LAN_ROLL_LOG_03', $username);
             break;
         case LOGIN_CHAP_FAIL:
             $message = LAN_LOGIN_21;
             $this->logNote('LAN_ROLL_LOG_03', 'CHAP: ' . $username);
             break;
         case LOGIN_BAD_USER:
             $message = LAN_LOGIN_21;
             $this->genNote($username, LAN_LOGIN_14);
             $this->logNote('LAN_ROLL_LOG_04', $username);
             $doCheck = true;
             break;
         case LOGIN_BAD_USERNAME:
             $message = LAN_LOGIN_21;
             $this->logNote('LAN_ROLL_LOG_08', $username);
             break;
         case LOGIN_MULTIPLE:
             $message = LAN_LOGIN_24;
             $this->logNote('LAN_ROLL_LOG_07', "U: {$username} IP: {$this->userIP}");
             $this->genNote($username, LAN_LOGIN_16);
             $doCheck = true;
             break;
         case LOGIN_BAD_CODE:
             $message = LAN_LOGIN_23;
             $this->logNote('LAN_ROLL_LOG_02', $username);
             break;
         case LOGIN_NOT_ACTIVATED:
             $srch = array("[", "]");
             $repl = array("<a href='" . e_HTTP . "signup.php?resend'>", "</a>");
             $message = str_replace($srch, $repl, LAN_LOGIN_22);
             $this->logNote('LAN_ROLL_LOG_05', $username);
             $this->genNote($username, LAN_LOGIN_27);
             $doCheck = true;
             break;
         case LOGIN_BLANK_FIELD:
             $message = LAN_LOGIN_20;
             $this->logNote('LAN_ROLL_LOG_01', $username);
             break;
         case LOGIN_BAD_TRIGGER:
             $message = $extra_text;
             $this->logNote('LAN_ROLL_LOG_06', $username);
             break;
         case LOGIN_BANNED:
             $message = LAN_LOGIN_21;
             // Just give 'incorrect login' message
             $this->genNote($username, LAN_LOGIN_25);
             $this->logNote('LAN_ROLL_LOG_09', $username);
             break;
         default:
             // Something's gone wrong!
             $message = LAN_LOGIN_21;
             // Just give 'incorrect login' message
             $this->genNote($username, LAN_LOGIN_26);
             $this->logNote('LAN_ROLL_LOG_10', $username);
     }
     e107::getMessage()->addError($message);
     if ($this->testMode === true) {
         return $message;
     }
     define('LOGINMESSAGE', $message);
     if ($doCheck) {
         if ($pref['autoban'] == 1 || $pref['autoban'] == 3) {
             $fails = $sql->count("generic", "(*)", "WHERE gen_ip='{$this->userIP}' AND gen_type='failed_login' ");
             $failLimit = vartrue($pref['failed_login_limit'], 10);
             if ($fails >= $failLimit) {
                 $time = time();
                 $description = e107::getParser()->lanVars(LAN_LOGIN_18, $failLimit);
                 e107::getIPHandler()->add_ban(4, $description, $this->userIP, 1);
                 e107::getDb()->insert("generic", "0, 'auto_banned', '" . $time . "', 0, '{$this->userIP}', '{$extra_text}', '" . LAN_LOGIN_20 . ": " . e107::getParser()->toDB($username) . ", " . LAN_LOGIN_17 . ": " . md5($ouserpass) . "' ");
                 e107::getEvent()->trigger('user_ban_failed_login', array('time' => $time, 'ip' => $this->userIP, 'other' => $extra_text));
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:gitye,项目名称:e107,代码行数:101,代码来源:login.php

示例12: AddSubmitTrigger

 /**
  * Quick Add user submit trigger
  */
 public function AddSubmitTrigger()
 {
     $e107cache = e107::getCache();
     $userMethods = e107::getUserSession();
     $mes = e107::getMessage();
     $sql = e107::getDb();
     $e_event = e107::getEvent();
     $admin_log = e107::getAdminLog();
     if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
         exit;
     }
     $e107cache->clear('online_menu_member_total');
     $e107cache->clear('online_menu_member_newest');
     $error = false;
     if (isset($_POST['generateloginname'])) {
         $_POST['loginname'] = $userMethods->generateUserLogin($pref['predefinedLoginName']);
     }
     $_POST['password2'] = $_POST['password1'] = $_POST['password'];
     // Now validate everything
     $allData = validatorClass::validateFields($_POST, $userMethods->userVettingInfo, true);
     // Fix Display and user name
     if (!check_class($pref['displayname_class'], $allData['data']['user_class'])) {
         if ($allData['data']['user_name'] != $allData['data']['user_loginname']) {
             $allData['data']['user_name'] = $allData['data']['user_loginname'];
             $mes->addWarning(str_replace('[x]', $allData['data']['user_loginname'], USRLAN_237));
             //$allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT;
         }
     }
     // Do basic validation
     validatorClass::checkMandatory('user_name, user_loginname', $allData);
     // Check for missing fields (email done in userValidation() )
     validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', 0);
     // Do basic DB-related checks
     $userMethods->userValidation($allData);
     // Do user-specific DB checks
     if (!isset($allData['errors']['user_password'])) {
         // No errors in password - keep it outside the main data array
         $savePassword = $allData['data']['user_password'];
         // Delete the password value in the output array
         unset($allData['data']['user_password']);
     }
     // Restrict the scope of this
     unset($_POST['password2'], $_POST['password1']);
     if (count($allData['errors'])) {
         $temp = validatorClass::makeErrorList($allData, 'USER_ERR_', '%n - %x - %t: %v', '<br />', $userMethods->userVettingInfo);
         $mes->addError($temp);
         $error = true;
     }
     // Always save some of the entered data - then we can redisplay on error
     $user_data =& $allData['data'];
     if ($error) {
         $this->setParam('user_data', $user_data);
         return;
     }
     if (varset($_POST['perms'])) {
         $allData['data']['user_admin'] = 1;
         $allData['data']['user_perms'] = implode('.', $_POST['perms']);
     }
     $user_data['user_password'] = $userMethods->HashPassword($savePassword, $user_data['user_login']);
     $user_data['user_join'] = time();
     if ($userMethods->needEmailPassword()) {
         // Save separate password encryption for use with email address
         $user_prefs = e107::getArrayStorage()->unserialize($user_data['user_prefs']);
         $user_prefs['email_password'] = $userMethods->HashPassword($savePassword, $user_data['user_email']);
         $user_data['user_prefs'] = e107::getArrayStorage()->serialize($user_prefs);
         unset($user_prefs);
     }
     $userMethods->userClassUpdate($allData['data'], 'userall');
     //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later)
     $allData['data']['user_realm'] = '';
     // Set any initial classes
     $userMethods->addNonDefaulted($user_data);
     validatorClass::addFieldTypes($userMethods->userVettingInfo, $allData);
     $userid = $sql->insert('user', $allData);
     if ($userid) {
         $sysuser = e107::getSystemUser(false, false);
         $sysuser->setData($allData['data']);
         $sysuser->setId($userid);
         $user_data['user_id'] = $userid;
         // Add to admin log
         e107::getLog()->add('USET_02', "UName: {$user_data['user_name']}; Email: {$user_data['user_email']}", E_LOG_INFORMATIVE);
         // Add to user audit trail
         e107::getLog()->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']);
         e107::getEvent()->trigger('userfull', $user_data);
         e107::getEvent()->trigger('admin_user_created', $user_data);
         // send everything available for user data - bit sparse compared with user-generated signup
         if (isset($_POST['sendconfemail'])) {
             $check = false;
             // Send confirmation email to user
             switch ((int) $_POST['sendconfemail']) {
                 case 0:
                     // activate, don't notify
                     $check = -1;
                     break;
                 case 1:
                     // activate and send password
                     $check = $sysuser->email('quickadd', array('user_password' => $savePassword, 'mail_subject' => USRLAN_187 . SITENAME, 'activation_url' => USRLAN_238));
//.........这里部分代码省略.........
开发者ID:armpit,项目名称:e107,代码行数:101,代码来源:users.php

示例13: config

 function config()
 {
     //global $ns, $rs, $frm, $emessage;
     $ns = e107::getRender();
     $frm = e107::getForm();
     $mes = e107::getMessage();
     $events = e107::getEvent()->coreList();
     $tab = array();
     foreach ($events as $k => $cat) {
         $text = " <table class='table adminform'>\n        \t<colgroup>\n        \t\t<col class='col-label' />\n        \t\t<col class='col-control' />\n        \t</colgroup>";
         foreach ($cat as $c => $ev) {
             $text .= $this->render_event($c, $ev);
         }
         $text .= "</table>";
         $caption = str_replace("_menu", "", ucfirst($k)) . " " . LAN_NOTIFY_01;
         $tab[] = array('caption' => $caption, 'text' => $text);
     }
     if (!empty($this->notify_prefs['plugins'])) {
         foreach ($this->notify_prefs['plugins'] as $plugin_id => $plugin_settings) {
             if (is_readable(e_PLUGIN . $plugin_id . '/e_notify.php')) {
                 $config_category = $this->pluginConfig[$plugin_id]['category'];
                 $legacy = $this->pluginConfig[$plugin_id]['legacy'];
                 $text = "<table class='table adminform'>\n\t\t\t        \t<colgroup>\n\t\t\t        \t\t<col class='col-label' />\n\t\t\t        \t\t<col class='col-control' />\n\t\t\t        \t</colgroup>";
                 foreach ($this->pluginConfig[$plugin_id]['events'] as $event_id => $event_text) {
                     $text .= $this->render_event($event_id, $event_text, $plugin_id, $legacy);
                 }
                 $text .= "</table>\n";
                 $tab[] = array('caption' => $config_category, 'text' => $text);
             }
         }
     }
     $text2 = $frm->open('scanform', 'post', e_REQUEST_URL);
     // <form action='".e_SELF."?results' method='post' id='scanform'>
     $text2 .= $frm->tabs($tab);
     $text2 .= "<div class='buttons-bar center'>" . $frm->admin_button('update', LAN_UPDATE, 'update') . "</div>";
     $text2 .= $frm->close();
     $ns->tablerender(NT_LAN_1, $mes->render() . $text2);
     return;
     // <div>".NT_LAN_2.":</div>
     /*
     		$text = "
     		
     		<form action='".e_SELF."?results' method='post' id='scanform'>
     		    <ul class='nav nav-tabs'>
         <li class='active'><a href='#core' data-toggle='tab'>Users</a></li>
         <li><a href='#news' data-toggle='tab'>News</a></li>
         <li><a href='#mail' data-toggle='tab'>Mail</a></li>
         <li><a href='#files' data-toggle='tab'>Files</a></li>";
     	
     	if(!empty($this->notify_prefs['plugins']))
     	{
     		foreach ($this -> notify_prefs['plugins'] as $id => $var)
     		{
     			$text .= "<li><a href='#notify-".$id."' data-toggle='tab'>".ucfirst($id)."</a></li>";
     		}
     	}
     	
     	$text .= "
         </ul>
         <div class='tab-content'>
         <div class='tab-pane active' id='core'>
     		<fieldset id='core-notify-config'>
     		<legend>".NU_LAN_1."</legend>
             <table class='table adminform'>
             	<colgroup>
             		<col class='col-label' />
             		<col class='col-control' />
             	</colgroup>
     		";
     
     		$text .= $this -> render_event('usersup', NU_LAN_2);
     		$text .= $this -> render_event('userveri', NU_LAN_3);
     		$text .= $this -> render_event('login', NU_LAN_4);
     		$text .= $this -> render_event('logout', NU_LAN_5);
     		$text .= $this -> render_event('user_xup_', NU_LAN_5);
     
     		$text .= "</table></fieldset>
     		<fieldset id='core-notify-2'>
             <legend>".NS_LAN_1."</legend>
             <table class='table adminform'>
             	<colgroup>
             		<col class='col-label' />
             		<col class='col-control' />
             	</colgroup>";
     
     		$text .= $this -> render_event('flood', NS_LAN_2);
     
     
     		$text .= "</table></fieldset>
     		</div>
     		
     		
     		<div class='tab-pane' id='news'>
     		<fieldset id='core-notify-3'>
             <legend>".NN_LAN_1."</legend>
             <table class='table adminform'>
             	<colgroup>
             		<col class='col-label' />
             		<col class='col-control' />
             	</colgroup>";
//.........这里部分代码省略.........
开发者ID:armpit,项目名称:e107,代码行数:101,代码来源:notify.php

示例14: __get

 public function __get($name)
 {
     switch ($name) {
         case 'tp':
             $ret = e107::getParser();
             break;
         case 'sql':
             $ret = e107::getDb();
             break;
         case 'ecache':
             $ret = e107::getCache();
             break;
         case 'arrayStorage':
             $ret = e107::getArrayStorage();
             break;
         case 'e_event':
             $ret = e107::getEvent();
             break;
         case 'ns':
             $ret = e107::getRender();
             break;
         case 'url':
             $ret = e107::getUrl();
             break;
         case 'admin_log':
             $ret = e107::getAdminLog();
             break;
         case 'override':
             $ret = e107::getSingleton('override', e_HANDLER . 'override_class.php');
             break;
         case 'notify':
             $ret = e107::getNotify();
             break;
         case 'e_online':
             $ret = e107::getOnline();
             break;
         case 'eIPHandler':
             $ret = e107::getIPHandler();
             break;
         case 'user_class':
             $ret = e107::getUserClass();
             break;
         default:
             trigger_error('$e107->$' . $name . ' not defined', E_USER_WARNING);
             return null;
             break;
     }
     $this->{$name} = $ret;
     return $ret;
 }
开发者ID:KonzolozZ,项目名称:e107,代码行数:50,代码来源:e107_class.php

示例15: submit_item

 function submit_item($news, $smessages = false)
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $admin_log = e107::getAdminLog();
     $pref = e107::getPref();
     $e_event = e107::getEvent();
     $e107cache = e107::getCache();
     $emessage = e107::getMessage();
     $error = false;
     if (empty($news['news_title'])) {
         $error = true;
         $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
         if (!empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     } else {
         // first format sef...
         if (empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::title2sef($news['news_title']);
         } else {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     }
     // ...then check it
     if (empty($news['news_sef'])) {
         $error = true;
         $emessage->add('Validation error: News SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     } elseif ($sql->db_Count('news', '(news_id)', ($news['news_sef'] ? 'news_id<>' . intval($news['news_id']) . ' AND ' : '') . "news_sef='" . $tp->toDB($news['news_sef']) . "'")) {
         $error = true;
         $emessage->add('Validation error: News SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR, $smessages);
     }
     if (empty($news['news_category'])) {
         $error = true;
         $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     }
     $data = array();
     //DB Array
     $data['data']['news_title'] = $news['news_title'];
     $data['_FIELD_TYPES']['news_title'] = 'todb';
     $data['data']['news_sef'] = $news['news_sef'];
     $data['_FIELD_TYPES']['news_sef'] = 'todb';
     $data['data']['news_body'] = $news['news_body'];
     $data['_FIELD_TYPES']['news_body'] = 'todb';
     $data['data']['news_extended'] = $news['news_extended'];
     $data['_FIELD_TYPES']['news_extended'] = 'todb';
     $data['data']['news_datestamp'] = $news['news_datestamp'];
     $data['_FIELD_TYPES']['news_datestamp'] = 'int';
     $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
     $data['_FIELD_TYPES']['news_author'] = 'int';
     $data['data']['news_category'] = $news['news_category'];
     $data['_FIELD_TYPES']['news_category'] = 'int';
     $data['data']['news_allow_comments'] = $news['news_allow_comments'];
     $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
     $data['data']['news_start'] = $news['news_start'];
     $data['_FIELD_TYPES']['news_start'] = 'int';
     $data['data']['news_end'] = $news['news_end'];
     $data['_FIELD_TYPES']['news_end'] = 'int';
     $data['data']['news_class'] = $news['news_class'];
     $data['_FIELD_TYPES']['news_class'] = 'todb';
     $data['data']['news_render_type'] = $news['news_render_type'];
     $data['_FIELD_TYPES']['news_render_type'] = 'todb';
     //news_comment_total
     $data['data']['news_summary'] = $news['news_summary'];
     $data['_FIELD_TYPES']['news_summary'] = 'todb';
     $data['data']['news_thumbnail'] = $news['news_thumbnail'];
     $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
     $data['data']['news_sticky'] = $news['news_sticky'];
     $data['_FIELD_TYPES']['news_sticky'] = 'int';
     $data['data']['news_meta_keywords'] = eHelper::formatMetaKeys($news['news_meta_keywords']);
     $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
     $data['data']['news_meta_description'] = eHelper::formatMetaDescription($news['news_meta_description']);
     //handle bbcodes
     $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
     if ($error) {
         $data['error'] = true;
         return $data;
     }
     // Calculate short strings for admin logging - no need to clog up the log with potentially long items
     $logData = $data['data'];
     if (isset($logData['news_body'])) {
         $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']), 300, '...');
     }
     if (isset($logData['news_extended'])) {
         $logData['news_extended'] = $tp->text_truncate($tp->toDB($logData['news_extended']), 300, '...');
     }
     //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
     if ($news['news_id']) {
         // Updating existing item
         $data['WHERE'] = 'news_id=' . intval($news['news_id']);
         //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
         if ($sql->db_Update('news', $data)) {
             e107::getAdminLog()->logArrayAll('NEWS_09', $logData);
             $data['data']['news_id'] = $news['news_id'];
             e107::getEvent()->trigger('newsupd', $data['data']);
             $message = LAN_NEWS_21;
             $emessage->add(LAN_NEWS_21, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //FIXME - triggerHook should return array(message, message_type)
             $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
//.........这里部分代码省略.........
开发者ID:notzen,项目名称:e107,代码行数:101,代码来源:news_class.php


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