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


PHP Record::escape方法代码示例

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


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

示例1: updateRole

 public function updateRole($name, $label = "", $permissions = array(), $add = false)
 {
     global $pawUsers;
     // CHECK PERMISSIONS
     if ($this->hasPermission("pawu_perm_manage") === false) {
         $this->_error(__("You don't have the Permission to perform this action!"));
         return false;
     }
     // VALIDATE
     if (($name = $this->validateRole($name, false)) === false) {
         return false;
     }
     if (($label = $this->validateLabel($label)) === false) {
         return false;
     }
     $permissions = paw_xss_cleaner($permissions, true);
     if (!is_array($permissions)) {
         $permissions = array();
     }
     // ADD ALL SYSTEM PERMISSIONS TO THE ADMIN ROLE
     if ($name == "administrator") {
         $permissions = array_merge($permissions, $this->system);
     }
     $role = $this->getRoles($name, false);
     $role = $role[$name]["id"];
     // ADD NEW PERMISSIONS
     if ($add === true) {
         $this->updatePermissions($permissions, false);
     }
     // UPDATE ROLE
     $query = "UPDATE " . TABLE_PREFIX . "role SET label=:label WHERE name=:name";
     $query = Record::query($query, array(":name" => $name, ":label" => $label));
     if ($query === false) {
         $this->_error(__("An unknown error is occurred!"));
         return false;
     }
     // DELETE ROLE PERMISSIONS
     $query = "DELETE FROM " . TABLE_PREFIX . "role_permission WHERE role_id=" . $role;
     if (Record::query($query) === false) {
         $this->_error(__("An unknown error is occurred!"));
         return false;
     }
     // LINK NEW PERMISSIONS SET TO ROLE
     if (!empty($permissions)) {
         $queries = array();
         foreach ($this->getPermissions(false) as $id => $perm) {
             if (in_array($perm["name"], $permissions)) {
                 $queries[] = "(" . Record::escape($role) . ", " . Record::escape($perm["id"]) . ")";
             }
         }
         $query = "INSERT INTO " . TABLE_PREFIX . "role_permission (role_id, permission_id) VALUES " . implode(", ", $queries) . ";";
         $query = Record::query($query, array(":name" => $name, ":label" => $label));
         if ($query === false) {
             $this->_error(__("An unknown error is occurred!"));
             return false;
         }
     }
     return true;
 }
开发者ID:pawedWolf,项目名称:wolfcms-pawusers,代码行数:59,代码来源:class.permissions.php

示例2: updateData

 public function updateData($id, $type, $value, $status = false, $config = "")
 {
     global $pawUsers;
     // CHECK PERMISSIONS
     if ($pawUsers->permissions->hasPermission("pawu_list_manage") === false) {
         $this->_error(__("You don't have the Permission to perform this action!"));
         return false;
     }
     // VALIDATE
     $value = paw_xss_cleaner($value);
     $status = in_array($status, array(1, "1", true)) ? 1 : 0;
     if ($this->validateData($type, $value) !== true) {
         return false;
     }
     $settings = $this->_settings($type, $config);
     // CHECK IF ITEM EXIST
     $query = "SELECT * FROM " . TABLE_PREFIX . "blacklist WHERE id=:id";
     $query = Record::query($query, array(":id" => $id));
     if (empty($query) || !isset($query[0])) {
         $this->_error(__("The blacklist item does not exists!"));
         return false;
     }
     // UPDATE BLACKLIST ITEM
     $data = array("value=:value", "type=" . Record::escape($type), "status=" . Record::escape($status), "settings=" . Record::escape(paw_serializer($settings)));
     $query = "UPDATE " . TABLE_PREFIX . "blacklist SET " . implode(", ", $data) . " WHERE id=" . $id;
     $query = Record::query($query, array(":value" => $value));
     if ($query !== false) {
         return true;
     }
     $this->_error(__("An unknown error is occurred!"));
     return false;
 }
开发者ID:pawedWolf,项目名称:wolfcms-pawusers,代码行数:32,代码来源:class.blacklist.php

示例3: updateUser

 public function updateUser($data, $update)
 {
     $data = paw_xss_cleaner($data);
     $update = paw_xss_cleaner($update);
     if (!is_array($update)) {
         $this->_error(__("The Action is invalid!"));
         return false;
     }
     // GET USER
     $user = $this->_getUser($data);
     if (empty($user)) {
         $this->_error(__("The User does not exist!"));
         return false;
     }
     // CHECK PERMISSIONS
     if ($this->login === false) {
         if ((int) $user->id !== (int) $this->currentID) {
             if (!$this->permissions->hasPermission("user_edit")) {
                 $this->_error(__("You don't have the Permission to perform this action!"));
                 return false;
             } else {
                 $url = get_url("user/edit/" . $user->id . "/" . $this->currentID);
                 if (!isset($update["token"]) || !SecureToken::validateToken($update["token"], $url)) {
                     $this->_error(__("The CSRF Token does not exist or is invalid!"));
                     return false;
                 }
             }
         }
     }
     // FETCH EMAIL AND PASSWORD REQUESTS
     if ($this->login === false) {
         // UPDATE eMAIL ADDRESS
         if (isset($update["email"]) && (isset($update["password"]) || $this->permissions->hasPermission("user_edit"))) {
             if (($mail = $this->validateUsermail($update["email"], true)) === false) {
                 return false;
             }
             if ((int) $user->id === (int) $this->currentID && isset($update["password"])) {
                 if (!$this->_checkPassword($user, $update["password"])) {
                     $this->_error(__("The Password is incorrect!"));
                     return false;
                 }
                 $this->_userPassword($user, $update["password"]);
             }
             if ($this->_userMail($user, $update["email"])) {
                 return true;
             }
         }
         // UPDATE PASSWORD
         if (isset($update["new-password"]) && (isset($update["password"]) || $this->permissions->hasPermission("user_edit"))) {
             if (($pass = $this->validatePassword($update["new-password"], true)) === false) {
                 return false;
             }
             if ((int) $user->id === (int) $this->currentID && isset($update["password"])) {
                 if (!$this->_checkPassword($user, $update["password"])) {
                     $this->_error(__("The Password is incorrect!"));
                     return false;
                 }
             }
             if ($this->_userPassword($user, $pass)) {
                 return true;
             }
         }
     }
     // VALIDATE
     $valid = array("name", "ip", "language", "last_login", "last_failure", "failure_count", "updated_by_id", "roles");
     $sql = array();
     $values = array();
     foreach ($update as $key => $value) {
         if (!in_array($key, $valid)) {
             unset($update[$key]);
             continue;
         }
         if ($key === "name" && strlen($value) > 50) {
             unset($update["name"]);
             continue;
         }
         if ($key === "roles") {
             $roles = $value;
             continue;
         }
         $sql[$key] = $key . "=:" . $key;
         $values[":" . $key] = $value;
     }
     $sql["updated_on"] = "updated_on=" . Record::escape(date("Y-m-d H:i:s"));
     // UPDATED BY ID
     if (!isset($sql["updated_by_id"])) {
         if ($this->isLoggedIn()) {
             $sql["updated_by_id"] = "updated_by_id=" . Record::escape($this->currentID);
         } else {
             $sql["updated_by_id"] = "updated_by_id=" . $user->id;
         }
     }
     $query = "UPDATE " . TABLE_PREFIX . "user SET " . implode(", ", $sql) . " WHERE id=" . $user->id;
     $query = Record::query($query, $values);
     if ($query !== false) {
         if (isset($roles) && $this->permissions->hasPermission("user_edit")) {
             if (is_string($roles)) {
                 $roles = array($roles);
             }
             $userroles = array_keys($this->permissions->getRoles(NULL, false));
//.........这里部分代码省略.........
开发者ID:pawedWolf,项目名称:wolfcms-pawusers,代码行数:101,代码来源:class.users.php

示例4: findById

	public static function findById($id) {
		return self::find(array(
			'where' => 'error404s.id=' . Record::escape((int)$id),
			'limit' => 1
		));
	} //*/
开发者ID:realslacker,项目名称:Redirector-Plugin,代码行数:6,代码来源:Redirector404s.php

示例5: __storetags

	private function __storetags($tags,$download_id=null) {
	
		//	if download_id is provided clear out old tags
		if (!is_null($download_id)) Record::deleteWhere('DownloadTagConnection','download_id='.Record::escape((int)$download_id));
		
		//	check to make sure there are some tags
		if (empty($tags)) return true;
		
		//	take either an array or comma separated list of tags
		if (!is_array($tags)) $tags = explode(',',$tags);
		$tags = preg_replace('/[^a-z0-9 _,-]/','',$tags);
		
		//	find or create tag and connect to download
		foreach ($tags as $tagname) {
			$tagname = trim(strtolower($tagname));
			//	check for minimum tag length; must be at least three characters
			if (strlen($tagname) >= 3) {
				if (!$tag = DownloadTag::findByName($tagname)) {
					$tag = new DownloadTag(array('name'=>$tagname));
					$tag->save();
				}
				
				if (!is_null($download_id)) {
					$connection = new DownloadTagConnection(array(
						'download_id'=>(int)$download_id,
						'tag_id'=>$tag->id
					));
					$connection->save();
				}
			}
		}
		
		return true;
	}//*/
开发者ID:realslacker,项目名称:Downloads-Plugin,代码行数:34,代码来源:DownloadsController.php

示例6: downloadSearch

function downloadSearch($terms,$limit=10,$offset=0,$order='name',$expired=false,$inactive=false) {

	$where = '1';
	
	//	show expired downloads?
	if ($expired === false) $where .= " AND ( `downloads`.`expires` > NOW() || `downloads`.`expires` IS NULL )";
	
	//	show inactive downloads?
	if ($inactive === false) $where .= " AND `downloads`.`active` = '1'";

	$order = strtolower($order);
	$order = in_array($order,explode(',','id,name,filename,active,downloads,expires,created,updated')) && !empty($order) ? $order : 'name' ;
	$order = $order == 'downloads' ? 'downloads.'.$order.' DESC' : 'downloads.'.$order.' ASC';
	
	if (! empty($terms)) {
		$querys = preg_replace('/[^a-z0-9 %]/i',' ',$terms);
		$querys = strstr($querys,' ') !== false ? explode(' ',$querys) : array($querys);
		$querys = preg_replace(array('/ing$/i','/ed$/i','/s$/i'),'',$querys);
		
		foreach ($querys as $query) {
			if (strstr($query,'%') === false && !empty($query)) $query = "%{$query}%";
			if (!empty($query))	$where .= " AND ( downloads.name LIKE ".Record::escape($query)." OR downloads.description LIKE ".Record::escape($query)." OR downloads.keywords LIKE ".Record::escape($query)." ) ";
		}
	}
	
	if (!$results = Download::findAll(array('where'=>$where,'limit'=>$limit,'offset'=>$offset,'order'=>$order))) return false;
	$count = Record::countFrom('Download',$where);
	
	return array('downloads'=>$results,'count'=>$count);

}
开发者ID:realslacker,项目名称:Downloads-Plugin,代码行数:31,代码来源:index.php

示例7: findAllByTagName

	public static function findAllByTagName($tags=array()) {
		$tags = is_array($tags) ? $tags : explode(',',$tags);
		$where = '';
		$count = 0;
		foreach ($tags as $tag) if (! empty($tag)) {
			$where .= (!empty($where) ? ',' : '') . Record::escape($tag);
			$count++;
		}
		return self::find(array(
			'where' => "downloadtags.name IN ($where)",
			'order' => 'downloads.name ASC',
			'group' => 'downloads.id',
			'having' => "COUNT(*)>=$count"
		));
		
	} //*/
开发者ID:realslacker,项目名称:Downloads-Plugin,代码行数:16,代码来源:DownloadTagConnection.php

示例8: findByName

	public static function findByName($name) {
		return self::find(array(
			'where' => 'facts.name='.Record::escape($name),
			'limit' => 1
		));
	} //*/
开发者ID:realslacker,项目名称:Facts-Plugin,代码行数:6,代码来源:Fact.php

示例9: findByHash

	public static function findByHash($hash) {
		return self::find(array(
			'where' => 'downloads.hash='.Record::escape($hash),
			'limit' => 1
		));
	} //*/
开发者ID:realslacker,项目名称:Downloads-Plugin,代码行数:6,代码来源:Download.php


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