本文整理汇总了PHP中reset函数的典型用法代码示例。如果您正苦于以下问题:PHP reset函数的具体用法?PHP reset怎么用?PHP reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSignVeryfy
/**
* 获取返回时的签名验证结果
* @param $para_temp 通知返回来的参数数组
* @param $sign 返回的签名结果
* @return 签名验证结果
*/
protected function getSignVeryfy($param, $sign)
{
//除去待签名参数数组中的空值和签名参数
$param_filter = array();
while (list($key, $val) = each($param)) {
if ($key == "sign" || $key == "sign_type" || $val == "") {
continue;
} else {
$param_filter[$key] = $param[$key];
}
}
ksort($param_filter);
reset($param_filter);
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = "";
while (list($key, $val) = each($param_filter)) {
$prestr .= $key . "=" . $val . "&";
}
//去掉最后一个&字符
$prestr = substr($prestr, 0, -1);
$prestr = $prestr . $this->config['key'];
$mysgin = md5($prestr);
if ($mysgin == $sign) {
return true;
} else {
return false;
}
}
示例2: validatePartial
/**
* Validates a partial array. Some data may be missing from the given $array, then it will be taken from the
* full array.
*
* Since the array can be incomplete, this method does not validate required parameters.
*
* @param array $array
* @param array $fullArray
*
* @return bool
*/
public function validatePartial(array $array, array $fullArray)
{
$unvalidatedFields = array_flip(array_keys($array));
// field validators
foreach ($this->validators as $field => $validator) {
unset($unvalidatedFields[$field]);
// if the value is present
if (isset($array[$field])) {
// validate it if a validator is given, skip it otherwise
if ($validator && !$validator->validate($array[$field])) {
$this->setError($validator->getError());
return false;
}
}
}
// check if any unsupported fields remain
if ($unvalidatedFields) {
reset($unvalidatedFields);
$field = key($unvalidatedFields);
$this->error($this->messageUnsupported, $field);
return false;
}
// post validators
foreach ($this->postValidators as $validator) {
if (!$validator->validatePartial($array, $fullArray)) {
$this->setError($validator->getError());
return false;
}
}
return true;
}
示例3: prepare_form
/**
* {@inheritdoc}
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
$avatar_list = $this->get_avatar_list($user);
$category = $request->variable('avatar_local_cat', key($avatar_list));
foreach ($avatar_list as $cat => $null) {
if (!empty($avatar_list[$cat])) {
$template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category));
}
if ($cat != $category) {
unset($avatar_list[$cat]);
}
}
if (!empty($avatar_list[$category])) {
$template->assign_vars(array('AVATAR_LOCAL_SHOW' => true));
$table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
$row_count = $col_count = $avatar_pos = 0;
$avatar_count = sizeof($avatar_list[$category]);
reset($avatar_list[$category]);
while ($avatar_pos < $avatar_count) {
$img = current($avatar_list[$category]);
next($avatar_list[$category]);
if ($col_count == 0) {
++$row_count;
$template->assign_block_vars('avatar_local_row', array());
}
$template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
$template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
$col_count = ($col_count + 1) % $table_cols;
++$avatar_pos;
}
}
return true;
}
示例4: up
public static function up($html, $spruce)
{
self::$tokenizer = new PHP_CodeSniffer_Tokenizers_CSS();
// TODO: parse $spruce to see if it's a path or a full Spruce string
self::$tokens = self::$tokenizer->tokenizeString(file_get_contents($spruce));
self::$tree = array();
//print_r(self::tokens);
reset(self::$tokens);
while ($t = current(self::$tokens)) {
if ($t['type'] != 'T_OPEN_TAG' && $t['type'] != 'T_DOC_COMMENT' && $t['type'] != 'T_COMMENT') {
if ($t['type'] == 'T_ASPERAND') {
$temp = next(self::$tokens);
switch ($temp['content']) {
case 'import':
next(self::$tokens);
self::addImportRule();
//print_r($temp);
continue;
case 'media':
next(self::$tokens);
self::addMediaRule();
continue;
}
} elseif ($t['type'] == 'T_STRING') {
self::addStatement();
}
}
next(self::$tokens);
}
return self::$tree;
}
示例5: oembed
/**
* @param string $url
* @return array
*/
public function oembed($url)
{
$embedly = new Embedly();
$response = $embedly->oembed(['url' => $url]);
$data = json_decode(json_encode(reset($response)), true);
return $data;
}
示例6: xfac_get_avatar
function xfac_get_avatar($avatar = '', $id_or_email, $size = 96, $default = '', $alt = '')
{
if (is_numeric($id_or_email)) {
$wpUserId = (int) $id_or_email;
} elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) {
$wpUserId = $user->ID;
} elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) {
$wpUserId = (int) $id_or_email->user_id;
}
if (empty($wpUserId)) {
// cannot figure out the user id...
return $avatar;
}
$apiRecords = xfac_user_getRecordsByUserId($wpUserId);
if (empty($apiRecords)) {
// no api records
return $avatar;
}
$apiRecord = reset($apiRecords);
if (empty($apiRecord->profile['links']['avatar'])) {
// no avatar?
return $avatar;
}
$avatar = $apiRecord->profile['links']['avatar'];
$size = (int) $size;
if (empty($alt)) {
$alt = get_the_author_meta('display_name', $wpUserId);
}
$author_class = is_author($wpUserId) ? ' current-author' : '';
$avatar = "<img alt='" . esc_attr($alt) . "' src='" . esc_url($avatar) . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
return $avatar;
}
示例7: __construct
/**
* Constructs a file picker object.
*
* The following are possible options for the filepicker:
* - accepted_types (*)
* - return_types (FILE_INTERNAL)
* - env (filepicker)
* - client_id (uniqid)
* - itemid (0)
* - maxbytes (-1)
* - maxfiles (1)
* - buttonname (false)
*
* @param stdClass $options An object containing options for the file picker.
*/
public function __construct(stdClass $options)
{
global $CFG, $USER, $PAGE;
require_once $CFG->dirroot . '/repository/lib.php';
$defaults = array('accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'env' => 'filepicker', 'client_id' => uniqid(), 'itemid' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'buttonname' => false);
foreach ($defaults as $key => $value) {
if (empty($options->{$key})) {
$options->{$key} = $value;
}
}
$options->currentfile = '';
if (!empty($options->itemid)) {
$fs = get_file_storage();
$usercontext = context_user::instance($USER->id);
if (empty($options->filename)) {
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id DESC', false)) {
$file = reset($files);
}
} else {
$file = $fs->get_file($usercontext->id, 'user', 'draft', $options->itemid, $options->filepath, $options->filename);
}
if (!empty($file)) {
$options->currentfile = html_writer::link(moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename()), $file->get_filename());
}
}
// initilise options, getting files in root path
$this->options = initialise_filepicker($options);
// copying other options
foreach ($options as $name => $value) {
if (!isset($this->options->{$name})) {
$this->options->{$name} = $value;
}
}
}
示例8: sanitize_uri
function sanitize_uri()
{
global $PATH_INFO, $SCRIPT_NAME, $REQUEST_URI;
if (isset($PATH_INFO) && $PATH_INFO != "") {
$SCRIPT_NAME = $PATH_INFO;
$REQUEST_URI = "";
}
if ($REQUEST_URI == "") {
//necessary for some IIS installations (CGI in particular)
$get = httpallget();
if (count($get) > 0) {
$REQUEST_URI = $SCRIPT_NAME . "?";
reset($get);
$i = 0;
while (list($key, $val) = each($get)) {
if ($i > 0) {
$REQUEST_URI .= "&";
}
$REQUEST_URI .= "{$key}=" . URLEncode($val);
$i++;
}
} else {
$REQUEST_URI = $SCRIPT_NAME;
}
$_SERVER['REQUEST_URI'] = $REQUEST_URI;
}
$SCRIPT_NAME = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1);
if (strpos($REQUEST_URI, "?")) {
$REQUEST_URI = $SCRIPT_NAME . substr($REQUEST_URI, strpos($REQUEST_URI, "?"));
} else {
$REQUEST_URI = $SCRIPT_NAME;
}
}
示例9: get_first_entry
/**
* @param $tag
* @return bool|mixed
*/
function get_first_entry($tag)
{
if ($references = $this->get_references($tag, 1)) {
return reset($references);
}
return false;
}
示例10: preparePrimaryKeyDeleteStatement
protected function preparePrimaryKeyDeleteStatement(DataSourceHandler $handler, DatasetMetaData $dataset, array $originalKeyColumnNames)
{
$sql = 'DROP PRIMARY KEY';
// we need to use the fix only for first column in primary key
$firstColumnName = reset($originalKeyColumnNames);
return $this->fixForeignKeyProblem($handler, $dataset, $firstColumnName, TRUE, $sql) . ', ' . $this->fixDropPrimaryKeyColumnProblem($handler, $dataset, $originalKeyColumnNames);
}
示例11: upload
public function upload()
{
/** import upload library **/
_wpl_import('assets.packages.ajax_uploader.UploadHandler');
$kind = wpl_request::getVar('kind', 0);
$params = array();
$params['accept_ext'] = wpl_flex::get_field_options(301);
$extentions = explode(',', $params['accept_ext']['ext_file']);
$ext_str = '';
foreach ($extentions as $extention) {
$ext_str .= $extention . '|';
}
// remove last |
$ext_str = substr($ext_str, 0, -1);
$ext_str = rtrim($ext_str, ';');
$custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null);
$upload_handler = new UploadHandler($custom_op);
$response = json_decode($upload_handler->json_response);
if (isset($response->files[0]->error)) {
return;
}
$attachment_categories = wpl_items::get_item_categories('attachment', $kind);
// get item category with first index
$item_cat = reset($attachment_categories)->category_name;
$index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0;
$item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index);
wpl_items::save($item);
}
示例12: CheckFilter
function CheckFilter($arFilterFields)
{
global $lAdmin;
$FilterArr = $arFilterFields;
reset($FilterArr);
foreach ($FilterArr as $f) {
global ${$f};
}
$str = "";
if (strlen(trim($find_timestamp_1)) > 0 || strlen(trim($find_timestamp_2)) > 0) {
$date_1_ok = false;
$date1_stm = MkDateTime(FmtDate($find_timestamp_1, "D.M.Y"), "d.m.Y");
$date2_stm = MkDateTime(FmtDate($find_timestamp_2, "D.M.Y") . " 23:59", "d.m.Y H:i");
if (!$date1_stm && strlen(trim($find_timestamp_1)) > 0) {
$str .= GetMessage("MAIN_WRONG_TIMESTAMP_FROM") . "<br>";
} else {
$date_1_ok = true;
}
if (!$date2_stm && strlen(trim($find_timestamp_2)) > 0) {
$str .= GetMessage("MAIN_WRONG_TIMESTAMP_TILL") . "<br>";
} elseif ($date_1_ok && $date2_stm <= $date1_stm && strlen($date2_stm) > 0) {
$str .= GetMessage("MAIN_FROM_TILL_TIMESTAMP") . "<br>";
}
}
$lAdmin->AddFilterError($str);
if (strlen($str) > 0) {
return false;
}
return true;
}
示例13: refactor
public function refactor(RefactorFileset $fileset) {
$tofunc = reset(explode('(',$this->to));
$toargs = reset(explode(')',end(explode('(',$this->to))));
$mod = array();
foreach($fileset->files as $file) {
if (file_exists($file.'.rf')) {
$in = file_get_contents($file.'.rf');
} else {
$in = file_get_contents($file);
}
foreach($this->from as $from) {
$func = reset(explode('(',$from));
$args = reset(explode(')',end(explode('(',$from))));
if ($args == $toargs) {
// Just change function names
$ref = str_replace($func.'(',$tofunc.'(',$in);
}
}
if ($ref != $in) {
$mod[] = $file;
file_put_contents($file.'.rf', $ref);
}
}
return $mod;
}
示例14: projectImport
public function projectImport($api, $args)
{
$this->checkACL($api, $args);
$this->requireArgs($args, array('module'));
$bean = BeanFactory::getBean($args['module']);
if (!$bean->ACLAccess('save') || !$bean->ACLAccess('import')) {
throw new SugarApiExceptionNotAuthorized('EXCEPTION_NOT_AUTHORIZED');
}
if (isset($_FILES) && count($_FILES) === 1) {
reset($_FILES);
$first_key = key($_FILES);
if (isset($_FILES[$first_key]['tmp_name']) && $this->isUploadedFile($_FILES[$first_key]['tmp_name']) && isset($_FILES[$first_key]['size']) && isset($_FILES[$first_key]['size']) > 0) {
try {
$importerObject = new PMSEProjectImporter();
$name = $_FILES[$first_key]['name'];
$extension = pathinfo($name, PATHINFO_EXTENSION);
if ($extension == $importerObject->getExtension()) {
$data = $importerObject->importProject($_FILES[$first_key]['tmp_name']);
$results = array('project_import' => $data);
} else {
throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
}
} catch (SugarApiExceptionNotAuthorized $e) {
throw new SugarApiExceptionNotAuthorized('ERROR_UPLOAD_ACCESS_PD');
} catch (Exception $e) {
throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
}
return $results;
}
} else {
throw new SugarApiExceptionMissingParameter('ERROR_UPLOAD_FAILED');
}
}
示例15: uploadFile
/**
* Uploads a XLS file with all attribute texts.
*
* @param \stdClass $params Object containing the properties
*/
public function uploadFile(\stdClass $params)
{
$this->checkParams($params, array('site'));
$this->setLocale($params->site);
if (($fileinfo = reset($_FILES)) === false) {
throw new \Aimeos\Controller\ExtJS\Exception('No file was uploaded');
}
$config = $this->getContext()->getConfig();
/** controller/extjs/attribute/import/text/standard/enablecheck
* Enables checking uploaded files if they are valid and not part of an attack
*
* This configuration option is for unit testing only! Please don't disable
* the checks for uploaded files in production environments as this
* would give attackers the possibility to infiltrate your installation!
*
* @param boolean True to enable, false to disable
* @since 2014.03
* @category Developer
*/
if ($config->get('controller/extjs/attribute/import/text/standard/enablecheck', true)) {
$this->checkFileUpload($fileinfo['tmp_name'], $fileinfo['error']);
}
$fileext = pathinfo($fileinfo['name'], PATHINFO_EXTENSION);
$dest = md5($fileinfo['name'] . time() . getmypid()) . '.' . $fileext;
$fs = $this->getContext()->getFilesystemManager()->get('fs-admin');
$fs->writef($dest, $fileinfo['tmp_name']);
$result = (object) array('site' => $params->site, 'items' => array((object) array('job.label' => 'Attribute text import: ' . $fileinfo['name'], 'job.method' => 'Attribute_Import_Text.importFile', 'job.parameter' => array('site' => $params->site, 'items' => $dest), 'job.status' => 1)));
$jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController($this->getContext());
$jobController->saveItems($result);
return array('items' => $dest, 'success' => true);
}