本文整理汇总了PHP中DBLayer类的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer类的具体用法?PHP DBLayer怎么用?PHP DBLayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBLayer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: userRegistration
/**
* This function is beign used to change the users emailaddress info.
* It will first check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* The emailaddress will be validated first. If the checking was successful the email will be updated and the settings template will be reloaded. Errors made by invalid data will be shown
* also after reloading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function userRegistration()
{
try {
//if logged in
if (WebUsers::isLoggedIn()) {
$dbl = new DBLayer("lib");
$dbl->update("settings", array('Value' => $_POST['userRegistration']), "`Setting` = 'userRegistration'");
$result['target_id'] = $_GET['id'];
global $SITEBASE;
require_once $SITEBASE . '/inc/settings.php';
$pageElements = settings();
$pageElements = array_merge(settings(), $result);
$pageElements['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
// pass error and reload template accordingly
helpers::loadtemplate('settings', $pageElements);
throw new SystemExit();
} else {
//ERROR: user is not logged in
header("Location: index.php");
throw new SystemExit();
}
} catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
throw new SystemExit();
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:34,代码来源:userRegistration.php
示例2: deactivate_plugin
/**
* This function is used in deactivating plugins.
* This can be done by providing id using $_GET global variable of the plugin which
* we want to activate. After getting id we update the respective plugin with status
* deactivate which here means '0'.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function deactivate_plugin()
{
// if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_GET['id'])) {
// id of plugin to deactivate
$id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$db = new DBLayer('lib');
$result = $db->update("plugins", array('Status' => '0'), "Id = {$id}");
if ($result) {
// if result is successfull it redirects and shows success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=5");
throw new SystemExit();
} else {
// if result is unsuccessfull it redirects and shows success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=6");
throw new SystemExit();
}
} else {
//if $_GET variable is not set it redirects and shows error
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=6");
throw new SystemExit();
}
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:36,代码来源:deactivate_plugin.php
示例3: delete_plugin
/**
* This function is used in deleting plugins.
* It removes the plugin from the codebase as well as
* from the Database. When user request to delete a plugin
* id of that plugin is sent in $_GET global variable.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function delete_plugin()
{
// if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_GET['id'])) {
// id of plugin to delete after filtering
$id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$db = new DBLayer('lib');
$sth = $db->selectWithParameter("FileName", "plugins", array('id' => $id), "Id=:id");
$name = $sth->fetch();
if (is_dir("{$name['FileName']}")) {
// removing plugin directory from the code base
if (Plugincache::rrmdir("{$name['FileName']}")) {
$db->delete('plugins', array('id' => $id), "Id=:id");
//if result successfull redirect and show success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=2");
throw new SystemExit();
} else {
// if result unsuccessfull redirect and show error message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=0");
throw new SystemExit();
}
}
} else {
// if result unsuccessfull redirect and show error message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=0");
throw new SystemExit();
}
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:41,代码来源:delete_plugin.php
示例4: settings
/**
* This function is beign used to load info that's needed for the settings page.
* check if the person who wants to view this page is a mod/admin or the user to whom te settings belong himself, if this is not the case, he will be redirected to an error page.
* it will return a lot of information of that user, that's being used for loading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function settings()
{
if (WebUsers::isLoggedIn()) {
//in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
if (isset($_GET['id'])) {
if ($_GET['id'] != $_SESSION['id'] && !Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
} else {
$webUser = new Webusers($_GET['id']);
$result = $webUser->getInfo();
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_GET['id'] != $_SESSION['id']) {
$result['changesOther'] = "TRUE";
}
$result['target_id'] = $_GET['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
} else {
$webUser = new Webusers($_SESSION['id']);
$result = $webUser->getInfo();
$result['target_id'] = $_SESSION['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
//Sanitize Data
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
$result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
$result['country_array'] = getCountryArray();
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
$dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM settings");
$rows = $statement->fetchAll();
foreach ($rows as &$value) {
$result[$value['Setting']] = $value['Value'];
}
return $result;
} else {
//ERROR: not logged in!
header("Location: index.php");
header("Cache-Control: max-age=1");
throw new SystemExit();
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:59,代码来源:settings.php
示例5: isKnownUser
function isKnownUser($username, $userpass = null)
{
global $db, $CNF;
// echo $username;
if (strlen($username) > 0) {
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
$sql_pass = $userpass != null ? "`status_id` !=4 AND `pass`='{$userpass}'" : '`status_id` !=4';
$query = $db->query("SELECT `uid`,`login`,`lastname`,`firstname`,`middlename` FROM users WHERE `login`='{$username}' AND {$sql_pass}");
if ($db->num_rows($query) > 0) {
$auth = $db->fetch_assoc($query);
return $auth;
}
}
return false;
}
开发者ID:progervlad,项目名称:utils,代码行数:16,代码来源:subs.php
示例6: getTableDescription
private function getTableDescription()
{
$tname = $this->__get_entity_name();
if (!isset($_SESSION['makiavelo']['t_descriptions'][$tname])) {
$_SESSION['makiavelo']['t_descriptions'][$tname] = DBLayer::describeTable($tname);
}
return $_SESSION['makiavelo']['t_descriptions'][$tname];
}
开发者ID:quyen91,项目名称:lfpr,代码行数:8,代码来源:MakiaveloEntityClass.php
示例7: query
public static function query($sql)
{
$db = DBLayer::connect();
$return = mysql_query($sql, $db);
if (!$return) {
Makiavelo::info("Error on MYSQL Query:: " . mysql_error());
}
return $return;
}
开发者ID:quyen91,项目名称:lfpr,代码行数:9,代码来源:DBLayerClass.php
示例8: __construct
/**
* Constructor.
* will fetch the correct elements that match to a specific page (specified by the $_GET['pagenum'] variable). The query has to be passed as a string to the function
* that way it will only load the specific elements that are related to the pagenumber. The $params, parameter is optional and is used to pass the parameters for the query.
* The result class will be used to instantiate the found elements with, their set() function will be called. The class its getters can be later used to get the info out of the object.
* @param $query the query to be paginated
* @param $db the db on which the query should be performed
* @param $nrDisplayed the amount of elements that should be displayed /page
* @param $resultClass the elements that should be returned should be of that specific class.
* @param $params the parameters used by the query (optional)
*/
function __construct($query, $db, $nrDisplayed, $resultClass, $params = array())
{
if (!isset($_GET['pagenum'])) {
$this->current = 1;
} else {
$this->current = $_GET['pagenum'];
}
//Here we count the number of results
$db = new DBLayer($db);
$rows = $db->execute($query, $params)->rowCount();
$this->amountOfRows = $rows;
//the array hat will contain all users
if ($rows > 0) {
//This is the number of results displayed per page
$page_rows = $nrDisplayed;
//This tells us the page number of our last page
$this->last = ceil($rows / $page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($this->current < 1) {
$this->current = 1;
} else {
if ($this->current > $this->last) {
$this->current = $this->last;
}
}
//This sets the range to display in our query
$max = 'limit ' . ($this->current - 1) * $page_rows . ',' . $page_rows;
//This is your query again, the same one... the only difference is we add $max into it
$data = $db->execute($query . " " . $max, $params);
$this->element_array = array();
//This is where we put the results in a resultArray to be sent to smarty
while ($row = $data->fetch(PDO::FETCH_ASSOC)) {
$element = new $resultClass();
$element->set($row);
$this->element_array[] = $element;
}
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:49,代码来源:pagination.php
示例9: checkInputValues
function checkInputValues()
{
global $fdb;
// Check connection
$conn = @mysql_connect($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password']);
if (!$conn) {
myerror('Unable to connect to MySQL server. Please check your settings again.<br><br><a href="?page=settings">Go back to settings</a>');
}
// Check databases
if (!@mysql_select_db($_SESSION['php_db_clean'], $conn)) {
// Fetch database list
$list = '';
$result = @mysql_query('SHOW databases', $conn);
while ($ob = mysql_fetch_row($result)) {
$list .= '   <a href="?page=settings&newdb=' . $ob[0] . '">' . $ob[0] . '</a><br>' . "\n";
}
// Close connection and show message
mysql_close($conn);
myerror('Unable to select database.' . '<br><br>Found these databases:<br><font color="gray">' . $list . '</font>' . '<br><a href="?page=settings">Go back to settings</a>');
}
mysql_close($conn);
// Include FORUM's config file
include './' . $_SESSION['forum'] . '/_config.php';
// Check prefix
$fdb = new DBLayer($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['php_db_clean'], $_SESSION['php_prefix'], false);
$res = $fdb->query('SELECT count(*) FROM ' . $_SESSION['php'] . $tables['Users']);
if (intval($fdb->result($res, 0)) == 0) {
// Select a list of tables
$list = array();
$res = $fdb->query('SHOW TABLES IN ' . $_SESSION['php_db']);
while ($ob = $fdb->fetch_row($res)) {
$list[] = $ob[0];
}
// check list size
sizeof($list) == 0 ? $list[] = 'None' : null;
// Get list of "proabable" prefixes
$prefix_list = '';
$res = $fdb->query('SHOW TABLES FROM ' . $_SESSION['php_db'] . ' LIKE \'%' . $tables['Posts'] . '\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
// $res = $fdb->query('SHOW TABLES FROM '.$_SESSION['php_db'].' LIKE \'%'.$tables['Users'].'\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
while ($ob = $fdb->fetch_row($res)) {
$prefix = substr($ob[0], 0, strlen($ob[0]) - strlen($tables['Users']));
$prefix_list .= ' <a href="?page=settings&newprefix=' . $prefix . '">' . $prefix . '</a><br>' . "\n";
}
// Print message
$prefix = $_SESSION['php_prefix'] == '' ? 'no' : '\'' . $_SESSION['php_prefix'] . '\'';
myerror('Unable to find ' . $_SESSION['forum'] . ' tables! (using prefix: <i>' . $prefix . '</i>)' . '<br><br>Go back to settings and choose another prefix, or select one of these prefixes:<br><font color="gray">' . $prefix_list . '</font>' . '<br>These are the tables in the selected database:<br><font color="gray"> ' . implode("<br> ", $list) . '</font>' . '<br><br><a href="?page=settings">Go back to settings</a>');
}
}
开发者ID:neofutur,项目名称:MyBestBB,代码行数:48,代码来源:functions.php
示例10: update_plugin
/**
* This function is used in installing updates for plugins.
* It takes id of the plugin whose update is available using
* $_GET global variable and then extract the update details
* from db and then install it in the plugin.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function update_plugin()
{
// if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_GET['id'])) {
// id of plugin to update
$id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$db = new DBLayer('lib');
$sth = $db->executeWithoutParams("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id={$id}");
$row = $sth->fetch();
// replacing update in the database
Plugincache::rrmdir($row['FileName']);
Plugincache::zipExtraction($row['UpdatePath'], rtrim($row['FileName'], strtolower($row['Name'])));
$db->update("plugins", array('Info' => $row['UpdateInfo']), "Id={$row['Id']}");
// deleting the previous update
$db->delete("updates", array('id' => $row['s.no']), "s.no=:id");
// if update is installed succesffully redirect to show success message
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=8");
throw new SystemExit();
}
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:31,代码来源:update_plugin.php
示例11: execute
public function execute($params)
{
Makiavelo::info("Creating Database...");
$sql_folder_path = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER;
Makiavelo::puts("Creating database...");
$conn = DBLayer::connect();
$db_name = DBLayer::getDBName();
$sql = "CREATE DATABASE `{$db_name}`";
if (!mysql_query($sql, $conn)) {
Makiavelo::info("ERROR creating db: " . mysql_error());
}
//We also have to create the migrations table
$sql_migrations = "CREATE TABLE migrations ( migration INT PRIMARY KEY);";
mysql_select_db($db_name);
if (!mysql_query($sql_migrations, $conn)) {
Makiavelo::info("ERROR creating migrations table:: " . mysql_error());
}
DBLayer::disconnect($conn);
}
开发者ID:quyen91,项目名称:lfpr,代码行数:19,代码来源:DBCreatorActionClass.php
示例12: loadEntities
private function loadEntities()
{
$sql_folder_path = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER;
$d = dir($sql_folder_path);
while (($item = $d->read()) != false) {
if ($item != "create_db.sql" && substr($item, 0, 1) != ".") {
$file_path = $sql_folder_path . "/" . $item;
$fp = fopen($file_path, "r");
if ($fp) {
Makiavelo::puts("Loading entity: {$item} ...");
$conn = DBLayer::connect();
$sql = fread($fp, filesize($file_path));
fclose($fp);
$res = mysql_query($sql, $conn);
if (!$res && mysql_errno($conn) == 1050) {
Makiavelo::puts("---- Entity already loaded, ignoring");
}
DBLayer::disconnect($conn);
}
}
}
}
开发者ID:quyen91,项目名称:lfpr,代码行数:22,代码来源:DBLoaderActionClass.php
示例13: alter_table
/**
Allows the dev to modify the structure of a table:
Supported operations:
- add_field
- drop_field
*/
protected function alter_table($tname, $params)
{
global $__db_conn;
foreach ($params as $operation => $parms) {
switch ($operation) {
case "add_field":
$keys = array_keys($parms);
$new_field = $keys[0];
$type = $this->sql_types_mapping[$parms[$new_field]];
$sql = "ALTER TABLE {$tname} ADD COLUMN {$new_field} {$type}";
break;
case "drop_field":
$new_field = $parms;
$sql = "ALTER TABLE {$tname} drop column {$new_field} ";
break;
default:
break;
}
Makiavelo::info("Altering table :: " . $sql);
DBLayer::query($sql);
}
}
开发者ID:quyen91,项目名称:lfpr,代码行数:29,代码来源:MigrationClass.php
示例14: saveRecipeWork
public function saveRecipeWork()
{
$dbl=new DBLayer();
$dbl->setCollectionObj($this->RecipeColname);
$obj=$this->CreateRecipeArray();//prepare_array_Recipework();
$dbl->InsertCollection($obj);
//$cursor = $dbl->get_CollectionObject($this->RecipeColname);//,$this->objID);
}
开发者ID:nmp36,项目名称:FinalRecipe,代码行数:8,代码来源:Recipe.php
示例15: isset
$arr[$i]['cl'] = $result['class'];
$arr[$i]['race'] = $result['race'];
$arr[$i]['level'] = $char_data[$UNIT_FIELD_LEVEL];
$arr[$i]['gender'] = $char_gender[3];
$arr[$i]['Extention'] = $Extention;
$arr[$i]['leaderGuid'] = isset($groups[$char_data[0]]) ? $groups[$char_data[0]] : 0;
$i++;
}
$mangos_db->close();
usort($arr, "sort_players");
$arr = array_merge($Count, $arr);
$res['online'] = $arr;
} else {
$res['online'] = NULL;
}
if ($show_status) {
$mangos_db = new DBLayer($mangos[$royaume]['host'], $mangos[$royaume]['user'], $mangos[$royaume]['password'], $mangos[$royaume]['db']);
$mangos_db->query("SET NAMES " . $mangos[$royaume]['encoding'] . "");
$query = $mangos_db->query("SELECT `starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
if ($result = $mangos_db->fetch_assoc($query)) {
$status['uptime'] = time() - $result['starttime'];
$status['maxplayers'] = $result['maxplayers'];
$status['online'] = test_realm() ? 1 : 0;
}
$mangos_db->close();
} else {
$status = NULL;
}
unset($mangos_db);
$res['status'] = $status;
$_RESULT = $res;
开发者ID:galathil,项目名称:coolwow2,代码行数:31,代码来源:map_core.php
示例16: SearchThing
public function SearchThing($parmName, $parmval)
{
$dbl = new DBLayer();
$dbl->setCollectionObj($this->Colname);
$cursor = $dbl->get_CollectionObjectbysearchParameter($this->Colname, $parmName, $parmval);
foreach ($cursor as $arr) {
$this->objID = $arr["_id"];
$this->name->value = $arr["name"];
$this->url->value = $arr["url"];
$this->image->value = $arr["image"];
$this->description->value = $arr["description"];
}
//echo 'Printing';
echo '<b>Name<b></b> :' . $this->printNameHtmlTag() . '<br>';
echo '<b>Description</b> :' . $this->printDescriptionHtmlTag() . '<br>';
echo '<b>URL </b> :' . $this->printUrlHtmlTag() . '<br>';
echo '<b>Image </b> :' . $this->printImageHtmlTag() . '<br>';
//$this->printNameHtmlTag();
}
开发者ID:nmp36,项目名称:FinalRecipeProject,代码行数:19,代码来源:testclass.php
示例17: spl_autoload_register
spl_autoload_register('__autoload_entities');
spl_autoload_register('__autoload_validator');
spl_autoload_register('__autoload_tasks');
spl_autoload_register('__autoload_lib');
include_once ROOT_PATH . "/core/spyc.php";
include_once ROOT_PATH . "/config/config.php";
//Includes all sql helpers
$sql_helper_folder = ROOT_PATH . Makiavelo::SQL_HELPERS_FOLDER;
$d = dir($sql_helper_folder);
while (false !== ($entry = $d->read())) {
if ($entry[0] != ".") {
include $sql_helper_folder . "/" . $entry;
}
}
//DB connection... simple for now...
$__db_conn = DBLayer::connect();
$parameters = $argv;
if (count($parameters) > 1) {
$mk = new Makiavelo();
$action = $mk->getAction($parameters[1]);
unset($parameters[0]);
unset($parameters[1]);
$action->execute(array_values($parameters));
} else {
echo "Welcome to Makiavelo command line utility";
echo "\nUsage: makiavelo [COMMAND] [ATTRIBUTES] \n";
echo "\nValid commands:";
echo "\n g: Generator command";
echo "\n Attributes:";
echo "\n crud: Generates a controller, an entity and a set of views for the CRUD operations. Needs a name for the entity";
echo "\n controller: Generates an empty controller. Needs a controller name as parameter";
开发者ID:quyen91,项目名称:lfpr,代码行数:31,代码来源:makiavelo.php
示例18: ini_set
<?php
/**
* Created by PhpStorm.
* User: megadozz
* Date: 01.07.2014
* Time: 10:54
*/
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
//echo "$_SERVER[DOCUMENT_ROOT]";
require_once "{$_SERVER['DOCUMENT_ROOT']}/lib/dblayer.php";
require_once "{$_SERVER['DOCUMENT_ROOT']}/conf.inc.php";
require_once "{$_SERVER['DOCUMENT_ROOT']}/subs.php";
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
function translit($str)
{
$tr = array("А" => "A", "Б" => "B", "В" => "V", "Г" => "G", "Д" => "D", "Е" => "E", "Ё" => "E", "Ж" => "ZH", "З" => "Z", "И" => "I", "Й" => "Y", "К" => "K", "Л" => "L", "М" => "M", "Н" => "N", "О" => "O", "П" => "P", "Р" => "R", "С" => "S", "Т" => "T", "У" => "U", "Ф" => "F", "Х" => "H", "Ц" => "TS", "Ч" => "CH", "Ш" => "SH", "Щ" => "SCH", "Ъ" => "", "Ы" => "YI", "Ь" => "", "Э" => "E", "Ю" => "YU", "Я" => "YA", "а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "e", "ж" => "zh", "з" => "z", "и" => "i", "й" => "y", "к" => "k", "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f", "х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "y", "ы" => "yi", "ь" => "", "э" => "e", "ю" => "yu", "я" => "ya");
return strtr($str, $tr);
}
function generate_password($length)
{
$pass = "";
$arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
for ($i = 0; $i < $length; $i++) {
$index = rand(0, count($arr) - 1);
// Случайный индекс массива
$pass .= $arr[$index];
}
return $pass;
开发者ID:progervlad,项目名称:utils,代码行数:31,代码来源:create_users_shadows.php
示例19: DBLayer
}
} else {
$lang = $language;
}
$database_encoding = $site_encoding;
$server = $server_arr[$realm_id]["addr"];
$port = $server_arr[$realm_id]["game_port"];
$host = $characters_db[$realm_id]["addr"];
$user = $characters_db[$realm_id]["user"];
$password = $characters_db[$realm_id]["pass"];
$db = $characters_db[$realm_id]["name"];
$hostr = $realm_db["addr"];
$userr = $realm_db["user"];
$passwordr = $realm_db["pass"];
$dbr = $realm_db["name"];
$sql = new DBLayer($hostr, $userr, $passwordr, $dbr);
$query = $sql->query("SELECT name FROM realmlist WHERE id = " . $realm_id);
$realm_name = $sql->fetch_assoc($query);
$realm_name = htmlentities($realm_name["name"]);
$gm_show_online = $gm_online;
$gm_show_online_only_gmoff = $map_gm_show_online_only_gmoff;
$gm_show_online_only_gmvisible = $map_gm_show_online_only_gmvisible;
$gm_add_suffix = $map_gm_add_suffix;
$gm_include_online = $gm_online_count;
$show_status = $map_show_status;
$time_to_show_uptime = $map_time_to_show_uptime;
$time_to_show_maxonline = $map_time_to_show_maxonline;
$time_to_show_gmonline = $map_time_to_show_gmonline;
$status_gm_include_all = $map_status_gm_include_all;
$time = $map_time;
$show_time = $map_show_time;
开发者ID:BACKUPLIB,项目名称:minimanager,代码行数:31,代码来源:pomm_conf.php
示例20: loadTemplate
/**
* workhorse of the website, it loads the template and shows it or returns th html.
* it uses smarty to load the $template, but before displaying the template it will pass the $vars to smarty. Also based on your language settings a matching
* array of words & sentences for that page will be loaded. In case the $returnHTML parameter is set to true, it will return the html instead of displaying the template.
*
* @param $template the name of the template(page) that we want to load.
* @param $vars an array of variables that should be loaded by smarty before displaying or returning the html.
* @param $returnHTML (default=false) if set to true, the html that should have been displayed, will be returned.
* @return in case $returnHTML=true, it returns the html of the template being loaded.
*/
public static function loadTemplate($template, $vars = array(), $returnHTML = false)
{
//error_log(print_r($_GET,true));
//error_log(print_r($_POST,true));
global $AMS_LIB;
global $SITEBASE;
global $AMS_TRANS;
global $INGAME_LAYOUT;
global $AMS_CACHEDIR;
global $AMS_PLUGINS;
// define('SMARTY_SPL_AUTOLOAD',1);
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
spl_autoload_register('__autoload');
$smarty = new Smarty();
$smarty->setCompileDir($SITEBASE . '/templates_c/');
$smarty->setCacheDir($AMS_CACHEDIR);
$smarty->setConfigDir($SITEBASE . '/configs/');
// turn smarty debugging on/off
$smarty->debugging = false;
// caching must be disabled for multi-language support
$smarty->caching = false;
$smarty->cache_lifetime = 300;
$smarty->addPluginsDir($AMS_PLUGINS);
if (function_exists('apc_cache_info')) {
// production
//$smarty->caching = true;
//$smarty->setCachingType("apc");
//$smarty->compile_check = false;
}
// needed by smarty.
helpers::create_folders();
global $FORCE_INGAME;
// if ingame, then use the ingame templates
if (helpers::check_if_game_client() or $FORCE_INGAME) {
$smarty->template_dir = $AMS_LIB . '/ingame_templates/';
$smarty->setConfigDir($AMS_LIB . '/configs');
$variables = parse_ini_file($AMS_LIB . '/configs/ingame_layout.ini', true);
foreach ($variables[$INGAME_LAYOUT] as $key => $value) {
$smarty->assign($key, $value);
}
} else {
$smarty->template_dir = $SITEBASE . '/templates/';
$smarty->setConfigDir($SITEBASE . '/configs');
}
foreach ($vars as $key => $value) {
$smarty->assign($key, $value);
}
// load page specific variables that are language dependent
$variables = Helpers::handle_language();
if ($template != 'layout_plugin') {
foreach ($variables[$template] as $key => $value) {
$smarty->assign($key, $value);
}
}
// load ams content variables that are language dependent
foreach ($variables['ams_content'] as $key => $value) {
$smarty->assign($key, $value);
}
//load ams content variables that are language dependent
foreach ($variables['ams_content'] as $key => $value) {
$smarty->assign($key, $value);
}
$id = session_id();
$smarty->assign("sessionid", $id);
$dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM settings");
$rows = $statement->fetchAll();
foreach ($rows as &$value) {
$smarty->assign($value['Setting'], $value['Value']);
}
// smarty inheritance for loading the matching wrapper layout (with the matching menu bar)
if (isset($vars['permission']) && $vars['permission'] == 3) {
$inherited = "extends:layout_admin.tpl|";
} else {
if (isset($vars['permission']) && $vars['permission'] == 2) {
$inherited = "extends:layout_mod.tpl|";
} else {
if (isset($vars['permission']) && $vars['permission'] == 1) {
$inherited = "extends:layout_user.tpl|";
} else {
$inherited = "";
}
}
}
// if $returnHTML is set to true, return the html by fetching the template else display the template.
if ($returnHTML == true) {
return $smarty->fetch($inherited . $template . '.tpl');
} else {
$smarty->display($inherited . $template . '.tpl');
}
//.........这里部分代码省略.........
开发者ID:ryzom,项目名称:ryzomcore,代码行数:101,代码来源:helpers.php
注:本文中的DBLayer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论