本文整理汇总了PHP中stripinput函数的典型用法代码示例。如果您正苦于以下问题:PHP stripinput函数的具体用法?PHP stripinput怎么用?PHP stripinput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stripinput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: awec_post_process_events
function awec_post_process_events(&$events, &$out)
{
global $ec_today, $ec_tomorrow, $locale, $awec_settings;
$count = 0;
$current = 'others';
$path_event = INFUSIONS . 'aw_ecal_panel/view_event.php?id=';
$path_birthday = INFUSIONS . 'aw_ecal_panel/birthday.php?id=';
$show_details = $awec_settings['show_today_in_panel'] ? true : false;
foreach ($events as $year => $y_data) {
ksort($y_data, SORT_NUMERIC);
foreach ($y_data as $month => $m_data) {
ksort($m_data, SORT_NUMERIC);
$today_month = $ec_today['mon'] == $month && $ec_today['year'] == $year;
$tomorrow_month = $ec_tomorrow['mon'] == $month && $ec_tomorrow['year'] == $year;
foreach ($m_data as $mday => $d_data) {
if ($today_month && $ec_today['mday'] == $mday) {
$current = 'today';
} else {
if ($tomorrow_month && $ec_tomorrow['mday'] == $mday) {
$current = 'tomorrow';
} else {
$current = 'others';
}
}
foreach ($d_data as $ev) {
$item = '';
if ($current != 'others') {
if ($ev['start_time']) {
$item .= $ev['start_time'];
if ($ev['end_time']) {
$item .= '-' . $ev['end_time'];
}
$item .= ' ';
}
} else {
$item .= ec_format_fucking_date($year, $month, $mday) . ' ';
}
if ($ev['is_birthday']) {
$path = $path_birthday . $ev['user_id'];
} else {
$path = $path_event . $ev['ev_id'];
}
$item .= '<a href="' . $path . '">' . $ev['ev_title'] . '</a>';
if ($show_details && $current == 'today') {
$body = parseubb($ev['ev_body']);
$body = explode(stripinput(AWEC_BREAK), $body);
if (count($body) > 1) {
$body[0] .= ' <a href="' . $path . '">' . $locale['EC207'] . '</a>';
}
$item .= '<br /><span class="small2">' . $body[0] . '</span>';
}
$out[$current][] = $item;
++$count;
}
}
}
}
return $count;
}
示例2: gp_content
function gp_content()
{
global $gp_content;
if (!empty($gp_content)) {
eval(stripinput($gp_content) . "();");
} else {
include LAYOUT_DIR . "content.php";
}
}
示例3: form_datepicker
function form_datepicker($title, $input_name, $input_id, $input_value, $array = FALSE)
{
if (!defined('DATEPICKER')) {
define('DATEPICKER', TRUE);
add_to_head("<link href='" . DYNAMICS . "assets/datepicker/css/datepicker3.css' rel='stylesheet' />");
add_to_head("<script src='" . DYNAMICS . "assets/datepicker/js/bootstrap-datepicker.js'></script>");
}
$title2 = isset($title) && !empty($title) ? stripinput($title) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
$input_name = isset($input_name) && !empty($input_name) ? stripinput($input_name) : "";
$input_id = isset($input_id) && !empty($input_id) ? stripinput($input_id) : "";
if ($input_value && strstr($input_value, "-")) {
// then this is date.
$input_value = $input_value;
} else {
$input_value = $input_value ? date("d-m-Y", $input_value) : '';
}
if (!is_array($array)) {
$placeholder = "";
$date_format = "dd-mm-yyyy";
$width = "250px";
$required = 0;
$safemode = 0;
$deactivate = 0;
$icon = '';
$inline = 0;
$error_text = '';
$class = '';
} else {
$icon = array_key_exists('icon', $array) ? $array['icon'] : "";
$placeholder = array_key_exists("placeholder", $array) ? $array['placeholder'] : "";
$width = array_key_exists("width", $array) ? $array['width'] : "250px";
$date_format = array_key_exists("date_format", $array) ? $array['date_format'] : "dd-mm-yyyy";
$class = array_key_exists('class', $array) ? $array['class'] : "";
$error_text = array_key_exists("error_text", $array) ? $array['error_text'] : "";
$required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
$safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
$deactivate = array_key_exists('deactivate', $array) && $array['deactivate'] == 1 ? 1 : 0;
$inline = array_key_exists("inline", $array) ? 1 : 0;
}
$html = "<div id='{$input_id}-field' class='form-group m-b-0 {$class} " . ($icon ? 'has-feedback' : '') . "'>\n";
$html .= $title ? "<label class='control-label " . ($inline ? "col-sm-3 col-md-3 col-lg-3" : '') . "' for='{$input_id}'>{$title} " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</label>\n" : '';
$html .= $inline ? "<div class='col-sm-9 col-md-9 col-lg-9'>\n" : "";
$html .= "<div class='input-group date' " . ($width ? "style='width:{$width};'" : '') . ">\n";
$html .= "<input type='text' name='" . $input_name . "' id='" . $input_id . "' value='" . $input_value . "' class='form-control textbox' placeholder='{$placeholder}' />\n";
$html .= $icon ? "<div class='form-control-feedback'><i class='glyphicon {$icon}'></i></div>\n" : '';
$html .= "<span class='input-group-addon'><i class='entypo calendar'></i></span>\n";
$html .= "</div>\n";
$html .= "<div id='{$input_id}-help' style='display:inline-block !important;'></div>";
$html .= $inline ? "</div>\n" : "";
$html .= "</div>\n";
// Generate Defender Strings
$html .= "<input type='hidden' name='def[{$input_name}]' value='[type=date],[title={$title2}],[id={$input_id}],[required={$required}],[safemode={$safemode}]" . ($error_text ? ",[error_text={$error_text}]" : '') . "' readonly />";
if ($deactivate !== 1) {
add_to_jquery("\n \$('#{$input_id}-field .input-group.date').datepicker({\n format: '" . $date_format . "',\n todayBtn: 'linked',\n autoclose: true,\n todayHighlight: true\n });\n ");
}
return $html;
}
示例4: _authenticate
private function _authenticate($inputUserName, $inputPassword, $remember)
{
global $locale, $settings;
$inputUserName = preg_replace(array("/\\=/", "/\\#/", "/\\sOR\\s/"), "", stripinput($inputUserName));
$result = dbquery("SELECT * FROM " . DB_USERS . " WHERE user_name='" . $inputUserName . "' LIMIT 1");
if (dbrows($result) == 1) {
$user = dbarray($result);
require_once CLASSES . "PasswordAuth.class.php";
// Initialize password auth
$passAuth = new PasswordAuth();
$passAuth->currentAlgo = $user["user_algo"];
$passAuth->currentSalt = $user["user_salt"];
$passAuth->currentPasswordHash = $user["user_password"];
$passAuth->inputPassword = $inputPassword;
// Check if input password is valid
if ($passAuth->isValidCurrentPassword(true)) {
if ($settings['multiple_logins'] != 1) {
$user['user_algo'] = $passAuth->getNewAlgo();
$user['user_salt'] = $passAuth->getNewSalt();
$user['user_password'] = $passAuth->getNewHash();
$result = dbquery("UPDATE " . DB_USERS . "\n\t\t\t\t\t\tSET user_algo='" . $user['user_algo'] . "', user_salt='" . $user['user_salt'] . "', user_password='" . $user['user_password'] . "'\n\t\t\t\t\t\tWHERE user_id='" . $user['user_id'] . "'");
}
if ($user['user_status'] == 0 && $user['user_actiontime'] == 0) {
Authenticate::setUserCookie($user['user_id'], $user['user_salt'], $user['user_algo'], $remember, true);
Authenticate::_setUserTheme($user);
$this->_userData = $user;
} else {
require_once INCLUDES . "suspend_include.php";
require_once INCLUDES . "sendmail_include.php";
if ($user['user_status'] == 3 && $user['user_actiontime'] < time() || $user['user_status'] == 7) {
$result = dbquery("UPDATE " . DB_USERS . " SET user_status='0', user_actiontime='0' WHERE user_id='" . $user['user_id'] . "'");
if ($user['user_status'] == 3) {
$subject = $locale['global_453'];
$message = $locale['global_455'];
unsuspend_log($user['user_id'], 3, $locale['global_450'], true);
} else {
$subject = $locale['global_454'];
$message = $locale['global_452'];
}
$message = str_replace("USER_NAME", $user['user_name'], $message);
sendemail($user['user_name'], $user['user_email'], $settings['siteusername'], $settings['siteemail'], $subject, $message);
} else {
redirect(Authenticate::getRedirectUrl(4, $user['user_status'], $user['user_id']));
}
}
} else {
redirect(Authenticate::getRedirectUrl(1));
}
} else {
redirect(Authenticate::getRedirectUrl(1));
}
}
示例5: new_warning_post
function new_warning_post($post_or_userid, $subject, $message, $points, $KIND)
{
global $userdata, $settings, $locale;
if ($KIND == "Forum") {
$new_warning_sql = dbquery("SELECT post_id, thread_id, forum_id, post_author FROM " . DB_POSTS . " WHERE post_id='" . $post_or_userid . "'");
}
if ($KIND == "Other" || dbrows($new_warning_sql) != 0) {
if ($KIND == "Forum") {
$post_warn_data = dbarray($new_warning_sql);
$warnuser_id = $post_warn_data['post_author'];
$post = $post_or_userid;
$threadid = $post_warn_data['thread_id'];
$forumid = $post_warn_data['forum_id'];
} else {
$warnuser_id = $post_or_userid;
$post = "0";
$threadid = "0";
$forumid = "0";
}
$insertdate = date("U");
$sql = dbquery("INSERT INTO " . DB_WARNING . "\r\n\t\t(warn_kind, user_id, post_id, thread_id, forum_id, warn_subject, warn_message, warn_point, warn_admin, warn_datestamp)\r\n\t\tVALUES\r\n\t\t(" . _db($KIND) . ", " . _db($warnuser_id) . ", " . _db($post) . ", " . _db($threadid) . ", " . _db($forumid) . ", " . _db($subject) . ", " . _db($message) . ",\r\n\t\t" . _db($points) . ", " . _db($userdata['user_id']) . ", " . _db($insertdate) . ");");
// We need to send a PM to the warned user
if ($settings['warning_set_send_pm'] == 1) {
$pn_subject = stripinput(trim($locale['WARN210']));
if ($KIND == "Forum") {
$in = $locale['WARN211'] . " [url=" . $settings['siteurl'] . "forum/viewthread.php?thread_id=" . $post_warn_data['thread_id'] . "&pid=" . $post_warn_data['post_id'] . "#post_" . $post_warn_data['post_id'] . "]" . GetPostTitle($post_warn_data['thread_id']) . "[/url]\n";
} else {
$in = '';
}
$warning_subject = dbarray(dbquery("SELECT warn_subject FROM " . DB_WARNING_CATALOG . " WHERE warn_id='" . $subject . "'"));
$data_w = dbarray(dbquery("SELECT warn_length FROM " . DB_WARNING_CATALOG . " WHERE warn_id='" . (int) $subject . "'"));
$warning_length = $insertdate + $data_w['warn_length'] * 86400;
$pn_messages = stripinput(trim($in . $locale['WARN212'] . " " . $warning_subject['warn_subject'] . "\r\n\t\t\t\t\t\t\t\t\t" . $locale['WARN213'] . " " . $message . "\r\n\t\t\t\t\t\t\t\t\t" . $locale['WARN214'] . date($locale['WARN215'], $warning_length) . $locale['WARN216']));
if ($settings['warning_set_pm_from'] == 0) {
$pn_from = $userdata['user_id'];
} else {
$pn_from = $settings['warning_set_pm_from'];
}
$result = dbquery("INSERT INTO " . DB_MESSAGES . " (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('" . $warnuser_id . "','" . $pn_from . "','" . $pn_subject . "','" . $pn_messages . "','y','0','" . $insertdate . "','0')");
}
// We need to send a PM to an Admin if User has more than 100 points
if (show_warning_points($warnuser_id) >= 100) {
$pn_subject = stripinput(trim($locale['WARN217']));
$pn_messages = stripinput(trim("The member reached the limit:\n [url=" . $settings['siteurl'] . "warning.php?lookup=" . $warnuser_id . "]" . $locale['WARN218'] . "[/url]\n You should take some actions and suspend/bann this member!"));
$result = dbquery("INSERT INTO " . DB_MESSAGES . " (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('" . $settings['warning_set_pm_to'] . "','" . "0" . "','" . $pn_subject . "','" . $pn_messages . "','y','0','" . $insertdate . "','0')");
}
return true;
} else {
return false;
}
}
示例6: filter_show
function filter_show($row_start_key = false, $items_per_page_key = false)
{
if (isset($_GET[$row_start_key]) || isset($_GET[$items_per_page_key])) {
$condition = '';
if ($_GET[$items_per_page_key]) {
// WHEN show is available we set to rowstat, and show items.
$condition = " LIMIT ";
$condition .= isset($_GET[$row_start_key]) && isnum($_GET[$row_start_key]) ? stripinput($_GET[$row_start_key]) : 0;
if (isset($_GET[$items_per_page_key]) && isnum($_GET[$items_per_page_key])) {
$condition .= "," . stripinput($_GET[$items_per_page_key]);
}
}
return $condition;
}
}
示例7: form_badge
function form_badge($title, $array = false)
{
if (!is_array($array)) {
$class = "";
$icon = "";
} else {
$class = array_key_exists('class', $array) ? $array['class'] : "";
$icon = array_key_exists('icon', $array) ? "<i class='" . $array['icon'] . "'></i>" : "";
}
if (isset($title) && $title !== "") {
$title = stripinput($title);
} else {
$title = "";
}
return "<span class='badge {$class}'>{$icon} {$title}</span>\n";
}
示例8: stripinput_fix
function stripinput_fix($text)
{
if (!is_array($text)) {
if (QUOTES_GPC) {
$text = stripslashes($text);
}
$search = array("&", "\"", "'", "\\", '\\"', "\\'", "<", ">", " ");
$replace = array("&", """, "'", "\", """, "'", "<", ">", " ");
$text = str_replace($search, $replace, $text);
} else {
while (list($key, $value) = each($text)) {
$text[$key] = stripinput($value);
}
}
return $text;
}
示例9: get_current_SiteLinks
/**
* Given a matching URL, fetch Sitelinks data
* @param string $url - url to match (link_url) column
* @param string $key - column data to output, blank for all
* @return array|bool
*/
public static function get_current_SiteLinks($url = "", $key = NULL)
{
$url = stripinput($url);
static $data = array();
if (empty($data)) {
if (!$url) {
$pathinfo = pathinfo($_SERVER['PHP_SELF']);
$url = FUSION_FILELINK;
}
$result = dbquery("SELECT * FROM " . DB_SITE_LINKS . " WHERE link_url='" . $url . "' AND link_language='" . LANGUAGE . "'");
if (dbrows($result) > 0) {
$data = dbarray($result);
}
}
return $key === NULL ? (array) $data : (isset($data[$key]) ? $data[$key] : NULL);
}
示例10: get_current_SiteLinks
/**
* Given a matching URL, fetch Sitelinks data
* @param string $url - url to match (link_url) column
* @param string $column - column data to output, blank for all
* @return array|bool
*/
public static function get_current_SiteLinks($url = "", $key = NULL)
{
$url = stripinput($url);
static $data = array();
if (empty($data)) {
if (!$url) {
$pathinfo = pathinfo($_SERVER['PHP_SELF']);
$url = str_replace(fusion_get_settings("site_path"), "", $pathinfo['dirname']) . '/' . $pathinfo['basename'];
}
$result = dbquery("SELECT * FROM " . DB_SITE_LINKS . " WHERE link_url='" . $url . "' AND link_language='" . LANGUAGE . "'");
if (dbrows($result) > 0) {
$data = dbarray($result);
}
}
return $key === NULL ? $data : (isset($data[$key]) ? $data[$key] : NULL);
}
示例11: __construct
function __construct()
{
// Save some memory.. (since we don't use these anyway.)
unset($GLOBALS['HTTP_COOKIE_VARS'], $GLOBALS['HTTP_ENV_VARS'], $GLOBALS['HTTP_GET_VARS']);
unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_SERVER_VARS'], $GLOBALS['HTTP_POST_FILES']);
unset($GLOBALS['_FILES'], $GLOBALS['_ENV']);
// Filter. No any html/js/non_uft code
foreach ($_COOKIE as $numop => $valo) {
$_COOKIE[$numop] = stripinput($valo);
}
foreach ($_POST as $numop => $valo) {
$_POST[$numop] = stripinput($valo);
}
foreach ($_GET as $numop => $valo) {
$_GET[$numop] = stripinput($valo);
}
foreach ($_REQUEST as $numop => $valo) {
$_REQUEST[$numop] = stripinput($valo);
}
// Prevent any possible XSS attacks via $_GET.
foreach ($_GET as $check_url) {
if (eregi("<[^>]*script*\"?[^>]*>", $check_url) || eregi("<[^>]*object*\"?[^>]*>", $check_url) || eregi("<[^>]*iframe*\"?[^>]*>", $check_url) || eregi("<[^>]*applet*\"?[^>]*>", $check_url) || eregi("<[^>]*meta*\"?[^>]*>", $check_url) || eregi("<[^>]*style*\"?[^>]*>", $check_url) || eregi("<[^>]*form*\"?[^>]*>", $check_url) || eregi("\\([^>]*\"?[^)]*\\)", $check_url) || eregi("\"", $check_url)) {
//die ('XSS attack filtred');
die;
}
}
// Some PHP defaults. For stable work on different systems.
ini_set('precision', 14);
ini_set('serialize_precision', 14);
/*
if(!iCONSOLE) {
$_SERVER['HTTP_ACCEPT_ENCODING'] = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '';
// enable Gzip compression
if(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start(array('ob_gzhandler',9));
// no caching hint
//header("Expires: Mon, 01 Jan 2000 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");// HTTP/1.0
}
*/
}
示例12: setError
function setError($error_level, $error_message, $error_file, $error_line, $error_context)
{
global $userdata, $_errorHandler;
$showError = true;
$result = dbquery("SELECT error_id, error_status FROM " . DB_ERRORS . "\n\t\tWHERE error_level='" . intval($error_level) . "' AND error_file='" . stripinput($error_file) . "'\n\t\tAND error_line='" . intval($error_line) . "' AND error_status!='1'\n\t\tORDER BY error_timestamp DESC LIMIT 1");
if (dbrows($result) == 0) {
$result = dbquery("INSERT INTO " . DB_ERRORS . " (\n\t\t\t\terror_level, error_message, error_file, error_line, error_page,\n\t\t\t\terror_user_level, error_user_ip, error_user_ip_type, error_status, error_timestamp\n\t\t\t) VALUES (\n\t\t\t\t'" . intval($error_level) . "', '" . stripinput($error_message) . "',\n\t\t\t\t'" . stripinput($error_file) . "', '" . intval($error_line) . "',\n\t\t\t\t'" . TRUE_PHP_SELF . "', '" . $userdata['user_level'] . "', '" . USER_IP . "', '" . USER_IP_TYPE . "',\n\t\t\t\t'0', '" . time() . "'\n\t\t\t)");
$errorId = mysql_insert_id();
} else {
$data = dbarray($result);
$errorId = $data['error_id'];
if ($data['error_status'] == 2) {
$showError = false;
}
}
if ($showError) {
$_errorHandler[] = array("id" => $errorId, "level" => $error_level, "file" => $error_file, "line" => $error_line);
}
}
示例13: _isValidEMailAddress
private function _isValidEMailAddress($email)
{
$email = stripinput(trim(preg_replace("/ +/i", "", $email)));
if (preg_match("/^[-0-9A-Z_\\.]{1,50}@([-0-9A-Z_\\.]+\\.){1,50}([0-9A-Z]){2,4}\$/i", $email)) {
$check = dbcount("(user_id)", DB_USERS, "user_email='" . $email . "'");
if ($check > 0) {
$this->_userEMail = $email;
return TRUE;
} else {
// e-mail adress is not found
$this->_error = 1;
return FALSE;
}
} else {
// no valid e-mail adress
$this->_error = 2;
return FALSE;
}
}
示例14: form_btngroup
/**
* Button Groups
* @param $input_name
* @param string $label
* @param $input_value
* @param array $options
* @return string
*/
function form_btngroup($input_name, $label = "", $input_value, array $options = array())
{
global $defender, $locale;
$title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
$input_value = isset($input_value) && !empty($input_value) ? stripinput($input_value) : "";
$default_options = array('options' => array($locale['disable'], $locale['enable']), 'input_id' => $input_name, 'class' => "btn-default", 'icon' => "", "multiple" => FALSE, "delimiter" => ",", 'deactivate' => FALSE, 'error_text' => "", 'inline' => FALSE, 'safemode' => FALSE, 'required' => FALSE, 'callback_check' => '');
$options += $default_options;
$error_class = "";
if ($defender->inputHasError($input_name)) {
$error_class = "has-error ";
if (!empty($options['error_text'])) {
$new_error_text = $defender->getErrorText($input_name);
if (!empty($new_error_text)) {
$options['error_text'] = $new_error_text;
}
addNotice("danger", "<strong>{$title}</strong> - " . $options['error_text']);
}
}
$html = "<div id='" . $options['input_id'] . "-field' class='form-group " . $error_class . "clearfix'>\n";
$html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3 p-l-0" : 'col-xs-12 col-sm-12 col-md-12 col-lg-12 p-l-0') . "' for='" . $options['input_id'] . "'>{$label} " . ($options['required'] == 1 ? "<span class='required'>*</span>" : '') . "</label>\n" : '';
$html .= $options['inline'] ? "<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9'>\n" : '';
$html .= "<div class='btn-group' id='" . $options['input_id'] . "'>";
$i = 1;
if (!empty($options['options']) && is_array($options['options'])) {
foreach ($options['options'] as $arr => $v) {
$active = '';
if ($input_value == $arr) {
$active = "active";
}
$html .= "<button type='button' data-value='{$arr}' class='btn " . $options['class'] . " " . (count($options['options']) == $i ? 'last-child' : '') . " {$active}'>" . $v . "</button>\n";
$i++;
}
}
$html .= "</div>\n";
$html .= "<input name='{$input_name}' type='hidden' id='" . $options['input_id'] . "-text' value='{$input_value}' />\n";
$html .= $defender->inputHasError($input_name) ? "<div id='" . $options['input_id'] . "-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
$html .= $options['inline'] ? "</div>\n" : '';
$html .= "</div>\n";
$input_name = $options['multiple'] ? str_replace("[]", "", $input_name) : $input_name;
$defender->add_field_session(array('input_name' => $input_name, 'title' => trim($title, '[]'), 'id' => $options['input_id'], 'type' => 'dropdown', 'required' => $options['required'], 'callback_check' => $options['callback_check'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'], 'delimiter' => $options['delimiter']));
add_to_jquery("\n\t\$('#" . $options['input_id'] . " button').bind('click', function(e){\n\t\t\$('#" . $options['input_id'] . " button').removeClass('active');\n\t\t\$(this).toggleClass('active');\n\t\tvalue = \$(this).data('value');\n\t\t\$('#" . $options['input_id'] . "-text').val(value);\n\t});\n\t");
return $html;
}
示例15: form_colorpicker
function form_colorpicker($input_name, $label = '', $input_value = '', array $options = array())
{
global $defender, $locale;
if (!defined("COLORPICKER")) {
define("COLORPICKER", TRUE);
add_to_head("<link href='" . DYNAMICS . "assets/colorpick/css/bootstrap-colorpicker.css' rel='stylesheet' media='screen' />");
add_to_head("<script src='" . DYNAMICS . "assets/colorpick/js/bootstrap-colorpicker.js'></script>");
}
$title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
$input_name = stripinput($input_name);
$input_value = stripinput($input_value);
$default_options = array('input_id' => $input_name, 'required' => FALSE, 'placeholder' => '', 'deactivate' => FALSE, 'width' => '250px', 'class' => '', 'inline' => FALSE, 'error_text' => $locale['error_input_default'], 'safemode' => FALSE, 'icon' => "", "tip" => "", 'format' => 'hex');
$options += $default_options;
if (!$options['width']) {
$options['width'] = $default_options['width'];
}
$input_id = $options['input_id'] ?: $default_options['input_id'];
$error_class = "";
if ($defender->inputHasError($input_name)) {
$error_class = "has-error ";
if (!empty($options['error_text'])) {
$new_error_text = $defender->getErrorText($input_name);
if (!empty($new_error_text)) {
$options['error_text'] = $new_error_text;
}
addNotice("danger", "<strong>{$title}</strong> - " . $options['error_text']);
}
}
$html = "<div id='{$input_id}-field' class='form-group clearfix m-b-10 " . $error_class . $options['class'] . " '>\n";
$html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3" : '') . "' for='{$input_id}'>{$label} " . ($options['required'] ? "<span class='required'>*</span>" : '') . "\n\t" . ($options['tip'] ? "<i class='pointer fa fa-question-circle' title='" . $options['tip'] . "'></i>" : '') . "\n\t</label>\n" : '';
$html .= $options['inline'] ? "<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9'>\n" : "<br/>\n";
$html .= "<div id='{$input_id}' style='width: " . $options['width'] . "' class='input-group colorpicker-component bscp colorpicker-element m-b-10' data-color='{$input_value}' data-color-format='" . $options['format'] . "'>";
$html .= "<input type='text' name='{$input_name}' class='form-control " . $options['class'] . "' id='" . $input_id . "' value='{$input_value}' data-color-format='" . $options['format'] . "' placeholder='" . $options['placeholder'] . "' " . ($options['deactivate'] ? "readonly" : "") . ">";
$html .= "<span id='{$input_id}-cp' class='input-group-addon'>";
$html .= "<i style='background: rgba(255,255,255,1);'></i>";
$html .= "</span></div>";
$html .= $options['inline'] ? "</div>\n" : "";
$html .= "</div>\n";
$defender->add_field_session(array('input_name' => $input_name, 'type' => 'color', 'title' => $title, 'id' => $input_id, 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text']));
add_to_jquery("\$('#{$input_id}').colorpicker({ format : '" . $options['format'] . "' });");
return $html;
}