本文整理汇总了PHP中clean_string函数的典型用法代码示例。如果您正苦于以下问题:PHP clean_string函数的具体用法?PHP clean_string怎么用?PHP clean_string使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clean_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param String $url - REST url
*/
function __construct($url)
{
$GLOBALS['log']->info('Begin: SugarRestService->__construct');
$this->restURL = $url;
$responseTypeString = 'SugarRest';
if (!empty($_REQUEST['response_type'])) {
$responseTypeString = clean_string($_REQUEST['response_type'], 'ALPHANUM');
if (strcasecmp($responseTypeString, 'JSON') === 0) {
$responseTypeString = 'SugarRest' . 'JSON';
} elseif (strcasecmp($responseTypeString, 'RSS') === 0) {
$responseTypeString = 'SugarRest' . 'RSS';
} elseif (strcasecmp($responseTypeString, 'Serialize') === 0) {
$responseTypeString = 'SugarRest' . 'Serialize';
}
}
// if
$this->responseClass = $responseTypeString;
//$this->responseClass = (!empty($_REQUEST['response_type']))?'SugarRest'.clean_string($_REQUEST['response_type'], 'ALPHANUM'): 'SugarRest';
if (!file_exists('service/core/REST/' . $this->responseClass . '.php')) {
$this->responseClass = 'SugarRest';
}
$this->serverClass = !empty($_REQUEST['input_type']) ? 'SugarRest' . clean_string($_REQUEST['input_type'], 'ALPHANUM') : 'SugarRest';
$GLOBALS['log']->info('SugarRestService->__construct serverclass = ' . $this->serverClass);
if (!file_exists('service/core/REST/' . $this->serverClass . '.php')) {
$this->serverClass = 'SugarRest';
}
require_once 'service/core/REST/' . $this->serverClass . '.php';
$GLOBALS['log']->info('End: SugarRestService->__construct');
}
示例2: loadFromFile
/**
* Loads up menu items from files located in include/contextMenus/menuDefs
* @param string $name name of the object
*/
function loadFromFile($name)
{
global $menuDef;
clean_string($name, 'FILE');
require_once 'include/contextMenus/menuDefs/' . $name . '.php';
$this->loadFromDef($name, $menuDef[$name]);
}
示例3: construct_clean_output_for_employee
function construct_clean_output_for_employee($employee)
{
$a = clean_string(8, $employee['Units']);
$b = clean_string(45, $employee['Name']);
$c = " {$employee['Employee Number']}";
return "{$a}|{$b}|{$c}";
}
示例4: sendEmail
function sendEmail($name, $from, $to, $user_subject, $msg)
{
// check strings for cross site scripting (illegal characters).
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$subject = "{$name} send you a message via your contact form";
$message = "Name: " . clean_string($name) . "\r\n";
$message .= "Email: " . clean_string($from) . "\r\n";
if (isset($subject)) {
$message .= "Subject: " . clean_string($user_subject) . "\r\n";
}
$message .= "Message: \r\n" . clean_string($msg) . "\r\n";
$message = wordwrap($message, 72);
// create email headers From, Cc and Bcc.
$headers = "MINE-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: {$name} <{$from}>\r\n";
// $headers .= "Cc: publicarray@icloud.com\r\n";
// $headers .= "Bcc: admin@publicarray.com\r\n";
'Reply-To: ' . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
set_time_limit(0);
// actually send email & redirect
if (mail($to, $subject, $message, $headers)) {
echo '<div class="block"><div class="alert green">Message Send!</div></div>';
} else {
echo '<div class="block"><div class="alert red">Sorry, but it there was a problem sending this email. <br /> Please try again later or send it directly to: admin@publicarray.com</div></div>';
}
}
示例5: product_link
function product_link($product)
{
$name = clean_string($product->name);
$segments = array('nutrition-facts', $product->id, $product->name);
$url = generate_url($segments);
return $url;
}
示例6: discourse
private function discourse($volume, $discourse)
{
$this->Discourse =& ClassRegistry::init('Discourse');
$volume = str_pad((int) $volume, 2, "0", STR_PAD_LEFT);
$discourse = str_pad($discourse, 2, "0", STR_PAD_LEFT);
App::import('Core', array('Xml', 'HttpSocket'));
$this->Http =& new HttpSocket();
$url = "http://scriptures.byu.edu/gettalk.php?vol={$volume}&disc={$discourse}";
$html = $this->Http->get($url);
if (strpos($html, 'file_get_contents') !== false) {
return false;
}
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$start_page = (int) $xpath->evaluate('//a[@name][1]')->item(0)->getAttribute('name');
$column_anchors = $xpath->evaluate('//a[@name]');
$end_page = (int) $column_anchors->item($column_anchors->length - 1)->getAttribute('name');
$title = clean_string(find_content($xpath, '//div[@class="title"]'));
$subtitle = find_content($xpath, '//div[@class="subtitle"]');
$reported_by = clean_string(find_content($xpath, '//div[@class="reportedBy"]'));
$page_header = clean_string(find_content($xpath, '//div[@class="pageHeader"]'));
$speaker = clean_string(find_content($xpath, '//div[@class="speaker"]'));
$date = prepare_date(find_content($xpath, '//div[@class="date"]'));
$content = find_content($xpath, '//div[@class="discourseBody"]');
$this->Discourse->create();
$this->Discourse->save(array('volume' => $volume, 'start_page' => $start_page, 'end_page' => $end_page, 'title' => $title, 'subtitle' => $subtitle, 'reported_by' => $reported_by, 'page_header' => $page_header, 'speaker' => $speaker, 'date' => $date, 'subtitle' => $subtitle, 'content' => $content));
return true;
}
示例7: listViewProcess
function listViewProcess()
{
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
global $sugar_config;
global $current_user;
global $app_strings;
global $timedate;
$type = clean_string($_REQUEST['module']);
$db = DBManagerFactory::getInstance();
/* $query = $_REQUEST['query'];
if($query){
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$w = $ret_array['where'];
$where = "IN ( SELECT id from grouplists WHERE ".$w .")";
}
else{
$where = '';
} */
/*$ids = $_REQUEST['uid'];
if($ids) {
$ids = explode(',', $ids);
$ids = "'" . implode("','", $ids) . "'";
$where = "in ($ids)";
}
else if (isset($_REQUEST['all']) ){
$where = '';//get all
} else {
if(!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$w = $ret_array['where'];
$where = "IN ( SELECT id from grouplists WHERE ".$w .")";
} else {
$where = '';
}
}*/
$focus = new GroupLists();
// $query = $focus->create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false, $parentbean=null, $singleSelect = false);
$query = $focus->{$start_date} = $_REQUEST['start_date'];
$end_date = $_REQUEST['end_date'];
$template = file_get_contents('modules/GroupLists/tpls/report.tpl');
$template = str_replace('{START}', $start_date, $template);
$template = str_replace('{END}', $end_date, $template);
$template = str_replace('{LIST_GIT}', $focus->get_GIT_to_report($where), $template);
$template = str_replace('{LIST_FIT}', $focus->get_FIT_to_report($where), $template);
$size = strlen($template);
$filename = "DS KHACH DI TOUR TU " . $start_date . " DEN " . $end_date . ".doc";
ob_end_clean();
header("Cache-Control: private");
header("Content-Type: application/force-download;");
header("Content-Disposition:attachment; filename=\"{$filename}\"");
header("Content-length:{$size}");
echo $template;
ob_flush();
// header("Location: index.php?module=GroupLists&action=index");
sugar_cleanup(true);
}
示例8: generate_url
function generate_url($segments)
{
for ($i = 0; $i < count($segments); $i++) {
$segments[$i] = clean_string($segments[$i]);
}
$url = site_url($segments);
return $url;
}
示例9: testCleanString
/**
* @dataProvider providerCleanString
* @ticket 45877
*/
public function testCleanString($string, $filter, $resultBool)
{
if ($resultBool) {
$this->assertEquals($string, clean_string($string, $filter, false));
} else {
$this->assertFalse(clean_string($string, $filter, false));
}
}
示例10: sendEmail
function sendEmail()
{
if (isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "thesportsage16@gmail.com";
$email_subject = "Website Inquiry : ";
function died($error)
{
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error . "<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die;
}
// validation expected data exists
if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['subject']) || !isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name'];
// required
$email = $_POST['email'];
// required
$subject = $_POST['subject'];
// required
$message = $_POST['message'];
// required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+\$/";
if (!preg_match($string_exp, $name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if (strlen($message) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if (strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Name: " . clean_string($name) . "\n";
$email_message .= "Email: " . clean_string($email) . "\n";
$email_message .= "Subject: " . clean_string($subject) . "\n";
$email_message .= "Message: " . clean_string($message) . "\n";
// create email headers
$headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
}
示例11: recup_noticeunimarc_suite
function recup_noticeunimarc_suite($notice)
{
global $tit_200a, $serie_200;
if (clean_string($serie_200[0]['i']) != "") {
$tmp_buffer = $serie_200[0]['i'];
$serie_200[0]['i'] = $tit_200a[0];
$tit_200a[0] = $tmp_buffer;
}
}
示例12: createContingent
function createContingent($nameParam)
{
$password = random_password();
$name = clean_string($nameParam);
$loginID = registration_id();
$db = \Udaan\Database::connect();
$sth = $db->prepare("INSERT INTO contingent_college(name,loginid,password) VALUES('{$name}','{$loginID}','{$password}')");
$sth->execute();
header('Location: college.php');
}
示例13: value_row
/**
* Add Value Row
*
* Adds a row that is just a <label></label> Value row
*
* @param string $label What to put in the <label>
* @param string $value What to put as the value
* @param boolean $full
*
* @return void
*/
function value_row($label, $value, $full = FALSE)
{
if ($this->fieldset == 0) {
show_error('You must create a fieldset before adding fields.');
}
$CI =& get_instance();
$CI->load->helper('clean_string_helper');
$name = clean_string($label);
$this->fields[$this->fieldset][] = array('type' => 'value_row', 'label' => $label, 'value' => $value, 'full' => $full, 'name' => $name);
}
示例14: new_content_type
/**
* Create New Content Type
*
* Creates a new content type, including the associated table and custom field group
*
* @param string $name
* @param boolean $is_standard Include Title, URL Path, and Topic dropdown? (default: FALSE)
* @param boolean $is_privileged Include Restrict Access to Member Group(s) Dropdown? (default: FALSE)
* @param boolean $is_module Should this be treated as an automatic content type? Or is there another admin module which will manage this content type? (default: FALSE)
* @param string $template The filename of the template in the theme directory to use for output (default: content.thtml)
* @param string $base_url If this will be managed with the standard content module, we can pre-populate the URL string with this base_url. (default: '')
*
* @return int $content_type_id
*/
function new_content_type($name, $is_standard = TRUE, $is_privileged = FALSE, $is_module = FALSE, $template = 'content.thtml', $base_url = '')
{
// prep base url
$base_url = rtrim($base_url, '/');
$base_url = !empty($base_url) ? $base_url . '/' : '';
// get system name
$this->load->helper('clean_string');
$system_name = clean_string($name);
// make sure table doesn't already exist, after we clear the cache
// we clear the cache because, when theme installs run, we don't want to run into errors about
// non-existant table conflicts
$this->db->data_cache = array();
if ($this->db->table_exists($system_name)) {
die(show_error('There is already a table in the database by the name of ' . $system_name . '. You should rename your content type to avoid a conflict.'));
}
// create custom field group
$this->load->model('custom_fields_model');
$custom_field_group_id = $this->custom_fields_model->new_group('Content: ' . $name);
$insert_fields = array('content_type_is_module' => $is_module == FALSE ? '0' : '1', 'content_type_friendly_name' => $name, 'content_type_system_name' => $system_name, 'content_type_is_standard' => $is_standard == TRUE ? '1' : '0', 'content_type_is_privileged' => $is_privileged == TRUE ? '1' : '0', 'content_type_template' => $template, 'content_type_base_url' => $base_url, 'custom_field_group_id' => $custom_field_group_id);
$this->db->insert('content_types', $insert_fields);
$content_type_id = $this->db->insert_id();
// if this content type isn't another admin module, we'll create a table for it
// otherwise, we expect the developer to create it's own table in the module install
if ($is_module == FALSE) {
/*
OLD DBFORGE METHOD
// database functions
$this->load->dbforge();
// add ID, date, edit_date, admin rows
$this->dbforge->add_field('`' . $system_name . '_id` INT(11) auto_increment PRIMARY KEY');
$this->dbforge->add_field('`content_id` INT(11) NOT NULL');
// create table
$this->dbforge->create_table($system_name);
// add the content_id index to VASTLY speed up queries
$this->db->query('ALTER TABLE `' . $system_name . '` ADD INDEX ( `content_id` )');
*/
/*
We can't use dbforge anymore as it doesn't let us specify a table-type,
which we need to be able to support FULLTEXT queries.
*/
$prefix = $this->db->dbprefix;
$sql = "CREATE TABLE `{$prefix}{$system_name}` (\n\t\t\t\t`{$system_name}_id` INT(11) AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`content_id` INT(11) NOT NULL,\n\t\t\t\tINDEX ( `content_id` )\n\t\t\t) ENGINE = MYISAM";
$this->db->query($sql);
}
// clear cache
if (isset($this->CI->cache)) {
$this->CI->cache->file->clean();
}
return $content_type_id;
}
示例15: send_mail
function send_mail($email_to, $email_subject, $first_name, $last_name, $email_from, $telephone, $comments)
{
$email_message = "Form details below.\n\n";
$email_message .= "First Name: " . clean_string($first_name) . "\n";
$email_message .= "Last Name: " . clean_string($last_name) . "\n";
$email_message .= "Email: " . clean_string($email_from) . "\n";
$email_message .= "Telephone: " . clean_string($telephone) . "\n";
$email_message .= "Comments: " . clean_string($comments) . "\n";
// create email headers
$headers = 'From: ' . $email_from . "\r\n" . 'Reply-To: ' . $email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}