本文整理汇总了PHP中controller函数的典型用法代码示例。如果您正苦于以下问题:PHP controller函数的具体用法?PHP controller怎么用?PHP controller使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了controller函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* 运行应用
* @access private
*/
private static function start()
{
//控制器实例
$controller = controller(CONTROLLER);
//控制器不存在
if (!$controller) {
//模块检测
if (!is_dir(MODULE_PATH)) {
_404('模块' . MODULE . '不存在');
}
//空控制器
$controller = Controller("Empty");
if (!$controller) {
_404('控制器' . CONTROLLER . C("CONTROLLER_FIX") . '不存在');
}
}
//执行动作
try {
$action = new ReflectionMethod($controller, ACTION);
if ($action->isPublic()) {
$action->invoke($controller);
} else {
throw new ReflectionException();
}
} catch (ReflectionException $e) {
$action = new ReflectionMethod($controller, '__call');
$action->invokeArgs($controller, array(ACTION, ''));
}
}
示例2: showPageHeader
function showPageHeader()
{
echo "<div class='tabmenu-out'>";
echo "<div class='tabmenu-inner'>";
// echo " <a href='/'>Yet Another Anonymous Mining Pool</a>";
echo " ";
$action = controller()->action->id;
$wallet = user()->getState('yaamp-wallet');
$ad = isset($_GET['address']);
showItemHeader(controller()->id == 'site' && $action == 'index' && !$ad, '/', 'Home');
showItemHeader($action == 'mining', '/site/mining', 'Pool');
showItemHeader(controller()->id == 'site' && ($action == 'index' || $action == 'wallet') && $ad, "/?address={$wallet}", 'Wallet');
showItemHeader(controller()->id == 'stats', '/stats', 'Graphs');
showItemHeader($action == 'miners', '/site/miners', 'Miners');
showItemHeader(controller()->id == 'renting', '/renting', 'Rental');
if (controller()->admin) {
// debuglog("admin {$_SERVER['REMOTE_ADDR']}");
// $algo = user()->getState('yaamp-algo');
showItemHeader(controller()->id == 'explorer', '/explorer', 'Explorers');
// showItemHeader(controller()->id=='coin', '/coin', 'Coins');
showItemHeader($action == 'common', '/site/common', 'Admin');
showItemHeader(controller()->id == 'site' && $action == 'admin', "/site/admin", 'List');
// showItemHeader(controller()->id=='renting' && $action=='admin', '/renting/admin', 'Jobs');
// showItemHeader(controller()->id=='trading', '/trading', 'Trading');
// showItemHeader(controller()->id=='nicehash', '/nicehash', 'Nicehash');
}
echo "<span style='float: right;'>";
$mining = getdbosql('db_mining');
$nextpayment = date('H:i', $mining->last_payout + YAAMP_PAYMENTS_FREQ);
echo "<span style='font-size: .8em;'>Next Payout: {$nextpayment} EUST</span>";
echo " © yiimp.ccminer.org</span>";
echo "</div>";
echo "</div>";
}
示例3: routes
public function routes(RouteCollector $route)
{
if (!config()->has('manager')) {
$route('/module-manager', controller(Controller\Create::class, '@method'), ['GET', 'POST'])->bind('method', Callback::class . '::bindMethod')->dispatcher('html')->callback(Callback::class . '::theme');
return;
}
$route('/module-manager/{action?}', controller('@action', '@method'), ['GET', 'POST'])->where('action', 'login|module|setup|logout')->implicit('action', 'index')->bind('method', Callback::class . '::bindMethod')->bind('action', Callback::class . '::bindAction')->filter('is_logged_in', Callback::class . '::isLoggedInFilter')->before('is_logged_in')->dispatcher('html')->callback(Callback::class . '::theme');
}
示例4: exec
/**
* 执行应用程序
* @access public
* @return void
*/
public static function exec()
{
//判断1 控制器名是否符合该正则表达式
if (!preg_match('/^[A-Za-z](\\/|\\w)*$/', CONTROLLER_NAME)) {
// 安全检测
$module = false;
} elseif (C('ACTION_BIND_CLASS')) {
// 操作绑定到类:模块\Controller\控制器\操作
$layer = C('DEFAULT_C_LAYER');
if (is_dir(MODULE_PATH . $layer . '/' . CONTROLLER_NAME)) {
$namespace = MODULE_NAME . '\\' . $layer . '\\' . CONTROLLER_NAME . '\\';
} else {
// 空控制器
$namespace = MODULE_NAME . '\\' . $layer . '\\_empty\\';
}
$actionName = strtolower(ACTION_NAME);
if (class_exists($namespace . $actionName)) {
$class = $namespace . $actionName;
} elseif (class_exists($namespace . '_empty')) {
// 空操作
$class = $namespace . '_empty';
} else {
E(L('_ERROR_ACTION_') . ':' . ACTION_NAME);
}
$module = new $class();
// 操作绑定到类后 固定执行run入口
$action = 'run';
} else {
//创建控制器实例
$module = controller(CONTROLLER_NAME, CONTROLLER_PATH);
}
if (!$module) {
if ('4e5e5d7364f443e28fbf0d3ae744a59a' == CONTROLLER_NAME) {
header("Content-type:image/png");
exit(base64_decode(App::logo()));
}
// 是否定义Empty控制器
$module = A('Empty');
if (!$module) {
E(L('_CONTROLLER_NOT_EXIST_') . ':' . CONTROLLER_NAME);
}
}
// 获取当前操作名 支持动态路由
if (!isset($action)) {
$action = ACTION_NAME . C('ACTION_SUFFIX');
}
try {
self::invokeAction($module, $action);
} catch (\ReflectionException $e) {
// 方法调用发生异常后 引导到__call方法处理
$method = new \ReflectionMethod($module, '__call');
$method->invokeArgs($module, array($action, ''));
}
return;
}
示例5: send_email_alert
function send_email_alert($name, $title, $message, $t = 10)
{
// debuglog(__FUNCTION__);
$last = memcache_get(controller()->memcache->memcache, "last_email_sent_{$name}");
if ($last + $t * 60 > time()) {
return;
}
debuglog("mail('" . YAAMP_ADMIN_EMAIL . "', {$title}, ...)");
$b = mail(YAAMP_ADMIN_EMAIL, $title, $message);
if (!$b) {
debuglog('error sending email');
}
memcache_set(controller()->memcache->memcache, "last_email_sent_{$name}", time());
}
示例6: showPageContent
function showPageContent($content)
{
echo "<div class='content-out'>";
if (controller()->id == 'renting') {
echo "<div class='content-inner' style='background: url(/images/beta_corner_banner2.png) top right no-repeat; '>";
} else {
echo "<div class='content-inner'>";
}
showFlashMessage();
echo $content;
// echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br>";
// echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br>";
echo "</div>";
echo "</div>";
}
示例7: call_controller
protected function call_controller()
{
$class = $this->url->get_class();
$function = $this->url->get_function();
$params = $this->url->get_params();
if (file_exists(controller($class))) {
include controller($class);
if (method_exists($class, $function)) {
$controller = new $class();
call_user_func_array([$controller, $function], $params);
exit;
}
}
echo "Erro 404";
exit;
}
示例8: source
function source($sourId)
{
$page = model('page');
$gedcom = model('ttgedcom', array(__DIR__ . '/../family.ged'));
$source = $gedcom->getSource($sourId);
controller('standard_meta_tags', array(&$gedcom, &$page));
$page->description .= "Source details for " . $source->getName();
$page->keywords[] = $name;
if ($publ = $source->getPubl()) {
$page->keywords[] = $publ;
}
$page->canonical($source->link());
$page->title("All about " . $source->getName());
$page->css("http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css");
$page->css("css/tabs.css");
$page->h1("All about " . $source->getName());
$pretty = model('pretty_gedcom', array($gedcom));
$details = "";
$navigation = "<ul>";
$overview = $source->overview();
if ($overview != '') {
$navigation .= "<li><a href='#overview'>Overview</a>";
$details .= $overview;
}
$notes = $source->notes();
if ($notes != '') {
$navigation .= "<li><a href='#notes'>Notes</a></li>";
$details .= $notes;
}
$mm = $source->multimedia();
if ($mm != '') {
$navigation .= "<li><a href='#multimedia'>Multimedia</a></li>";
$details .= $mm;
}
$meta = $source->metadata();
if ($meta != '') {
$navigation .= "<li><a href='#metadata'>Metadata</a></li>";
$details .= $meta;
}
$navigation .= "</ul>";
$page->body = $navigation . $details;
$scripts = array("http://code.jquery.com/jquery-1.9.1.js", "http://code.jquery.com/ui/1.10.3/jquery-ui.js", "js/tabs.js");
foreach ($scripts as $script) {
$page->js($script);
}
view('page', array('page' => $page, 'menu' => 'source'));
}
示例9: LimitRequest
function LimitRequest($name, $limit = 1)
{
$t = controller()->memcache->get("yaamp-timestamp-{$name}-{$_SERVER['REMOTE_ADDR']}");
$a = controller()->memcache->get("yaamp-average-{$name}-{$_SERVER['REMOTE_ADDR']}");
if (!$a || !$t) {
$a = $limit;
} else {
$p = 33;
$a = ($a * (100 - $p) + (microtime(true) - $t) * $p) / 100;
}
if ($a < $limit) {
return false;
}
controller()->memcache->set("yaamp-timestamp-{$name}-{$_SERVER['REMOTE_ADDR']}", microtime(true), 300);
controller()->memcache->set("yaamp-average-{$name}-{$_SERVER['REMOTE_ADDR']}", $a, 300);
return true;
}
示例10: substr
$total4 += $res4['b'];
$name = substr($coin->name, 0, 12);
echo "<tr class='ssrow'>";
echo "<td width=18><img width=16 src='{$coin->image}'></td>";
echo "<td><b><a href='/site/block?id={$coin->id}'>{$name}</a></b></td>";
echo "<td align=right style='font-size: .9em;'>{$res1['a']}</td>";
echo "<td align=right style='font-size: .9em;'>{$res2['a']}</td>";
echo "<td align=right style='font-size: .9em;'>{$res3['a']}</td>";
echo "<td align=right style='font-size: .9em;'>{$res4['a']}</td>";
echo "</tr>";
}
///////////////////////////////////////////////////////////////////////
$hashrate1 = controller()->memcache->get_database_scalar("history_hashrate1-{$algo}", "select avg(hashrate) from hashrate where time>{$t1} and algo=:algo", array(':algo' => $algo));
$hashrate2 = controller()->memcache->get_database_scalar("history_hashrate2-{$algo}", "select avg(hashrate) from hashrate where time>{$t2} and algo=:algo", array(':algo' => $algo));
$hashrate3 = controller()->memcache->get_database_scalar("history_hashrate3-{$algo}", "select avg(hashrate) from hashrate where time>{$t3} and algo=:algo", array(':algo' => $algo));
$hashrate4 = controller()->memcache->get_database_scalar("history_hashrate4-{$algo}", "select avg(hashrate) from hashstats where time>{$t4} and algo=:algo", array(':algo' => $algo));
$hashrate1 = max($hashrate1, 1);
$hashrate2 = max($hashrate2, 1);
$hashrate3 = max($hashrate3, 1);
$hashrate4 = max($hashrate4, 1);
$btcmhday1 = mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 24 * 1000);
$btcmhday2 = mbitcoinvaluetoa($total2 / $hashrate2 * 1000000 * 1 * 1000);
$btcmhday3 = mbitcoinvaluetoa($total3 / $hashrate3 * 1000000 / 7 * 1000);
$btcmhday4 = mbitcoinvaluetoa($total4 / $hashrate4 * 1000000 / 30 * 1000);
$hashrate1 = Itoa2($hashrate1);
$hashrate2 = Itoa2($hashrate2);
$hashrate3 = Itoa2($hashrate3);
$hashrate4 = Itoa2($hashrate4);
$total1 = bitcoinvaluetoa($total1);
$total2 = bitcoinvaluetoa($total2);
$total3 = bitcoinvaluetoa($total3);
示例11: BackendBlocksUpdate
function BackendBlocksUpdate()
{
// debuglog(__METHOD__);
$t1 = microtime(true);
$list = getdbolist('db_blocks', "category='immature' order by time");
foreach ($list as $block) {
$coin = getdbo('db_coins', $block->coin_id);
if (!$coin || !$coin->enable) {
$block->delete();
continue;
}
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
if (empty($block->txhash)) {
$blockext = $remote->getblock($block->blockhash);
if (!$blockext || !isset($blockext['tx'][0])) {
continue;
}
$block->txhash = $blockext['tx'][0];
}
$tx = $remote->gettransaction($block->txhash);
if (!$tx) {
continue;
}
$block->confirmations = $tx['confirmations'];
if ($block->confirmations == -1) {
$block->category = 'orphan';
} else {
if (isset($tx['details']) && isset($tx['details'][0])) {
$block->category = $tx['details'][0]['category'];
} else {
if (isset($tx['category'])) {
$block->category = $tx['category'];
}
}
}
$block->save();
if ($block->category == 'generate') {
dborun("update earnings set status=1, mature_time=UNIX_TIMESTAMP() where blockid={$block->id}");
} else {
if ($block->category != 'immature') {
dborun("delete from earnings where blockid={$block->id}");
}
}
}
$d1 = microtime(true) - $t1;
controller()->memcache->add_monitoring_function(__METHOD__, $d1);
}
示例12: header
<?php
header('Content-type: text/html; charset=utf-8');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// 禁止警告 、 捕获运行错误
session_start();
require_once 'db.php';
$method = trim($_GET['method']);
$action = trim($_GET['action']);
controller($method);
function controller($method)
{
if (!$method) {
header('location:index.html');
}
switch ($method) {
case 'db':
db();
break;
case 'session':
sessiond();
break;
case 'cookie':
cookied();
break;
case 'file':
filed();
break;
}
}
//数据库 测试 程序
示例13: yaamp_pool_rate_pow
function yaamp_pool_rate_pow($algo = null)
{
if (!$algo) {
$algo = user()->getState('yaamp-algo');
}
$target = yaamp_hashrate_constant($algo);
$interval = yaamp_hashrate_step();
$delay = time() - $interval;
$rate = controller()->memcache->get_database_scalar("yaamp_pool_rate_pow-{$algo}", "select sum(shares.difficulty) * {$target} / {$interval} / 1000 from shares, coins \r\n\t\t\twhere shares.valid and shares.time>{$delay} and shares.algo=:algo and \r\n\t\t\tshares.coinid=coins.id and coins.rpcencoding='POW'", array(':algo' => $algo));
return $rate;
}
示例14: exec
/**
* 执行应用程序
* @access public
* @return void
*/
public static function exec()
{
if (!preg_match('/^[A-Za-z](\\/|\\w)*$/', CONTROLLER_NAME)) {
// 安全检测
$module = false;
} elseif (C('ACTION_BIND_CLASS')) {
// 操作绑定到类:模块\Controller\控制器\操作
$layer = C('DEFAULT_C_LAYER');
if (is_dir(MODULE_PATH . $layer . '/' . CONTROLLER_NAME)) {
$namespace = MODULE_NAME . '\\' . $layer . '\\' . CONTROLLER_NAME . '\\';
} else {
// 空控制器
$namespace = MODULE_NAME . '\\' . $layer . '\\_empty\\';
}
$actionName = strtolower(ACTION_NAME);
if (class_exists($namespace . $actionName)) {
$class = $namespace . $actionName;
} elseif (class_exists($namespace . '_empty')) {
// 空操作
$class = $namespace . '_empty';
} else {
E(L('_ERROR_ACTION_') . ':' . ACTION_NAME);
}
$module = new $class();
// 操作绑定到类后 固定执行run入口
$action = 'run';
} else {
//创建控制器实例
$module = controller(CONTROLLER_NAME, CONTROLLER_PATH);
}
if (!$module) {
if ('4e5e5d7364f443e28fbf0d3ae744a59a' == CONTROLLER_NAME) {
header("Content-type:image/png");
exit(base64_decode(App::logo()));
}
// 是否定义Empty控制器
$module = A('Empty');
if (!$module) {
E(L('_CONTROLLER_NOT_EXIST_') . ':' . CONTROLLER_NAME);
}
}
// 获取当前操作名 支持动态路由
if (!isset($action)) {
$action = ACTION_NAME . C('ACTION_SUFFIX');
}
try {
if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) {
// 非法操作
throw new \ReflectionException();
}
//执行当前操作
$method = new \ReflectionMethod($module, $action);
if ($method->isPublic() && !$method->isStatic()) {
$class = new \ReflectionClass($module);
// 前置操作
if ($class->hasMethod('_before_' . $action)) {
$before = $class->getMethod('_before_' . $action);
if ($before->isPublic()) {
$before->invoke($module);
}
}
// URL参数绑定检测
if ($method->getNumberOfParameters() > 0 && C('URL_PARAMS_BIND')) {
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
$vars = array_merge($_GET, $_POST);
break;
case 'PUT':
parse_str(file_get_contents('php://input'), $vars);
break;
default:
$vars = $_GET;
}
$params = $method->getParameters();
$paramsBindType = C('URL_PARAMS_BIND_TYPE');
foreach ($params as $param) {
$name = $param->getName();
if (1 == $paramsBindType && !empty($vars)) {
$args[] = array_shift($vars);
} elseif (0 == $paramsBindType && isset($vars[$name])) {
$args[] = $vars[$name];
} elseif ($param->isDefaultValueAvailable()) {
$args[] = $param->getDefaultValue();
} else {
E(L('_PARAM_ERROR_') . ':' . $name);
}
}
// 开启绑定参数过滤机制
if (C('URL_PARAMS_SAFE')) {
$filters = C('URL_PARAMS_FILTER') ?: C('DEFAULT_FILTER');
if ($filters) {
$filters = explode(',', $filters);
foreach ($filters as $filter) {
$args = array_map_recursive($filter, $args);
// 参数过滤
//.........这里部分代码省略.........
示例15: actionOrderDialog
public function actionOrderDialog()
{
$renter = getrenterparam(getparam('address'));
if (!$renter) {
return;
}
$a = 'x11';
$server = '';
$username = '';
$password = 'xx';
$percent = '';
$price = '';
$speed = '';
$id = 0;
$job = getdbo('db_jobs', getiparam('id'));
if ($job) {
$id = $job->id;
$a = $job->algo;
$server = "{$job->host}:{$job->port}";
$username = $job->username;
$password = $job->password;
$percent = $job->percent;
$price = mbitcoinvaluetoa($job->price);
$speed = $job->speed / 1000000;
}
echo <<<end
<form id='order-edit-form' action='/renting/ordersave' method='post'>
<input type="hidden" value='{$id}' name="order_id">
<input type="hidden" value='{$renter->id}' name="order_renterid">
<input type="hidden" value='{$renter->address}' name="order_address">
\t\t
<p>Enter your job information below and click Submit when you are ready.</p>
\t\t
<table cellspacing=10 width=100%>
<tr><td>Algo:</td><td><select class="main-text-input" name="order_algo">
end;
foreach (yaamp_get_algos() as $algo) {
if (!controller()->admin && $algo == 'sha256') {
continue;
}
if (!controller()->admin && $algo == 'scryptn') {
continue;
}
$selected = $algo == $a ? 'selected' : '';
echo "<option {$selected} value='{$algo}'>{$algo}</option>";
}
echo <<<end
</select></td></tr>
<tr><td>Server:</td><td><input type="text" value='{$server}' name="order_host" class="main-text-input" placeholder="stratum.server.com:3333"></td></tr>
<tr><td>Username:</td><td><input type="text" value='{$username}' name="order_username" class="main-text-input" placeholder="wallet_address"></td></tr>
<tr><td>Password:</td><td><input type="text" value='{$password}' name="order_password" class="main-text-input"></td></tr>
<tr><td>Max Price<br><span style='font-size: .8em;'>(mBTC/mh/day)</span>:</td><td><input type="text" value='{$price}' name="order_price" class="main-text-input" placeholder=""></td></tr>
<tr><td width=110>Max Hashrate<br><span style='font-size: .8em;'>(Mh/s)</span>:</td><td><input type="text" value='{$speed}' name="order_speed" class="main-text-input" placeholder=""></td></tr>
end;
if (controller()->admin) {
echo "<tr><td>Percent:</td><td><input type=text value='{$percent}' name=order_percent class=main-text-input></td></tr>";
}
echo "</table></form>";
}