public function init_flow_handle(Flow $flow) { if (Mobile::is_mobile()) { $vars = $flow->vars(); mb_convert_variables('utf-8', 'utf-8,SJIS-win', $vars); $flow->vars($vars); } }
public function init_flow_handle(Flow $flow) { $map = $flow->handled_map(); $ref = new ReflectionMethod($map['class'], $map['method']); $doc = $ref->getDocComment(); if (stripos($doc, '@login_required') !== false) { $flow->a('user', 'require', true, true); } }
function run() { global $Templates, $DB, $Controller; $_REQUEST->setType('item', 'numeric'); $PERPAGE = 5; if ($_REQUEST['item']) { $obj = $Controller->{$_REQUEST['item']}; $content = $obj->display(false, true, true, true); } else { $QUEUE = $this->ID; $COUNT = (int) $DB->flow->count(array('queue~' => $QUEUE), 'id'); $pagination = Pagination::getRange($PERPAGE, $COUNT); $Objects = Flow::retrieve('News', $PERPAGE, false, false, false, $pagination['range']['start']); $content = ''; $first = true; foreach ($Objects as $obj) { $content .= '<li' . ($first ? '' : ' class="cols"') . '>' . $obj->display(false, $first, true) . '</li>'; $first = false; } $content = '<ul>' . $content . '</ul>' . $pagination['links']; } $r = '<h1>FlowView</h1>' . Design::row(array(Design::column('<div class="padded">' . $content . '</div>', 8, true, true, true), Design::column('Möjlighet att följa nyheterna via RSS kommer... ', 4, false, true, true)), true); $this->setContent('main', $r); $this->setContent('menu', $this->submenu()); $Templates->yweb('empty')->render(); }
public function run() { $dispatcher = Flow::app()->getComponent('url_router'); $action_name = $dispatcher->getAction(); $method_name = $dispatcher->getMethod(); $action_name = ucfirst($action_name) . "Controller"; // 检测是否存在 if (empty(FLow::$classMap[$action_name])) { if (DEV_MODE) { header("HTTP/1.1 404 Not Found"); throw new Exception("Controller {$action_name} Not Found"); } else { header("HTTP/1.1 404 Not Found"); die; } } $action = Flow::app()->createComponent(array('class' => $action_name, 'view' => Flow::app()->view_engine, 'request' => Flow::app()->getComponent('request'))); $action->beforeController(); $method_name = "action" . $method_name; // 检测方法 if (!method_exists($action, $method_name)) { if (DEV_MODE) { header("HTTP/1.1 404 Not Found"); throw new Exception("Controller {$action_name} has No {$method_name} Method"); } else { header("HTTP/1.1 404 Not Found"); die; } } // 执行方法 $action->{$method_name}(); }
public function test_getTableName() { $func = function () use($a) { echo 'Hello world!'; }; $this->assertEquals(BILLING_DB_PMDB . '.flow', Flow::getTableName()); }
/** * 负责分发错误到日志记录 */ public static function errorHandler($errno, $errstr, $errfile, $errline, $obj) { restore_error_handler(); restore_exception_handler(); // 处理@符号的情况 if (!(error_reporting() !== 0 && $errno)) { return; } switch ($errno) { case E_NOTICE: case E_USER_NOTICE: $errors = "Notice"; break; case E_WARNING: case E_USER_WARNING: $errors = "Warning"; break; case E_ERROR: case E_USER_ERROR: $errors = "Fatal Error"; break; default: $errors = "Unknown"; break; } Flow::Log()->clear(); Flow::Log()->error(sprintf("%s in %s on line %d", $errstr, $errfile, $errline)); self::dieErrorLogs(); return false; }
/** * 两种加载模式 * @param $class_name * @throws Exception */ public static function autoLoadHandler($class_name) { if (isset(Flow::$classMap[$class_name])) { include Flow::$classMap[$class_name]; return; } if (strpos($class_name, "_") !== false) { $paths = explode("_", $class_name); if (isset($paths[0])) { if ($paths[0] == "F") { $paths[0] = "system"; } $paths[0] = Flow::getPathOfAlias($paths[0]); $lastp = $paths[count($paths) - 1]; unset($paths[count($paths) - 1]); foreach ($paths as $i => $path_seg) { if ($i != 0) { $paths[$i] = strtolower($path_seg); } } $file_path = implode(DIRECTORY_SEPARATOR, $paths) . DIRECTORY_SEPARATOR . $lastp . ".php"; if (DEV_MODE) { if (!file_exists($file_path)) { throw new Exception("Class {$class_name} LoadError" . PHP_EOL . "File {$file_path} Not Existed"); } } include $file_path; } } }
/** * パッケージのメディアへのURLを定義する * @param string $url パッケージのメディアと認識されるURL */ public static final function config_package_media_url($url) { if (substr($url, 0, 1) == "/") { $url = substr($url, 1); } if (substr($url, -1) == "/") { $url = substr($url, 0, -1); } self::$package_media_url = $url; }
public function actionIndex() { FLow::app()->request->getText("a"); $entry_acm = Flow::app()->acf->table("entry"); $comicnodes = $entry_acm->where("cat='cartoon'")->order("publish_date desc, `dsr_score` desc")->limit("30")->findall(); $movienodes = $entry_acm->where("cat='movie'")->order("publish_date desc, `dsr_score` desc")->limit("30")->findall(); $this->assign("comicnodes", $comicnodes); $this->assign("movienodes", $movienodes); $this->display(); }
public function stopAnalyze() { $flow = new Flow($this); $this->flows[] = $flow; $flow->flow(); $fieldSets = []; foreach ($this->flows as $flow) { $fields = $flow->getFields(); foreach ($fieldSets as $fieldSet) { if ($fieldSet == $fields) { continue 2; } } $fieldSets[] = $fields; } $this->fields = $fieldSets; echo "\rFinished analyzing {$this->name} (memory: " . round(memory_get_usage() / 1024, 2) . " KB)\n"; unset($this->instr); gc_collect_cycles(); echo "Freed resources (memory: " . round(memory_get_usage() / 1024, 2) . " KB)\n"; }
public function flow_verify(Flow $flow) { if (!$flow->isSessions("_onetimeticket") || $flow->inVars("_onetimeticket") !== $flow->inSessions("_onetimeticket")) { $flow->vars("_onetimeticket", $flow->inSessions("_onetimeticket")); throw new Exception("invalid ticket"); } }
/** * This is the callback function for ALL flows that the flow module responds to. * All flow processing starts here. * * Request Params supported: * _fid - the id of the flow * _faction - the name of the action that the user is taking * */ function requestAction() { $url = parse_url($this->getRequest()->getRequestUri()); $uri = $url['path']; $flowFile = $this->getFlowFile(); // Pull the flowId out of the request $flowId = $this->_getParam('_fid'); $action = $this->_getParam('_faction'); $flow = null; $session = new Zend_Session_Namespace('flow'); // If the flowId exists on the request then try to continue the existing flow if (!empty($flowId)) { $flow = unserialize($session->{$flowId}); $this->flow = $flow; } // If no existing flow then create a new one and stick it in the session if (empty($flow)) { $flow = new Flow($flowFile, $uri, $this, $this->_request->getControllerName()); $this->flow = $flow; $flow->process("__INIT__"); } // Have to always set the controller, because we serialize it but the next request will have a // Different one $flow->controller = $this; $flowId = $flow->id; // If the user actually tried to do something other than refresh the page if (!empty($action)) { // Process the action $flow->process($action); // Store the result in the session $session->{$flowId} = serialize($flow); // Redirect so that the user can refresh, without warnings from the browser $this->_helper->redirector->gotoUrl($uri . "?_fid={$flow->id}"); } // Otherwise, we will just render using the same state info. // Store the result in the session $session->{$flowId} = serialize($flow); $flow->render(); $session->{$flowId} = serialize($flow); }
function run() { global $Templates, $CONFIG, $DB, $Controller; $_REQUEST->setType('flash', 'any'); if ($_REQUEST->valid('flash')) { Flash::create($_REQUEST['flash'] . '_flash_1', $_REQUEST['flash']); } $_REQUEST->setType('addToConfig', 'any'); if ($_REQUEST->valid('addToConfig')) { $CONFIG->Frontpage->setType('NewsItems', 'text'); $CONFIG->Frontpage->setDescription('NewsItems', 'Number of news items displayed'); $CONFIG->Frontpage->NewsItems = 5; } $content = ''; $newsNum = $CONFIG->Frontpage->NewsItems; if (!is_numeric($newsNum) || $newsNum < 1 || $newsNum > 30) { $newsNum = 5; } $newsNum = 3; /* Retrive news objects */ if ($newsNum > 0) { $newsObj = Flow::retrieve('News', $newsNum, false, false, false, 0, true); } /* <<< New flowing design >>> */ foreach ($newsObj as $news) { $content .= $news->display('new'); } $mlForm = new Form('mailListForm'); $ml = $mlForm->quick(null, __('Send'), new Input('Email', 'mlmail')); $r = '<div id="intro"> <div class="lcol"><img src="' . $Templates->current->webdir . 'images/intro/IMG_0817.jpg" width="400" alt="Lihkoren" /></div> <div class="rcol"><p>Linköpings Studentsångarförening Lihkören är en manskör som verkar vid Linköpings universitet, under ledning av director musices Hans Lundgren. Kören bildades 1972 av studenter vid dåvarande Linköpings Högskola. Lihkören uttalas som det smakar. Kören framför främst nordisk och europeisk musik, delvis från den traditionella manskörsrepertoaren men även nyskriven musik. Glimten i ögat och den goda kontakten med publiken präglar konserterna.<br>Väl mött.</p></div> <img src="' . $Templates->current->webdir . 'images/rand_top.png" alt="pagesplit" class="pagesplit" /> </div> <div id="fbottom"> <div class="lcol"> <div class="lbox coming"><h1 class="icn-hdr"><span class="icn icn-coming"></span>' . __('Kommande händelser') . '</h1> <p>Kommande händelser i kalendern.</p> </div> <div class="lbox maillist"><h1 class="icn-hdr"><span class="icn icn-mail"></span>' . __('Nyhetsbrev') . '</h1> <p class="pre">Vill du få information om kommande konserter och andra arrangemang med Lihkören?</p> ' . $ml . ' <p>Du kommer då att få ett e-brev som du måste svara på för att bekräfta att du vill att informationen ska skickas till dig</p> </div> </div> <div class="rbox news"><h1 class="icn-hdr"><span class="icn icn-news"></span>' . __('Nyheter') . '</h1>' . $content . '<a href="/flowView?q=News">' . __('View all news') . '</a></div> </div>'; /* dump($Templates->current->webdir); */ $this->setContent('main', $r); $Templates->render(); }
/** * Flowのモジュール * @param Flow $flow */ public function flow_verify(Flow $flow) { if (!$flow->is_sessions("_onetimeticket") || $flow->in_vars("_onetimeticket") !== $flow->in_sessions("_onetimeticket")) { $flow->vars("_onetimeticket", $flow->in_sessions("_onetimeticket")); return false; } return true; }
/** * 汇报到log里面 */ private function _reportLogger() { foreach ($this->_stat_entries as $stat_name => $stat_entry) { $log_row = "[{$stat_name}]"; if (isset($stat_entry['end_time_ms'])) { $stat_entry['cost'] = $stat_entry['end_time_ms'] - $stat_entry['start_time_ms']; unset($stat_entry['end_time_ms']); unset($stat_entry['start_time_ms']); } foreach ($stat_entry as $entry_key => $entry_val) { $log_row .= "{$entry_key} {$entry_val} "; } Flow::Log()->debug($log_row); } }
private function _routeRequest() { $action = isset(Flow::$cfg['default_controller']) ? Flow::$cfg['default_controller'] : "index"; $method = 'index'; $base_path = Flow::app()->basePath; $uri = $_SERVER['REQUEST_URI']; if (strpos($uri, $base_path) === 0) { $uri = substr($uri, strlen($base_path)); } // 如果有pattern 用pattern的匹配 if (!empty($this->rewrite_rules)) { foreach ($this->rewrite_rules as $url_pattern => $dest) { $uri = preg_replace($url_pattern, $dest, $uri); break; } } $uri_parsed = parse_url($uri); if (empty($uri_parsed['path'])) { $uri_parsed['path'] = '/'; } // 按斜杠分拆 $params = explode("/", trim($uri_parsed['path'], "/\\")); if (!empty($params[0])) { $action = $params[0]; if (strpos($action, '.') !== false) { $action = 'Main'; } } if (!empty($params[1])) { $method = $params[1]; } if (!empty($_GET['action'])) { $action = $_GET['action']; } if (!empty($_GET['method'])) { $method = $_GET['method']; } // 多余的参数设置到请求里面 foreach ($params as $i => $j) { if ($i % 2 == 1 && $i != 0) { if ($params[$i - 1] != "") { $_GET[$params[$i - 1]] = $params[$i]; } } } $this->action = $action; $this->method = $method; }
/** * 包含数据模型 * @param $modleName 模型的名字 结尾需要是.class.php */ function M($modelName) { global $m; isset($m) ? $m : ($m = array()); if (!array_key_exists($modelName, $m)) { $t = (include_once APP_BASE . "/models/" . $modelName . ".class.php"); if (!$t) { throw new FlowException("模型" . $modelName . "载入失败, 没有文件 " . APP_BASE . "/module/" . $modelName . ".class.php"); } else { Flow::Log()->i("模型" . $modelName . "载入成功"); } $m[$modelName] = new $modelName($modelName); } //$m->setFormName($modleName); return $m[$modelName]; }
public function send($from, $to, $subject, $content) { $from = strip($from); if (is_array($to)) { $to = implode(";", $to); } $to = strip($to); $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: text/html; charset=gbk' . "\n"; //$headers .= "To: $to \n"; $headers .= 'From: ' . $from . "\n"; $subject = "=?gbk?B?" . base64_encode($subject) . "?="; $result = mail($to, $subject, $content, $headers); if ($result) { return true; } else { Flow::Log()->w($result); return false; } }
/** * 依据配置文件数组创建一个类 * array('class'=>'xxxxx','import'=>'lib.go', 'a'=>'b') * 其他将被注入到参数中 * * @param $config * @return mixed * @throws Exception */ public function createComponent($config) { if (!is_array($config)) { return $config; } if (empty($config['class'])) { return $config; } if (!empty($config['import'])) { foreach ($config['import'] as $imt) { Flow::import($imt); } } $class_name = $config['class']; $comp = new $class_name(); unset($config['class']); unset($config['import']); foreach ($config as $key => $val) { $comp->{$key} = $this->createComponent($val); } $comp->init(); return $comp; }
<?php /** * Copyright 2013 princehaku * * FileName : index.php * Created on : 13-3-19 , 下午7:01 * Author : zhongwei.bzw */ define("DEV_MODE", true); define("APP_PATH", dirname(__FILE__)); define("FLOW_PATH", dirname(dirname(dirname(__FILE__))) . "/flowphp/"); include FLOW_PATH . "flow.php"; $flow = new Flow(); $flow->run('cli');
$cards = $cardObj->create(); $cards = $cardObj->shuffle($cards); $groups = $cardObj->Dealer(count($players), $cards); // suit $suit = $cardObj->suit(); echo json_encode($groups) . '<br>'; //$groups = json_decode('[[14,3,47,6,20,33,17,51,9,11,29],[21,13,7,5,34,8,40,10,30,12,31],[32,16,43,28,45,42,15,36,26,25],[23,38,52,22,39,27,2,44,24,49],[35,41,48,4,37,1,19,46,50,18]]'); // testing foreach ($groups as $key => $val) { echo '[' . $players[$key] . ']  '; sort($val); $cardObj->watch_card($val); } echo '<hr>'; // 遊戲開始 $flow = new Flow(); $tab = new Table(); $flow::$members = count($players); // 第一手 $card = $flow->fire($groups); $tab->add($card); echo $players[$flow->now_player()] . ' : ' . $suit[$card] . '<br>'; for ($i = 0; $i < 55; $i++) { $flow->move_next(); $card = $flow->run($tab->get_on_table()); if (!$card) { echo '[' . $i . '] ' . $players[$flow->now_player()] . ' : PASS ! <br>'; continue; // 沒牌了 } if ($card > 0) {
$messages = array(); // foreach(R(new TwitterAPI())->friends_timeline() as $message) $messages[] = Message::parse($message); foreach (R(new WassrAPI())->friends_timeline() as $message) { $messages[] = Message::parse($message); } $messages = omerge($messages, "key"); rosort($messages, "created_at"); return $messages; } public static function update($text) { R(new TwitterAPI())->update($text); R(new WassrAPI())->update($text); } } $flow = new Flow(); if ($flow->isPost() && $flow->isVars("text")) { Message::update($flow->inVars("text")); $flow->redirect_self(); } $flow->vars("messages", Message::friends_timeline()); //$flow->output(__FILE__); exit; ?> <rt:template> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <form method="post">
<?php include_once dirname(__FILE__) . "/__settings__.php"; application_settings(__FILE__, null, dirname(dirname(__FILE__))); import("core.Log"); import("core.Flow"); import("core.File"); import("ext.Test"); import("ext.Setup"); header_output_text(); $flow = new Flow(); if ($flow->isVars("class")) { test($flow->inVars("class"), $flow->inVars("method"), $flow->inVars("block")); } else { if (!$flow->isVars("full")) { Test::exec_type(Test::FAIL); } tests(root_path()); }
protected function _beforeQuery($sql) { Flow::Log()->debug("[SQL] " . $sql); return; }
public function actionIndex() { header('Location:' . Flow::app()->basePath . '/test/b'); $this->display(); }
public static function updateApplication($id) { $detail = Claims_App::find($id); $detail->status = Flow::next(); $detail->save(); }
public function handler(array $urlconf = array()) { if (empty($urlconf)) { $urlconf = array("^/(.+?)/create[/]*\$" => "method=do_create", "^/(.+?)/update[/]*\$" => "method=do_update", "^/(.+?)/detail[/]*\$" => "method=do_detail", "^/(.+?)/drop[/]*\$" => "method=do_drop", "^/(.+?)[/]*\$" => "method=do_find", "" => "method=models"); } parent::handler($urlconf); return $this; }
function flowList() { $r = array(); $flows = Flow::flows(); foreach ($flows as $f) { $r[] = '<span class="fixed-width">' . $f . '</span><div class="tools">' . icon('small/pencil', __('Edit flow'), url(array('edit' => $f->ID))) . icon('small/feed', __('View flow'), $f->link) . '</div>'; } return listify($r); }
/** * URLのパターンからTemplateを切り替える * @param array $urlconf */ public function handler(array $urlconf = array()) { $params = array(); foreach ($urlconf as $pattern => $conf) { if (is_int($pattern)) { $pattern = $conf; $conf = null; } if (preg_match("/" . str_replace(array("\\/", "/", "__SLASH__"), array("__SLASH__", "\\/", "\\/"), $pattern) . "/", $this->args(), $params)) { if ($conf !== null) { if (is_array($conf)) { if (isset($conf["class"])) { $this->class = $conf["class"]; } if (isset($conf["method"])) { $this->method = $conf["method"]; } if (isset($conf["template"])) { $this->template = $conf["template"]; } if (isset($conf["name"])) { $this->name = $conf["name"]; } } else { $this->dict($conf); } } self::$match_pattern = empty($this->name) ? $params[0] : $this->name; if (!empty($this->class)) { if (false !== strrpos($this->class, ".") || !class_exists($this->class)) { $this->class = Rhaco::import($this->class); } if (empty($this->method) && !empty($pattern)) { $method_patterns = array(); $patterns = explode("/", $pattern); if ($patterns[0] == "^") { array_shift($patterns); } foreach ($patterns as $p) { if (!preg_match("/[\\w_]/", $p)) { break; } $method_patterns[] = $p; } if (!empty($method_patterns)) { $this->method = implode("_", $method_patterns); } } } if (empty($this->method) && !empty($this->template)) { $obj = new self(); $obj->copy_module($this, true); $obj->template($this->template); } else { $method = empty($this->method) ? "index" : $this->method; if (!method_exists($this->class, $method)) { throw new Exception("Not found " . $this->class . "::" . $method); } array_shift($params); try { $class = $this->class; $action = new $class(); $action->copy_module($this, true); if ($action instanceof self) { $action->handled(); } $obj = call_user_func_array(array($action, $method), $params); } catch (Exception $e) { Log::debug($e); $on_error = Rhaco::def("core.Flow@on_error"); if ($on_error === null) { throw $e; } if (isset($on_error[0])) { Http::status_header((int) $on_error[0]); } if (isset($on_error[2])) { Http::redirect($on_error[2]); } if (isset($on_error[1])) { $template = new Template(); $template->output($on_error[1]); } exit; } } if ($obj instanceof self) { $obj = $obj->templ(); } if (!$obj instanceof Template) { throw new Exception("Forbidden " . $this->args()); } $obj->path($this->path()); $obj->url($this->url()); $this->templ = $obj; if (!$this->isTemplate()) { $this->template($obj->filename()); } if (!$this->isTemplate()) { $cs = explode(".", $this->class); $class = array_pop($cs); $class = implode("/", $cs) . (!empty($cs) ? "/" : "") . strtolower($class[0]) . substr($class, 1); $this->template($class . "/" . $method . ".html"); } return $this; } } throw new Exception("no match pattern"); }
/** * application xmlを実行する * @param string $path xmlファイルのパス */ function app($path = null) { if ($path === null) { list($debug) = debug_backtrace(false); $path = $debug["file"]; } Flow::load($path); }