本文整理汇总了PHP中functions类的典型用法代码示例。如果您正苦于以下问题:PHP functions类的具体用法?PHP functions怎么用?PHP functions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了functions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->folder = functions::q($_POST['id']);
$this->act = functions::q($_POST['op']);
$this->db = new DataBase();
$this->f = new functions();
$this->image = new SimpleImage();
if ($this->act == 'upload') {
$name = $_FILES['uploadfile']['name'];
$exp = explode('.', $name);
$this->ext = $exp[count($exp) - 1];
$filetypes = array('jpg', 'gif', 'bmp', 'png', 'JPG', 'BMP', 'GIF', 'PNG', 'jpeg', 'JPEG');
if (!in_array($this->ext, $filetypes)) {
die("wrong_format");
} else {
$this->photoName();
if ($this->getNum() < $this->_count) {
$this->uploadFile();
} else {
die("Максимальное количество загружаемых фотографий в объявление не должно превышать 6 шт.");
}
}
} elseif ($this->act == 'delete') {
$this->delete();
}
}
开发者ID:Sywooch,项目名称:dump,代码行数:26,代码来源:upload.php
示例2: __construct
function __construct($params)
{
$file = 'console-' . date(@$params['log'] ?: 'Y-m-d') . '.log';
$this->_file = \loader::get_temp($file);
$this->_uid = substr(\functions::hash(microtime(true)), -5);
$this->_head();
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:7,代码来源:FileConsole.php
示例3: run
function run()
{
/**@var tf_sat $sat */
$sat = core::module('sat');
$site = $sat->get_current_site();
$json_file = loader::get_public('assets/' . $site->domain . '.json');
$last_mod = @filemtime($json_file);
$tree_last_mod = 0;
if ($last_mod) {
$last_node = $sat->get_node_handle()->set_where('site_id = %d', $sat->get_current_site_id())->set_order('updated_at DESC')->load_first();
$tree_last_mod = $last_node ? $last_node->updated_at : 0;
core::dprint(__METHOD__ . ': cached');
// uptodate
if ($tree_last_mod <= $last_mod) {
$this->renderer->set_ajax_answer(file_get_contents($json_file))->ajax_flush();
return;
}
}
core::dprint(__METHOD__ . ': fetch!');
$tree = $sat->get_current_site_tree();
$allowedKeys = array('title', 'url');
array_walk($tree, function (&$v) use($allowedKeys) {
$v = array_intersect_key($v, array_flip($allowedKeys));
});
$tree = array_values($tree);
// cache
file_put_contents($json_file, functions::json_encode($tree));
$this->renderer->set_ajax_answer($tree)->ajax_flush();
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:29,代码来源:tree.php
示例4: run
/**
* Run block
* Called from module::run_block
*
* Params passed to 'block.data'
* action converted to object!
*
* Extended params passed to {$block.params}
*
* @throws modules_exception
*/
function run($action, $params)
{
$_tag = $this->get_context()->get_tag();
core::dprint('[BLOCK] start ' . $_tag . '::' . $action, core::E_DEBUG);
$return = false;
// @todo check for callable
if (is_callable(array($this, $action))) {
if (!empty($params)) {
// convert parameters to object
$c_params = functions::array2object($params);
$data = call_user_func(array($this, $action), $c_params);
} else {
$data = call_user_func(array($this, $action));
}
// get block builtin properties
$props = $this->get_block($action);
// assign params
$props['params'] = $params;
$return = $this->get_context()->get_core()->lib('renderer')->render_block($props, $data);
} else {
throw new modules_exception('Not callable action supplied - ' . $action);
}
core::dprint('[/BLOCK] end ' . $_tag . '::' . $action, core::E_DEBUG);
return $return;
}
开发者ID:rustyJ4ck,项目名称:moswarBot,代码行数:36,代码来源:module_blocks.php
示例5: run
function run()
{
$q = $this->get_param('query');
if (empty($q)) {
$q = functions::request_var('keyword');
}
if (loader::in_ajax()) {
$keyword = trim($q);
} else {
$keyword = trim(urldecode($q));
}
$this->renderer->set_return('keyword', $keyword);
$this->renderer->set_main_title('search');
if (empty($q)) {
return;
}
if (strings::strlen($keyword) < 3) {
$this->renderer->set_message('sat.search_too_short', array('result' => false));
$this->renderer->set_ajax_message('sat.search_too_short');
return false;
}
// make search and redirect to it
$id = $this->make_search($keyword);
// redirect to search results
$url = $this->_controller->get_context()->get_router()->make_url('/search/' . $id . '/');
if (loader::in_ajax()) {
$this->_controller->set_null_template();
$this->renderer->set_ajax_message($this->_found ? sprintf('По вашему запросу найдено %d записей', $this->_found) : 'Подходящих записей не найдено')->set_ajax_result($this->_found)->set_ajax_redirect($url);
} else {
functions::redirect($url);
core::get_instance()->halt();
}
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:33,代码来源:query.php
示例6: action_system
function action_system()
{
$this->collection->toggle_system($this->params->id, 'true' == functions::request_var('to', 'false'));
if ($this->in_ajax()) {
$this->_ajax_answer(true, i18n::T('Status changed'));
}
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:7,代码来源:config.php
示例7: __construct
function __construct($dependencies = null, $context)
{
if (empty($dependencies)) {
return;
}
$this->context = $context;
$this->dependencies = is_array($this->dependencies) ? functions::array_merge_recursive_distinct($dependencies, $this->dependencies) : $dependencies;
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:8,代码来源:module_ioc.php
示例8: __construct
public function __construct()
{
parent::__construct();
//necessary
functions::accountExpiration();
$this->playlist_model = new Playlist_Model();
$this->layout_model = new Layout_Model();
}
开发者ID:steamboy,项目名称:ds,代码行数:8,代码来源:xml.php
示例9: Indicadores
function Indicadores($tematica_id)
{
if ($tematica_id > 0) {
return functions::indicadores($tematica_id);
} else {
// todos los indicadores de observatic
return functions::indicador();
}
}
开发者ID:eduardoxlau,项目名称:web_server,代码行数:9,代码来源:soap.php
示例10: run
/**
* Remember!
* Assign current item in controller for comment linking!
*/
function run()
{
if (loader::in_ajax() !== true) {
throw new controller_exception('Cant touch this ' . __METHOD__);
return false;
}
core::dprint('run comment modify');
$pctl = core::modules()->get_router()->get_controller();
$user = core::lib('auth')->get_user();
/**
* Parent item, must be assigned thru @see module_controller::set_current_item()
* @var abs_collection_item
*/
$post = $pctl->get_current_item();
// var_dump(get_class($post), core::get_modules()->get_router()->get_name());
if (!$post) {
throw new controller_exception('No item assigned');
}
if (!$post->has_behavior('sat.commentable')) {
throw new controller_exception('Not commentable');
}
$comments = $post->behavior('sat.commentable')->get_attach_model();
//get_comments();
$request = core::lib('request');
$renderer = core::lib('renderer');
$user_id = core::lib('auth')->get_user()->id;
$pid = (int) $request->post('pid', 0);
$limit = core::selfie()->cfg('comment_interval', 60);
$auth = core::lib('auth');
/** @var aregistry $sd */
$sd = $auth->get_current_session()->get_storage();
$time = $sd->comments_last_time;
//$time = $comments->get_last_time($pid, $user_id);
// disallow by interval
if ($time && $time + $limit > time()) {
$pctl->set_null_template();
$renderer->set_ajax_answer(array('status' => false, 'id' => 0, 'message' => vsprintf(i18n::T('sat\\comment_interval_restriction'), $time + $limit - time())))->ajax_flush();
// else core::get_instance()->set_message(array('content', 'comment_interval_restriction'));
return;
// exit
}
$sd->comments_last_time = time();
$username = functions::request_var('username', '');
$text = functions::request_var('text', '');
$api = functions::request_var('api');
$id = $comments->modify(array('user_ip' => core::lib('auth')->get_user_ip(true), 'user_id' => $user_id, 'ctype_id' => $post->get_ctype_id(), 'username' => $username, 'pid' => $pid, 'text' => $text, 'type' => functions::request_var('type', 0), 'tpid' => functions::request_var('tpid', 0), 'api' => $api));
$comment = $comments->get_item_by_id($id);
if (!$comment) {
throw new controller_exception('[ajax] Comment create failed');
}
$comment->load_secondary();
$renderer->set_data('comment', $comment->render())->set_ajax_answer(array('status' => true, 'id' => $id))->set_ajax_message(i18n::T('sat\\comment_posted'));
//->set_main_template('content/comment/view');
$renderer->ajax_flush('shared/comments/comment');
// alright, update counter
return $id;
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:61,代码来源:modify.php
示例11: applyStatus
function applyStatus($id, $act)
{
if ($act == 'top') {
$sql = "UPDATE board SET top_time='" . (14 * 86400 + time()) . "' WHERE id='{$id}'";
} elseif ($act == 'color') {
$sql = "UPDATE board SET is_color='1' WHERE id='" . functions::q($id) . "'";
} elseif ($act == 'important') {
$sql = "UPDATE board SET is_important='1' WHERE id='" . functions::q($id) . "'";
}
return mysql_query($sql);
}
开发者ID:Sywooch,项目名称:dump,代码行数:11,代码来源:service.php
示例12: init_config
/**
* Init config
*/
function init_config($config = array(), $append = false)
{
if (empty($config)) {
return;
}
if (!$append) {
$this->config = $config;
} else {
$this->config = functions::array_merge_recursive_distinct($this->config, $config);
}
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:14,代码来源:config.php
示例13: getPhoto
function getPhoto($name, $width, $height, $params = "", $method = "echo")
{
$url = HOME . substr($name, 2);
$size = functions::getFullSize(DIR . substr($name, 2), $width, $height);
$width = $size['width'];
$height = $size['height'];
$txt = "<img src=\"" . $url . "\" width=" . $width . " height=" . $height . " " . $params . "/>";
if ($method == "return") {
return $txt;
} else {
echo $txt;
}
}
开发者ID:Sywooch,项目名称:dump,代码行数:13,代码来源:functions.php
示例14: init
public function init()
{
// Make a controller copy of $user since it won't report anything back
$user = $this->user;
$this->passChanged = isset($_GET['passchanged']) ? $_GET['passchanged'] : false;
// Is this user allowed here
if (!$user->isSigned() and !isset($_GET['c']) and !$this->passChanged) {
//Redirect
functions::_index();
}
if ($user->isSigned() and $this->passChanged || isset($_GET['c'])) {
$this->_redirect("http://" . $_SERVER['HTTP_HOST'] . "/user/profile");
}
//Proccess Password change
if (count($_POST)) {
// Set some session variables
$pass = array();
$_SESSION['pass'] = $pass;
$_SESSION['pass']['Password'] = $_POST['password'];
$_SESSION['pass']['Password2'] = $_POST['password2'];
$_SESSION['hash'] = $_POST['c'];
// Ensures session is written before redirect.
session_write_close();
if ($_SESSION['hash']) {
$this->_redirect("http://" . $_SERVER['HTTP_HOST'] . "/user/changepassword?c=" . $_SESSION['hash']);
} else {
$this->_redirect("http://" . $_SERVER['HTTP_HOST'] . "/user/changepassword");
}
} else {
if (isset($_SESSION['pass'])) {
$hash = $_SESSION['hash'];
$pass = $_SESSION['pass'];
if (!$user->isSigned() and $hash) {
//Change Password with confirmation hash
$user->newPassword($hash, $pass);
} else {
//Change the Password of signed in user without a confirmation hash
$user->update($pass);
}
// If password was changed
if (!count($user->log->getFormErrors())) {
session_unset();
session_destroy();
// Log the user out
$user->logout();
$this->_redirect("http://" . $_SERVER['HTTP_HOST'] . "/user/changepassword?passchanged=1");
}
}
}
}
开发者ID:bala0302,项目名称:Website-Framework,代码行数:50,代码来源:changepassword.php
示例15: execute
/**
* render|update|create model model ...
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
* @throws \tf_exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
//require('../_tests/loader.php');
$core = $this->core();
$this->prepare_db($input->getOption('database'));
$action = $input->getArgument('action');
if (empty($action)) {
throw new \tf_exception("empty action\n");
}
$ids = $input->getArgument('models');
if (empty($ids)) {
throw new \tf_exception("empty ID\n");
}
if ($ids[0] == '*') {
$ids = Helpers\ModelEnumerator::find();
}
/*
* $action = @$_SERVER['argv'][2] ? : 'render';
if (in_array('--', $_SERVER['argv'])) {
}
*/
$output->writeln('action: ' . $action);
/** @var collection_generator */
$generator = \abs_collection::get_generator();
foreach ($ids as $mid) {
$_mid = explode('.', trim($mid));
if (count($_mid) == 1) {
array_unshift($_mid, 'core');
$container = core::selfie();
} else {
$container = core::module($_mid[0]);
}
if (!$container) {
$output->writeln('skip ' . $mid);
continue;
}
$method = 'get_' . $_mid[1] . '_handle';
// allow model with params: get_model_handle | model('model')
$obj = \functions::is_callable(array($container, $method)) ? $container->{$method}() : $container->model($_mid[1]);
$generator->append_object($obj);
}
$output->writeln($generator->render_table_structure(), OutputInterface::OUTPUT_RAW);
if ($action == 'update') {
$generator->update_table_structure();
}
if ($action == 'create') {
$generator->update_table_structure(true);
}
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:56,代码来源:GeneratorCommand.php
示例16: get_top
function get_top($order = 'postforum')
{
$req = mysql_query("SELECT * FROM `users` WHERE `{$order}` > 0 ORDER BY `{$order}` DESC LIMIT 9");
if (mysql_num_rows($req)) {
$out = '';
while ($res = mysql_fetch_assoc($req)) {
$out .= $i % 2 ? '<div class="list2">' : '<div class="list1">';
$out .= functions::display_user($res, array('header' => '<b>' . $res[$order] . '</b>')) . '</div>';
++$i;
}
return $out;
} else {
return '<div class="menu"><p>' . $lng['list_empty'] . '</p></div>';
}
}
开发者ID:chegestar,项目名称:catroxs,代码行数:15,代码来源:top.php
示例17: run
function run()
{
$name = functions::request_var('template', '');
$name = $name ? $name : 'default';
if (empty($name) || !preg_match('@^[a-z\\d]+$@i', $name)) {
throw new controller_exception('Bad id');
}
$domain = preg_replace('@^www\\.@', '', $_SERVER['HTTP_HOST']);
$vars = $this->request->post();
$to = $vars['email'];
/** @var tf_mailer */
$mailer = core::lib('mailer');
$result = $mailer->email_template($name, $to, $vars, true);
$this->renderer->set_ajax_result($result)->set_ajax_message('ok')->ajax_flush();
return;
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:16,代码来源:mailer.php
示例18: __construct
public function __construct()
{
parent::__construct();
//necessary
//Auth
if (!$this->auth->logged_in('login')) {
$this->session->set_flash('login_message', 'Please login to continue');
$this->session->set('referer', url::current());
url::redirect('users/login');
}
functions::accountExpiration();
$this->playlist_model = new Playlist_Model();
$this->layout_model = new Layout_Model();
$this->dstemplate_model = new Dstemplate_Model();
$this->template->title = 'Layout';
}
开发者ID:steamboy,项目名称:ds,代码行数:16,代码来源:layout.php
示例19: nextDepartureFromRuddammen
public static function nextDepartureFromRuddammen($maxNumber = 3)
{
$times = array();
$url = "https://api.resrobot.se/departureBoard.json?" . "maxJourneys=5" . "&passlist=0" . "&id=" . self::$ruddammen_locationid . "&key=" . self::$norditas_api_nyckel_stolptidtabeller;
$json = functions::acurl($url);
$djson = json_decode($json, 1);
if (is_array($djson) && isset($djson["Departure"])) {
$darray = $djson["Departure"];
foreach ($darray as $array) {
if (strtotime($array["time"]) >= time()) {
$times[] = preg_replace("/:\\d\\d\$/", "", $array["time"]);
}
}
}
return array_slice($times, 0, $maxNumber);
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例20: auth
static function auth($login, $password)
{
$login = functions::check($login);
$password = functions::check($password);
$error = "";
if (!empty($login) && !empty($password)) {
$user = users::getUser(1, $login, $password);
if ($user->id > 0) {
$_SESSION["s_user"] = $user->toArray();
} else {
$error = "Вы ввели не верные логин или пароль";
}
} else {
$error = "Необходимо заполнить все поля";
}
return $error;
}
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:17,代码来源:functions.php
注:本文中的functions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论