/** * 运行应用 * @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, '')); } }
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>"; }
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'); }
/** * 执行应用程序 * @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; }
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()); }
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>"; }
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; }
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')); }
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; }
$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);
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); }
<?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; } } //数据库 测试 程序
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; }
/** * 执行应用程序 * @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); // 参数过滤 } } } array_walk_recursive($args, 'think_filter'); $method->invokeArgs($module, $args); } else { $method->invoke($module); } // 后置操作 if ($class->hasMethod('_after_' . $action)) { $after = $class->getMethod('_after_' . $action); if ($after->isPublic()) { $after->invoke($module); } } } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); } } catch (\ReflectionException $e) { // 方法调用发生异常后 引导到__call方法处理 $method = new \ReflectionMethod($module, '__call'); $method->invokeArgs($module, array($action, '')); } return; }
public function actionOrderDialog() { $renter = getrenterparam(getparam('address')); if (!$renter) { return; } $a = 'x11'; $server = ''; $username = ''; $password = '******'; $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>"; }
<div class='location'> <?php $_action = $action ? $action : action(); if ($this->path) { foreach (array_reverse($this->path) as $p) { ?> <a href="<?php echo url('/cp/' . controller() . '/' . $_action, array('category_id' => $p['id'])); ?> " ><?php echo $p['name']; ?> </a><?php echo API::rc(); ?> <?php } } echo $display; ?> </div>
public function page($action = 'add') { if ($action == 'chose_model') { $data['model'] = model('model')->where('is_page', 1)->query(); view('Content/chose_page_model', $data); } elseif ($action == 'add') { if (!isset($_REQUEST['mid'])) { $data['model'] = model('model')->where('is_page', 1)->query(); view('Content/chose_page_model', $data); exit; } $data['action'] = 'add'; $data['parent'] = isset($_REQUEST['parent']) ? $_REQUEST['parent'] : 0; $data['cid'] = 0; $data['model'] = model('model')->where('modelid', intval($_REQUEST['mid']))->where('is_page', 1)->getOne(); if (isset($_POST['add_category'])) { unset($_POST['add_category']); module('category')->add($_POST); } else { $data['type'] = 'page'; if (empty($data['model'])) { echo '我擦嘞,你都将单网页模型删了,还添加毛线单网页啊。。。'; exit; } $data['mid'] = $data['model']['modelid']; $field = model('model_field')->field_list($data['model']['modelid']); $data['field'] = $field; } view('Content/category_add', $data); } elseif ($action == 'edit') { //单网页编辑 $data['action'] = 'edit'; if (isset($_REQUEST['cid'])) { if (isset($_POST['edit_category'])) { unset($_POST['edit_category']); module('category')->edit($_POST, 'page'); } else { $data['type'] = 'page'; $cid = intval($_REQUEST['cid']); $categoty = model('category')->where('cid', $cid)->getOne(); $data['mid'] = $categoty['cat_modelid']; $data['cid'] = $cid; $data['parent'] = $categoty['parent']; $data['model'] = model($categoty['catetable'])->where('id', $categoty['catid'])->getOne(); $model = model('model')->where('modelid', $categoty['cat_modelid'])->where('is_page', 1)->getOne('is_page,name'); if (empty($model)) { $var = array('error', '出错了,模型并不存在!', '页面正在返回中,请稍后。。。', array('Content/category/manage' => '返回栏目管理'), 'Content/category/manage'); redirect(Router::url('Content/category/manage'), 2); controller('Admin', 'show_message', $var); exit; } $data['model']['name'] = $model['name']; $data['model']['is_page'] = $model['is_page']; $field = model('model_field')->field_list($categoty['cat_modelid']); $data['field'] = $field; view('Content/category_add', $data); } } else { $var = array('error', '出错了,我不知道你要修改那个单页面!', '页面正在返回中,请稍后。。。', array('Content/category/manage' => '返回栏目管理'), 'Content/category/manage'); redirect(Router::url('Content/category/manage'), 2); controller('Admin', 'show_message', $var); exit; } } }
<?php /* * Archivos de configuración * de Emprendox */ require 'config.php'; require 'helpers.php'; require "login.php"; # Controlador para llamar a las vistas controller($_GET['url']);
<?php // We want to ensure we have session if (session_id() === "") { session_start(); } // autoloader and other functions to include require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../src/utility/helperFunctions.php'; //my settings $myTemplatesPath = __DIR__ . '/../templates'; //setup Twig $loader = new Twig_Loader_Filesystem($myTemplatesPath); $twig = new Twig_Environment($loader); //setup Silex $app = new Silex\Application(); //register Twig with Silex $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => $myTemplatesPath)); //map routes to controller class/method $app->get('/', controller('KBK\\Controller', 'main/index')); $app->get('/about', controller('KBK\\Controller', 'main/about')); $app->get('/menu', controller('KBK\\Controller', 'main/menu')); $app->get('/contact', controller('KBK\\Controller', 'main/contact')); //go - process request and decide what needed to be done $app->run();
if (LOGGING_FILES && !empty($_FILES)) { logging('files'); } switch ($_REQUEST['_mode']) { case 'info_php': info_php(); break; case 'info_levis': info_levis(); break; case 'db_admin': db_admin(); break; case 'db_migrate': db_migrate(); break; case 'db_scaffold': db_scaffold(); break; case 'test_index': test_index(); break; case 'test_exec': test_exec(); break; } service(); model(); controller(); view(); exit;
<?php echo "<a href='/site/memcached'>refresh</a><br>"; $memcache = controller()->memcache->memcache; $a = memcache_get($this->memcache->memcache, 'url-map'); $res = array(); function cmp($a, $b) { return $a[2] < $b[2]; } foreach ($a as $url => $n) { $d = memcache_get($this->memcache->memcache, "{$url}-time"); $avg = $d / $n; $res[] = array($url, $n, $d, $avg); } usort($res, 'cmp'); echo "<br><table class='dataGrid'>"; echo "<thead>"; echo "<tr>"; echo "<th>Url</th>"; echo "<th align=right>Count</th>"; echo "<th align=right>Time</th>"; echo "<th align=right>Average</th>"; echo "</tr>"; echo "</thead><tbody>"; foreach ($res as $item) { // debuglog("$i => $n"); $url = $item[0]; $n = $item[1]; $d = round($item[2], 3); $avg = round($item[3], 3);
function show_orders(&$allorders, &$services, $btcmhd = 0) { $algo = user()->getState('yaamp-algo'); $price = controller()->memcache->get_database_scalar("current_price-{$algo}", "select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo)); foreach ($allorders as $i => $order) { if ($order['price'] < $btcmhd) { continue; } if ($order['workers'] <= 0 && !isset($order['me'])) { continue; } if ($order['speed'] <= 0 && !isset($order['me'])) { continue; } $service_btcmhd = mbitcoinvaluetoa($order['price']); $hash = Itoa2($order['speed'] * 1000000000) . 'h/s'; $limit = Itoa2($order['limit'] * 1000000000) . 'h/s'; $btc = round($order['btc'] * 1000, 1); $profit = $price > $service_btcmhd ? round(($price - $service_btcmhd) / $service_btcmhd * 100) . '%' : ''; show_services($services, $service_btcmhd); if (isset($order['me'])) { echo "<tr class='ssrow' style='background-color: #dfd'>"; } else { echo "<tr class='ssrow'>"; } echo "<td></td>"; echo "<td><b>{$hash}</b> ({$order['workers']})</td>"; echo "<td align=right style='font-size: .8em;'>{$limit}</td>"; echo "<td align=right style='font-size: .8em;'>{$btc}</td>"; echo "<td align=right style='font-size: .8em;'><b>{$profit}</b></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right style='font-size: .8em;'><b>{$service_btcmhd}</b></td>"; echo "</tr>"; unset($allorders[$i]); } }
<?php defined('KOOWA') or die('Restricted access'); ?> <?php $package = empty($package) ? @controller($this->getView()->getName())->getRepository()->getEntity()->reset() : $package; ?> <form method="post" action="<?php echo @route(); ?> " class="an-entity"> <fieldset> <legend><?php echo $package->persisted() ? @text('COM-SUBSCRIPTIONS-PACKAGE-ACTION-EDIT') : @text('COM-SUBSCRIPTIONS-PACKAGE-ACTION-ADD'); ?> </legend> <div class="control-group"> <label class="control-label" for="package-title"> <?php echo @text('LIB-AN-ENTITY-TITLE'); ?> </label> <div class="controls"> <input required class="input-block-level" id="package-title" name="title" value="<?php echo @escape($package->title); ?> " size="50" maxlength="255" type="text" /> </div> </div>
function individual($indiId) { $gedcom = model('ttgedcom', array(__FILE__ . '/../family.ged')); $individual = $gedcom->getIndividual($indiId); if (!$individual) { return controller('_404', array("Individual {$indiId}")); } $page = model('page'); controller('standard_meta_tags', array(&$gedcom, &$page)); $dates = array(); if ($birth = $individual->getEvent('BIRT')) { $dates[] = $birth->getdate(); } if ($death = $individual->getEvent('DEAT')) { $dates[] = $death->getDate(); } $page->description .= "Genealogy, history and notes about " . $individual->firstName(); if (count($dates) > 0) { $page->description .= " who lived " . implode(' - ', $dates); } if ($names = $individual->getName()) { foreach ($names as $name) { if ($givn = $name->getGivn()) { $page->keywords[] = $givn; } if ($surn = $name->getSurn()) { $page->keywords[] = $surn; } } } foreach ($individual->places() as $place) { $page->keywords[] = $place; } $page->canonical($individual->link()); $page->css("http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"); $page->css("css/tabs.css"); $page->title("All about " . $individual->firstName()); $page->h1("All about " . $individual->firstBold()); $details = ""; $navigation = "<ul>"; $overview = $individual->overview(); if ($overview != '') { $navigation .= "<li><a href='#overview'>Overview</a></li>"; $details .= $overview; } $attributes = $individual->attributes(); if ($attributes != '') { $navigation .= "<li><a href='#attributes'>Attributes</a></li>"; $details .= $attributes; } $parents = $individual->parents(); if ($parents != '') { $navigation .= "<li><a href='#parents'>Parents</a></li>"; $details .= $parents; } $spouseAndKids = $individual->spouseAndKids(); if ($spouseAndKids != '') { $navigation .= "<li><a href='#spouses'>Spouses</a></li>"; $details .= $spouseAndKids; } $events = $individual->events(); if ($events != '') { $navigation .= "<li><a href='#events'>Events</a></li>"; $details .= $events; } $associates = $individual->associates(); if ($associates != '') { $navigation .= "<li><a href='#associates'>Associates</a></li>"; $details .= $associates; } $notes = $individual->notes(); if ($notes != '') { $navigation .= "<li><a href='#notes'>Notes</a></li>"; $details .= $notes; } $refs = $individual->references(); if ($refs != '') { $navigation .= "<li><a href='#references'>References and Sources</a></li>"; $details .= $refs; } $mm = $individual->multimedia(); if ($mm != '') { $navigation .= "<li><a href='#multimedia'>Multimedia</a></li>"; $details .= $mm; } $meta = $individual->metadata(); if ($meta != '') { $navigation .= "<li><a href='#metadata'>Metadata</a></li>"; $details .= $meta; } // Most people probably won't want this online // $ord = $individual->ordinances(); // if($ord != ''){ // $navigation .= "<li><a href='#ordinances'>Ordinances</a></li>"; // $details .= $ord; // } $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' => 'individual')); }
static function readfile($basefile = NULL, $h = NULL, $w = NULL, $attachment = FALSE) { $mime = obje::mime($basefile); $file = obje::fsPath($basefile); $attachmentName = basename($file); if (!file_exists($file)) { return controller('_404'); } // print these two headers now since if we can't cache the image we'll return immediately header("Content-Description: File Transfer"); header("Content-type: {$mime}"); if (!is_null($h) || !is_null($w)) { switch ($mime) { case 'image/jpeg': $img = imagecreatefromjpeg($file); $outfunc = 'imagejpeg'; break; case 'image/png': $img = imagecreatefrompng($file); $outfunc = 'imagepng'; break; case 'image/gif': $img = imagecreatefromgif($file); $outfunc = 'imagegif'; break; default: // some other image format, just print it full sized return readfile($file); } $origwidth = imagesx($img); $origheight = imagesy($img); // preserve image aspect ratio while making the image fit within the h & w provided // both h & w given if (!is_null($h) && !is_null($w)) { if ($origwidth > $origheight) { $newwidth = $w; $newheight = floor($origheight / ($origwidth / $w)); } else { $newheight = $h; $newwidth = floor($origwidth / ($origheight / $h)); } } else { if (!is_null($h)) { $newheight = $h; $newwidth = floor($origwidth / ($origheight / $h)); } else { if (!is_null($w)) { $newwidth = $w; $newheight = floor($origheight / ($origwidth / $w)); } } } $cachePath = __DIR__ . "/../cache/{$newheight}x{$newwidth}/" . obje::relPath($basefile); if (file_exists($cachePath)) { $file = $cachePath; } else { $tmpimg = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($tmpimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $origwidth, $origheight); $dir = dirname($cachePath); @umask(022); if (!is_dir($dir)) { @mkdir($dir, 0775, TRUE); } if (is_dir($dir)) { @$outfunc($tmpimg, $cachePath); } if (file_exists($cachePath)) { $file = $cachePath; } else { return $outfunc($tmpimg); } } } header("Content-Length: " . filesize($file)); if ($attachment) { header("Content-disposition: attachment; filename={$attachmentName}"); } return readfile($file); }
$route->controller = $public_profile_controller; $route->action = $public_profile_action; $output = controller($route->controller); } } // If no controller found or nothing is returned, give friendly error if ($output['content'] === "#UNDEFINED#") { header($_SERVER["SERVER_PROTOCOL"] . " 406 Not Acceptable"); $output['content'] = "URI not acceptable. No controller '" . $route->controller . "'. (" . $route->action . "/" . $route->subaction . ")"; } // If not authenticated and no ouput, asks for login if ($output['content'] == "" && (!isset($session['read']) || isset($session['read']) && !$session['read'])) { $route->controller = "user"; $route->action = "login"; $route->subaction = ""; $output = controller($route->controller); } $output['route'] = $route; $output['session'] = $session; // 7) Output if ($route->format == 'json') { header('Content-Type: application/json'); if ($route->controller == 'time') { print $output['content']; } elseif ($route->controller == 'input' && $route->action == 'post') { print $output['content']; } elseif ($route->controller == 'input' && $route->action == 'bulk') { print $output['content']; } else { print json_encode($output['content']); }
function lib($realController) { $args = func_get_args(); array_shift($args); return controller($realController, $args); }
<?php $page = model('page'); $gedcom = model('ttgedcom', array(__DIR__ . '/../family.ged')); global $_BASEURL; $page->canonical(linky($_BASEURL . '/map.php')); controller('standard_meta_tags', array(&$gedcom, &$page)); $focusId = $gedcom->getFocusId(); $focus = $gedcom->getIndividual($focusId); $geocoder = model('geocoder'); $eventTypes = array(); $allPlaces = array(); $pretty_gedcom = model('pretty_gedcom', $gedcom->gedcom); foreach ($gedcom->gedcom->getIndi() as $individual) { $indi = model('individual', array($individual, $gedcom->gedcom, $pretty_gedcom)); foreach ($indi->eventsList() as $event) { if ($plac = $event->getPlac()) { $eventTypes[$event->getType()][] = $plac->getPlac(); $allPlaces[$plac->getPlac()][$indi->sortName()] = "<a href='" . $indi->link() . "' title='" . $indi->firstName() . "'>" . $indi->firstBold() . "</a>"; } } } // Find top 5 used places for description $mostUsedPlaces = array(); foreach ($allPlaces as $k => $people) { $mostUsedPlaces[$k] = count($people); } ksort($mostUsedPlaces); if (count($mostUsedPlaces) > 10) { $mostUsedPlaces = array_slice($mostUsedPlaces, -10); }
echo "<td><img width=16 src='{$refcoin->image}'></td>"; echo "<td colspan=3><b>Balance</b></td>"; echo "<td align=right style='font-size: .8em;'><b></b></td>"; echo "<td align=right style='font-size: .9em;'><b>{$balance} {$refcoin->symbol}</b></td>"; echo "</tr>"; //////////////////////////////////////////////////////////////////////////// $total_unpaid = bitcoinvaluetoa($balance + $total_unsold); //$total_unpaid_usd = number_format($total_unpaid*$mining->usdbtc*$refcoin->price, 3, '.', ' '); echo "<tr class='ssrow' style='border-top: 3px solid #eee;'>"; echo "<td><img width=16 src='{$refcoin->image}'></td>"; echo "<td colspan=3><b>Total Unpaid</b></td>"; echo "<td align=right style='font-size: .8em;'></td>"; echo "<td align=right style='font-size: .9em;'>{$total_unpaid} {$refcoin->symbol}</td>"; echo "</tr>"; //////////////////////////////////////////////////////////////////////////// $total_paid = controller()->memcache->get_database_scalar("wallet_total_paid-{$user->id}", "select sum(amount) from payouts where account_id={$user->id}"); $total_paid = bitcoinvaluetoa($total_paid); //$total_paid_usd = number_format($total_paid*$mining->usdbtc*$refcoin->price, 3, '.', ' '); echo "<tr class='ssrow' style='border-top: 1px solid #eee;'>"; echo "<td><img width=16 src='{$refcoin->image}'></td>"; echo "<td colspan=3><b>Total Paid</b></td>"; echo "<td align=right style='font-size: .8em;'></td>"; echo "<td align=right style='font-size: .9em;'><a href='javascript:main_wallet_tx()'>{$total_paid} {$refcoin->symbol}</a></td>"; echo "</tr>"; //////////////////////////////////////////////////////////////////////////// //$delay = 7*24*60*60; $total_earned = bitcoinvaluetoa($total_unsold + $balance + $total_paid); //$total_earned_usd = number_format($total_earned*$mining->usdbtc*$refcoin->price, 3, '.', ' '); echo "<tr class='ssrow' style='border-top: 3px solid #eee;'>"; echo "<td><img width=16 src='{$refcoin->image}'></td>"; echo "<td colspan=3><b>Total Earned</b></td>";
/** * 执行应用程序 * @access public * @return void */ public static function exec() { if (!preg_match('/^[A-Za-z](\\/|\\w)*$/', CONTROLLER_NAME)) { // 安全检测 $module = false; } else { //创建控制器实例 $module = controller(CONTROLLER_NAME); } if (!$module) { // 是否定义Empty控制器 $module = A('Empty'); if (!$module) { E(L('_CONTROLLER_NOT_EXIST_') . ':' . CONTROLLER_NAME); } } // 获取当前操作名 支持动态路由 $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); // 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); // 参数过滤 } } } array_walk_recursive($args, 'think_filter'); $method->invokeArgs($module, $args); } else { $method->invoke($module); } } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); } } catch (\ReflectionException $e) { // 方法调用发生异常后 引导到__call方法处理 $method = new \ReflectionMethod($module, '__call'); $method->invokeArgs($module, array($action, '')); } return; }