本文整理汇总了PHP中my_serialize函数的典型用法代码示例。如果您正苦于以下问题:PHP my_serialize函数的具体用法?PHP my_serialize怎么用?PHP my_serialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了my_serialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
if ($access == 0) {
++$no_access;
}
}
// User can't access any actions in this module - just disallow it completely
if ($no_access == count($actions)) {
unset($mybb->input['permissions'][$module]);
}
}
// Does an options row exist for this admin already?
$query = $db->simple_select("adminoptions", "COUNT(uid) AS existing_options", "uid='" . $mybb->get_input('uid', MyBB::INPUT_INT) . "'");
$existing_options = $db->fetch_field($query, "existing_options");
if ($existing_options > 0) {
$db->update_query("adminoptions", array('permissions' => $db->escape_string(my_serialize($mybb->input['permissions']))), "uid = '" . $mybb->get_input('uid', MyBB::INPUT_INT) . "'");
} else {
$insert_array = array("uid" => $mybb->get_input('uid', MyBB::INPUT_INT), "permissions" => $db->escape_string(my_serialize($mybb->input['permissions'])), "notes" => '', "defaultviews" => '');
$db->insert_query("adminoptions", $insert_array);
}
$plugins->run_hooks("admin_user_admin_permissions_edit_commit");
// Log admin action
if ($uid > 0) {
// Users
$user = get_user($uid);
log_admin_action($uid, $user['username']);
} elseif ($uid < 0) {
// Groups
$gid = abs($uid);
$query = $db->simple_select("usergroups", "title", "gid='{$gid}'");
$group = $db->fetch_array($query);
log_admin_action($uid, $group['title']);
} else {
示例2: eval
$modann = '';
}
$plugins->run_hooks("forumdisplay_announcement");
eval("\$announcements .= \"" . $templates->get("forumdisplay_announcements_announcement") . "\";");
$bgcolor = alt_trow();
}
if ($announcements) {
eval("\$announcementlist = \"" . $templates->get("forumdisplay_announcements") . "\";");
$shownormalsep = true;
}
if (empty($cookie)) {
// Clean up cookie crumbs
my_setcookie('mybb[announcements]', 0, TIME_NOW - 60 * 60 * 24 * 365);
} else {
if (!empty($cookie)) {
my_setcookie("mybb[announcements]", addslashes(my_serialize($cookie)), -1);
}
}
} else {
$announcementlist = '';
}
$tids = $threadcache = array();
$icon_cache = $cache->read("posticons");
if ($fpermissions['canviewthreads'] != 0) {
$plugins->run_hooks("forumdisplay_get_threads");
// Start Getting Threads
$query = $db->query("\n\t\tSELECT t.*, {$ratingadd}t.username AS threadusername, u.username\n\t\tFROM " . TABLE_PREFIX . "threads t\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid)\n\t\tWHERE t.fid='{$fid}' {$tuseronly} {$tvisibleonly} {$datecutsql2} {$prefixsql2}\n\t\tORDER BY t.sticky DESC, {$t}{$sortfield} {$sortordernow} {$sortfield2}\n\t\tLIMIT {$start}, {$perpage}\n\t");
$ratings = false;
$moved_threads = array();
while ($thread = $db->fetch_array($query)) {
$threadcache[$thread['tid']] = $thread;
示例3: my_unserialize
exit;
}
$page->show_login($login_message, "error");
}
}
// Time to check for Two-Factor Authentication
// First: are we trying to verify a code?
if ($mybb->input['do'] == "do_2fa" && $mybb->request_method == "post") {
// Test whether it's a recovery code
$recovery = false;
$codes = my_unserialize($admin_options['recovery_codes']);
if (!empty($codes) && in_array($mybb->get_input('code'), $codes)) {
$recovery = true;
$ncodes = array_diff($codes, array($mybb->input['code']));
// Removes our current code from the codes array
$db->update_query("adminoptions", array("recovery_codes" => $db->escape_string(my_serialize($ncodes))), "uid='{$mybb->user['uid']}'");
if (count($ncodes) == 0) {
flash_message($lang->my2fa_no_codes, "error");
}
}
// Validate the code
require_once MYBB_ROOT . "inc/3rdparty/2fa/GoogleAuthenticator.php";
$auth = new PHPGangsta_GoogleAuthenticator();
$test = $auth->verifyCode($admin_options['authsecret'], $mybb->get_input('code'));
// Either the code was okay or it was a recovery code
if ($test === true || $recovery === true) {
// Correct code -> session authenticated
$db->update_query("adminsessions", array("authenticated" => 1), "sid='" . $db->escape_string($mybb->cookies['adminsid']) . "'");
$admin_session['authenticated'] = 1;
$db->update_query("adminoptions", array("loginattempts" => 0, "loginlockoutexpiry" => 0), "uid='{$mybb->user['uid']}'");
my_setcookie('acploginattempts', 0);
示例4: array
$errors[] = $lang->error_missing_action_type;
}
if (!$errors) {
// Ban
if ($mybb->input['action_type'] == 1) {
$action = array("type" => 1, "usergroup" => $mybb->get_input('action_1_usergroup', MyBB::INPUT_INT), "length" => fetch_time_length($mybb->input['action_1_time'], $mybb->input['action_1_period']));
} else {
if ($mybb->input['action_type'] == 2) {
$action = array("type" => 2, "length" => fetch_time_length($mybb->input['action_2_time'], $mybb->input['action_2_period']));
} else {
if ($mybb->input['action_type'] == 3) {
$action = array("type" => 3, "length" => fetch_time_length($mybb->input['action_3_time'], $mybb->input['action_3_period']));
}
}
}
$updated_level = array("percentage" => $mybb->get_input('percentage', MyBB::INPUT_INT), "action" => my_serialize($action));
$plugins->run_hooks("admin_config_warning_edit_level_commit");
$db->update_query("warninglevels", $updated_level, "lid='{$level['lid']}'");
// Log admin action
log_admin_action($level['lid'], $mybb->input['percentage']);
flash_message($lang->success_warning_level_updated, 'success');
admin_redirect("index.php?module=config-warning&action=levels");
}
}
$page->add_breadcrumb_item($lang->edit_warning_level);
$page->output_header($lang->warning_levels . " - " . $lang->edit_warning_level);
$sub_tabs['edit_level'] = array('link' => "index.php?module=config-warning&action=edit_level&lid={$level['lid']}", 'title' => $lang->edit_warning_level, 'description' => $lang->edit_warning_level_desc);
$page->output_nav_tabs($sub_tabs, 'edit_level');
$form = new Form("index.php?module=config-warning&action=edit_level&lid={$level['lid']}", "post");
if ($errors) {
$page->output_inline_error($errors);
示例5: urlencode
$popup->add_item($lang->show_users_posted_with_ip, "index.php?module=user-users&results=1&action=search&conditions=" . urlencode(my_serialize(array("postip" => $user['regip']))));
$popup->add_item($lang->info_on_ip, "index.php?module=user-users&action=iplookup&ipaddress={$user['regip']}", "MyBB.popupWindow('index.php?module=user-users&action=iplookup&ipaddress={$user['regip']}', null, true); return false;");
$popup->add_item($lang->ban_ip, "index.php?module=config-banning&filter={$user['regip']}");
$controls = $popup->fetch();
}
$table->construct_cell("<strong>{$lang->registration_ip}:</strong> " . $user['regip']);
$table->construct_cell($controls, array('class' => "align_center"));
$table->construct_row();
$counter = 0;
$query = $db->simple_select("posts", "DISTINCT ipaddress", "uid='{$mybb->input['uid']}'");
while ($ip = $db->fetch_array($query)) {
++$counter;
$ip['ipaddress'] = my_inet_ntop($db->unescape_binary($ip['ipaddress']));
$popup = new PopupMenu("id_{$counter}", $lang->options);
$popup->add_item($lang->show_users_regged_with_ip, "index.php?module=user-users&results=1&action=search&conditions=" . urlencode(my_serialize(array("regip" => $ip['ipaddress']))));
$popup->add_item($lang->show_users_posted_with_ip, "index.php?module=user-users&results=1&action=search&conditions=" . urlencode(my_serialize(array("postip" => $ip['ipaddress']))));
$popup->add_item($lang->info_on_ip, "index.php?module=user-users&action=iplookup&ipaddress={$ip['ipaddress']}", "MyBB.popupWindow('index.php?module=user-users&action=iplookup&ipaddress={$ip['ipaddress']}', null, true); return false;");
$popup->add_item($lang->ban_ip, "index.php?module=config-banning&filter={$ip['ipaddress']}");
$controls = $popup->fetch();
$table->construct_cell($ip['ipaddress']);
$table->construct_cell($controls, array('class' => "align_center"));
$table->construct_row();
}
$table->output($lang->ip_address_for . " {$user['username']}");
$page->output_footer();
}
if ($mybb->input['action'] == "merge") {
$plugins->run_hooks("admin_user_users_merge");
if ($mybb->request_method == "post") {
$source_user = get_user_by_username($mybb->input['source_username'], array('fields' => '*'));
if (!$source_user['uid']) {
示例6: set_default_view
function set_default_view($type, $vid)
{
global $mybb, $db;
$query = $db->simple_select("adminoptions", "defaultviews", "uid='{$mybb->user['uid']}'");
$default_views = my_unserialize($db->fetch_field($query, "defaultviews"));
if (!$db->num_rows($query)) {
$create = true;
}
$default_views[$type] = $vid;
$default_views = my_serialize($default_views);
$updated_admin = array("defaultviews" => $db->escape_string($default_views));
if ($create == true) {
$updated_admin['uid'] = $mybb->user['uid'];
$updated_admin['notes'] = '';
$updated_admin['permissions'] = '';
$db->insert_query("adminoptions", $updated_admin);
} else {
$db->update_query("adminoptions", $updated_admin, "uid='{$mybb->user['uid']}'");
}
}
示例7: flash_message
if (!is_array($mybb->input['tables'])) {
flash_message($lang->error_no_tables_selected, 'error');
admin_redirect("index.php?module=tools-optimizedb");
}
@set_time_limit(0);
$db->set_table_prefix('');
foreach ($mybb->input['tables'] as $table) {
if ($db->table_exists($db->escape_string($table))) {
$db->optimize_table($table);
$db->analyze_table($table);
}
}
$db->set_table_prefix(TABLE_PREFIX);
$plugins->run_hooks("admin_tools_optimizedb_start_begin");
// Log admin action
log_admin_action(my_serialize($mybb->input['tables']));
flash_message($lang->success_tables_optimized, 'success');
admin_redirect("index.php?module=tools-optimizedb");
}
$page->extra_header = "\t<script type=\"text/javascript\">\n\tfunction changeSelection(action, prefix)\n\t{\n\t\tvar select_box = document.getElementById('table_select');\n\n\t\tfor(var i = 0; i < select_box.length; i++)\n\t\t{\n\t\t\tif(action == 'select')\n\t\t\t{\n\t\t\t\tselect_box[i].selected = true;\n\t\t\t}\n\t\t\telse if(action == 'deselect')\n\t\t\t{\n\t\t\t\tselect_box[i].selected = false;\n\t\t\t}\n\t\t\telse if(action == 'forum' && prefix != 0)\n\t\t\t{\n\t\t\t\tselect_box[i].selected = false;\n\t\t\t\tvar row = select_box[i].value;\n\t\t\t\tvar subString = row.substring(prefix.length, 0);\n\t\t\t\tif(subString == prefix)\n\t\t\t\t{\n\t\t\t\t\tselect_box[i].selected = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t</script>\n";
$page->output_header($lang->optimize_database);
$table = new Table();
$table->construct_header($lang->table_selection);
$table_selects = array();
$table_list = $db->list_tables($config['database']['database']);
foreach ($table_list as $id => $table_name) {
$table_selects[$table_name] = $table_name;
}
$form = new Form("index.php?module=tools-optimizedb", "post", "table_selection", 0, "table_selection");
$table->construct_cell("{$lang->tables_select_desc}\n<br /><br />\n<a href=\"javascript:changeSelection('select', 0);\">{$lang->select_all}</a><br />\n<a href=\"javascript:changeSelection('deselect', 0);\">{$lang->deselect_all}</a><br />\n<a href=\"javascript:changeSelection('forum', '" . TABLE_PREFIX . "');\">{$lang->select_forum_tables}</a>\n<br /><br />\n<div class=\"form_row\">" . $form->generate_select_box("tables[]", $table_selects, false, array('multiple' => true, 'id' => 'table_select', 'size' => 20)) . "</div>", array('rowspan' => 5, 'width' => '50%'));
$table->construct_row();
示例8: upgrade30_updatetheme
function upgrade30_updatetheme()
{
global $db, $mybb, $output, $config;
if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) {
require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php";
} else {
if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) {
require_once MYBB_ROOT . "admin/inc/functions_themes.php";
} else {
$output->print_error("Please make sure your admin directory is uploaded correctly.");
}
}
$output->print_header("Updating Themes");
// New default user star
$contents = "<p>Updating the Default user star image... ";
$db->update_query("usergroups", array('starimage' => 'images/star.png'), "starimage='images/star.gif'");
$contents .= "done.</p>";
$contents .= "<p>Adding new stylesheets... ";
$query = $db->simple_select("themes", "*", "tid='1'");
$theme = $db->fetch_array($query);
$properties = my_unserialize($theme['properties']);
$stylesheets = my_unserialize($theme['stylesheets']);
$old = array("global.css", "usercp.css", "modcp.css", "star_ratings.css");
require_once MYBB_ROOT . "inc/class_xml.php";
$colors = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme.xml');
$parser = new XMLParser($colors);
$tree = $parser->get_tree();
if (is_array($tree) && is_array($tree['theme'])) {
if (is_array($tree['theme']['stylesheets'])) {
foreach ($tree['theme']['stylesheets']['stylesheet'] as $stylesheet) {
$new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => 1, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => TIME_NOW, "cachefile" => $db->escape_string($stylesheet['attributes']['name']));
if (in_array($new_stylesheet['name'], $old)) {
// We can update the disporder here
$properties['disporder'][$stylesheet['attributes']['name']] = $stylesheet['attributes']['disporder'];
} else {
// Insert new stylesheet
$sid = $db->insert_query("themestylesheets", $new_stylesheet);
$css_url = "css.php?stylesheet={$sid}";
$cached = cache_stylesheet($tid, $stylesheet['attributes']['name'], $stylesheet['value']);
if ($cached) {
$css_url = $cached;
}
// Add to display and stylesheet list
$properties['disporder'][$stylesheet['attributes']['name']] = $stylesheet['attributes']['disporder'];
$attachedto = $stylesheet['attributes']['attachedto'];
if (!$attachedto) {
$attachedto = "global";
}
// private.php?compose,folders|usercp.php,global|global
$attachedto = explode("|", $attachedto);
foreach ($attachedto as $attached_file) {
$attached_actions = explode(",", $attached_file);
$attached_file = array_shift($attached_actions);
if (count($attached_actions) == 0) {
$attached_actions = array("global");
}
foreach ($attached_actions as $action) {
$stylesheets[$attached_file][$action][] = $css_url;
}
}
}
}
}
}
$update_array = array("properties" => $db->escape_string(my_serialize($properties)), "stylesheets" => $db->escape_string(my_serialize($stylesheets)));
$db->update_query("themes", $update_array, "tid = '1'");
$contents .= "done.</p>";
$contents .= "<p>Adding a disporder to all stylesheets... ";
$query = $db->simple_select("themes", "tid,properties,stylesheets");
while ($theme = $db->fetch_array($query)) {
$properties = my_unserialize($theme['properties']);
$stylesheets = my_unserialize($theme['stylesheets']);
// Disporder already set?
if (isset($properties['disporder']) && !empty($properties['disporder'])) {
continue;
}
$disporder = 1;
// First go through all own stylesheets
$query2 = $db->simple_select("themestylesheets", "name", "tid='{$theme['tid']}'");
while ($name = $db->fetch_field($query2, "name")) {
$properties['disporder'][$name] = $disporder;
$disporder++;
}
// Next go through the inherited stylesheets
if (!empty($stylesheets)) {
foreach ($stylesheets as $a) {
foreach ($a as $file => $stylesheet) {
// Don't ask me... Throws an error otherwise
if (empty($stylesheet)) {
continue;
}
foreach ($stylesheet as $s) {
$name = pathinfo($s, PATHINFO_BASENAME);
if (empty($properties['disporder']) || !in_array($name, array_keys($properties['disporder']))) {
$properties['disporder'][$name] = $disporder;
$disporder++;
}
}
}
}
//.........这里部分代码省略.........
示例9: update_theme_stylesheet_list
/**
* @param int $tid
* @param bool|array $theme
* @param bool $update_disporders
*
* @return bool
*/
function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true)
{
global $mybb, $db, $cache, $plugins;
$stylesheets = array();
$child_list = make_child_theme_list($tid);
$parent_list = make_parent_theme_list($tid);
if (!is_array($parent_list)) {
return false;
}
$tid_list = implode(',', $parent_list);
// Get our list of stylesheets
$query = $db->simple_select("themestylesheets", "*", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));
while ($stylesheet = $db->fetch_array($query)) {
if (empty($stylesheets[$stylesheet['name']])) {
if ($stylesheet['tid'] != $tid) {
$stylesheet['inherited'] = $stylesheet['tid'];
}
$stylesheets[$stylesheet['name']] = $stylesheet;
}
}
$theme_stylesheets = array();
foreach ($stylesheets as $name => $stylesheet) {
$sid = $stylesheet['sid'];
$css_url = "css.php?stylesheet={$sid}";
foreach ($parent_list as $theme_id) {
if ($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath'])) {
$cdnpath = rtrim($mybb->settings['cdnpath'], '/\\') . '/';
if (file_exists($cdnpath . "cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime($cdnpath . "cache/themes/theme{$theme_id}/{$stylesheet['name']}") >= $stylesheet['lastmodified']) {
$css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}";
break;
}
} else {
if (file_exists(MYBB_ROOT . "cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(MYBB_ROOT . "cache/themes/theme{$theme_id}/{$stylesheet['name']}") >= $stylesheet['lastmodified']) {
$css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}";
break;
}
}
}
if (is_object($plugins)) {
$plugins->run_hooks('update_theme_stylesheet_list_set_css_url', $css_url);
}
$attachedto = $stylesheet['attachedto'];
if (!$attachedto) {
$attachedto = "global";
}
// private.php?compose,folders|usercp.php,global|global
$attachedto = explode("|", $attachedto);
foreach ($attachedto as $attached_file) {
$attached_actions = array();
if (strpos($attached_file, '?') !== false) {
$attached_file = explode('?', $attached_file);
$attached_actions = explode(",", $attached_file[1]);
$attached_file = $attached_file[0];
}
if (count($attached_actions) == 0) {
$attached_actions = array("global");
}
foreach ($attached_actions as $action) {
$theme_stylesheets[$attached_file][$action][] = $css_url;
if (!empty($stylesheet['inherited'])) {
$theme_stylesheets['inherited']["{$attached_file}_{$action}"][$css_url] = $stylesheet['inherited'];
}
}
}
}
// Now we have our list of built stylesheets, save them
$updated_theme = array("stylesheets" => $db->escape_string(my_serialize($theme_stylesheets)));
// Do we have a theme present? If so, update the stylesheet display orders
if ($update_disporders) {
if (!is_array($theme) || !$theme) {
$theme_cache = cache_themes();
$theme = $theme_cache[$tid];
}
$orders = $orphaned_stylesheets = array();
$properties = $theme['properties'];
if (!is_array($properties)) {
$properties = my_unserialize($theme['properties']);
}
$max_disporder = 0;
foreach ($stylesheets as $stylesheet) {
if (!isset($properties['disporder'][$stylesheet['name']])) {
$orphaned_stylesheets[] = $stylesheet['name'];
continue;
}
if ($properties['disporder'][$stylesheet['name']] > $max_disporder) {
$max_disporder = $properties['disporder'][$stylesheet['name']];
}
$orders[$stylesheet['name']] = $properties['disporder'][$stylesheet['name']];
}
if (!empty($orphaned_stylesheets)) {
$loop = $max_disporder + 1;
$max_disporder = $loop;
foreach ($orphaned_stylesheets as $stylesheet) {
//.........这里部分代码省略.........
示例10: flush
}
}
$page->output_header("{$lang->orphan_attachments_search} - {$lang->step1}");
$page->output_nav_tabs($sub_tabs, 'find_orphans');
echo "<h3>{$lang->step1of2}</h3>";
echo "<p class=\"align_center\">{$lang->step1of2_line1}</p>";
echo "<p class=\"align_center\">{$lang->step_line2}</p>";
echo "<p class=\"align_center\"><img src=\"styles/{$page->style}/images/spinner_big.gif\" alt=\"{$lang->scanning}\" id=\"spinner\" /></p>";
$page->output_footer(false);
flush();
scan_attachments_directory();
global $bad_attachments;
$form = new Form("index.php?module=forum-attachments&action=orphans&step=2", "post", "redirect_form", 0, "");
// Scan complete
if (is_array($bad_attachments) && count($bad_attachments) > 0) {
$bad_attachments = my_serialize($bad_attachments);
echo $form->generate_hidden_field("bad_attachments", $bad_attachments);
}
$form->end();
echo "<script type=\"text/javascript\">\$(function() {\n\t\t\t\twindow.setTimeout(\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\t\$(\"#redirect_form\").submit();\n\t\t\t\t\t}, 100\n\t\t\t\t);\n\t\t\t});</script>";
exit;
}
}
}
if (!$mybb->input['action']) {
$plugins->run_hooks("admin_forum_attachments_start");
if ($mybb->request_method == "post" || $mybb->input['results'] == 1) {
$search_sql = '1=1';
// Build the search SQL for users
// List of valid LIKE search fields
$user_like_fields = array("filename", "filetype");
示例11: insert_pm
/**
* Insert a new private message.
*
* @return array Array of PM useful data.
*/
function insert_pm()
{
global $cache, $db, $mybb, $plugins, $lang;
// Yes, validating is required.
if (!$this->get_validated()) {
die("The PM needs to be validated before inserting it into the DB.");
}
if (count($this->get_errors()) > 0) {
die("The PM is not valid.");
}
// Assign data to common variable
$pm =& $this->data;
if (empty($pm['pmid'])) {
$pm['pmid'] = 0;
}
$pm['pmid'] = (int) $pm['pmid'];
if (empty($pm['icon']) || $pm['icon'] < 0) {
$pm['icon'] = 0;
}
$uid = 0;
if (!is_array($pm['recipients'])) {
$recipient_list = array();
} else {
// Build recipient list
foreach ($pm['recipients'] as $recipient) {
if (!empty($recipient['bcc'])) {
$recipient_list['bcc'][] = $recipient['uid'];
} else {
$recipient_list['to'][] = $recipient['uid'];
$uid = $recipient['uid'];
}
}
}
$this->pm_insert_data = array('fromid' => (int) $pm['sender']['uid'], 'folder' => $pm['folder'], 'subject' => $db->escape_string($pm['subject']), 'icon' => (int) $pm['icon'], 'message' => $db->escape_string($pm['message']), 'dateline' => TIME_NOW, 'status' => 0, 'includesig' => $pm['options']['signature'], 'smilieoff' => $pm['options']['disablesmilies'], 'receipt' => (int) $pm['options']['readreceipt'], 'readtime' => 0, 'recipients' => $db->escape_string(my_serialize($recipient_list)), 'ipaddress' => $db->escape_binary($pm['ipaddress']));
// Check if we're updating a draft or not.
$query = $db->simple_select("privatemessages", "pmid, deletetime", "folder='3' AND uid='" . (int) $pm['sender']['uid'] . "' AND pmid='{$pm['pmid']}'");
$draftcheck = $db->fetch_array($query);
// This PM was previously a draft
if ($draftcheck['pmid']) {
if ($draftcheck['deletetime']) {
// This draft was a reply to a PM
$pm['pmid'] = $draftcheck['deletetime'];
$pm['do'] = "reply";
}
// Delete the old draft as we no longer need it
$db->delete_query("privatemessages", "pmid='{$draftcheck['pmid']}'");
}
// Saving this message as a draft
if (!empty($pm['saveasdraft'])) {
$this->pm_insert_data['uid'] = $pm['sender']['uid'];
// If this is a reply, then piggyback into the deletetime to let us know in the future
if ($pm['do'] == "reply" || $pm['do'] == "replyall") {
$this->pm_insert_data['deletetime'] = $pm['pmid'];
}
$plugins->run_hooks("datahandler_pm_insert_updatedraft", $this);
$db->insert_query("privatemessages", $this->pm_insert_data);
// If this is a draft, end it here - below deals with complete messages
return array("draftsaved" => 1);
}
$this->pmid = array();
// Save a copy of the PM for each of our recipients
foreach ($pm['recipients'] as $recipient) {
// Send email notification of new PM if it is enabled for the recipient
$query = $db->simple_select("privatemessages", "dateline", "uid='" . $recipient['uid'] . "' AND folder='1'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit' => 1));
$lastpm = $db->fetch_array($query);
if ($recipient['pmnotify'] == 1 && $recipient['lastactive'] > $lastpm['dateline']) {
if ($recipient['language'] != "" && $lang->language_exists($recipient['language'])) {
$uselang = $recipient['language'];
} elseif ($mybb->settings['bblanguage']) {
$uselang = $mybb->settings['bblanguage'];
} else {
$uselang = "english";
}
if ($uselang == $mybb->settings['bblanguage'] && !empty($lang->emailsubject_newpm)) {
$emailsubject = $lang->emailsubject_newpm;
$emailmessage = $lang->email_newpm;
} else {
$userlang = new MyLanguage();
$userlang->set_path(MYBB_ROOT . "inc/languages");
$userlang->set_language($uselang);
$userlang->load("messages");
$emailsubject = $userlang->emailsubject_newpm;
$emailmessage = $userlang->email_newpm;
}
if (!$pm['sender']['username']) {
$pm['sender']['username'] = $lang->mybb_engine;
}
require_once MYBB_ROOT . 'inc/class_parser.php';
$parser = new Postparser();
$parser_options = array('me_username' => $pm['sender']['username'], 'filter_badwords' => 1);
$pm['message'] = $parser->text_parse_message($pm['message'], $parser_options);
$emailmessage = $lang->sprintf($emailmessage, $recipient['username'], $pm['sender']['username'], $mybb->settings['bbname'], $mybb->settings['bburl'], $pm['message']);
$emailsubject = $lang->sprintf($emailsubject, $mybb->settings['bbname'], $pm['subject']);
$new_email = array("mailto" => $db->escape_string($recipient['email']), "mailfrom" => '', "subject" => $db->escape_string($emailsubject), "message" => $db->escape_string($emailmessage), "headers" => '');
$db->insert_query("mailqueue", $new_email);
//.........这里部分代码省略.........
示例12: elseif
$form_container->end();
$buttons[] = $form->generate_submit_button($lang->schedule_for_delivery);
$form->output_submit_wrapper($buttons);
$form->end();
$page->output_footer();
} elseif ($mybb->input['step'] == 3) {
// Define the recipients/conditions
if ($mybb->request_method == "post") {
// Need to perform the search to fetch the number of users we're emailing
$member_query = build_mass_mail_query($mybb->input['conditions']);
$query = $db->simple_select("users u", "COUNT(uid) AS num", $member_query);
$num = $db->fetch_field($query, "num");
if ($num == 0) {
$errors[] = $lang->error_no_users;
} else {
$updated_email = array("totalcount" => $num, "conditions" => $db->escape_string(my_serialize($mybb->input['conditions'])));
$plugins->run_hooks("admin_user_mass_email_send_define_commit");
$db->update_query("massemails", $updated_email, "mid='{$email['mid']}'");
// Take the user to the next step
admin_redirect("index.php?module=user-mass_mail&action=send&step=4&mid={$email['mid']}");
}
}
$page->output_header("{$lang->send_mass_mail}: {$lang->step_three}");
$form = new Form("index.php?module=user-mass_mail&action=send&step=3&mid={$email['mid']}", "post");
$page->output_nav_tabs($sub_tabs, 'send_mass_mail');
// If we have any error messages, show them
if ($errors) {
$page->output_inline_error($errors);
$input = $mybb->input;
} else {
if ($email['conditions'] != '') {
示例13: hook_newpoints_do_shop_start
//.........这里部分代码省略.........
error($lang->newpoints_shop_inventory_empty);
}
$key = array_search($item['iid'], $myitems);
if ($key === false) {
error($lang->newpoints_shop_selected_item_not_owned);
}
$this->load_language();
if ($do) {
// ~~~ @ https://github.com/PaulBender/Move-Posts/blob/master/inc/plugins/moveposts.php#L217 //
if ($db->table_exists('google_seo')) {
$regexp = "{$mybb->settings['bburl']}/{$mybb->settings['google_seo_url_threads']}";
if ($regexp) {
$regexp = preg_quote($regexp, '#');
$regexp = str_replace('\\{\\$url\\}', '([^./]+)', $regexp);
$regexp = str_replace('\\{url\\}', '([^./]+)', $regexp);
$regexp = "#^{$regexp}\$#u";
}
$url = $mybb->get_input('threadurl');
$url = preg_replace('/^([^#?]*)[#?].*$/u', '\\1', $url);
$url = preg_replace($regexp, '\\1', $url);
$url = urldecode($url);
$query = $db->simple_select('google_seo', 'id', "idtype='4' AND url='{$db->escape_string($url)}'");
$redeemtid = $db->fetch_field($query, 'id');
}
$realurl = explode('#', $mybb->get_input('threadurl'));
$mybb->input['threadurl'] = $realurl[0];
if (substr($mybb->get_input('threadurl'), -4) == 'html') {
preg_match('#thread-([0-9]+)?#i', $mybb->get_input('threadurl'), $threadmatch);
preg_match('#post-([0-9]+)?#i', $mybb->get_input('threadurl'), $postmatch);
if ($threadmatch[1]) {
$parameters['tid'] = $threadmatch[1];
}
if ($postmatch[1]) {
$parameters['pid'] = $postmatch[1];
}
} else {
$splitloc = explode('.php', $mybb->get_input('threadurl'));
$temp = explode('&', my_substr($splitloc[1], 1));
if (!empty($temp)) {
for ($i = 0; $i < count($temp); $i++) {
$temp2 = explode('=', $temp[$i], 2);
$parameters[$temp2[0]] = $temp2[1];
}
} else {
$temp2 = explode('=', $splitloc[1], 2);
$parameters[$temp2[0]] = $temp2[1];
}
}
if ($parameters['pid'] && !$parameters['tid']) {
$query = $db->simple_select('posts', '*', "pid='" . (int) $parameters['pid'] . "'");
$post = $db->fetch_array($query);
$redeemtid = $post['tid'];
} elseif ($parameters['tid']) {
$redeemtid = $parameters['tid'];
}
$thread = get_thread($redeemtid);
// ~~~ //
if (!$thread['tid'] || !$thread['visible'] || $thread['deletetime']) {
error($lang->newpoints_buy_sticky_redeem_error_invalid);
}
if ($thread['sticky']) {
error($lang->newpoints_buy_sticky_redeem_error_alreadystickied);
}
if ($thread['closed']) {
error($lang->newpoints_buy_sticky_redeem_error_closedthread);
}
if ($thread['uid'] != $mybb->user['uid']) {
error($lang->newpoints_buy_sticky_redeem_error_wronguser);
}
// We need more extensive permission checkings here late on..
require_once MYBB_ROOT . 'inc/class_moderation.php';
$moderation = new Moderation();
$lang->load('moderation');
$moderation->stick_threads($thread['tid']);
log_moderator_action(array('fid' => $thread['fid'], 'tid' => $thread['tid']), $lang->sprintf($lang->mod_process, $lang->stuck));
newpoints_log('buy_sticky', $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']), $mybb->user['username'], $mybb->user['uid']);
$rundate = TIME_NOW + $item['buy_sticky_time'] * 86400;
$did = $db->insert_query("delayedmoderation", array('type' => $db->escape_string('stick'), 'delaydateline' => (int) $rundate, 'uid' => (int) $mybb->user['uid'], 'tids' => (int) $thread['tid'], 'fid' => (int) $thread['fid'], 'dateline' => TIME_NOW, 'inputs' => $db->escape_string(my_serialize(array('new_forum' => (int) $thread['fid'], 'method' => 'move', 'redirect_expire' => '')))));
$plugins->run_hooks('moderation_do_delayedmoderation');
// remove item from our inventory
unset($myitems[$key]);
sort($myitems);
$db->update_query('users', array('newpoints_items' => serialize($myitems)), "uid='" . (int) $mybb->user['uid'] . "'");
$plugins->run_hooks('newpoints_shop_do_buy_sticky_end');
$message = $lang->sprintf($lang->newpoints_buy_sticky_redeem_done, my_date('relative', $rundate, '', 2));
redirect($mybb->settings['bburl'] . '/newpoints.php?action=shop&shop_action=myitems', $message, $lang->newpoints_buy_sticky_redeem_done_title);
} else {
$lang->newpoints_shop_action = $lang->newpoints_buy_sticky_redeem_title;
$item['name'] = htmlspecialchars_uni($item['name']);
global $shop_action, $data, $colspan;
$colspan = 2;
$shop_action = 'do_buy_sticky';
$fields = '<input type="hidden" name="iid" value="' . $item['iid'] . '">';
$data = "<td class=\"trow1\" width=\"50%\"><strong>" . $lang->newpoints_buy_sticky_redeem_thread . ":</strong><br /><small>" . $lang->newpoints_buy_sticky_redeem_message . "</small></td><td class=\"trow1\" width=\"50%\"><input type=\"text\" class=\"textbox\" name=\"threadurl\" value=\"\"></td>";
$plugins->run_hooks('newpoints_shop_buy_sticky_end');
$page = eval($templates->render('newpoints_shop_do_action'));
output_page($page);
}
exit;
}
示例14: add_upgrade_store
function add_upgrade_store($title, $contents)
{
global $db;
$replace_array = array("title" => $db->escape_string($title), "contents" => $db->escape_string(my_serialize($contents)));
$db->replace_query("upgrade_data", $replace_array, "title");
}
示例15: array
$table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
$query = $db->simple_select("datacache");
while ($cacheitem = $db->fetch_array($query)) {
$table->construct_cell("<strong><a href=\"index.php?module=tools-cache&action=view&title=" . urlencode($cacheitem['title']) . "\">{$cacheitem['title']}</a></strong>");
$table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
if (method_exists($cache, "update_" . $cacheitem['title'])) {
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=rebuild&title=" . urlencode($cacheitem['title']) . "&my_post_key={$mybb->post_code}\">" . $lang->rebuild_cache . "</a>", array("class" => "align_center"));
} elseif (method_exists($cache, "reload_" . $cacheitem['title'])) {
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=" . urlencode($cacheitem['title']) . "&my_post_key={$mybb->post_code}\">" . $lang->reload_cache . "</a>", array("class" => "align_center"));
} elseif (function_exists("update_" . $cacheitem['title'])) {
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=rebuild&title=" . urlencode($cacheitem['title']) . "&my_post_key={$mybb->post_code}\">" . $lang->rebuild_cache . "</a>", array("class" => "align_center"));
} elseif (function_exists("reload_" . $cacheitem['title'])) {
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=" . urlencode($cacheitem['title']) . "&my_post_key={$mybb->post_code}\">" . $lang->reload_cache . "</a>", array("class" => "align_center"));
} else {
$table->construct_cell("");
}
$table->construct_row();
}
// Rebuilds forum settings
$cachedsettings = (array) $mybb->settings;
if (isset($cachedsettings['internal'])) {
unset($cachedsettings['internal']);
}
$table->construct_cell("<strong><a href=\"index.php?module=tools-cache&action=view&title=settings\">settings</a></strong>");
$table->construct_cell(get_friendly_size(strlen(my_serialize($cachedsettings))), array("class" => "align_center"));
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=settings&my_post_key={$mybb->post_code}\">" . $lang->reload_cache . "</a>", array("class" => "align_center"));
$table->construct_row();
$table->output("<div style=\"float: right;\"><small><a href=\"index.php?module=tools-cache&action=rebuild_all&my_post_key={$mybb->post_code}\">" . $lang->rebuild_reload_all . "</a></small></div>" . $lang->cache_manager);
$page->output_footer();
}