/** * Default dispatcher * * @param string $action * @param string $subaction */ public function index($action = '') { template('Install/templates/header')->show('info'); new Menu_Tabs(array('name' => 'install', 'render' => 'content', 'elements' => array(array('label' => t('1. Начало'), 'link' => '', 'active' => check_route('install$')), array('label' => t('2. Проверка'), 'link' => '', 'active' => check_route('check$')), array('label' => t('3. Настройки'), 'link' => '', 'active' => check_route('site$')), array('label' => t('4. Завершение'), 'link' => '', 'active' => check_route('finish$'))))); switch ($action) { case 'check': $tpl = new Template('Install/templates/check'); $tpl->show(); break; case 'site': append('content', '<p class="alert alert-info">' . t('Определите базовые настройки сайта.') . '</p>'); $form = new Form('Install/forms/site'); if ($result = $form->result()) { $site = new Config(SITE . DS . 'site' . EXT); $config = new Config(SITE . DS . 'config' . EXT); $config->site->name = $result->sitename; $site->key or $site->key = md5(md5(time()) + time() + $site->site->name); $result->port or $result->port = 3306; $site->database = array('driver' => config('database.driver'), 'host' => $result->host, 'base' => $result->base, 'user' => $result->user, 'pass' => $result->pass, 'port' => $result->port, 'prefix' => $result->prefix); $db = Db::factory('temp', $site->database); if (!$db->connect()) { if ($result->create_db && $db->connect(FALSE)) { $db->query("CREATE DATABASE `{$site->database->base}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;\n CREATE USER '{$site->database->user}'@'{$site->database->host}' IDENTIFIED BY '{$site->database->pass}';\n GRANT ALL ON `{$site->database->base}`.* TO '{$site->database->user}'@'localhost';\n FLUSH PRIVILEGES;"); } $db->connect(); } if ($db->is_connected) { $site->store(TRUE); $config->store(TRUE); if ($db->import($this->dir . DS . 'cogear.sql', $site->database->prefix)) { redirect(l('/install/finish')); } } else { error(t("Не удалось установить подключение к базе данных."), '', 'content'); } } else { $form->save->label = t('Попробуйте снова'); } $form->show(); break; case 'finish': $tpl = new Template('Install/templates/finish'); $tpl->show(); break; case 'done': // $site = new Config(SITE . DS . 'site' . EXT); // $site->store(TRUE); flash_success(t('Ваш сайт успешно настроен! <p> Данные для входа – логин <b>admin</b> и пароль <b>password</b>.'), '', 'info'); $this->disable(); redirect(); break; default: case 'welcome': $tpl = new Template('Install/templates/welcome'); $tpl->show(); } }
function verbose($text) { if (verboseMode == "true") { append("<i>" . $text . "</i><br />\n"); } if (verboseHead == "true") { echo "<i>" . $text . "</i><br />\n"; } }
/** * * @param type $options */ public function __construct($options = NULL) { parent::__construct($options); if ($this->options->render) { // If $render is set to TRUE make it 'content' TRUE === $this->options->render && ($this->options->render = 'content'); append($this->options->render, new Callback(array($this, 'hookRender'))); } }
/** * Обработка 404 ошибки * * Предложение пользователю создать страницу */ public function hook404() { if ($this->hookRouterRun($this->Router, TRUE)) { flash('event.404', FALSE); } else { if (access('Pages.admin')) { append('content', template('Pages/templates/invitation')); } } }
/** * Add final point and show calculations for system benchmark */ public function finalPoint() { $this->addPoint('system.end'); if (access('development')) { $cogear = getInstance(); $template = new Template('Dev.results'); $template->data = Dev_Gear::humanize($cogear->dev->measurePoint('system')); append('footer', $template->render()); js($this->folder . '/js/inline/debug.js'); } }
/** * Show message * * @param type $body * @param type $title * @param type $class * @param type $region */ public function showMessage($body, $title = NULL, $class = NULL, $region = 'info') { if ($region == 'growl') { $this->template = 'Notify/templates/growl'; $region = 'after'; } $tpl = new Template($this->template); $tpl->body = $body; $tpl->title = $title; $tpl->class = $class; $output = $tpl->render(); return $region ? append($region, $output) : $output; }
/** * Панель управления */ public function admin_action() { $form = new Form("Wysiwyg/forms/config"); $options = new Core_ArrayObject(); $options->type = config('wysiwyg.editor'); $form->type->setValues(self::$editors); $form->object($options); if ($result = $form->result()) { if (isset(self::$editors[$result['type']])) { cogear()->set('wysiwyg.editor', $result['type']); success(t('Конфигурация успешно сохранена.')); } } append('content', $form->render()); }
/** * Control Panel */ public function admin() { $form = new Form("Wysiwyg.config"); $options = new Core_ArrayObject(); $options->editor = config('wysiwyg.editor'); $form->init(); $form->elements->type->setValues(self::$editors); $form->object($options); if ($result = $form->result()) { if (isset(self::$editors[$result['type']])) { cogear()->set('wysiwyg.editor', $result['type']); success('Configuration saved successfully.'); } } append('content', $form->render()); }
public function index($action = NULL) { switch ($action) { case 'file': $tpl = new Template('Upload.file'); $tpl->show(); break; case 'image': $image = new Upload_Image('file', array('preset' => 'post', 'path' => UPLOADS . DS . 'posts' . DS . date('Y/m/d'))); if ($result = $image->upload()) { exit(HTML::img($result)); } break; default: append('content', HTML::a(Url::gear('upload') . '/file?iframe', t('Upload'), array('rel' => 'modal', 'class' => 'button'))); } }
/** * Theme admin page * * @param type $action * @param type $subaction */ public function admin($action = NULL, $subaction = NULL) { $form = new Form('Admin.theme'); if ($form->is_ajaxed) { if ($form->elements->logo->is_ajaxed) { $cogear->set('theme.logo', ''); } if ($form->elements->favicon->is_ajaxed) { $cogear->set('theme.favicon', ''); } } else { $form->setValues(array('logo' => config('theme.logo'), 'favicon' => config('theme.favicon'))); } if ($result = $form->result()) { $result->logo && $cogear->set('theme.logo', $result->logo); $result->favicon && $cogear->set('theme.favicon', $result->favicon); } append('content', $form->render()); }
function process_the_content($the_text) { // split text into an array of sentences $sentenceArray = preg_split('/(?<=[.?!])\\s+(?=[a-z])/i', $the_text); //echo json_encode($sentenceArray); foreach ($sentenceArray as $sentence) { // for each sentence, $this_result = tag_the_content($sentence); } // run the tagger echo json_encode($this_result); echo "\n"; set_time_limit(40); $taggedSpans = ""; // create spans with tag as class foreach ($this_result as $element) { set_time_limit(40); $text = $element[0]; $tag = $element[1]; $span = "<span class=" + $tag + ">" + $text + "</span>"; $taggedSpans . append($span); } echo $taggedSpans; }
function generateXML() { global $keywords, $from, $to, $condition, $seller, $buyingFormats, $handlingTime, $sortBy, $resultsPerPage, $url, $xml, $pageNumber; $length = 0; $i = 0; /*if(isset($_GET["search"])) {*/ $keywords = $_GET["keywords"]; $keyword = urlencode($keywords); $string = "&keywords=" . $keyword; if (isset($_GET["from"]) && $_GET["from"] != "") { $from = $_GET["from"]; append($string, $i, "MinPrice", $from, 0); } if (isset($_GET["to"]) && $_GET["to"] != "") { $to = $_GET["to"]; append($string, $i, "MaxPrice", $to, 0); } if (isset($_GET["condition"])) { $condition = $_GET["condition"]; $length = count($condition); append($string, $i, "Condition", $condition, $length); } if (isset($_GET["buyingFormats"])) { $buyingFormats = $_GET["buyingFormats"]; $length = count($buyingFormats); append($string, $i, "ListingType", $buyingFormats, $length); } if (isset($_GET["returnsAccepted"])) { append($string, $i, "ReturnsAcceptedOnly", "true", 0); } if (isset($_GET["freeShipping"])) { append($string, $i, "FreeShippingOnly", "true", 0); } if (isset($_GET["expeditedShipping"])) { append($string, $i, "ExpeditedShippingType", "Expedited", 0); } if (isset($_GET["maxDays"]) && $_GET["maxDays"] != "") { $handlingTime = $_GET["maxDays"]; append($string, $i, "MaxHandlingTime", $handlingTime, 0); } $sortBy = $_GET["sortBy"]; $string .= "&sortOrder=" . $sortBy; $resultsPerPage = $_GET["resultsPerPage"]; $string .= "&paginationInput.entriesPerPage=" . $resultsPerPage; /*$string .= "&paginationInput.pageNumber=".$_GET["pageNumber"];*/ $url .= $string; $xml = simplexml_load_file($url); //echo $url; //echo "<br>"; }
append("<table border=\"0\" width=\"100%\">\n"); for ($i = 0; $i < count($selection); $i++) { $item = $selection[$i]; append("<tr>"); append("<td width=\"20%\">" . readableTS($item["from"], "date") . "</td>"); append("<td width=\"20%\">von " . readableTS($item["from"], "time") . "<br />bis " . readableTS($item["to"], "time") . "</td>"); append("<td>" . $item["summary"] . "</td>"); append("</tr>"); } append("</table>"); break; case "day": append("<h1>Termine am " . readableTS($_SESSION["calorientation"], "date") . "</h1>"); $base_tpl = file_get_contents(designroot . "/display/item.calendar.list.html"); for ($i = 0; $i < count($selection); $i++) { append(replaceFields($base_tpl, "calendar", $selection[$i])); } /* append("<table border=\"0\" width=\"100%\">\n"); for($i=0;$i<count($selection);$i++){ $item = $selection[$i]; append("<tr>"); append("<td width=\"20%\">".readableTS($item["from"],"date")."</td>"); append("<td width=\"20%\">von ".readableTS($item["from"],"time")."<br />bis ". readableTS($item["to"],"time")."</td>"); append("<td>".$item["summary"]."</td>"); append("</tr>"); } append("</table>"); */ break;
<?php ################################################ ## Robert Schrenk, 2007, phPIMap ## ## This code is distributed under the GNU/GPL ## ################################################ if (phPIMap != "ok") { die("Direct access to this location is not allowed"); } $id = RetrieveVar("id", "0111"); $item = $GLOBALS["restree"]["contact"][$id]; if ($id == "" or $item == "") { append("Sorry, a Contact with this ID does not exist!"); } else { $fields = $GLOBALS["fields"]; $tpl = file_get_contents(designroot . "/display/item.contact.html"); $tpl = replaceFields($tpl, "contact", $item); append($tpl); }
public static function loadAllPaymentsForBill($bill, $lab_config_id) { $billId = $bill->id; $query_string = "SELECT id FROM `payments` WHERE `bill_id` = {$billId}"; $saved_db = DbUtil::switchToLabConfig($lab_config_id); $retVal = query_associative_all($query_string); DbUtil::switchRestore($saved_db); $payments = array(); if (count($retVal != 0)) { foreach ($retVal as $val) { $payments . append(Payment::loadFromId($val, $lab_config_id)); } return $payments; } else { return 0; } }
function page_header($title, $level = 1) { append('info', '<div class="page-header"><h' . $level . '>' . $title . '</h' . $level . '></div>'); title($title); }
/** * * * @param int $position */ public function show($region = 'content', $position = 0, $where = 0) { $position ? inject($region, $this->render(), $position, $where) : append($region, $this->render()); }
<?php ################################################ ## Robert Schrenk, 2007, phPIMap ## ## This code is distributed under the GNU/GPL ## ################################################ if (phPIMap != "ok") { die("Direct access to this location is not allowed"); } $selection = $GLOBALS["restree"]["todo"]; //$selection = filterResources($GLOBALS["restree"]["todo"],"due",TimeStamp(0),">",null); //$selection = sortResources($selection,null,"due","DESC"); for ($i = 0; $i < count($selection); $i++) { $item = $selection[$i]; append("<div><div style=\"width: 100%;\">" . "<a href=\"?module=todo&id=" . $item[internalid] . "\" " . "onclick=\"return AjaxGet(getElement('details'),'?module=todo&" . "id=" . $item[internalid] . "&ajax=1',null,'highlight');\">" . $item["summary"] . "</a>" . "</div></div>"); } /* for($i=0;$i<count($GLOBALS["restree"]["todo"]);$i++) append("<div><div style=\"width: 20%;\">".$GLOBALS["restree"]["todo"][$i]["due"]."</div><div style=\"width: 79%;\">".$GLOBALS["restree"]["todo"][$i]["summary"]."</div></div>"); */
/** * This method process nested function calls that may be in the arguments * passed into a higher level function. * * @param String|\Tbm\Peval\Types\String $arguments * * @throws \Tbm\Peval\EvaluationException * @return \Tbm\Peval\Types\String The arguments with any nested function calls evaluated. * */ public function processNestedFunctions(string $arguments) { $evaluatedArguments = new String(); // Process nested function calls. if ($arguments->length() > 0) { $argumentsEvaluator = new Evaluator($this->quoteCharacter, $this->loadMathVariables, $this->loadMathFunctions, $this->loadStringFunctions, $this->processNestedFunctions); $this->argumentsEvaluator->setFunctions(getFunctions()); $this->argumentsEvaluator->setVariables(getVariables()); $this->argumentsEvaluator->setVariableResolver(getVariableResolver()); $tokenizer = new ArgumentTokenizer($arguments, EvaluationConstants::FUNCTION_ARGUMENT_SEPARATOR); $evaluatedArgumentList = new ArrayList(); while ($tokenizer . hasMoreTokens()) { $argument = $tokenizer->nextToken()->trim(); try { $argument = $argumentsEvaluator->evaluate1($argument); } catch (Exception $e) { throw new EvaluationException($e->getMessage(), $e); } $evaluatedArgumentList->add($argument); } $evaluatedArgumentIterator = $evaluatedArgumentList->iterator(); while ($evaluatedArgumentIterator->valid()) { if ($evaluatedArguments->length() > 0) { $evaluatedArguments->append(EvaluationConstants::FUNCTION_ARGUMENT_SEPARATOR); } $evaluatedArgumentIterator->next(); $evaluatedArgument = (string) $evaluatedArgumentIterator->current(); $evaluatedArguments . append($evaluatedArgument); } } return $evaluatedArguments; }
<?php $newNodeId = $_POST['newNodeId']; $parentNodeId = $_POST['parentNodeId']; include 'dbConnect.inc'; include 'append.inc'; if (append($newNodeId, $parentNodeId)) { echo 'true'; } else { echo 'false'; }
public function admin($action = 'active') { new Menu_Tabs('gears', Url::gear('admin') . 'gears'); d('Admin Gears'); $all_gears = $this->getAllGears(); $active_gears = $this->getActiveGears(); $inactive_gears = array_diff($all_gears, $active_gears); $doaction = NULL; if (!empty($_REQUEST['action-top'])) { $doaction = $_REQUEST['action-top']; } if (!empty($_REQUEST['action-bottom'])) { $doaction = $_REQUEST['action-bottom']; } if (!empty($_REQUEST['action'])) { $doaction = $_REQUEST['action']; } if ($doaction && isset($_REQUEST['gears'])) { $gears = $this->filter_gears($_REQUEST['gears']); switch ($doaction) { case 'activate': $this->activate_gears($gears); break; case 'deactivate': $this->deactivate_gears($gears); break; case 'update': $this->update_gears($_REQUEST['gears']); break; } back(); } switch ($action) { case 'index': case 'active': $gears = array(); foreach ($active_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = TRUE; $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'all': $gears = array(); foreach ($all_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'inactive': $gears = array(); foreach ($inactive_gears as $gear => $class) { if (class_exists($class)) { $object = new $class(); $object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))); $gears[$object->package][$gear] = $object; } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; case 'new': $gears = array(); $new_period = 60 * 60 * 7; // Gears that has been updated last week are to be new foreach ($all_gears as $gear => $class) { $object = new $class(); if (time() - $object->file->getMTime() <= $new_period) { if (!($object->active = ($object->package == 'Core' or $object->type == Gear::CORE or in_array($gear, array_keys($active_gears))))) { $gears[$object->package][$gear] = $object; } } } $tpl = new Template('Gears.list'); $tpl->packages = $gears; $tpl->link = Url::gear('admin') . '/gears'; append('content', $tpl->render()); break; } }
public function getSavePath($depth = 0) { // error: if (!$this->id) { throw new CException("getSavePath must be called only after this object has an id"); } if ($depth != 0 && $depth != -1) { throw new CException("getSavePath depth is currently only 0 or -1"); } $path = append($this->basepath, $this->path); if ($depth == -1) { array_pop($path); } return implode('.', $path); }
/** * Show GoBack button hook */ public function showGoBackButton() { $link = $this->session->history->getIterator()->current(); append('content', HTML::a($link, t("← Go back"), array('class' => 'button goback'))); }
function checkAndAppend(&$attributes, &$object, $name, $pre = null, $post = null) { if (!isset($object->{$name})) { return; } $value = $pre . trim($object->{$name}) . $post; append($attributes, ' ', trim($value)); }
append(" <td class=\"calweeklink\"><a href=\"?module=calendar&calorientation=" . $orient . "&calrange=week\" onclick=\"return " . "AjaxGet(getElement('details'),'?module=calendar&" . "calorientation=" . $orient . "&calrange=week&ajax=1',null,null);\"><i>" . date("W", mktime(0, 0, 0, date("m", $time), $daycount, date("Y", $time))) . "</i></a></td>\n"); $inweek = 0; } if ($i >= $first_weekday && $daycount <= $days) { if ($hasevent[$daycount]) { $orient = date("YmdHis", mktime(0, 0, 0, date("m", $time), $daycount, date("Y", $time))); $class = "hasevent"; $daylink = "<a href=\"?module=calendar&calorientation=" . $orient . "&calrange=day\" onclick=\"return AjaxGet(getElement('details'),'?module=calendar&" . "calorientation=" . $orient . "&calrange=day&ajax=1',null,'highlight');\">" . $daycount++ . "</a>"; } else { $daylink = $daycount++; $class = "noevent"; } append(" <td class=\"" . $class . "\">" . $daylink . "</td>\n"); } else { append(" <td class=\"empty\"> </td>\n"); } $inweek++; $i++; } append(" </tr>\n"); append("</table>\n"); /* for($i=0;$i<count($selection);$i++){ $item = $selection[$i]; append("<div><div style=\"width: 100%;\">".$item["summary"]."</div></div>"); } */ /* for($i=0;$i<count($GLOBALS["restree"]["calendar"]);$i++) append("<div><div style=\"width: 40%;\">".$GLOBALS["restree"]["calendar"][$i]["from"]." - ".$GLOBALS["restree"]["calendar"][$i]["to"]."</div><div style=\"width: 59%;\">".$GLOBALS["restree"]["calendar"][$i]["summary"]."</div></div>"); */
<?php include 'osrmlib.php'; include 'input.php'; append("from;to;status;distance;time", $out); /* * Distance and time between all listed points */ for ($i = 0; $i < $size; $i++) { for ($j = 0; $j < $size; $j++) { if ($i == $j) { continue; } $arrres = request($csv[$i]["node"], $csv[$i]["lat"], $csv[$i]["lon"], $csv[$j]["node"], $csv[$j]["lat"], $csv[$j]["lon"]); $res = implode(";", $arrres); append($res, $out); } } function append($message, $file = 'log.txt') { $handle = fopen($file, 'a'); if (!$handle) { echo "File cannot be opened"; } $message .= PHP_EOL; fwrite($handle, $message); fclose($handle); }
/** * 处理get_peers请求 * @param array $msg 接收到的get_peers请求数据 * @param array $address 对端链接信息 * @return void */ function on_get_peers($msg, $address) { global $nid; //write(date('Y-m-d H:i:s', time()) . " on_get_peers\n"); // 获取info_hash信息 $infohash = $msg['a']['info_hash']; // 获取node id $id = $msg['a']['id']; // 生成回复数据 $msg = array('t' => $msg['t'], 'y' => 'r', 'r' => array('id' => $nid, 'nodes' => Base::encode_nodes(get_nodes()), 'token' => substr($infohash, 0, 2))); // 将node加入路由表 append(new Node($id, $address[0], $address[1])); // 向对端发送回复数据 send_response($msg, $address); }
/** * @return The hash code of this secure hash. */ public function hashCode() { return new HashCodeBuilder(78543919, 483927) . append(hashValue) . append(randomSalt) . toHashCode(); }
/** * Управление элементами отдельного меню * * @param mixed $id */ public function items_action($menu_id, $id = NULL) { $this->theme->hookAdminMenu(); $this->hookAdminMenu(); if ($menu = menu($menu_id)) { append('content', '<div class="page-header"><h2>' . $menu->name . '</h2></div>'); } else { return event('empty'); } $pills = new Menu_Pills(array('name' => 'admin.menu.items', 'render' => FALSE, 'elements' => array(array('label' => icon('list') . ' ' . t('Список пунктов'), 'link' => l('/admin/theme/menu/' . $menu_id . '/items')), array('label' => icon('plus') . ' ' . t('Добавить'), 'link' => l('/admin/theme/menu/' . $menu_id . '/item/add'), 'class' => 'fl_r'), array('label' => icon('pencil') . ' ' . t('Редактировать'), 'link' => l('/admin/theme/menu/' . $menu_id . '/item/' . $this->router->getSegments(5)), 'access' => check_route('admin/theme/menu/\\d+/item/\\d+'), 'class' => 'fl_r')))); append('content', $pills->render()); if (NULL === $id) { $handler = new Menu_Db_Item(); $handler->menu_id = $menu->id; if ($items = $handler->findAll()) { $tree = new Db_Tree_DDList(array('items' => $items, 'saveUri' => l('/admin/theme/menu/ajax/saveItemsTree/'))); } else { return event('empty'); } } else { $form = new Form('Menu/forms/item'); $item = new Menu_Db_Item(); if ($id != 'add' && is_numeric($id)) { $item->id = $id; if ($item->find()) { $form->object($item); } else { return event('empty'); } } else { $form->remove('delete'); $item->menu_id = $menu_id; } $form->pid->setValues($item->getSelectValues('label')); if ($result = $form->result()) { if ($result->delete && $item->delete()) { flash_success(t('Элемент меню <b>«%s»</b> был удалён!', $item->label), '', 'growl'); redirect(l('admin/theme/menu/' . $menu_id . '/items')); } $item->object()->extend($result); if ($id !== 'add') { $item->branching(); } if ($item->save()) { flash_success($id == 'add' ? t('Элемент меню <b>«%s»</b> успешно создан!', $item->label) : t('Элемент меню <b>«%s»</b> успешно отредактирован!', $item->label), '', 'growl'); redirect(l('admin/theme/menu/' . $menu_id . '/items')); } } $form->show(); } }
/** * Show */ public function show($region = NULL, $position = 0, $where = 0) { !$region && ($region = $this->options && is_string($this->options->render) ? $this->options->render : 'content'); $position ? inject($region, $this->render(), $position, $where) : append($region, $this->render()); }