当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::enum方法代码示例

本文整理汇总了PHP中Validator::enum方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::enum方法的具体用法?PHP Validator::enum怎么用?PHP Validator::enum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::enum方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editWithArray

		function editWithArray($itemId, $arg){
			if (!isset($itemId) || !is_array($arg)) {
				return false;
			}
			foreach ($arg as $key=>$value) {
				if (!Validator::enum($key, 'author,permalink,title,autoUpdate,allowRedistribute,tags,focus,visibility')) {
					return false;
				}
				if (!FeedItem::edit($itemId, $key, $value)) {
					return false;
				}
			}
			return true;
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:14,代码来源:Bloglounge.Data.FeedItems.php

示例2: on

		function on($event, $input = null) {
			global $service;

			if (empty($event)) return false;
			if (!isset($this->case) || !is_array($this->case) || !isset($this->case[$event]) || empty($this->case[$event])) return $input;
			if (Validator::enum($event, 'Plugin.on,Plugin.off,Plugin.set') && isset($input['plugin']) && !empty($input['plugin'])) { // Plug.on & off & set 이벤트는 연쇄작용 없음
				$pluginName = $input['plugin'];
				include_once(ROOT . '/plugins/'.$input['plugin'].'/index.php');
				if (function_exists($this->case[$event][$pluginName])) {
					$this->pluginURL = $service['path'] . '/plugins/'.$input['plugin'].'/';
					return call_user_func($this->case[$event][$pluginName], $input, Plugin::getConfig($pluginName));
				}
			} else {
				foreach ($this->case[$event] as $plugin=>$func) {
					include_once(ROOT . '/plugins/'.$plugin.'/index.php');		
					if (function_exists($func)) {
						$this->pluginURL = $service['path'] . '/plugins/'.$plugin;
						$input = call_user_func($func, $input, Plugin::getConfig($plugin));
					}
				}
				return $input;
			}
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:23,代码来源:Bloglounge.Model.Event.php

示例3: testEnumValidation

 public function testEnumValidation()
 {
     $validator = new Validator();
     // This method should fail if we haven't set up the enum list
     $this->assertThrows('LogicException', array($validator, 'enum'), array('foo'));
     $validator->setEnumValues(array('', '0', 0, false, '1', 'foo', ' BAR '));
     // Passing anything that's not a scalar should throw an exception
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(array()));
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(new stdClass()));
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(null));
     // But we can get nulls to validate if we pass the proper assertion
     $this->assertNull($validator->enum(null, null, Validator::ASSERT_ALLOW_NULL));
     /* If we don't pass any options, we get loose matching. Note that
        boolean true was not included in the enumeration. */
     $this->assertSame(true, $validator->enum(true));
     // Asserting the type should stop that from working
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(true, null, Validator::ASSERT_TYPE_MATCH));
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(1, null, Validator::ASSERT_TYPE_MATCH));
     $this->assertSame('1', $validator->enum('1', null, Validator::ASSERT_TYPE_MATCH));
     $this->assertSame(false, $validator->enum(false, null, Validator::ASSERT_TYPE_MATCH));
     $this->assertSame('0', $validator->enum('0', null, Validator::ASSERT_TYPE_MATCH));
     $this->assertSame(0, $validator->enum(0, null, Validator::ASSERT_TYPE_MATCH));
     $this->assertSame('', $validator->enum('', null, Validator::ASSERT_TYPE_MATCH));
     // The trim filter could also be useful
     $this->assertSame('', $validator->enum('     ', null, Validator::FILTER_TRIM));
     $this->assertSame('foo', $validator->enum('    foo', null, Validator::FILTER_TRIM));
     /* This won't work though, because the string is trimmed before it is
        tested for presence in the enumeration. */
     $this->assertThrows('InvalidArgumentException', array($validator, 'enum'), array(' BAR ', null, Validator::FILTER_TRIM));
 }
开发者ID:performics,项目名称:ga-cli-api,代码行数:30,代码来源:ValidatorTestCase.class.php

示例4: array

<body style="background:transparent;">
<?php
	$config = new Settings;
	$requests = array();
	$requests['title'] = $db->escape($_POST['title']);
	$requests['description'] = $db->escape($_POST['description']);
	if (isset($_POST['delLogo'])) {
		$requests['logo'] = '';
		@unlink(ROOT.'/cache/logo/'.$config->logo);
	}

	$config->setWithArray($requests);

	if(!empty($_FILES['logoFile']['tmp_name']) && !isset($_POST['delLogo'])){
		if (!Validator::enum(func::getExt($_FILES['logoFile']['name']), 'gif,jpg,png')) {
			echo '<script type="text/javascript">parent.addMessage("'._t('로고는 GIF, JPG, PNG 형식의 파일만 가능합니다').'");</script>';
			exit;
		} else {
			$path = ROOT . '/cache/logo';
			if (!is_dir($path)) {
				mkdir($path);
				if (!is_dir($path)) {
					echo '<script type="text/javascript">parent.addMessage("'._t('로고 이미지를 업로드 할 수 없었습니다').'");</script>';
					exit;
				}
				@chmod($path, 0777);
			}

			if (file_exists($path . '/'. basename($_FILES['logoFile']['name']))) {
				$filename = substr(md5(time()), -1, 8).$_FILES['logoFile']['name'];
开发者ID:ncloud,项目名称:bloglounge,代码行数:30,代码来源:index.php

示例5: array

<?php
	define('ROOT', '../..');
	include ROOT . '/lib/includeForAjax.php';

	requireStrictRoute();

	$response = array();
	$response['error'] = 0;
	$response['message'] = '';

	if (!isAdmin()) {
		$response['error'] = 1;
		$response['message'] = _t('관리자만이 이 기능을 사용할 수 있습니다.');
	} else {
		$config = new Settings;
		$newSettings = array();

		foreach ($_POST as $key=>$value) {
			if (!Validator::enum($key, 'skin,title,description,logo,updateCycle,updateProcess,archivePeriod,totalVisit,filter,blackfilter,restrictJoin,restrictBoom,rankBy,rankPeriod,rankLife,welcomePack,language,boomDownReactor,boomDownReactLimit,useRssOut,countRobotVisit,thumbnailLimit,thumbnailSize,thumbnailType,feeditemsOnRss,summarySave,filterType,blackfilterType,useVerifier,verifierType,verifier,directView,saveImages,addressType')) 
				continue;
			$newSettings[$key] = $db->escape($value);
		}

		if (!$config->setWithArray($newSettings)) {
			$response['error'] = 1 ;
			$response['message'] = $config->_error;
		}
	}

	func::printRespond($response);
?>
开发者ID:ncloud,项目名称:bloglounge,代码行数:31,代码来源:save.php

示例6: array

	requireStrictRoute();

	$response = array();
	$response['error'] = 0;
	$response['message'] = '';

	if (Validator::getBool(Settings::get('restrictBoom')) && !isLoggedIn()) {
		$response['error'] = 1;
		$response['message'] = _t('로그인 한 사람만 이 기능을 사용할 수 있습니다');
		func::printRespond($response);
	}

	requireComponent('Bloglounge.Model.Boom');

	if (!Validator::enum($_POST['direction'], 'up,down')) {
		$response['error'] = 1;
		$response['message'] = $_POST['direction'].'is undefined direction';
		func::printRespond($response);
	}

	if (!Validator::is_digit($_POST['itemId'])) {
		$response['error'] = 1;
		$response['message'] = 'illegal id';
	}
	$itemId = $_POST['itemId'];

	switch($_POST['direction']) {
		case 'up':				
			if (isLoggedIn()) {
				$userid = $session['id'];
开发者ID:ncloud,项目名称:bloglounge,代码行数:30,代码来源:index.php

示例7: _t

				$step_text = _t('삭제완료');

				include ROOT . '/config.php'; // $database

				if (!isset($database['type'])) $database['type'] = 'mysql';

				$db = DB::start($database['type']);
				if (!($database['alive'] || $db->alive)) {
					header("Location: {$path}/setup/?step=uninstall&error=8");
					exit;
				}

				$IV = array();
				foreach ($_POST as $key=>$value) {
					if (Validator::enum($key, 'userid,userpw'))
						$IV[$key] = $db->escape($value);
				}

				if (!isset($IV['userid']) || !isset($IV['userpw'])) {
					header("Location: {$path}/setup/?step=uninstall&error=10");
					exit;
				}

				if (!list($loginid, $password, $is_admin) = $db->pick("SELECT loginid, password, is_admin FROM {$database['prefix']}Users WHERE loginid='{$IV['userid']}'")) {
					header("Location: {$path}/setup/?step=uninstall&error=11");
					exit;
				}

				if ($password != Encrypt::hmac($IV['userid'], md5(md5($IV['userpw'])))) {
					header("Location: {$path}/setup/?step=uninstall&error=12");
开发者ID:ncloud,项目名称:bloglounge,代码行数:30,代码来源:setup.php

示例8: if

<?php
	// ** 검색어 호환 처리
	if (isset($_GET['type']) && Validator::enum($_GET['type'], 'all,tag,blogURL,archive')) {
		switch (strtolower($_GET['type'])) {
			case 'tag':
				$_GET['tag'] = $_GET['keyword'];
				$_GET['keyword'] = '';
				break;
			case 'blogurl':
				$_GET['blogURL'] = $_GET['keyword'];
				$_GET['keyword'] = '';
				break;
			case 'archive':
				$_GET['archive'] = $_GET['keyword'];
				$_GET['keyword'] = '';
				break;
		}
	}	

	$searchType = 'all'; // global
	if (isset($_GET['tag']) && !empty($_GET['tag'])) $searchType = 'tag';
	else if (isset($_GET['blogURL']) && !empty($_GET['blogURL'])) $searchType = 'blogURL';
	else if (isset($_GET['archive']) && !empty($_GET['archive'])) $searchType = 'archive';
	
	$searchKeyword = ''; // global
	if (isset($_GET['keyword']) && !empty($_GET['keyword']))
		$searchKeyword = urldecode(trim($_GET['keyword']));
	else if (isset($_GET['tag']) && !empty($_GET['tag']))
		$searchKeyword = urldecode(trim($_GET['tag']));
	else if (isset($_GET['blogURL']) && !empty($_GET['blogURL']))
		$searchKeyword = urldecode(trim($_GET['blogURL']));
开发者ID:ncloud,项目名称:bloglounge,代码行数:31,代码来源:index.php

示例9: array

	define('ROOT', '../..');
	include ROOT . '/lib/includeForAjax.php';

	requireStrictRoute();

	$response = array();
	$response['error'] = 0;
	$response['message'] = '';
	
	if (!isAdmin()) {
		$response['error'] = 1;
		$response['message'] = _t('관리자만이 이 기능을 사용할 수 있습니다.');
	} else {
		$arg = array();
		foreach ($_POST as $key=>$value) {
			if (!Validator::enum($key, 'postList,postListDivision,postListDirection,postTitleLength,postDescLength,postNewLife,feedList,feedOrder,feedTitleLength,boomList,boomTitleLength,feedListPage,feedListPageOrder,feedListPageTitleLength,feedListRecentFeedList,focusList,focusTitleLength,focusDescLength,tagCloudOrder,tagCloudLimit'))
				continue;
			$arg[$key] = $value;
		}

		$__s = new SkinSettings;
		if (!$__s->setWithArray($arg)) {
			$response['error'] = 1;
			$rseponse['message'] = $__s->_error;
		}
	}


	func::printRespond($response);
?>
开发者ID:ncloud,项目名称:bloglounge,代码行数:30,代码来源:setting.php

示例10: num2talk

		function num2talk($num) {
			global $__locale;
			$myLocale = (isset($__locale['locale']) && !empty($__locale['locale'])) ? $__locale['locale'] : 'ko'; // default is ko
			if (!Validator::enum($myLocale, 'ko,ja,zn')) // only CJK
				return $num;

			$zero = array();
			$zero['ko'] = '영';
			$zero['ja'] = $zero['zh']= '零';

			if (!isset($num) || ($num <= 0)) 
				return $zero[$myLocale];
			$num = "$num";
			$len = $s = strlen($num);
			$result = array();

			switch ($myLocale) {
				case 'zh':
				case 'ja':
					$hfix = '二十';
					$units = array('','萬','億','兆','京','垓');
					$unitl = array('','十','百','千');

					$nc = array('','一','二','三','四','五','六','七','八','九');
					$nk = array('','一','二','三','四','五','六','七','八','九');
					$nh = array('','十','二十','三十','四十','五十','六十','七十','八十','九十');
					break;

				default:
				case 'ko':
					$hfix = '스무';
					$units = array('','만','억','조','경','해');
					$unitl = array('','십','백','천');

					$nc = array('','일','이','삼','사','오','육','칠','팔','구');
					$nk = array('','한','두','세','네','다섯','여섯','일곱','여덟','아홉');
					$nh = array('','열','스물','서른','마흔','쉰','예순','일흔','여든','아흔');
					break;
			}

			for ($i = 0; $i < $len; $i++) {
				$v = $num{$i};
				$r = $nc[$v];
				if ($i > $len-2) $r = $nk[$v];
				$c = ( --$s % 4 );
				$t = ( $v ) ? $unitl[$c] : '';

				switch ($c) {
					case 0:
						$cut = ($i < 4) ? $i : 3;
						$tmp = substr($num, $i-$cut, $cut+1);
						if (!intval($tmp)) $t = '';
						else $t = $units[floor($s/4)];
						break;

					case 1:
						if ($i > $len-3) {
							if (($v == 2) && ($num{$i+1} == '0')) $r = $hfix;
							else $r = $nh[$v];
							$t = '';
						} else if ($v == 1) 
							$r = '';
						break;

					case 2:
					case 3:
						if ($v == 1) $r = '';
						break;
				}
				array_push($result, $r.$t);
			}
			return @implode('', $result);
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:73,代码来源:LZ.PHP.Locale.php

示例11: saveFeedItem

		function saveFeedItem($feedId,$feedVisibility,$item){
			global $database, $db, $event;

			$db->query("SELECT id FROM {$database['prefix']}DeleteHistory WHERE feed='$feedId' and permalink='{$item['permalink']}'");
			if ($db->numRows() > 0) 
				return false;
	
			if ($item['written']>gmmktime()+86400)
				return false;

			$item['title']=$db->escape($db->lessen(UTF8::correct($item['title'])));

			list($useRssOut) = Settings::gets('useRssOut');
		
			list($feedCreated,$localFilter,$localFilterType) = Feed::gets($feedId, 'created,filter,filterType');

			$tagString=$db->escape($db->lessen(UTF8::correct(implode(', ',$item['tags']))));

			list($globalFilter,$blackFilter,$globalFilterType,$blackFilterType) = Settings::gets('filter,blackfilter,filterType,blackfilterType');
			$filter = empty($globalFilter)?$localFilter:$globalFilter;
			$filterType = empty($globalFilter)?$localFilterType:$globalFilterType;


			if (!Validator::is_empty($filter)) {
				$filtered = true;				
				$allowTags = explode(',', $filter);

				if($filterType == 'tag' || $filterType == 'tag+title') {					
					foreach ($allowTags as $ftag) {
						if (Validator::enum($ftag, $tagString)) {
							$filtered = false;
							break;
						}
					}
				}

				if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
					foreach ($allowTags as $ftag) {
						if(strpos($item['title'],$ftag)!==false) {
							$filtered = false;
							break;
						}
					}
				}

				if ($filtered) return false;
			}

			if (!Validator::is_empty($blackFilter)) {
				$filtered = false;
				$denyTags = explode(',', $blackFilter);
				if($blackFilterType == 'tag' || $blackFilterType == 'tag+title') {					
					foreach ($denyTags as $ftag) {
						if (Validator::enum($ftag, $tagString)) {
							$filtered = true;
							break;
						}
					}
				}
				if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
					foreach ($denyTags as $ftag) {
						if(strpos($item['title'],$ftag)!==false) {
							$filtered = true;
							break;
						}
					}
				}

				if ($filtered) return false;
			}

			if (preg_match('/\((.[^\)]+)\)$/Ui', trim($item['author']), $_matches)) $item['author'] = $_matches[1];
			$item['author']=$db->escape($db->lessen(UTF8::correct($item['author'])));
			$item['permalink']=$db->escape($db->lessen(UTF8::correct($item['permalink'])));
			$item['description']=$db->escape($db->lessen(UTF8::correct(trim($item['description'])),65535));
			
			$enclosures = array();
			foreach($item['enclosures'] as $en) {
				array_push($enclosures, $en['url']);
			}

			$enclosureString=$db->escape($db->lessen(UTF8::correct(implode('|',$enclosures))));				

			$deadLine=0;
			$feedLife = Settings::get('archivePeriod');
			if ($feedLife > 0) $deadLine=gmmktime()-($feedLife*86400);

			requireComponent('Bloglounge.Data.FeedItems');

			$oldTags = null;
			$id = FeedItem::getIdByURL($item['permalink']);
			if($id === false && isset($item['guid'])) {
				$item['guid']=$db->escape($db->lessen(UTF8::correct($item['guid'])));
				$id = FeedItem::getIdByURL($item['guid']);
			}

			$item['author'] = Feed::getAuthor($item, $feedId, $id);
			$item['title'] = Feed::getTitle($item, $feedId, $id);

			$affected = 0;
//.........这里部分代码省略.........
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:LZ.PHP.Feeder.php


注:本文中的Validator::enum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。