本文整理汇总了PHP中my_strpos函数的典型用法代码示例。如果您正苦于以下问题:PHP my_strpos函数的具体用法?PHP my_strpos怎么用?PHP my_strpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了my_strpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade31_dbchanges
function upgrade31_dbchanges()
{
global $db, $output;
$output->print_header("Updating Database");
echo "<p>Performing necessary upgrade queries...</p>";
flush();
$query = $db->simple_select("templategroups", "COUNT(*) as numexists", "prefix='sendthread'");
if ($db->fetch_field($query, "numexists") == 0) {
$db->insert_query("templategroups", array('prefix' => 'sendthread', 'title' => '<lang:group_sendthread>', 'isdefault' => '1'));
}
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'statslimit\', \'maxmultipagelinks\', \'deleteinvites\', \'gziplevel\', \'subforumsindex\', \'showbirthdayspostlimit\', \'threadsperpage\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'hottopic\', \'hottopicviews\', \'announcementlimit\', \'postsperpage\', \'threadreadcut\', \'similarityrating\', \'similarlimit\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'minnamelength\', \'maxnamelength\', \'minpasswordlength\', \'maxpasswordlength\', \'betweenregstime\', \'maxregsbetweentime\', \'failedcaptchalogincount\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'failedlogincount\', \'failedlogintime\', \'regtime\', \'maxsigimages\', \'siglength\', \'avatarsize\', \'customtitlemaxlength\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'minmessagelength\', \'maxmessagelength\', \'postfloodsecs\', \'postmergemins\', \'maxpostimages\', \'maxpostvideos\', \'subscribeexcerpt\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'wordwrap\', \'maxquotedepth\', \'polloptionlimit\', \'maxpolloptions\', \'polltimelimit\', \'maxattachments\', \'attachthumbh\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'attachthumbw\', \'membersperpage\', \'repsperpage\', \'maxreplength\', \'minreplength\', \'maxwarningpoints\', \'pmfloodsecs\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'maxpmquotedepth\', \'wolcutoffmins\', \'refreshwol\', \'prunepostcount\', \'dayspruneregistered\', \'dayspruneunactivated\', \'portal_numannouncements\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'portal_showdiscussionsnum\', \'searchfloodtime\', \'minsearchword\', \'searchhardlimit\', \'smilieinsertertot\', \'smilieinsertercols\', \'maxloginattempts\') AND optionscode=\'text\'');
$db->update_query('settings', array('optionscode' => 'numeric'), 'name IN (\'loginattemptstimeout\', \'contact_maxsubjectlength\', \'contact_minmessagelength\', \'contact_maxmessagelength\', \'purgespammerpostlimit\', \'purgespammerbangroup\', \'statscachetime\') AND optionscode=\'text\'');
// Update help documents
$query = $db->simple_select('helpdocs', 'document', 'hid=\'3\'');
$helpdoc = $db->fetch_array($query);
if (my_strpos($helpdoc['document'], ';key={1}') !== false) {
$helpdoc['document'] = str_replace(';key={1}', ';my_post_key={1}', $helpdoc['document']);
}
$db->update_query('helpdocs', array('document' => $db->escape_string($helpdoc['document'])), 'hid=\'3\'');
$output->print_contents("<p>Click next to continue with the upgrade process.</p>");
$output->print_footer("31_done");
}
示例2: verify_username
/**
* Verifies if a username is valid or invalid.
*
* @param boolean True when valid, false when invalid.
*/
function verify_username()
{
global $mybb;
$username =& $this->data['username'];
require_once MYBB_ROOT . 'inc/functions_user.php';
// Fix bad characters
$username = trim_blank_chrs($username);
$username = str_replace(array(unichr(160), unichr(173), unichr(0xca), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
// Remove multiple spaces from the username
$username = preg_replace("#\\s{2,}#", " ", $username);
// Check if the username is not empty.
if ($username == '') {
$this->set_error('missing_username');
return false;
}
// Check if the username belongs to the list of banned usernames.
if (is_banned_username($username, true)) {
$this->set_error('banned_username');
return false;
}
// Check for certain characters in username (<, >, &, commas and slashes)
if (strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false)) {
$this->set_error("bad_characters_username");
return false;
}
// Check if the username is of the correct length.
if ($mybb->settings['maxnamelength'] != 0 && my_strlen($username) > $mybb->settings['maxnamelength'] || $mybb->settings['minnamelength'] != 0 && my_strlen($username) < $mybb->settings['minnamelength']) {
$this->set_error('invalid_username_length', array($mybb->settings['minnamelength'], $mybb->settings['maxnamelength']));
return false;
}
return true;
}
示例3: get_board_stat_func
function get_board_stat_func()
{
global $mybb, $cache, $db;
// Get the online users.
$timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
$query = $db->query("\n SELECT s.sid, s.uid, s.time\n FROM " . TABLE_PREFIX . "sessions s\n WHERE s.time>'{$timesearch}'\n ORDER BY s.time DESC\n ");
$membercount = 0;
$guestcount = 0;
$doneusers = array();
// Fetch spiders
$spiders = $cache->read("spiders");
// Loop through all users.
while ($user = $db->fetch_array($query)) {
// Create a key to test if this user is a search bot.
$botkey = my_strtolower(str_replace("bot=", '', $user['sid']));
// Decide what type of user we are dealing with.
if ($user['uid'] > 0) {
// The user is registered.
if ($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']]) {
++$membercount;
$doneusers[$user['uid']] = $user['time'];
}
} elseif (my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey]) {
} else {
++$guestcount;
}
}
$onlinecount = $membercount + $guestcount;
$stats = $cache->read("stats");
$board_stat = array('total_threads' => new xmlrpcval($stats['numthreads'], 'int'), 'total_posts' => new xmlrpcval($stats['numposts'], 'int'), 'total_members' => new xmlrpcval($stats['numusers'], 'int'), 'guest_online' => new xmlrpcval($guestcount, 'int'), 'total_online' => new xmlrpcval($onlinecount, 'int'));
$response = new xmlrpcval($board_stat, 'struct');
return new xmlrpcresp($response);
}
示例4: action
/**
This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
*/
public function action()
{
global $mybb, $db, $cache;
require_once MYBB_ROOT . "inc/functions_online.php";
$timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
switch ($db->type) {
case "sqlite":
$sessions = array();
$query = $db->simple_select("sessions", "sid", "time > {$timesearch}");
while ($sid = $db->fetch_field($query, "sid")) {
$sessions[$sid] = 1;
}
$online_count = count($sessions);
unset($sessions);
break;
case "pgsql":
default:
$query = $db->simple_select("sessions", "COUNT(sid) as online", "time > {$timesearch}");
$online_count = $db->fetch_field($query, "online");
break;
}
$query = $db->query("\n\t\t\tSELECT DISTINCT s.sid, s.ip, s.uid, s.time, s.location, u.username, s.nopermission, u.invisible, u.usergroup, u.displaygroup\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\t\tWHERE s.time>'{$timesearch}'\n\t\t\t");
//ORDER BY $sql
// LIMIT {$start}, {$perpage}
$users = array();
$guests = array();
$spiders = $cache->read("spiders");
while ($user = $db->fetch_array($query)) {
// Fetch the WOL activity
$user['activity'] = fetch_wol_activity($user['location'], $user['nopermission']);
$botkey = my_strtolower(str_replace("bot=", '', $user['sid']));
// Have a registered user
if ($user['uid'] > 0) {
if ($users[$user['uid']]['time'] < $user['time'] || !$users[$user['uid']]) {
$users[$user['uid']] = $user;
}
} else {
if (my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey]) {
$user['bot'] = $spiders[$botkey]['name'];
$user['usergroup'] = $spiders[$botkey]['usergroup'];
$guests[] = $user;
} else {
$guests[] = $user;
}
}
}
foreach ($users as &$user) {
$user["display"] = format_name($user["username"], $user["usergroup"], $user["displaygroup"]);
}
$stdClass = new stdClass();
// remove keys from this otherwise we will get an object of objects, sigh!
$stdClass->users = array_values($users);
$stdClass->guests = $guests;
$stdClass->count = $online_count;
$stdClass->wolcutoffmins = $mybb->settings["wolcutoffmins"];
$stdClass->mostonline = $cache->read("mostonline");
return $stdClass;
}
示例5: init
/**
* Initialize a session
*/
function init()
{
global $db, $mybb, $cache;
// Get our visitor's IP.
$this->ipaddress = get_ip();
$this->packedip = my_inet_pton($this->ipaddress);
// Find out the user agent.
$this->useragent = $_SERVER['HTTP_USER_AGENT'];
// Attempt to find a session id in the cookies.
if (isset($mybb->cookies['sid']) && !defined('IN_UPGRADE')) {
$sid = $db->escape_string($mybb->cookies['sid']);
// Load the session
$query = $db->simple_select("sessions", "*", "sid='{$sid}' AND ip=" . $db->escape_binary($this->packedip));
$session = $db->fetch_array($query);
if ($session['sid']) {
$this->sid = $session['sid'];
}
}
// If we have a valid session id and user id, load that users session.
if (!empty($mybb->cookies['mybbuser'])) {
$logon = explode("_", $mybb->cookies['mybbuser'], 2);
$this->load_user($logon[0], $logon[1]);
}
// If no user still, then we have a guest.
if (!isset($mybb->user['uid'])) {
// Detect if this guest is a search engine spider. (bots don't get a cookied session ID so we first see if that's set)
if (!$this->sid) {
$spiders = $cache->read("spiders");
if (is_array($spiders)) {
foreach ($spiders as $spider) {
if (my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false) {
$this->load_spider($spider['sid']);
}
}
}
}
// Still nothing? JUST A GUEST!
if (!$this->is_spider) {
$this->load_guest();
}
}
// As a token of our appreciation for getting this far (and they aren't a spider), give the user a cookie
if ($this->sid && (!isset($mybb->cookies['sid']) || $mybb->cookies['sid'] != $this->sid) && $this->is_spider != true) {
my_setcookie("sid", $this->sid, -1, true);
}
}
示例6: error
/**
* Parses a error for processing.
*
* @param string The error type (i.e. E_ERROR, E_FATAL)
* @param string The error message
* @param string The error file
* @param integer The error line
* @return boolean True if parsing was a success, otherwise assume a error
*/
function error($type, $message, $file = null, $line = 0)
{
global $mybb;
// Error reporting turned off (either globally or by @ before erroring statement)
if (error_reporting() == 0) {
return true;
}
if (in_array($type, $this->ignore_types)) {
return true;
}
$file = str_replace(MYBB_ROOT, "", $file);
// Do we have a PHP error?
if (my_strpos(my_strtolower($this->error_types[$type]), 'warning') === false) {
$this->debug->log->error("\$type: {$type} \$message: {$message} \$file: {$file} \$line: {$line}");
} else {
$this->debug->log->warning("\$type: {$type} \$message: {$message} \$file: {$file} \$line: {$line}");
}
return parent::error($type, $message, $file, $line);
}
示例7: build_postbit
//.........这里部分代码省略.........
$postnum = $post['postnum'];
$post['postnum'] = my_number_format($post['postnum']);
// Determine the status to show for the user (Online/Offline/Away)
$timecut = TIME_NOW - $mybb->settings['wolcutoff'];
if ($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) {
eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_online") . "\";");
} else {
if ($post['away'] == 1 && $mybb->settings['allowaway'] != 0) {
eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_away") . "\";");
} else {
eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_offline") . "\";");
}
}
if ($post['avatar'] != "" && ($mybb->user['showavatars'] != 0 || !$mybb->user['uid'])) {
$post['avatar'] = htmlspecialchars_uni($post['avatar']);
$avatar_dimensions = explode("|", $post['avatardimensions']);
if ($avatar_dimensions[0] && $avatar_dimensions[1]) {
list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['postmaxavatarsize']));
if ($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height) {
require_once MYBB_ROOT . "inc/functions_image.php";
$scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
$avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
} else {
$avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
}
}
eval("\$post['useravatar'] = \"" . $templates->get("postbit_avatar") . "\";");
$post['avatar_padding'] = "padding-right: 10px;";
} else {
$post['useravatar'] = '';
$post['avatar_padding'] = '';
}
eval("\$post['button_find'] = \"" . $templates->get("postbit_find") . "\";");
if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
eval("\$post['button_pm'] = \"" . $templates->get("postbit_pm") . "\";");
}
if ($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid']) {
if (!$post['pid']) {
$post['pid'] = 0;
}
eval("\$post['button_rep'] = \"" . $templates->get("postbit_rep_button") . "\";");
}
if ($post['website'] != "") {
$post['website'] = htmlspecialchars_uni($post['website']);
eval("\$post['button_www'] = \"" . $templates->get("postbit_www") . "\";");
} else {
$post['button_www'] = "";
}
if ($post['hideemail'] != 1 && $mybb->usergroup['cansendemail'] == 1) {
eval("\$post['button_email'] = \"" . $templates->get("postbit_email") . "\";");
} else {
$post['button_email'] = "";
}
$post['userregdate'] = my_date($mybb->settings['regdateformat'], $post['regdate']);
// Work out the reputation this user has (only show if not announcement)
if ($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) {
$post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
eval("\$post['replink'] = \"" . $templates->get("postbit_reputation") . "\";");
}
// Showing the warning level? (only show if not announcement)
if ($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
$warning_level = round($post['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
if ($warning_level > 100) {
$warning_level = 100;
}
$warning_level = get_colored_warning_level($warning_level);
示例8: die
* MyBB 1.6
* Copyright 2010 MyBB Group, All Rights Reserved
*
* Website: http://mybb.com
* License: http://mybb.com/about/license
*
* $Id$
*/
// Disallow direct access to this file for security reasons
if (!defined("IN_MYBB")) {
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
// Neat trick for caching our custom template(s)
// Basically, when we include this from class_plugins.php we can do stuff in init.php, which is before we cache our templates
// So we won't need an extra call to cache it.
if (my_strpos($_SERVER['PHP_SELF'], 'showthread.php')) {
global $templatelist;
if (isset($templatelist)) {
$templatelist .= ',';
}
$templatelist .= 'akismet_postbit_spam';
}
$plugins->add_hook("datahandler_post_insert_thread", "akismet_verify");
$plugins->add_hook("datahandler_post_insert_thread_post", "akismet_verify");
$plugins->add_hook("datahandler_post_insert_post", "akismet_verify");
$plugins->add_hook("datahandler_post_validate_post", "akismet_fake_draft");
$plugins->add_hook("datahandler_post_validate_thread", "akismet_fake_draft");
$plugins->add_hook("newreply_do_newreply_end", "akismet_redirect_thread");
$plugins->add_hook("newthread_do_newthread_end", "akismet_redirect_forum");
$plugins->add_hook("moderation_start", "akismet_moderation_start");
$plugins->add_hook("postbit", "akismet_postbit");
示例9: ceil
$remaining_time_minutes = ceil($remaining_time / 60);
$lang->error_emailflooding = $lang->sprintf($lang->error_emailflooding_minutes, $mybb->usergroup['emailfloodtime'], $remaining_time_minutes);
}
error($lang->error_emailflooding);
}
}
$query = $db->simple_select("users", "uid, username, email, hideemail, ignorelist", "uid='" . $mybb->get_input('uid', MyBB::INPUT_INT) . "'");
$to_user = $db->fetch_array($query);
$lang->email_user = $lang->sprintf($lang->email_user, $to_user['username']);
if (!$to_user['uid']) {
error($lang->error_invaliduser);
}
if ($to_user['hideemail'] != 0) {
error($lang->error_hideemail);
}
if ($to_user['ignorelist'] && (my_strpos("," . $to_user['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") !== false && $mybb->usergroup['cansendemailoverride'] != 1)) {
error_no_permission();
}
if (isset($errors) && count($errors) > 0) {
$errors = inline_error($errors);
$fromname = htmlspecialchars_uni($mybb->get_input('fromname'));
$fromemail = htmlspecialchars_uni($mybb->get_input('fromemail'));
$subject = htmlspecialchars_uni($mybb->get_input('subject'));
$message = htmlspecialchars_uni($mybb->get_input('message'));
} else {
$errors = '';
$fromname = '';
$fromemail = '';
$subject = '';
$message = '';
}
示例10: intval
$pagenum = intval($mybb->input['page']);
if ($pagenum) {
$start = ($pagenum - 1) * 20;
} else {
$start = 0;
$pagenum = 1;
}
$table = new Table();
$table->construct_header($lang->image, array("class" => "align_center", "width" => 1));
$table->construct_header($lang->name, array("width" => "35%"));
$table->construct_header($lang->text_replace, array("width" => "35%"));
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
$query = $db->simple_select("smilies", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'disporder'));
while ($smilie = $db->fetch_array($query)) {
$smilie['image'] = str_replace("{theme:imgdir}", $theme['imgdir'], $smilie['image']);
if (my_strpos($smilie['image'], "p://") || substr($smilie['image'], 0, 1) == "/") {
$image = $smilie['image'];
} else {
$image = "../" . $smilie['image'];
}
$table->construct_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center"));
$table->construct_cell(htmlspecialchars_uni($smilie['name']));
$table->construct_cell(htmlspecialchars_uni($smilie['find']));
$table->construct_cell("<a href=\"index.php?module=config-smilies&action=edit&sid={$smilie['sid']}\">{$lang->edit}</a>", array("class" => "align_center"));
$table->construct_cell("<a href=\"index.php?module=config-smilies&action=delete&sid={$smilie['sid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_smilie_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
$table->construct_row();
}
if ($table->num_rows() == 0) {
$table->construct_cell($lang->no_smilies, array('colspan' => 5));
$table->construct_row();
}
示例11: array
$sub_tabs['add_multiple'] = array('title' => $lang->add_multiple_post_icons, 'link' => "index.php?module=config/post_icons&action=add_multiple");
$page->output_nav_tabs($sub_tabs, 'manage_icons');
$pagenum = intval($mybb->input['page']);
if ($pagenum) {
$start = ($pagenum - 1) * 20;
} else {
$start = 0;
$pagenum = 1;
}
$table = new Table();
$table->construct_header($lang->image, array('class' => "align_center", 'width' => 1));
$table->construct_header($lang->name, array('width' => "70%"));
$table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
$query = $db->simple_select("icons", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'name'));
while ($icon = $db->fetch_array($query)) {
if (my_strpos($icon['path'], "p://") || substr($icon['path'], 0, 1) == "/") {
$image = $icon['path'];
} else {
$image = "../" . $icon['path'];
}
$table->construct_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center"));
$table->construct_cell("{$icon['name']}");
$table->construct_cell("<a href=\"index.php?module=config/post_icons&action=edit&iid={$icon['iid']}\">{$lang->edit}</a>", array("class" => "align_center"));
$table->construct_cell("<a href=\"index.php?module=config/post_icons&action=delete&iid={$icon['iid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_post_icon_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
$table->construct_row();
}
if ($table->num_rows() == 0) {
$table->construct_cell($lang->no_post_icons, array('colspan' => 4));
$table->construct_row();
}
$table->output($lang->manage_post_icons);
示例12: ougc_showinportal_newthread_end
function ougc_showinportal_newthread_end()
{
global $modoptions;
if (!isset($modoptions) || my_strpos($modoptions, '<!--OUGC_SHOWINPORTAL-->') === false) {
return;
}
global $showinportal, $mybb, $fid;
if (!$showinportal->can_moderate($fid)) {
return;
}
global $templates, $lang, $thread;
$showinportal->lang_load();
// Figure out if checked
if (THIS_SCRIPT == 'newreply.php' && !isset($mybb->input['modoptions']) && !isset($mybb->input['modoptions']['showinportal']) && isset($thread['showinportal'])) {
$mybb->input['modoptions']['showinportal'] = (int) $thread['showinportal'];
}
$sip = (int) $mybb->input['modoptions']['showinportal'];
$checked = '';
if (!empty($sip)) {
$checked = ' checked="checked"';
}
// Show the option
$name = 'modoptions[showinportal]';
$message = $lang->ougc_showinportal_input_newthread;
eval('$ougc_showinportal = "' . $templates->get('ougcshowinportal_input') . '";');
$modoptions = str_replace('<!--OUGC_SHOWINPORTAL-->', $ougc_showinportal, $modoptions);
}
示例13: verify_subject
/**
* Verifies a post subject.
*
* @param string True if the subject is valid, false if invalid.
* @return boolean True when valid, false when not valid.
*/
function verify_subject()
{
global $db;
$post =& $this->data;
$subject =& $post['subject'];
$subject = trim_blank_chrs($subject);
// Are we editing an existing thread or post?
if ($this->method == "update" && $post['pid']) {
if (empty($post['tid'])) {
$query = $db->simple_select("posts", "tid", "pid='" . (int) $post['pid'] . "'");
$post['tid'] = $db->fetch_field($query, "tid");
}
// Here we determine if we're editing the first post of a thread or not.
$options = array("limit" => 1, "limit_start" => 0, "order_by" => "dateline", "order_dir" => "asc");
$query = $db->simple_select("posts", "pid", "tid='" . $post['tid'] . "'", $options);
$first_check = $db->fetch_array($query);
if ($first_check['pid'] == $post['pid']) {
$first_post = true;
} else {
$first_post = false;
}
// If this is the first post there needs to be a subject, else make it the default one.
if (my_strlen($subject) == 0 && $first_post) {
$this->set_error("firstpost_no_subject");
return false;
} elseif (my_strlen($subject) == 0) {
$thread = get_thread($post['tid']);
$subject = "RE: " . $thread['subject'];
}
} else {
if ($this->action == "post") {
if (my_strlen($subject) == 0) {
$thread = get_thread($post['tid']);
$subject = "RE: " . $thread['subject'];
}
} else {
if (my_strlen($subject) == 0) {
$this->set_error("missing_subject");
return false;
}
}
}
// If post is reply and begins with "RE: ", remove 4 from subject length.
$subject_length = my_strlen($subject);
if ($this->action == "post") {
$position_re = my_strpos($subject, "RE: ");
if ($position_re !== false && $position_re == 0) {
$subject_length = $subject_length - 4;
}
}
if ($subject_length > 85) {
// Subject is too long
$this->set_error('subject_too_long', my_strlen($subject));
return false;
}
// Subject is valid - return true.
return true;
}
示例14: clean_keywords_ft
/**
* Clean search keywords for fulltext searching, making them safe for querying
*
* @param string The keywords to be cleaned
* @return string The cleaned keywords
*/
function clean_keywords_ft($keywords)
{
if (!$keywords) {
return false;
}
$keywords = my_strtolower($keywords);
$keywords = str_replace("%", "\\%", $keywords);
$keywords = preg_replace("#\\*{2,}#s", "*", $keywords);
$keywords = preg_replace("#([\\[\\]\\|\\.\\,:])#s", " ", $keywords);
$keywords = preg_replace("#\\s+#s", " ", $keywords);
$words = array();
if (my_strpos($keywords, "\"") !== false) {
$inquote = false;
$keywords = explode("\"", $keywords);
foreach ($keywords as $phrase) {
if ($phrase != '') {
if ($inquote) {
$words[] = "\"" . trim($phrase) . "\"";
} else {
$split_words = preg_split("#\\s{1,}#", $phrase, -1);
if (!is_array($split_words)) {
continue;
}
foreach ($split_words as $word) {
if (!$word) {
continue;
}
$words[] = trim($word);
}
}
}
$inquote = !$inquote;
}
} else {
$split_words = preg_split("#\\s{1,}#", $keywords, -1);
if (!is_array($split_words)) {
continue;
}
foreach ($split_words as $word) {
if (!$word) {
continue;
}
$words[] = trim($word);
}
}
$keywords = '';
foreach ($words as $word) {
if ($word == "or") {
$boolean = '';
} elseif ($word == "and") {
$boolean = "+";
} elseif ($word == "not") {
$boolean = "-";
} else {
$keywords .= " " . $boolean . $word;
$boolean = '';
}
}
$keywords = "+" . trim($keywords);
return $keywords;
}
示例15: configure
function configure()
{
global $output, $mybb, $errors, $lang;
$output->print_header($lang->board_config, 'config');
// If board configuration errors
if (is_array($errors)) {
$error_list = error_list($errors);
echo $lang->sprintf($lang->config_step_error_config, $error_list);
$bbname = htmlspecialchars_uni($mybb->input['bbname']);
$bburl = htmlspecialchars_uni($mybb->input['bburl']);
$websitename = htmlspecialchars_uni($mybb->input['websitename']);
$websiteurl = htmlspecialchars_uni($mybb->input['websiteurl']);
$cookiedomain = htmlspecialchars_uni($mybb->input['cookiedomain']);
$cookiepath = htmlspecialchars_uni($mybb->input['cookiepath']);
$contactemail = htmlspecialchars_uni($mybb->input['contactemail']);
} else {
$bbname = 'Forums';
$cookiedomain = '';
$cookiepath = '/';
$websiteurl = $hostname . '/';
$websitename = 'Your Website';
$contactemail = '';
$protocol = "http://";
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" || substr($bburl, 0, 5) == "https") {
$protocol = "https://";
}
// Attempt auto-detection
if ($_SERVER['HTTP_HOST']) {
$hostname = $protocol . $_SERVER['HTTP_HOST'];
$cookiedomain = '.' . $_SERVER['HTTP_HOST'];
} elseif ($_SERVER['SERVER_NAME']) {
$hostname = $protocol . $_SERVER['SERVER_NAME'];
$cookiedomain = '.' . $_SERVER['SERVER_NAME'];
}
if (substr($cookiedomain, 0, 5) == ".www.") {
$cookiedomain = my_substr($cookiedomain, 4);
}
if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'localhost' || ip2long($_SERVER['SERVER_NAME']) != false) {
$cookiedomain = '';
}
if ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 && !preg_match("#:[0-9]#i", $hostname)) {
$hostname .= ':' . $_SERVER['SERVER_PORT'];
}
$currentlocation = get_current_location();
if ($currentlocation) {
// TODO: Change this to find the last position of /install/
$pos = my_strpos($currentlocation, '/install/');
if ($pos === 0) {
$cookiepath = "/";
} else {
$cookiepath = my_substr($currentlocation, 0, $pos) . '/';
}
}
$currentscript = $hostname . get_current_location();
if ($currentscript) {
$bburl = my_substr($currentscript, 0, my_strpos($currentscript, '/install/'));
}
if ($_SERVER['SERVER_ADMIN']) {
$contactemail = $_SERVER['SERVER_ADMIN'];
}
}
echo $lang->sprintf($lang->config_step_table, $bbname, $bburl, $websitename, $websiteurl, $cookiedomain, $cookiepath, $contactemail);
$output->print_footer('adminuser');
}