本文整理汇总了PHP中my_strlen函数的典型用法代码示例。如果您正苦于以下问题:PHP my_strlen函数的具体用法?PHP my_strlen怎么用?PHP my_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了my_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tags_validate
function tags_validate(&$datahandler)
{
global $mybb, $db, $thread, $lang;
if ($mybb->settings['tags_enabled'] == 0 || tags_in_disforum($datahandler->fid) || $mybb->settings['tags_groups'] != -1 && !is_member($mybb->settings['tags_groups'])) {
return;
}
$lang->load('tags');
$mybb->settings['tags_max_thread'] = (int) $mybb->settings['tags_max_thread'];
if ($mybb->get_input('tags') != '' && ($datahandler->action == 'thread' || is_array($thread) && $datahandler->data['pid'] == $thread['firstpost'])) {
$tags_value = $mybb->get_input('tags');
$tags_value = tags_string2tag($tags_value);
$tags = explode(',', $tags_value);
if (count($tags) > $mybb->settings['tags_max_thread'] && $mybb->settings['tags_max_thread'] > 0) {
$lang->many_tags = $lang->sprintf($lang->many_tags, $mybb->settings['tags_max_thread']);
$datahandler->set_error($lang->many_tags);
return;
}
foreach ($tags as $tag) {
if (my_strlen($tag) > 0 && my_strlen($tag) < $mybb->settings['tags_minchars']) {
$datahandler->set_error($lang->tags_too_short);
return;
} elseif (my_strlen($tag) > $mybb->settings['tags_maxchars'] && $mybb->settings['tags_maxchars'] > 0) {
$datahandler->set_error($lang->tags_too_long);
return;
}
}
}
}
示例2: verify_subject
/**
* Verifies a private message subject.
*
* @return boolean True when valid, false when invalid.
*/
function verify_subject()
{
$subject =& $this->data['subject'];
// Subject is over 85 characters, too long.
if (my_strlen($subject) > 85) {
$this->set_error("too_long_subject");
return false;
}
// No subject, apply the default [no subject]
if (!trim_blank_chrs($subject)) {
$this->set_error("missing_subject");
return false;
}
return true;
}
示例3: countWord
function countWord($string)
{
//출처 http://php.net/manual/en/function.str-word-count.php
// Return the number of words in a string.
$string = str_replace("'", "'", $string);
$t = array(' ', "\t", '=', '+', '-', '*', '/', '\\', ',', '.', ';', ':', '[', ']', '{', '}', '(', ')', '<', '>', '&', '%', '$', '@', '#', '^', '!', '?', '~');
// separators
$string = str_replace($t, " ", $string);
$string = trim(preg_replace("/\\s+/", " ", $string));
$num = 0;
if (my_strlen($string) > 0) {
$word_array = explode(" ", $string);
$num = count($word_array);
}
return $num;
}
示例4: array
}
$xml = "<?xml version=\"1.0\" encoding=\"{$lang->settings['charset']}\"?" . ">\n";
$xml = "<usergroups version=\"{$mybb->version_code}\" exported=\"" . TIME_NOW . "\">\n";
$query = $db->simple_select("usergroups", "*", $gidwhere, array('order_by' => 'gid', 'order_dir' => 'ASC'));
while ($usergroup = $db->fetch_array($query)) {
$xml .= "\t\t<usergroup>\n";
foreach ($usergroup as $key => $value) {
$value = str_replace(']]>', ']]]]><![CDATA[>', $value);
$xml .= "\t\t\t<{$key}><![CDATA[{$value}]]></{$key}>\n";
}
$xml .= "\t\t</usergroup>\n";
}
$xml .= "</usergroups>";
$mybb->settings['bbname'] = urlencode($mybb->settings['bbname']);
header("Content-disposition: filename=" . $mybb->settings['bbname'] . "-usergroups.xml");
header("Content-Length: " . my_strlen($xml));
header("Content-type: unknown/unknown");
header("Pragma: no-cache");
header("Expires: 0");
$plugins->run_hooks("admin_user_groups_export_end");
echo $xml;
exit;
}
if ($mybb->input['action'] == "approve_join_request") {
$plugins->run_hooks("admin_user_groups_approve_join_request");
$query = $db->simple_select("joinrequests", "*", "rid='" . $mybb->input['rid'] . "'");
$request = $db->fetch_array($query);
if (!$request['rid']) {
flash_message($lang->error_invalid_join_request, 'error');
admin_redirect("index.php?module=user-groups");
}
示例5: eval
echo $error;
exit;
}
// This user is trying to give a positive reputation, but positive reps have been disabled.
if ($mybb->get_input('reputation', MyBB::INPUT_INT) > 0 && $mybb->settings['posrep'] != 1) {
$message = $lang->add_positive_disabled;
if ($mybb->input['nomodal']) {
eval("\$error = \"" . $templates->get("reputation_add_error_nomodal", 1, 0) . "\";");
} else {
eval("\$error = \"" . $templates->get("reputation_add_error", 1, 0) . "\";");
}
echo $error;
exit;
}
// The length of the comment is too long
if (my_strlen($mybb->input['comments']) > $mybb->settings['maxreplength']) {
$message = $lang->sprintf($lang->add_toolong, $mybb->settings['maxreplength']);
if ($mybb->input['nomodal']) {
eval("\$error = \"" . $templates->get("reputation_add_error_nomodal", 1, 0) . "\";");
} else {
eval("\$error = \"" . $templates->get("reputation_add_error", 1, 0) . "\";");
}
echo $error;
exit;
}
// Build array of reputation data.
$reputation = array("uid" => $uid, "adduid" => $mybb->user['uid'], "pid" => $mybb->get_input('pid', MyBB::INPUT_INT), "reputation" => $mybb->get_input('reputation', MyBB::INPUT_INT), "dateline" => TIME_NOW, "comments" => $db->escape_string($mybb->input['comments']));
$plugins->run_hooks("reputation_do_add_process");
// Updating an existing reputation
if (!empty($existing_reputation['uid'])) {
$db->update_query("reputation", $reputation, "rid='" . $existing_reputation['rid'] . "'");
示例6: verify_profile_fields
/**
* Verifies if a profile fields are filled in correctly.
*
* @return boolean True when valid, false when invalid.
*/
function verify_profile_fields()
{
global $db, $cache;
$user =& $this->data;
$profile_fields =& $this->data['profile_fields'];
// Loop through profile fields checking if they exist or not and are filled in.
$userfields = array();
$comma = '';
// Fetch all profile fields first.
$pfcache = $cache->read('profilefields');
if (is_array($pfcache)) {
// Then loop through the profile fields.
foreach ($pfcache as $profilefield) {
if (isset($this->data['profile_fields_editable']) || isset($this->data['registration']) && ($profilefield['required'] == 1 || $profilefield['registration'] == 1)) {
$profilefield['editableby'] = -1;
}
if (!is_member($profilefield['editableby'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups']))) {
continue;
}
// Does this field have a minimum post count?
if (!isset($this->data['profile_fields_editable']) && !empty($profilefield['postnum']) && $profilefield['postnum'] > $user['postnum']) {
continue;
}
$profilefield['type'] = htmlspecialchars_uni($profilefield['type']);
$thing = explode("\n", $profilefield['type'], "2");
$type = trim($thing[0]);
$field = "fid{$profilefield['fid']}";
if (!isset($profile_fields[$field])) {
$profile_fields[$field] = '';
}
// If the profile field is required, but not filled in, present error.
if ($type != "multiselect" && $type != "checkbox") {
if (trim($profile_fields[$field]) == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP') && THIS_SCRIPT != "modcp.php") {
$this->set_error('missing_required_profile_field', array($profilefield['name']));
}
} elseif (($type == "multiselect" || $type == "checkbox") && $profile_fields[$field] == "" && $profilefield['required'] == 1 && !defined('IN_ADMINCP') && THIS_SCRIPT != "modcp.php") {
$this->set_error('missing_required_profile_field', array($profilefield['name']));
}
// Sort out multiselect/checkbox profile fields.
$options = '';
if (($type == "multiselect" || $type == "checkbox") && is_array($profile_fields[$field])) {
$expoptions = explode("\n", $thing[1]);
$expoptions = array_map('trim', $expoptions);
foreach ($profile_fields[$field] as $value) {
if (!in_array(htmlspecialchars_uni($value), $expoptions)) {
$this->set_error('bad_profile_field_values', array($profilefield['name']));
}
if ($options) {
$options .= "\n";
}
$options .= $db->escape_string($value);
}
} elseif ($type == "select" || $type == "radio") {
$expoptions = explode("\n", $thing[1]);
$expoptions = array_map('trim', $expoptions);
if (!in_array(htmlspecialchars_uni($profile_fields[$field]), $expoptions) && trim($profile_fields[$field]) != "") {
$this->set_error('bad_profile_field_values', array($profilefield['name']));
}
$options = $db->escape_string($profile_fields[$field]);
} else {
if ($profilefield['maxlength'] > 0 && my_strlen($profile_fields[$field]) > $profilefield['maxlength']) {
$this->set_error('max_limit_reached', array($profilefield['name'], $profilefield['maxlength']));
}
if (!empty($profilefield['regex']) && !preg_match("#" . $profilefield['regex'] . "#i", $profile_fields[$field])) {
$this->set_error('bad_profile_field_value', array($profilefield['name']));
}
$options = $db->escape_string($profile_fields[$field]);
}
$user['user_fields'][$field] = $options;
}
}
return true;
}
示例7: htmlspecialchars_uni
$message['subject'] = $parser->parse_badwords($message['subject']);
if (my_strlen($message['subject']) > 50) {
$message['subject'] = htmlspecialchars_uni(my_substr($message['subject'], 0, 50) . "...");
} else {
$message['subject'] = htmlspecialchars_uni($message['subject']);
}
if ($message['folder'] != "3") {
$senddate = my_date('relative', $message['dateline']);
} else {
$senddate = $lang->not_sent;
}
$foldername = $foldernames[$message['folder']];
// What we do here is parse the post using our post parser, then strip the tags from it
$parser_options = array('allow_html' => 0, 'allow_mycode' => 1, 'allow_smilies' => 0, 'allow_imgcode' => 0, 'filter_badwords' => 1);
$message['message'] = strip_tags($parser->parse_message($message['message'], $parser_options));
if (my_strlen($message['message']) > 200) {
$message['message'] = my_substr($message['message'], 0, 200) . "...";
}
eval("\$messagelist .= \"" . $templates->get("private_search_messagebit") . "\";");
}
if ($db->num_rows($query) == 0) {
eval("\$messagelist = \"" . $templates->get("private_search_results_nomessages") . "\";");
}
$plugins->run_hooks("private_results_end");
eval("\$results = \"" . $templates->get("private_search_results") . "\";");
output_page($results);
}
if ($mybb->input['action'] == "advanced_search") {
$plugins->run_hooks("private_advanced_search");
eval("\$advanced_search = \"" . $templates->get("private_advanced_search") . "\";");
output_page($advanced_search);
示例8: IN
$totalposts_query = $db->simple_select("posts", "fid,message", "uid='" . $user['uid'] . "' AND pid NOT IN(" . implode(',', $firstposts) . ")");
while ($post = $db->fetch_array($totalposts_query)) {
if ($mybb->settings['newpoints_income_newpost'] == 0) {
continue;
}
if (!$allforumrules[$post['fid']]) {
$allforumrules[$post['fid']]['rate'] = 1;
}
// no rule set so default income rate is 1
// if the forum rate is 0, nothing is going to be added so let's just skip to the next post
if ($allforumrules[$post['fid']]['rate'] == 0) {
continue;
}
// calculate points ber character bonus
// let's see if the number of characters in the post is greater than the minimum characters
if (($charcount = my_strlen($post['message'])) >= $mybb->settings['newpoints_income_minchar']) {
$bonus = $charcount * $mybb->settings['newpoints_income_perchar'];
} else {
$bonus = 0;
}
// give points to the poster
$points += ($mybb->settings['newpoints_income_newpost'] + $bonus) * $allforumrules[$post['fid']]['rate'];
$thread = get_thread($post['tid']);
if ($thread['uid'] != $user['uid']) {
// we are not the thread started so give points to him/her
if ($mybb->settings['newpoints_income_perreply'] != 0) {
newpoints_addpoints($thread['uid'], $mybb->settings['newpoints_income_perreply'], $allforumrules[$post['fid']]['rate'], $grouprules['rate']);
}
}
}
// poll votes
示例9: eval
} else {
eval("\$latest_post = \"" . $templates->get("modcp_awaitingmoderation_none") . "\";");
}
eval("\$awaitingposts = \"" . $templates->get("modcp_awaitingposts") . "\";");
}
if ($nummodqueuethreads > 0 || $mybb->usergroup['issupermod'] == 1) {
$query = $db->simple_select("threads", "COUNT(tid) AS unapprovedthreads", "visible='0' {$flist_queue_threads}");
$unapproved_threads = $db->fetch_field($query, "unapprovedthreads");
if ($unapproved_threads > 0) {
$query = $db->simple_select("threads", "tid, subject, uid, username, dateline", "visible='0' {$flist_queue_threads}", array('order_by' => 'dateline', 'order_dir' => 'DESC', 'limit' => 1));
$thread = $db->fetch_array($query);
$thread['date'] = my_date('relative', $thread['dateline']);
$thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);
$thread['link'] = get_thread_link($thread['tid']);
$thread['subject'] = $thread['fullsubject'] = $parser->parse_badwords($thread['subject']);
if (my_strlen($thread['subject']) > 25) {
$post['subject'] = my_substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
$thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']);
$unapproved_threads = my_number_format($unapproved_threads);
eval("\$latest_thread = \"" . $templates->get("modcp_lastthread") . "\";");
} else {
eval("\$latest_thread = \"" . $templates->get("modcp_awaitingmoderation_none") . "\";");
}
eval("\$awaitingthreads = \"" . $templates->get("modcp_awaitingthreads") . "\";");
}
if (!empty($awaitingattachments) || !empty($awaitingposts) || !empty($awaitingthreads)) {
eval("\$awaitingmoderation = \"" . $templates->get("modcp_awaitingmoderation") . "\";");
}
}
示例10: get_post_icons
$postoptions_subscriptionmethod_dont = "checked=\"checked\"";
}
}
}
}
if ($forum['allowpicons'] != 0) {
$posticons = get_post_icons();
}
// No subject?
if (!isset($subject)) {
if (!empty($mybb->input['subject'])) {
$subject = $mybb->get_input('subject');
} else {
$subject = $thread['subject'];
// Subject too long? Shorten it to avoid error message
if (my_strlen($subject) > 85) {
$subject = my_substr($subject, 0, 82) . '...';
}
$subject = "RE: " . $subject;
}
}
// Preview a post that was written.
$preview = '';
if (!empty($mybb->input['previewpost'])) {
// If this isn't a logged in user, then we need to do some special validation.
if ($mybb->user['uid'] == 0) {
// If they didn't specify a username then give them "Guest"
if (!$mybb->get_input('username')) {
$username = $lang->guest;
} else {
$username = $mybb->get_input('username');
示例11: google_seo_url_truncate
/**
* Truncate too long URLs.
*
* @param string The string to be truncated.
* @param string The word separator.
* @param int The soft limit.
* @param int The hard limit.
* @return string truncated string
*/
function google_seo_url_truncate($str)
{
global $settings;
$separator = $settings['google_seo_url_separator'];
$soft = $settings['google_seo_url_length_soft'];
$hard = $settings['google_seo_url_length_hard'];
// Cut off word past soft limit.
if ($soft && my_strlen($str) > $soft) {
// Search the separator after the soft limit.
$part = my_substr($str, $soft);
$pos = my_strpos($part, $separator);
if ($pos === 0 || $pos > 0) {
$str = my_substr($str, 0, $soft + $pos);
}
}
// Truncate hard limit.
if ($hard && my_strlen($str) > $hard) {
$str = my_substr($str, 0, $hard);
}
return $str;
}
示例12: count
break;
}
// Any events on this specific day?
if (is_array($events_cache) && array_key_exists("{$day}-{$calendar_month}-{$calendar_year}", $events_cache)) {
$total_events = count($events_cache["{$day}-{$calendar_month}-{$calendar_year}"]);
if ($total_events > $calendar['eventlimit'] && $calendar['eventlimit'] != 0) {
if ($total_events > 1) {
$day_events = "<div style=\"margin-bottom: 4px;\"><a href=\"" . get_calendar_link($calendar['cid'], $calendar_year, $calendar_month, $day) . "\" class=\"smalltext\">{$total_events} {$lang->events}</a></div>\n";
} else {
$day_events = "<div style=\"margin-bottom: 4px;\"><a href=\"" . get_calendar_link($calendar['cid'], $calendar_year, $calendar_month, $day) . "\" class=\"smalltext\">1 {$lang->event}</a></div>\n";
}
} else {
foreach ($events_cache["{$day}-{$calendar_month}-{$calendar_year}"] as $event) {
$event['eventlink'] = get_event_link($event['eid']);
$event['fullname'] = htmlspecialchars_uni($event['name']);
if (my_strlen($event['name']) > 15) {
$event['name'] = my_substr($event['name'], 0, 15) . "...";
}
$event['name'] = htmlspecialchars_uni($event['name']);
if ($event['private'] == 1) {
$event_class = " private_event";
} else {
$event_class = " public_event";
}
if ($event['visible'] == 0) {
$event_class .= " trow_shaded";
}
eval("\$day_events .= \"" . $templates->get("calendar_eventbit") . "\";");
}
}
}
示例13: draw_string
/**
* Writes text to the image.
*
* @param resource $im The image.
* @param string $string The string to be written
*
* @return bool False if string is empty, true otherwise
*/
function draw_string(&$im, $string)
{
global $use_ttf, $min_size, $max_size, $min_angle, $max_angle, $ttf_fonts, $img_height, $img_width;
if (empty($string)) {
return false;
}
$spacing = $img_width / my_strlen($string);
$string_length = my_strlen($string);
for ($i = 0; $i < $string_length; ++$i) {
// Using TTF fonts
if ($use_ttf) {
// Select a random font size
$font_size = my_rand($min_size, $max_size);
// Select a random font
$font = array_rand($ttf_fonts);
$font = $ttf_fonts[$font];
// Select a random rotation
$rotation = my_rand($min_angle, $max_angle);
// Set the colour
$r = my_rand(0, 200);
$g = my_rand(0, 200);
$b = my_rand(0, 200);
$color = imagecolorallocate($im, $r, $g, $b);
// Fetch the dimensions of the character being added
$dimensions = imageftbbox($font_size, $rotation, $font, $string[$i], array());
$string_width = $dimensions[2] - $dimensions[0];
$string_height = $dimensions[3] - $dimensions[5];
// Calculate character offsets
//$pos_x = $pos_x + $string_width + ($string_width/4);
$pos_x = $spacing / 4 + $i * $spacing;
$pos_y = ceil($img_height - $string_height / 2);
// Draw a shadow
$shadow_x = my_rand(-3, 3) + $pos_x;
$shadow_y = my_rand(-3, 3) + $pos_y;
$shadow_color = imagecolorallocate($im, $r + 20, $g + 20, $b + 20);
imagefttext($im, $font_size, $rotation, $shadow_x, $shadow_y, $shadow_color, $font, $string[$i], array());
// Write the character to the image
imagefttext($im, $font_size, $rotation, $pos_x, $pos_y, $color, $font, $string[$i], array());
} else {
// Get width/height of the character
$string_width = imagefontwidth(5);
$string_height = imagefontheight(5);
// Calculate character offsets
$pos_x = $spacing / 4 + $i * $spacing;
$pos_y = $img_height / 2 - $string_height - 10 + my_rand(-3, 3);
// Create a temporary image for this character
if (gd_version() >= 2) {
$temp_im = imagecreatetruecolor(15, 20);
} else {
$temp_im = imagecreate(15, 20);
}
$bg_color = imagecolorallocate($temp_im, 255, 255, 255);
imagefill($temp_im, 0, 0, $bg_color);
imagecolortransparent($temp_im, $bg_color);
// Set the colour
$r = my_rand(0, 200);
$g = my_rand(0, 200);
$b = my_rand(0, 200);
$color = imagecolorallocate($temp_im, $r, $g, $b);
// Draw a shadow
$shadow_x = my_rand(-1, 1);
$shadow_y = my_rand(-1, 1);
$shadow_color = imagecolorallocate($temp_im, $r + 50, $g + 50, $b + 50);
imagestring($temp_im, 5, 1 + $shadow_x, 1 + $shadow_y, $string[$i], $shadow_color);
imagestring($temp_im, 5, 1, 1, $string[$i], $color);
// Copy to main image
imagecopyresized($im, $temp_im, $pos_x, $pos_y, 0, 0, 40, 55, 15, 20);
imagedestroy($temp_im);
}
}
return true;
}
示例14: get_forum_link
$post['forumlink'] = "<a href=\"" . get_forum_link($post['fid']) . "\">" . $forumcache[$post['fid']]['name'] . "</a>";
} else {
$post['forumlink'] = "";
}
if (!$post['subject']) {
$post['subject'] = $post['message'];
}
if (my_strlen($post['subject']) > 50) {
$post['subject'] = htmlspecialchars_uni(my_substr($post['subject'], 0, 50) . "...");
} else {
$post['subject'] = htmlspecialchars_uni($post['subject']);
}
// What we do here is parse the post using our post parser, then strip the tags from it
$parser_options = array('allow_html' => 0, 'allow_mycode' => 1, 'allow_smilies' => 0, 'allow_imgcode' => 0, 'filter_badwords' => 1);
$post['message'] = strip_tags($parser->parse_message($post['message'], $parser_options));
if (my_strlen($post['message']) > 200) {
$prev = my_substr($post['message'], 0, 200) . "...";
} else {
$prev = $post['message'];
}
$posted = my_date($mybb->settings['dateformat'], $post['dateline']) . ", " . my_date($mybb->settings['timeformat'], $post['dateline']);
$thread_url = get_thread_link($post['tid']);
$post_url = get_post_link($post['pid'], $post['tid']);
// Inline post moderation
$inline_mod_checkbox = '';
if ($is_supermod || is_moderator($post['fid'])) {
eval("\$inline_mod_checkbox = \"" . $templates->get("search_results_posts_inlinecheck") . "\";");
} elseif ($is_mod) {
eval("\$inline_mod_checkbox = \"" . $templates->get("search_results_posts_nocheck") . "\";");
}
$plugins->run_hooks("search_results_post");
示例15: retrieve_buddylist_from_db
public function retrieve_buddylist_from_db($page, $memprofile)
{
global $db, $settings;
$page = (int) $page;
$buddylist = array();
$count = count(array_filter(explode(",", $memprofile["buddylist"])));
$limit = is_numeric($settings["mpbuddylistrecord"]) ? (int) $settings["mpbuddylistrecord"] : 4;
$membuddylistarray = array_slice(explode(",", $memprofile["buddylist"]), ($page - 1) * $limit, $limit);
$membuddylist = implode(",", $membuddylistarray);
if (my_strlen(trim($membuddylist)) != 0) {
$query = $db->simple_select("users", "*", "uid IN ({$membuddylist})", array("limit" => $limit));
while ($buddy = $db->fetch_array($query)) {
$buddylist[] = $buddy;
}
/* saving up a query */
}
return $this->buddylist_process($buddylist, $count, $memprofile, $limit, $page);
}