本文整理汇总了PHP中n函数的典型用法代码示例。如果您正苦于以下问题:PHP n函数的具体用法?PHP n怎么用?PHP n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了n函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_children
/**
* Получение ID подкатегорий, если необходимо
* @param array $curcats массив выбранных категорий
* @return null
*/
protected function get_children(&$curcats)
{
if (!$this->settings['check_children']) {
return;
}
/* @var $cats categories */
$cats = n("categories");
foreach ($curcats as $name => $cat) {
$cat = explode('|', $cat);
$c = count($cat);
$ids = array();
for ($i = 0; $i < $c; $i++) {
$ic = longval($cat[$i]);
if (!$ic || !$cats->get($ic)) {
continue;
}
$ids[] = $ic;
$cats->get_children_ids($ic, $ids);
}
if (!$ids) {
unset($curcats[$name]);
continue;
}
$ids = array_unique($ids);
$curcats[$name] = implode('|', $ids);
}
}
示例2: save
/**
* Сохранение бота
* @param array $data массив данных
* @return null
* @throws EngineException
*/
public function save($data)
{
$admin_file = globals::g('admin_file');
$cols = array('id', 'name', 'firstip', 'lastip', 'agent');
extract(rex($data, $cols));
$id = (int) $id;
/* @var $etc etc */
$etc = n("etc");
$etc->get_ips($firstip, $lastip, true);
if (!$name) {
throw new EngineException('bots_empty_name');
}
if (!$firstip && !$lastip && !$agent) {
throw new EngineException('bots_empty_data');
}
$update = array('name' => $name, 'firstip' => $firstip, 'lastip' => $lastip, 'agent' => $agent);
try {
plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_bots_save');
} catch (PReturn $e) {
return $e->r();
}
if (!$id) {
db::o()->insert($update, 'bots');
log_add('added_bot', 'admin');
} else {
db::o()->p($id)->update($update, 'bots', 'WHERE id=? LIMIT 1');
log_add('changed_bot', 'admin', $id);
}
furl::o()->location($admin_file);
}
示例3: init
/**
* Инициализация управления вложениями
* @return null
*/
public function init()
{
/* @var $attach attachments */
$attach = n("attachments");
$act = $_GET["act"];
switch ($act) {
case "upload":
$type = $_GET["type"];
$toid = $_GET["toid"];
$ret = $attach->change_type($type)->upload($toid);
ok(true);
print $ret;
break;
case "download":
$attach_id = (int) $_GET["id"];
$preview = (int) $_GET["preview"];
$attach->download($attach_id, $preview);
break;
case "delete":
$attach_id = $_POST["id"];
$ret = $attach->delete($attach_id);
if (!$ret) {
throw new Exception();
}
ok();
break;
}
die;
}
示例4: get_product_by_id
function get_product_by_id($productid)
{
$s = q("select * from product where productid = '" . clean_query($productid) . "' limit 1;");
if (n($s) > 0) {
return f($s);
}
return false;
}
示例5: get_bag_by_name
function get_bag_by_name($name)
{
$s = q("select * from bag where bag.name = '" . clean_query($name) . "';");
if (n($s) > 0) {
return f($s);
}
return false;
}
示例6: get_user_by_username
function get_user_by_username($username)
{
$s = q("select * from user where user.username = '" . clean_query($username) . "' limit 1;");
if (n($s) > 0) {
return f($s);
}
return null;
}
示例7: get_family_by_id
function get_family_by_id($clientid)
{
$s = q("select * from family, client where client.clientid = family.clientid and family.clientid = '" . clean_query($clientid) . "';");
if (n($s) > 0) {
return f($s);
}
return null;
}
示例8: init
/**
* Функция вызова captcha
* @return null
*/
public function init()
{
$background = 'include/backgrounds/' . $this->bckgrnds[rand(0, count($this->bckgrnds) - 1)];
$code = mb_strtoupper(users::o()->generate_salt(6));
if (!$_SESSION['captcha_key']) {
$_SESSION['captcha_key'] = array();
}
array_unshift($_SESSION['captcha_key'], $code);
unset($_SESSION['captcha_key'][self::capacity]);
/* @var $uploader uploader */
$uploader = n("uploader");
$uploader->watermark($background, $code, 'auto', false, '', 'cc', true, false);
}
示例9: baz
function baz($d)
{
$x = new D1();
$x = new D2();
$x = new D3();
$x = new D4();
$x = new D5();
$x = new D6();
$x = n($d . '1');
$x = n($d . '2');
$x = n($d . '3');
$x = n($d . '4');
$x = n($d . '5');
$x = n($d . '6');
$x = n('B1');
}
示例10: build
/**
* Построение плагина
* @param array $data массив данных
* @return null
* @throws EngineException
*/
public function build($data)
{
lang::o()->get('admin/plugins');
$data_params = array("plugin", "version", "author", "name", "descr", "comp", "comp_min", "comp_max");
extract(rex($data, $data_params));
if (!validword($plugin)) {
throw new EngineException("plugins_invalid_name");
}
$settings = modsettings::o()->make($data);
$defaults = modsettings::o()->save(modsettings::nocache_id, $data);
$vars = array($plugin, var_export((string) $version, true), var_export((string) $author, true), var_export((string) $name, true), var_export((string) $descr, true), var_export((string) $comp, true), var_export((string) $comp_min, true), var_export((string) $comp_max, true), var_export((array) $settings, true), $plugin, var_export((array) $defaults, true));
$contents = @file_get_contents(ROOT . self::plugin_template);
$contents = vsprintf($contents, $vars);
/* @var $uploader uploader */
$uploader = n("uploader");
$uploader->download_headers($contents, 'plugin.' . $plugin . '.php', 'text/plain');
}
示例11: init
/**
* Инициализация Ajax-части нижнего блока
* @return null
*/
public function init()
{
lang::o()->get("blocks/downm");
switch ($_GET["act"]) {
case "content":
users::o()->check_perms("content", 1, 2);
$sticky = isset($_GET["sticky"]) ? (bool) $_GET["sticky"] : true;
$this->show_content($sticky);
break;
case "comments":
users::o()->check_perms('comment', 1, 2);
/* @var $comments comments */
$comments = n("comments");
$comments->usertable();
break;
default:
users::o()->check_perms('profile', 1, 2);
$this->show_online();
break;
}
}
示例12: init
/**
* Инициализация рейтинга
* @return null
*/
public function init()
{
$act = $_GET['act'];
$type = $_POST['type'];
$toid = $_POST['toid'];
$this->rating = n("rating");
switch ($act) {
case "vote":
$value = $_POST['value'];
$stype = $_POST['stype'];
$stoid = $_POST['stoid'];
$this->vote_to($type, $toid, $value, $stoid, $stype);
break;
case "get":
$this->get($type, $toid);
break;
default:
break;
}
ok();
}
示例13: start_session_tracking
function start_session_tracking()
{
session_start();
return true;
clean_session_db();
error_reporting(E_ALL);
$sessionhash = md5(get_session_id());
$idhash = md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']);
// see: mysql.lib.php
$s = q("select * from `session` where `hash` = '" . clean_query($sessionhash) . "' limit 1;");
if (n($s) == 0) {
$s = q("insert into `session` values('', '0', '" . clean_query($sessionhash) . "', '" . clean_query($idhash) . "', '" . clean_query(time()) . "');");
if (a() == 1) {
// success
return true;
} else {
// failure
return false;
}
} else {
while ($r = f($s)) {
//4c5b06225553e12bed914e6836ff4859
if ($r["identity"] != $idhash) {
return false;
}
$s = q("update `session` set `activity` = '" . clean_query(time()) . "' where `hash` = '" . clean_query($sessionhash) . "' limit 1;");
return true;
/*if (a() == 1) {
// success
return true;
} else {
// failure
return false;
}*/
}
}
return false;
}
示例14: init
/**
* Инициализация управления комментариями
* @return null
*/
public function init()
{
$act = $_GET['act'];
$this->comments = n("comments");
switch ($act) {
case "edit":
$id = longval($_POST['id']);
$this->edit_form($id);
break;
case "add":
case "edit_save":
$content = $_POST['body'];
$resid = longval($_POST['resid']);
$type = $_POST['type'];
$id = longval($_POST['id']);
$this->save($content, $resid, $type, $id);
ok();
break;
case "show":
$resid = longval($_POST['resid']);
$type = $_POST['type'];
$this->show($resid, $type);
break;
case "del":
$id = (int) $_POST["id"];
$this->delete($id);
ok();
break;
case "quote":
$id = (int) $_POST["id"];
$this->quote($id);
die;
default:
break;
}
}
示例15: __construct
/**
* Конструктор
* @return null
*/
public function __construct()
{
$this->cats = n("categories");
}