本文整理汇总了PHP中trim_array函数的典型用法代码示例。如果您正苦于以下问题:PHP trim_array函数的具体用法?PHP trim_array怎么用?PHP trim_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trim_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim_if_string
/**
* Trim if variable is a string, otherwise trim as an array
*
* @param mixed $data
* @return mixed
*/
function trim_if_string($data)
{
if (is_array($data) or is_object($data)) {
return trim_array($data);
}
return trim($data);
}
示例2: storeSecurity
function storeSecurity(&$pParamHash)
{
if (@$this->verifyId($pParamHash['content_id'])) {
// We'll first nuke any security mappings for this content_id
$sql = "DELETE FROM `" . BIT_DB_PREFIX . "gatekeeper_security_map`\n\t\t\t\t\tWHERE `content_id` = ?";
$rs = $this->mDb->query($sql, array($pParamHash['content_id']));
}
if (!empty($pParamHash['access_level']) || @$this->verifyId($pParamHash['security_id']) && $pParamHash['security_id'] != 'public') {
if ($this->verifySecurity($pParamHash) && !empty($pParamHash['security_store'])) {
trim_array($pParamHash);
if (!empty($pParamHash['security_store'])) {
global $gBitUser;
$table = BIT_DB_PREFIX . "gatekeeper_security";
if (!@$this->verifyId($pParamHash['security_id'])) {
$pParamHash['security_store']['user_id'] = $gBitUser->mUserId;
$pParamHash['security_id'] = $this->mDb->GenID('gatekeeper_security_id_seq');
$pParamHash['security_store']['security_id'] = $pParamHash['security_id'];
$result = $this->mDb->associateInsert($table, $pParamHash['security_store']);
} else {
$result = $this->mDb->associateUpdate($table, $pParamHash['security_store'], array("security_id" => $pParamHash['security_id']));
}
}
}
if (@$this->verifyId($pParamHash['content_id']) && @$this->verifyId($pParamHash['security_id'])) {
$sql = "INSERT INTO `" . BIT_DB_PREFIX . "gatekeeper_security_map` ( `content_id`, `security_id` ) VALUES (?,?)";
$rs = $this->mDb->query($sql, array($pParamHash['content_id'], $pParamHash['security_id']));
}
}
return count($this->mErrors) == 0;
}
示例3: HookGrant_editEditeditbeforeheader
function HookGrant_editEditeditbeforeheader()
{
global $ref, $baseurl, $usergroup, $grant_edit_groups, $collection;
// Do we have access to do any of this, or is it a template
if (!in_array($usergroup, $grant_edit_groups) || $ref < 0) {
return;
}
// Check for Ajax POST to delete users
$grant_edit_action = getvalescaped("grant_edit_action", "");
if ($grant_edit_action != "") {
if ($grant_edit_action == "delete") {
$remove_user = escape_check(getvalescaped("remove_user", "", TRUE));
if ($remove_user != "") {
sql_query("delete from grant_edit where resource='{$ref}' and user={$remove_user}");
exit("SUCCESS");
}
}
exit("FAILED");
}
# If 'users' is specified (i.e. access is private) then rebuild users list
$users = getvalescaped("users", false);
if ($users != false) {
# Build a new list and insert
$users = resolve_userlist_groups($users);
$ulist = array_unique(trim_array(explode(",", $users)));
$urefs = sql_array("select ref value from user where username in ('" . join("','", $ulist) . "')");
if (count($urefs) > 0) {
$inserttext = array();
$grant_edit_expiry = getvalescaped("grant_edit_expiry", "");
foreach ($urefs as $uref) {
if ($grant_edit_expiry != "") {
$inserttext[] = $uref . ",'" . $grant_edit_expiry . "'";
} else {
$inserttext[] = $uref . ",NULL";
}
}
if ($collection != "") {
global $items;
foreach ($items as $collection_resource) {
sql_query("delete from grant_edit where resource='{$collection_resource}' and user in (" . implode(",", $urefs) . ")");
sql_query("insert into grant_edit(resource,user,expiry) values ({$collection_resource}," . join("),(" . $collection_resource . ",", $inserttext) . ")");
#log this
global $lang;
resource_log($collection_resource, 's', "", "Grant Edit - " . $users . " - " . $lang['expires'] . ": " . ($grant_edit_expiry != "" ? nicedate($grant_edit_expiry) : $lang['never']));
}
} else {
sql_query("delete from grant_edit where resource='{$ref}' and user in (" . implode(",", $urefs) . ")");
sql_query("insert into grant_edit(resource,user,expiry) values ({$ref}," . join("),(" . $ref . ",", $inserttext) . ")");
#log this
global $lang;
resource_log($ref, 's', "", "Grant Edit - " . $users . " - " . $lang['expires'] . ": " . ($grant_edit_expiry != "" ? nicedate($grant_edit_expiry) : $lang['never']));
}
}
}
return true;
}
示例4: comparble_version
function comparble_version($version_number)
{
$version_number = explode(".", $version_number);
$version_number = array_map("intval", $version_number);
$version_number = trim_array($version_number);
$version_number = array_map(function ($e) {
return str_pad($e, 10, "0", STR_PAD_LEFT);
}, $version_number);
return implode(".", $version_number);
}
示例5: compress
/**
* Compress content
*
* @return Response
*/
public function compress(Request $request, Response $response)
{
$acceptEncoding = $request->getHeaderLine('accept-encoding');
$encodings = array_flip(trim_array(explode(',', $acceptEncoding)));
if (isset($encodings['gzip'])) {
return $this->compressBody($response, 'gzip', 'gzcompress');
}
if (isset($encodings['deflate'])) {
return $this->compressBody($response, 'deflate', 'gzdeflate');
}
return $response;
}
示例6: index
public function index($category = null, $products = null)
{
if (is_null($category)) {
//show all categories
/* breadcrumbs */
$this->breadcrumbs->unshift('products', site_url('products'));
$this->breadcrumbs->unshift('Home', site_url('home'));
$this->data['title'] = 'Our categories';
$cat = $this->model_products->getCategories();
$this->data['content'] = $this->smarty->load('categories', $cat);
} elseif (!is_null($category) && is_null($products)) {
//if category part in the URL and no product number
$category = $this->security->xss_clean($category);
$this->data['title'] = $category . '- items';
$prod = $this->model_products->getProducts($category);
if ($prod) {
/* breadcrumbs */
$this->breadcrumbs->unshift($prod[0]["name"], site_url("products/") . $prod[0]['cat_machine']);
$this->breadcrumbs->unshift('products', site_url('products'));
$this->breadcrumbs->unshift('Home', site_url('home'));
$this->data['title'] = 'Phoneshop - ' . $prod[0]["cat_machine"];
$this->data['content'] = $this->smarty->load('category', $prod, 'category');
}
} elseif (!is_null($category) && !is_null($products)) {
//if category part in the URL and no product number
$products = $this->security->xss_clean($products);
$item = $this->model_products->getItem($products);
$images = explode(',', $item['images']);
$images = trim_array($images);
if ($item) {
/* breadcrumbs */
$this->breadcrumbs->unshift($item["title"], site_url("products/") . $item['cat_name'] . '/' . $item['machine_name']);
$this->breadcrumbs->unshift($item["cat_title"], site_url("products") . '/' . $item['cat_name']);
$this->breadcrumbs->unshift('products', site_url('products'));
$this->breadcrumbs->unshift('Home', site_url('home'));
$this->smarty->assign('images', $images);
$this->data['title'] = 'Phoneshop - ' . $item['title'];
$this->data['content'] = $this->smarty->load('item', $item);
}
}
$this->load->view('templates/main', $this->data);
//show the template main
}
示例7: email_collection
function email_collection($colrefs,$collectionname,$fromusername,$userlist,$message,$feedback,$access=-1,$expires="",$useremail="",$from_name="",$cc="",$themeshare=false,$themename="",$themeurlsuffix="")
{
# Attempt to resolve all users in the string $userlist to user references.
# Add $collection to these user's 'My Collections' page
# Send them an e-mail linking to this collection
# handle multiple collections (comma seperated list)
global $baseurl,$email_from,$applicationname,$lang,$userref, $email_multi_collections ;
if ($useremail==""){$useremail=$email_from;}
if (trim($userlist)=="") {return ($lang["mustspecifyoneusername"]);}
$userlist=resolve_userlist_groups($userlist);
$ulist=trim_array(explode(",",$userlist));
$emails=array();
$key_required=array();
if ($feedback) {$feedback=1;} else {$feedback=0;}
$reflist=trim_array(explode(",",$colrefs));
$emails_keys=resolve_user_emails($ulist);
$emails=$emails_keys['emails'];
$key_required=$emails_keys['key_required'];
# Add the collection(s) to the user's My Collections page
$urefs=sql_array("select ref value from user where username in ('" . join("','",$ulist) . "')");
if (count($urefs)>0)
{
# Delete any existing collection entries
sql_query("delete from user_collection where collection in ('" .join("','", $reflist) . "') and user in ('" . join("','",$urefs) . "')");
# Insert new user_collection row(s)
#loop through the collections
for ($nx1=0;$nx1<count($reflist);$nx1++)
{ #loop through the users
for ($nx2=0;$nx2<count($urefs);$nx2++)
{
sql_query("insert into user_collection(collection,user,request_feedback) values ($reflist[$nx1], $urefs[$nx2], $feedback )");
if ($access == 0) {
foreach (get_collection_resources($reflist[$nx1]) as $resource) {
open_access_to_user($urefs[$nx2],$resource,$expires);
}
}
#log this
collection_log($reflist[$nx1],"S",0, sql_value ("select username as value from user where ref = $urefs[$nx2]",""));
}
}
}
# Send an e-mail to each resolved user
# htmlbreak is for composing list
$htmlbreak="\r\n";
global $use_phpmailer;
if ($use_phpmailer){$htmlbreak="<br><br>";$htmlbreaksingle="<br>";}
if ($fromusername==""){$fromusername=$applicationname;} // fromusername is used for describing the sender's name inside the email
if ($from_name==""){$from_name=$applicationname;} // from_name is for the email headers, and needs to match the email address (app name or user name)
$templatevars['message']=str_replace(array("\\n","\\r","\\"),array("\n","\r",""),$message);
if (trim($templatevars['message'])==""){$templatevars['message']=$lang['nomessage'];}
$templatevars['fromusername']=$fromusername;
$templatevars['from_name']=$from_name;
if(count($reflist)>1){$subject=$applicationname.": ".$lang['mycollections'];}
else { $subject=$applicationname.": ".$collectionname;}
if ($fromusername==""){$fromusername=$applicationname;}
$externalmessage=$lang["emailcollectionmessageexternal"];
$internalmessage=$lang["emailcollectionmessage"];
$viewlinktext=$lang["clicklinkviewcollection"];
if ($themeshare) // Change the text if sharing a theme category
{
$externalmessage=$lang["emailthemecollectionmessageexternal"];
$internalmessage=$lang["emailthememessage"];
$viewlinktext=$lang["clicklinkviewcollections"];
}
## loop through recipients
for ($nx1=0;$nx1<count($emails);$nx1++)
{
## loop through collections
$list="";
$list2="";
$origviewlinktext=$viewlinktext; // Save this text as we may change it for internal theme shares for this user
if ($themeshare && !$key_required[$nx1]) # don't send a whole list of collections if internal, just send the theme category URL
{
$url="";
$subject=$applicationname.": " . $themename;
$url=$baseurl . "/pages/themes.php" . $themeurlsuffix;
$viewlinktext=$lang["clicklinkviewthemes"];
$emailcollectionmessageexternal=false;
if ($use_phpmailer){
$link="<a href=\"$url\">" . $themename . "</a>";
$list.= $htmlbreak.$link;
// alternate list style
$list2.=$htmlbreak.$themename.' -'.$htmlbreaksingle.$url;
//.........这里部分代码省略.........
示例8: check_view_display_condition
function check_view_display_condition($fields, $n)
{
#Check if field has a display condition set
$displaycondition = true;
if ($fields[$n]["display_condition"] != "") {
//echo $fields[$n]["display_condition"] . "<br>";
$fieldstocheck = array();
#' Set up array to use in jQuery script function
$s = explode(";", $fields[$n]["display_condition"]);
$condref = 0;
foreach ($s as $condition) {
$displayconditioncheck = false;
$s = explode("=", $condition);
for ($cf = 0; $cf < count($fields); $cf++) {
if ($s[0] == $fields[$cf]["name"]) {
$checkvalues = $s[1];
$validvalues = explode("|", strtoupper($checkvalues));
$v = trim_array(explode(",", strtoupper($fields[$cf]["value"])));
foreach ($validvalues as $validvalue) {
if (in_array($validvalue, $v)) {
$displayconditioncheck = true;
}
# this is a valid value
}
if (!$displayconditioncheck) {
$displaycondition = false;
}
}
}
# see if next field needs to be checked
$condref++;
}
# check next condition
}
return $displaycondition;
}
示例9: trim_array
<?php
/* --------Drop down list ---------------- */
# Translate all options
$options = trim_array(explode(",", $fields[$n]["options"]));
$adjusted_dropdownoptions = hook("adjustdropdownoptions");
if ($adjusted_dropdownoptions) {
$options = $adjusted_dropdownoptions;
}
$option_trans = array();
for ($m = 0; $m < count($options); $m++) {
$option_trans[$options[$m]] = i18n_get_translated($options[$m]);
}
if ($auto_order_checkbox) {
asort($option_trans);
}
if (substr($value, 0, 1) == ',') {
$value = substr($value, 1);
}
// strip the leading comma if it exists
?>
<select class="stdwidth" name="<?php
echo $name;
?>
" id="<?php
echo $name;
?>
" <?php
echo $help_js;
if ($edit_autosave) {
?>
示例10: trim_array
function trim_array(&$var)
{
if (is_string($var)) {
$var = trim($var);
} else {
if (is_array($var)) {
foreach ($var as $key => $value) {
trim_array($var[$key]);
}
}
}
}
示例11: filter_match
function filter_match($filter,$name,$value)
{
# In the given filter string, does name/value match?
# Returns:
# 0 = no match for name
# 1 = matched name but value was not present
# 2 = matched name and value was correct
$s=explode(";",$filter);
foreach ($s as $condition)
{
$s=explode("=",$condition);
$checkname=$s[0];
if ($checkname==$name)
{
$checkvalues=$s[1];
$s=explode("|",strtoupper($checkvalues));
$v=trim_array(explode(",",strtoupper($value)));
foreach ($s as $checkvalue)
{
if (in_array($checkvalue,$v)) {return 2;}
}
return 1;
}
}
return 0;
}
示例12: header
} else {
$url = $groupInfo['after_registration_page'];
}
}
header('Location: ' . $url);
exit;
}
} else {
$gBitSystem->setHttpStatus(HttpStatusCodes::HTTP_BAD_REQUEST);
$gBitSmarty->assignByRef('errors', $newUser->mErrors);
}
$gBitSmarty->assignByRef('reg', $reg);
} else {
if ($gBitSystem->isFeatureActive('custom_user_fields')) {
$fields = explode(',', $gBitSystem->getConfig('custom_user_fields'));
trim_array($fields);
$gBitSmarty->assign('customFields', $fields);
}
for ($i = 0; $i < BaseAuth::getAuthMethodCount(); $i++) {
$instance = BaseAuth::init($i);
if ($instance && $instance->canManageAuth()) {
$auth_reg_fields = $instance->getRegistrationFields();
foreach (array_keys($auth_reg_fields) as $auth_field) {
$auth_reg_fields[$auth_field]['value'] = $auth_reg_fields[$auth_field]['default'];
}
$gBitSmarty->assign('auth_reg_fields', $auth_reg_fields);
break;
}
}
}
$languages = array();
示例13: check_display_condition
function check_display_condition($n, $field)
{
global $fields, $scriptconditions, $required_fields_exempt;
$displaycondition = true;
$s = explode(";", $field["display_condition"]);
$condref = 0;
foreach ($s as $condition) {
$displayconditioncheck = false;
$s = explode("=", $condition);
for ($cf = 0; $cf < count($fields); $cf++) {
if ($s[0] == $fields[$cf]["name"]) {
$scriptconditions[$condref]["field"] = $fields[$cf]["ref"];
# add new jQuery code to check value
$scriptconditions[$condref]['type'] = $fields[$cf]['type'];
$scriptconditions[$condref]['options'] = $fields[$cf]['options'];
$checkvalues = $s[1];
$validvalues = explode("|", strtoupper($checkvalues));
$scriptconditions[$condref]["valid"] = "\"";
$scriptconditions[$condref]["valid"] .= implode("\",\"", $validvalues);
$scriptconditions[$condref]["valid"] .= "\"";
$v = trim_array(explode(",", strtoupper($fields[$cf]["value"])));
foreach ($validvalues as $validvalue) {
if (in_array($validvalue, $v)) {
$displayconditioncheck = true;
}
# this is a valid value
}
if (!$displayconditioncheck) {
$displaycondition = false;
$required_fields_exempt[] = $field["ref"];
}
#add jQuery code to update on changes
if ($fields[$cf]["type"] == 2) {
# construct the value from the ticked boxes
# Note: it seems wrong to start with a comma, but this ensures it is treated as a comma separated list by split_keywords(), so if just one item is selected it still does individual word adding, so 'South Asia' is split to 'South Asia','South','Asia'.
$options = trim_array(explode(",", $fields[$cf]["options"]));
?>
<script type="text/javascript">
jQuery(document).ready(function() {<?php
for ($m = 0; $m < count($options); $m++) {
$checkname = $fields[$cf]["ref"] . "_" . md5($options[$m]);
echo "\n\t\t\t\t\t\t\t\tjQuery('input[name=\"" . $checkname . "\"]').change(function (){\n\t\t\t\t\t\t\t\t\tcheckDisplayCondition" . $field["ref"] . "();\n\t\t\t\t\t\t\t\t\t});";
}
?>
});
</script><?php
} else {
if ($fields[$cf]['type'] == 12) {
$options = explode(',', $fields[$cf]['options']);
?>
<script type="text/javascript">
jQuery(document).ready(function() {
<?php
foreach ($options as $option) {
$element_id = 'field_' . $fields[$cf]['ref'] . '_' . sha1($option);
$jquery = sprintf('
jQuery("#%s").change(function() {
checkDisplayCondition%s();
});
', $element_id, $field["ref"]);
echo $jquery;
}
?>
});
</script>
<?php
} else {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#field_<?php
echo $fields[$cf]["ref"];
?>
').change(function (){
checkDisplayCondition<?php
echo $field["ref"];
?>
();
});
});
</script>
<?php
}
}
}
}
# see if next field needs to be checked
$condref++;
}
# check next condition
?>
<script type="text/javascript">
function checkDisplayCondition<?php
echo $field["ref"];
//.........这里部分代码省略.........
示例14: setArticleTags
function setArticleTags()
{
$id = db_escape_string($_REQUEST["id"]);
$tags_str = db_escape_string($_REQUEST["tags_str"]);
$tags = array_unique(trim_array(explode(",", $tags_str)));
db_query($this->link, "BEGIN");
$result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\tref_id = '{$id}' AND owner_uid = '" . $_SESSION["uid"] . "' LIMIT 1");
if (db_num_rows($result) == 1) {
$tags_to_cache = array();
$int_id = db_fetch_result($result, 0, "int_id");
db_query($this->link, "DELETE FROM ttrss_tags WHERE\n\t\t\t\tpost_int_id = {$int_id} AND owner_uid = '" . $_SESSION["uid"] . "'");
foreach ($tags as $tag) {
$tag = sanitize_tag($tag);
if (!tag_is_valid($tag)) {
continue;
}
if (preg_match("/^[0-9]*\$/", $tag)) {
continue;
}
// print "<!-- $id : $int_id : $tag -->";
if ($tag != '') {
db_query($this->link, "INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t(post_int_id, owner_uid, tag_name) VALUES ('{$int_id}', '" . $_SESSION["uid"] . "', '{$tag}')");
}
array_push($tags_to_cache, $tag);
}
/* update tag cache */
sort($tags_to_cache);
$tags_str = join(",", $tags_to_cache);
db_query($this->link, "UPDATE ttrss_user_entries\n\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$id}'\n\t\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
}
db_query($this->link, "COMMIT");
$tags = get_article_tags($this->link, $id);
$tags_str = format_tags_string($tags, $id);
$tags_str_full = join(", ", $tags);
if (!$tags_str_full) {
$tags_str_full = __("no tags");
}
print json_encode(array("tags_str" => array("id" => $id, "content" => $tags_str, "content_full" => $tags_str_full)));
}
示例15: update_rss_feed
//.........这里部分代码省略.........
}
}
db_query("COMMIT");
_debug("assigning labels...", $debug_enabled);
assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels);
_debug("looking for enclosures...", $debug_enabled);
// enclosures
$enclosures = array();
$encs = $item->get_enclosures();
if (is_array($encs)) {
foreach ($encs as $e) {
$e_item = array($e->link, $e->type, $e->length);
array_push($enclosures, $e_item);
}
}
if ($debug_enabled) {
_debug("article enclosures:", $debug_enabled);
print_r($enclosures);
}
db_query("BEGIN");
foreach ($enclosures as $enc) {
$enc_url = db_escape_string($enc[0]);
$enc_type = db_escape_string($enc[1]);
$enc_dur = db_escape_string($enc[2]);
$result = db_query("SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
if (db_num_rows($result) == 0) {
db_query("INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
}
}
db_query("COMMIT");
// check for manual tags (we have to do it here since they're loaded from filters)
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
$manual_tags = trim_array(explode(",", $f["param"]));
foreach ($manual_tags as $tag) {
if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
}
}
// Skip boring tags
$boring_tags = trim_array(explode(",", mb_strtolower(get_pref('BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
$filtered_tags = array();
$tags_to_cache = array();
if ($entry_tags && is_array($entry_tags)) {
foreach ($entry_tags as $tag) {
if (array_search($tag, $boring_tags) === false) {
array_push($filtered_tags, $tag);
}
}
}
$filtered_tags = array_unique($filtered_tags);
if ($debug_enabled) {
_debug("filtered article tags:", $debug_enabled);
print_r($filtered_tags);
}
// Save article tags in the database
if (count($filtered_tags) > 0) {
db_query("BEGIN");
foreach ($filtered_tags as $tag) {
$tag = sanitize_tag($tag);
$tag = db_escape_string($tag);
if (!tag_is_valid($tag)) {
continue;
}