本文整理汇总了PHP中sanitize_int函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitize_int函数的具体用法?PHP sanitize_int怎么用?PHP sanitize_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitize_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_suggestions
/**
*
* Returns array of people containing entity, mutuals (friends), groups (shared) and priority
* @param Int $guid
* @param Int $friends_limit
* @param Int $groups_limit
* @return Array
*/
function get_suggestions($guid, $friends_of_friends_limit = 10, $groups_members_limit = 10)
{
$dbprefix = elgg_get_config('dbprefix');
$guid = sanitize_int($guid);
$suggestions = array();
if ($friends_of_friends_limit) {
// get some friends of friends
$options = array('selects' => array('COUNT(fof.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships fr ON fr.guid_one = {$guid} AND fr.relationship = 'friend'", "JOIN {$dbprefix}entity_relationships fof ON fof.guid_one = fr.guid_two AND fof.relationship = 'friend'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "fof.guid_two = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => abs((int) $friends_of_friends_limit));
$fof = elgg_get_entities($options);
foreach ($fof as $f) {
$priority = (int) $f->getVolatileData('select:priority');
$suggestions[$f->guid] = array('entity' => $f, 'mutuals' => $priority, 'groups' => 0, 'priority' => $priority);
}
}
if ($groups_members_limit) {
// get some mutual group members
$options = array('selects' => array('COUNT(mog.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships g ON g.guid_one = {$guid} AND g.relationship = 'member'", "JOIN {$dbprefix}groups_entity ge ON ge.guid = g.guid_two", "JOIN {$dbprefix}entity_relationships mog ON mog.guid_two = g.guid_two AND mog.relationship = 'member'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "mog.guid_one = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => 3);
// get members of groups
$mog = elgg_get_entities($options);
foreach ($mog as $m) {
if (!isset($suggestions[$m->guid])) {
$priority = (int) $m->getVolatileData('select:priority');
$suggestions[$m->guid] = array('entity' => $m, 'mutuals' => 0, 'groups' => $priority, 'priority' => $priority);
} else {
$priority = (int) $m->getVolatileData('select:priority');
$suggestions[$m->guid]['groups'] = $priority;
$suggestions[$m->guid]['priority'] += $priority;
}
}
}
// sort by priority
usort($suggestions, __NAMESPACE__ . '\\suggested_friends_sorter');
return $suggestions;
}
示例2: validateEntity
/**
* Check if an entity_guid is valid for sending tag notifications
*
* @param int $entity_guid the entity GUID
*
* @return bool
*/
protected static function validateEntity($entity_guid)
{
$entity_guid = sanitize_int($entity_guid, false);
if (empty($entity_guid)) {
return false;
}
// cache plugin
self::cachePlugin();
if (check_entity_relationship(self::$plugin->getGUID(), 'tag_tools:notification', $entity_guid)) {
// already enqueued
return false;
}
// can't use elgg get entity because cache is not correctly updated
$entity_row = get_entity_as_row($entity_guid);
if ($entity_row === false) {
// invalid entity
return false;
}
$entity_access = sanitise_int($entity_row->access_id);
if ($entity_access === ACCESS_PRIVATE) {
// private entity
return false;
}
if (!tag_tools_is_notification_entity($entity_guid)) {
// not supported entity type/subtype
return false;
}
return true;
}
示例3: index
/**
* Load edit email template screen.
* @param mixed $iSurveyId
* @return
*/
function index($iSurveyId)
{
$clang = $this->getController()->lang;
$iSurveyId = sanitize_int($iSurveyId);
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminstyleurl') . "superfish.css");
Yii::app()->loadHelper('admin.htmleditor');
Yii::app()->loadHelper('surveytranslator');
Yii::app()->session['FileManagerContext'] = "edit:assessments:{$iSurveyId}";
if (isset($iSurveyId) && getEmailFormat($iSurveyId) == 'html') {
$ishtml = true;
} else {
$ishtml = false;
}
$grplangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyId)->language;
array_unshift($grplangs, $baselang);
$sEditScript = PrepareEditorScript(false, $this->getController());
$aData['attrib'] = array();
$aData['bplangs'] = array();
$aData['defaulttexts'] = array();
if ($ishtml) {
$sEscapeMode = 'html';
} else {
$sEscapeMode = 'unescaped';
}
foreach ($grplangs as $key => $grouplang) {
$aData['bplangs'][$key] = new limesurvey_lang($grouplang);
$aData['attrib'][$key] = Surveys_languagesettings::model()->find('surveyls_survey_id = :ssid AND surveyls_language = :ls', array(':ssid' => $iSurveyId, ':ls' => $grouplang));
$aData['defaulttexts'][$key] = templateDefaultTexts($aData['bplangs'][$key], $sEscapeMode);
}
$aData['surveyid'] = $iSurveyId;
$aData['ishtml'] = $ishtml;
$aData['grplangs'] = $grplangs;
$this->_renderWrappedTemplate('emailtemplates', array('output' => $sEditScript, 'emailtemplates_view'), $aData);
}
示例4: index
function index()
{
$sFieldName = isset($_GET['name']) ? $_GET['name'] : 0;
$sFieldText = isset($_GET['text']) ? $_GET['text'] : 0;
$sFieldType = isset($_GET['type']) ? $_GET['type'] : 0;
$sAction = isset($_GET['action']) ? $_GET['action'] : 0;
$iSurveyId = isset($_GET['sid']) ? $_GET['sid'] : 0;
$iGroupId = isset($_GET['gid']) ? $_GET['gid'] : 0;
$iQuestionId = isset($_GET['qid']) ? $_GET['qid'] : 0;
$sLanguage = isset($_GET['lang']) ? $_GET['lang'] : 0;
$aData['clang'] = $this->getController()->lang;
$aData['sFieldName'] = $sFieldName;
if (get_magic_quotes_gpc()) {
$aData['sFieldText'] = $sFieldText = stripslashes($sFieldText);
} else {
$aData['sFieldText'] = $sFieldText;
}
if (!$sFieldName || !$sFieldText) {
$this->getController()->render('/admin/htmleditor/pop_nofields_view', $aData);
} else {
$aData['sFieldType'] = $sFieldType = preg_replace("/[^_.a-zA-Z0-9-]/", "", $sFieldType);
$aData['sAction'] = preg_replace("/[^_.a-zA-Z0-9-]/", "", $sAction);
$aData['iSurveyId'] = sanitize_int($iSurveyId);
$aData['iGroupId'] = sanitize_int($iGroupId);
$aData['iQuestionId'] = sanitize_int($iQuestionId);
$aData['sControlIdEna'] = $sFieldName . '_popupctrlena';
$aData['sControlIdDis'] = $sFieldName . '_popupctrldis';
$aData['toolbarname'] = 'popup';
$aData['htmlformatoption'] = '';
if (in_array($sFieldType, array('email-inv', 'email-reg', 'email-conf', 'email-rem'))) {
$aData['htmlformatoption'] = ',fullPage:true';
}
$this->getController()->render('/admin/htmleditor/pop_editor_view', $aData);
}
}
示例5: index
function index()
{
$aData = array();
$needpermission = false;
$aData['surveyid'] = $surveyid = sanitize_int(Yii::app()->request->getQuery('sid'));
$aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index'));
if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) {
$needpermission = true;
}
if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
App()->getClientScript()->registerPackage('jquery-superfish');
$message['title'] = gT('Access denied!');
$message['message'] = gT('You do not have sufficient rights to access this page.');
$message['class'] = "error";
$this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
} else {
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js");
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css");
$this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'));
$aData['pagetitle'] = "ExpressionManager: {$aData['sa']}";
//header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding
if (isset($_GET['sa'])) {
$this->test($aData['sa'], $aData);
} else {
$this->_renderWrappedTemplate('expressions', 'test_view', $aData);
}
}
}
示例6: isCheckedIn
/**
* Check if the user is checked in at the place
*
* @param integer $user_guid GUID of the user to check
* @return integer Count of checkins within checkin duration limit
*/
public function isCheckedIn($user_guid = 0)
{
if (!$user_guid) {
$user_guid = elgg_get_logged_in_user_guid();
}
return elgg_get_annotations(array('guids' => $this->guid, 'annotation_owner_guids' => sanitize_int($user_guid), 'annotation_names' => 'checkin', 'annotation_created_time_lower' => time() - $this->getCheckinDuration(), 'count' => true));
}
示例7: thewire_tools_get_wire_length
/**
* Get the max number of characters allowed in a wire post
*
* @return int the number of characters
*/
function thewire_tools_get_wire_length()
{
static $result;
if (isset($result)) {
return $result;
}
$result = sanitize_int(elgg_get_plugin_setting('limit', 'thewire', 140), false);
return $result;
}
示例8: get
/**
* {@inheritdoc}
*/
public function get(ParameterBag $params)
{
$options = array('types' => 'object', 'subtypes' => 'file', 'limit' => $params->limit, 'offset' => $params->offset, 'container_guids' => sanitize_int($params->guid), 'sort' => $params->sort, 'preload_owners' => true, 'preload_containers' => true);
$getter = 'elgg_get_entities';
if ($params->simpletype) {
$options['metadata_name_value_pairs'] = array('name' => 'simpletype', 'value' => $params->simpletype);
$getter = 'elgg_get_entities_from_metadata';
}
return new BatchResult($getter, $options);
}
示例9: addAuthor
/**
* Add a user as an author
* @param int $user_guid
*
* @return bool
*/
public function addAuthor($user_guid)
{
$user_guid = sanitize_int($user_guid, false);
if (empty($user_guid)) {
return false;
}
$result = (bool) $this->addRelationship($user_guid, 'author');
$authors = explode(',', $this->authors);
$authors[] = $user_guid;
$this->authors = implode(',', $authors);
return $result;
}
示例10: friend_collections_message_picker_callback
function friend_collections_message_picker_callback($query, $options = array())
{
$id = sanitize_int(get_input('id'));
$guids = get_members_of_access_collection($id, true);
// replace mysql vars with escaped strings
$q = str_replace(array('_', '%'), array('\\_', '\\%'), $query);
if (!$guids || !$id) {
return array();
}
$dbprefix = elgg_get_config('dbprefix');
return elgg_get_entities(array('type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}access_collection_membership acm ON acm.user_guid = e.guid"), 'wheres' => array("ue.username LIKE '%{$q}%' OR ue.name LIKE '%{$q}%'", "acm.access_collection_id = {$id}"), 'order_by' => 'ue.name ASC'));
}
示例11: loadSurveyById
/**
* Loads a survey from the database that has the given ID. If no matching
* survey is found then null is returned. Note that no results are loaded
* from this function call, only survey structure/definition.
*
* In the future it would be nice to load all languages from the db at
* once and have the infrastructure be able to return responses based
* on language codes.
*
* @param int $id
* @return SurveyObj
*/
public function loadSurveyById($id, $lang = null)
{
$survey = new SurveyObj();
$clang = Yii::app()->lang;
$intId = sanitize_int($id);
$survey->id = $intId;
$survey->info = getSurveyInfo($survey->id);
$availableLanguages = Survey::model()->findByPk($intId)->getAllLanguages();
if (is_null($lang) || in_array($lang, $availableLanguages) === false) {
// use base language when requested language is not found or no specific language is requested
$lang = Survey::model()->findByPk($intId)->language;
}
$clang = new limesurvey_lang($lang);
$survey->fieldMap = createFieldMap($intId, 'full', true, false, $lang);
// Check to see if timings are present and add to fieldmap if needed
if ($survey->info['savetimings'] == "Y") {
$survey->fieldMap = $survey->fieldMap + createTimingsFieldMap($intId, 'full', true, false, $lang);
}
if (empty($intId)) {
//The id given to us is not an integer, croak.
safeDie("An invalid survey ID was encountered: {$sid}");
}
//Load groups
$sQuery = 'SELECT g.* FROM {{groups}} AS g ' . 'WHERE g.sid = ' . $intId . ' AND g.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order;';
$recordSet = Yii::app()->db->createCommand($sQuery)->query()->readAll();
$survey->groups = $recordSet;
//Load questions
$sQuery = 'SELECT q.* FROM {{questions}} AS q ' . 'JOIN {{groups}} AS g ON (q.gid = g.gid and q.language = g.language) ' . 'WHERE q.sid = ' . $intId . ' AND q.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order, q.question_order;';
$survey->questions = Yii::app()->db->createCommand($sQuery)->query()->readAll();
//Load answers
$sQuery = 'SELECT DISTINCT a.* FROM {{answers}} AS a ' . 'JOIN {{questions}} AS q ON a.qid = q.qid ' . 'WHERE q.sid = ' . $intId . ' AND a.language = \'' . $lang . '\' ' . 'ORDER BY a.qid, a.sortorder;';
//$survey->answers = Yii::app()->db->createCommand($sQuery)->queryAll();
$aAnswers = Yii::app()->db->createCommand($sQuery)->queryAll();
foreach ($aAnswers as $aAnswer) {
if (Yii::app()->controller->action->id != 'remotecontrol') {
$aAnswer['answer'] = stripTagsFull($aAnswer['answer']);
}
$survey->answers[$aAnswer['qid']][$aAnswer['scale_id']][$aAnswer['code']] = $aAnswer;
}
//Load language settings for requested language
$sQuery = 'SELECT * FROM {{surveys_languagesettings}} WHERE surveyls_survey_id = ' . $intId . ' AND surveyls_language = \'' . $lang . '\';';
$recordSet = Yii::app()->db->createCommand($sQuery)->query();
$survey->languageSettings = $recordSet->read();
$recordSet->close();
if (tableExists('tokens_' . $survey->id) && array_key_exists('token', SurveyDynamic::model($survey->id)->attributes) && Permission::model()->hasSurveyPermission($survey->id, 'tokens', 'read')) {
// Now add the tokenFields
$survey->tokenFields = getTokenFieldsAndNames($survey->id);
unset($survey->tokenFields['token']);
}
return $survey;
}
示例12: exportSurvey
/**
* Root function for any export results action
*
* @param mixed $iSurveyId
* @param mixed $sLanguageCode
* @param csv|doc|pdf|xls $sExportPlugin Type of export
* @param FormattingOptions $oOptions
* @param string $sFilter
*/
function exportSurvey($iSurveyId, $sLanguageCode, $sExportPlugin, FormattingOptions $oOptions, $sFilter = '')
{
//Do some input validation.
if (empty($iSurveyId)) {
safeDie('A survey ID must be supplied.');
}
if (empty($sLanguageCode)) {
safeDie('A language code must be supplied.');
}
if (empty($oOptions)) {
safeDie('Formatting options must be supplied.');
}
if (empty($oOptions->selectedColumns)) {
safeDie('At least one column must be selected for export.');
}
//echo $oOptions->toString().PHP_EOL;
$writer = null;
$iSurveyId = sanitize_int($iSurveyId);
if ($oOptions->output == 'display') {
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
}
$exports = $this->getExports();
if (array_key_exists($sExportPlugin, $exports) && !empty($exports[$sExportPlugin])) {
// This must be a plugin, now use plugin to load the right class
$event = new PluginEvent('newExport');
$event->set('type', $sExportPlugin);
$oPluginManager = App()->getPluginManager();
$oPluginManager->dispatchEvent($event, $exports[$sExportPlugin]);
$writer = $event->get('writer');
}
if (!$writer instanceof IWriter) {
throw new Exception(sprintf('Writer for %s should implement IWriter', $sExportPlugin));
}
$surveyDao = new SurveyDao();
$survey = $surveyDao->loadSurveyById($iSurveyId, $sLanguageCode);
$writer->init($survey, $sLanguageCode, $oOptions);
$surveyDao->loadSurveyResults($survey, $oOptions->responseMinRecord, $oOptions->responseMaxRecord, $sFilter, $oOptions->responseCompletionState);
$writer->write($survey, $sLanguageCode, $oOptions, true);
$result = $writer->close();
// Close resultset if needed
if ($survey->responses instanceof CDbDataReader) {
$survey->responses->close();
}
if ($oOptions->output == 'file') {
return $writer->filename;
} else {
return $result;
}
}
示例13: actionAJAXRegisterForm
function actionAJAXRegisterForm($surveyid)
{
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('replacements');
$redata = compact(array_keys(get_defined_vars()));
$surveyid = sanitize_int($surveyid);
$row = Survey::model()->find('sid=:sid', array(':sid' => $surveyid)) or show_error("Can't find survey data");
$thistpl = getTemplatePath(validateTemplateDir($row->template));
$data['sid'] = $surveyid;
$data['startdate'] = $row->startdate;
$data['enddate'] = $row->expires;
Yii::import('application.libraries.Limesurvey_lang');
Yii::app()->lang = new Limesurvey_lang($baselang);
echo templatereplace(file_get_contents("{$thistpl}/register.pstpl"), array(), $redata, 'register.php', false, NULL, $data);
}
示例14: fuzzy_filter_get_suggested_groups
/**
* Returns suggested groups ... to be implemented (Rosana)
*
* @param ElggUser $user (optional) the user to get the groups for, defaults to the current user
* @param int $limit (optional) the number of suggested groups to return, default = 10
*
* @return ElggGroup[]
*/
function fuzzy_filter_get_suggested_groups($user = null, $limit = null)
{
if (!$user instanceof ElggUser) {
$user = elgg_get_logged_in_user_entity();
}
if (is_null($limit)) {
$limit = (int) get_input('limit', 10);
}
$limit = sanitize_int($limit, false);
if (empty($user) || $limit < 1) {
return [];
}
$result = [];
return $result;
}
示例15: sidebody
/**
* Helper function to let a plugin put content
* into the side-body easily.
*
* @param int $surveyId
* @param string $plugin Name of the plugin class
* @param string $method Name of the plugin method
* @return void
*/
public function sidebody($surveyId, $plugin, $method)
{
$aData = array();
$surveyId = sanitize_int($surveyId);
$surveyinfo = getSurveyInfo($surveyId);
$aData['surveyid'] = $surveyId;
$aData['surveybar']['buttons']['view'] = true;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $surveyId . ")";
$content = $this->getContent($surveyId, $plugin, $method);
$aData['sidemenu'] = array();
$aData['sidemenu']['state'] = false;
$aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour');
$aData['content'] = $content;
$aData['activated'] = $surveyinfo['active'];
$this->_renderWrappedTemplate(null, array('super/sidebody'), $aData);
}