/** * @param $id * @return \Delivery\Entity\User */ public function findUser($id) { if ($this->cache->has($id)) { $entity = $this->cache->get($id); } else { $entity = $this->repository->find($id); } return $entity; }
function EditCSV() { $period = get('period', 'all'); $date_state = ""; if ($period != 'all') { $from = get('from_date', ''); $to = get('to_date', ''); if ($from && $to) { $from = explode('-', $from); $to = explode('-', $to); if (count($to) > 2 && count($from) > 2) { $from_date = mktime(0, 0, 0, $from[1], $from[2], $from[0]); $to_date = mktime(23, 59, 59, $to[1], $to[2], $to[0]); } } $date_state = " AND (o.order_date BETWEEN '" . $from_date . "' AND '" . $to_date . "')"; } $filename = $this->name . '_' . date('Y-m-d') . '.csv'; $data = $this->str('art') . ';' . $this->str('art2') . ';' . $this->str('name') . ';' . $this->str('manufacturer') . ';' . $this->str('catalog') . ';' . $this->str('order_id') . ';' . $this->str('order_date') . ';' . $this->str('quantity') . ';' . $this->str('price') . ';' . $this->str('customer_price') . "\n"; $client_id = get('client_id', NULL); if (isset($client_id)) { $rows = $this->getRows("SELECT p.art, p.art2, p.name, m.name as manufacturer, t.name as catalog, o.id as order_id, DATE_FORMAT(FROM_UNIXTIME(o.order_date),'%Y-%m-%d') as order_date, c.quantity, c.price, c.customer_price\n FROM orders AS o, cart AS c, elem_product AS ep\n LEFT JOIN products AS p ON c.product_id = p.id\n LEFT JOIN manufacturers AS m ON m.id = p.manufacturer_id\n LEFT JOIN tree AS t ON ep.pid = t.id\n LEFT JOIN auth_users AS c1 ON o.client_id=c1.id\n WHERE c.order_id=o.id AND ep.id=p.id AND o.status IN ('Delivered', 'ReadyPaid') " . $date_state . " AND o.client_id=" . $client_id . " ORDER BY o.order_date"); } else { $sql = "SELECT p.art, p.art2, p.name, m.name as manufacturer, t.name as catalog, o.id as order_id, DATE_FORMAT(FROM_UNIXTIME(o.order_date),'%Y-%m-%d') as order_date, c.quantity, c.price, c.customer_price\n FROM orders AS o, cart AS c, elem_product AS ep\n LEFT JOIN products AS p ON c.product_id = p.id\n LEFT JOIN manufacturers AS m ON m.id = p.manufacturer_id\n LEFT JOIN tree AS t ON ep.pid = t.id\n WHERE c.order_id = o.id AND ep.id=p.id AND o.status IN ('Delivered', 'ReadyPaid') " . $date_state . " ORDER BY o.order_date"; $rows = $this->getRows($sql); } if ($rows) { foreach ($rows as $i => $row) { $data .= $row['art'] . ';' . $row['art2'] . ';' . $row['name'] . ';' . $row['manufacturer'] . ';' . $row['catalog'] . ';' . $row['order_id'] . ';' . $row['order_date'] . ';' . $row['quantity'] . ';' . $row['price'] . ';' . $row['customer_price'] . "\n"; } } $zip = new ss_zip('', 6); $zip->add_data($filename, $data); $zip->save($filename . ".zip", 'd'); }
function ElemInit() { $columns = sql_getRows("SHOW COLUMNS FROM " . $this->elem_table . "", true); if (!isset($columns['footer_text_radio'])) { sql_query("ALTER TABLE " . $this->elem_table . " ADD footer_text_radio TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0 - редактор текста; 1 - html-код баннера'"); } if (!isset($columns['footer_title'])) { sql_query("ALTER TABLE {$this->elem_table} ADD footer_title VARCHAR( 255 ) NOT NULL COMMENT 'Название кнопки Подробнее';"); } if (!isset($columns['footer_title_link'])) { sql_query("ALTER TABLE {$this->elem_table} ADD footer_title_link VARCHAR( 255 ) NOT NULL COMMENT 'Ссылка на кнопке Подробнее';"); } $id = (int) get('id'); if ($id) { $infoblock_end = sql_getRow("SELECT * FROM " . $this->elem_table . " WHERE id = " . $id); if ($infoblock_end['footer_text_radio']) { $this->elem_fields['columns']['footer_text']['value'] = htmlspecialchars($infoblock_end['footer_text']); $this->elem_fields['columns']['footer_text_area']['value'] = $infoblock_end['footer_text']; } else { $this->elem_fields['columns']['footer_text_fck']['value'] = $infoblock_end['footer_text']; } } $this->script .= "\n\n function elem1(name) {\n return \$('#tr_fld\\\\[" . $this->tabname . "\\\\]\\\\[' + name + '\\\\]');\n }\n\n function elemName1(name) {\n return 'fld[" . $this->tabname . "][' + name + ']';\n };\n\n function getFck1(name) {\n name = elemName1(name);\n for(nameFck in CKEDITOR.instances) {\n if(name == nameFck) {\n return CKEDITOR.instances[name];\n }\n }\n }\n\n function open_fck_footer(name_fck, name_area) {\n var fck = getFck1(name_fck);\n var footer_text_fck = \$(elem1(name_fck));\n var footer_text_area = \$(elem1(name_area));\n\n footer_text_fck.children('span').show();\n footer_text_area.hide();\n\n var data = footer_text_area.children('textarea').val();\n if (data.length) fck.setData(data);\n\n fck.container.show();\n fck.updateElement();\n }\n\n function close_fck_footer(name_fck, name_area) {\n var fck = getFck1(name_fck);\n var footer_text_fck = \$(elem1(name_fck));\n var footer_text_area = \$(elem1(name_area));\n fck.container.hide();\n fck.updateElement();\n\n footer_text_fck.children('span').hide();\n footer_text_area.show();\n footer_text_area.children('textarea').css({\n 'width' : '98%',\n 'height' : fck.config.height\n });\n\n var data = fck.getData();\n if (data.length) footer_text_area.children('textarea').val(data);\n }\n\n \$(function () {\n var footer_text_radio = \$(elem1('footer_text_radio')).children('input');\n \$(footer_text_radio).click(function() {\n if(\$(this).val() == 1) {\n close_fck_footer('footer_text_fck', 'footer_text_area');\n } else {\n open_fck_footer('footer_text_fck', 'footer_text_area');\n }\n });\n\n CKEDITOR.on( 'instanceReady', function( ev )\n {\n " . (isset($infoblock_end) && $infoblock_end['footer_text_radio'] ? "close_fck_footer" : "open_fck_footer") . "('footer_text_fck', 'footer_text_area');\n });\n });\n "; TElems::ElemInit(); }
function GetTable() { global $limit; $offset = (int) get('offset'); $limit = (int) get('limit', $this->Param('limit', $limit)); $search = get('find', ''); $search_state = ''; if (!empty($search)) { $search_state = ' AND (pag.uri LIKE "' . $search . '" OR pag.host LIKE "' . $search . '")'; } // create temp table sql_query("\n\t\t\tCREATE TEMPORARY TABLE tmp_stat_popular\n\t\t\tSELECT\n\t\t\t\tlog.page_id AS page_id,\n\t\t\t\tpag.uri AS page,\n\t\t\t\tpag.host AS host\n\t\t\tFROM " . $this->log_table . " AS log\n\t\t\t\tLEFT JOIN " . $this->sess_table . " AS sess USING (sess_id)\n\t\t\t\tLEFT JOIN " . STAT_PAGES_TABLE . " AS pag ON pag.id=log.page_id\n\t\t\tWHERE log.status=200 AND sess.robot=0 {$search_state}"); $count = sql_getValue("SELECT COUNT(DISTINCT(page_id)) FROM tmp_stat_popular"); $total_value = sql_getValue("SELECT COUNT(*) FROM " . $this->log_table . " AS log\n LEFT JOIN " . $this->sess_table . " AS sess USING (sess_id)\n LEFT JOIN " . STAT_PAGES_TABLE . " AS pag ON pag.id=log.page_id\n WHERE log.status=200 AND sess.robot=0"); $data = sql_getRows("SELECT page, COUNT(*) AS kol, COUNT(*)/" . $total_value . "*100 AS proc, host, page_id FROM tmp_stat_popular GROUP BY page_id ORDER BY kol DESC LIMIT " . $offset . ", " . $limit); //$uri="http://doki/sell"; // Добавление последнего слэша если он отсутствует в uri. //if((substr($uri,0,-1)!='/') && (stristr($uri,'.') || stristr($uri,'?'))) { // $uri .= '/'; //} else { //if() //} //if (substr($uri,-1,1) != '/' && !stristr($uri,'.') && !stristr($uri,'?')){ // $uri .= '/'; //} //pr($uri); $total_head = array('', $this->_str('viewed')); $total[] = array($this->str('total_period'), $total_value); // Main Table $ret['table'] = $this->stat_table(array('columns' => array(array('header' => 'page', 'nowrap' => 1, 'type' => 'page'), array('header' => 'viewed', 'align' => 'right', 'width' => '20%'), array('header' => 'percent', 'align' => 'right', 'width' => '50%', 'type' => 'graph')), 'data' => $data, 'total' => $total, 'total_head' => $total_head, 'count' => $count, 'offset' => $offset, 'limit' => $limit)); return $ret; }
function Process() { $this->CheckAdminPrivs('refund'); $id = get('id', 'number'); $order = logic('order')->GetOne($id); if (!$order) { $this->Messager(__('找不到相关订单!'), '?mod=order'); } $user = user($order['userid'])->get(); $payment = logic('pay')->SrcOne($order['paytype']); $paylog = logic('pay')->GetLog($order['orderid'], $order['userid']); $coupons = logic('coupon')->SrcList($order['userid'], $order['orderid'], TICK_STA_ANY); $express = logic('express')->SrcOne($order['expresstype']); $address = logic('address')->GetOne($order['addressid']); $refund = logic('refund')->GetOne($order['orderid']); $order['ypaymoney'] = ($order['totalprice'] > $order['paymoney']) ? number_format(($order['totalprice'] - $order['paymoney']),2) : 0; $order['tpaymoney'] = $order['totalprice']; if($order['product']['type'] == 'ticket'){ $coupo = logic('coupon')->SrcList($order['userid'], $id); if($order['productnum'] != count($coupo) && $coupo[0]['mutis'] == 1){ $order['tpaymoney'] = count($coupo)*$order['productprice']; $order['tmsg'] = array( 'money' => $order['paymoney'], 'tnum' => $order['productnum'], 'num' => $order['productnum']-count($coupo) ); } } include handler('template')->file('@admin/refund_process'); }
function raspberrypi_controller() { global $mysqli, $session, $route, $user; include "Modules/raspberrypi/raspberrypi_model.php"; $raspberrypi = new RaspberryPI($mysqli); $result = false; // html views if ($route->format == 'html') { if ($route->action == "config" && $session['write']) { $result = view("Modules/raspberrypi/raspberrypi_view.php", array('settings' => $raspberrypi->get())); } if ($route->action == "api" && $session['write']) { $result = view("Modules/raspberrypi/raspberrypi_apipage.php", array()); } } // JSON api if ($route->format == 'json') { if ($route->action == "set" && $session['write']) { $result = $raspberrypi->set($session['userid'], $user->get_apikey_write($session['userid']), get('fields')); } if ($route->action == "get" && ($session['read'] || $_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR'])) { $result = $raspberrypi->get(); } if ($route->action == "setrunning" && ($session['write'] || $_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR'])) { $result = $raspberrypi->set_running(); } if ($route->action == "getrunning" && $session['read']) { $result = $raspberrypi->get_running(); } } return array('content' => $result); }
function doTransaction($url, $api, $trans_id_post, $id_get_post) { $trans_id = $trans_id_post; $id_get = $id_get_post; $result = get($url, $api, $trans_id, $id_get); return $result; }
function output() { global $db, $geoimage; $a_node = $db->get('latitude, longitude, elevation', 'nodes', "id = '" . get('a_node') . "'"); $b_node = $db->get('latitude, longitude, elevation', 'nodes', "id = '" . get('b_node') . "'"); $width = (int) $_GET['width']; $height = (int) $_GET['height']; if ($width == 0) { $width = 600; } if ($height == 0) { $height = 300; } $point_a = new coordinate($a_node[0]['latitude'], $a_node[0]['longitude']); $point_b = new coordinate($b_node[0]['latitude'], $b_node[0]['longitude']); if (!isset($_GET['frequency'])) { //Get the AP frequency and use that $a_link_data = $db->get('frequency,type', 'links', "node_id = '" . get('a_node') . "' and frequency > 0"); $b_link_data = $db->get('frequency,type', 'links', "node_id = '" . get('b_node') . "' and frequency > 0"); $apFreq = $a_link_data[0]['type'] == 'ap' ? $a_link_data[0]['frequency'] : ($b_link_data[0]['type'] == 'ap' ? $b_link_data[0]['frequency'] : ''); if ($apFreq > 0) { $point_a->freq = (int) $apFreq; } } $image = $geoimage->plotlink($width, $height, $point_a, $point_b, (int) $a_node[0]['elevation'], (int) $b_node[0]['elevation']); header('Content-type: image/png'); imagepng($image); exit; }
function parse_images($str) { $link = isset($str[2]) ? $str[2] : ""; if (strpos($str[1], "document.") !== false) { return ""; } // bugfix for javascript bs $url = preg_replace("/.*src\\s*=\\s*[\"']?\\s*(\\S+?)(?:[\\1\\s>]|\$).*/i", "\\1", $str[1]); $part = preg_match("/(?:https?|ftp):\\/\\/(.+?)(?:\\/|\$).*/i", $url, $matches); $extra = " ondblclick=\"if(this.parentNode.tagName != 'A') window.open(this.alt)\""; if (!$part) { return $str[0]; } $hide = session('hidemedia') ? true : false; if (get('media') && session('hidemedia')) { $hide = false; } if (get('media') && !session('hidemedia')) { $hide = true; } if ($hide) { return "<a href=\"{$url}\">IMAGE REMOVED CLICK TO VIEW</a> [{$matches['1']}]"; } else { return "<img src=\"{$url}\" alt=\"{$url}\"{$extra}/>"; } }
function OneQuery($query_key, $text, $limit = 1, $properties = null) { $url = 'http://gni.globalnames.org/name_strings.json?search_term=' . rawurlencode($text); $limit = 5; if (0) { file_put_contents('tmp/r.txt', "URL = {$url}\n", FILE_APPEND); } $json = get($url); if (0) { file_put_contents('tmp/r.txt', $json . "\n", FILE_APPEND); } $obj = json_decode($json); if (0) { file_put_contents('tmp/r.txt', print_r($obj, true), FILE_APPEND); } $n = min($limit, $obj->name_strings_total); for ($i = 0; $i < $n; $i++) { $hit = new stdclass(); $hit->match = $obj->name_strings_total == 1; $hit->name = $obj->name_strings[$i]->name; $hit->id = $obj->name_strings[$i]->id; similar_text($text, $hit->name, $hit->score); $this->StoreHit($query_key, $hit); } }
public function add() { $self = $this; $model = $this->model(); $structure = $this->structure($model); $modalsize = $this->field()->modalsize(); $fieldsetName = get("fieldset"); $fieldsetStructure = $this->fieldsetStructure($fieldsetName); if (!$fieldsetStructure) { return $this->modal('error', array('text' => 'No fieldset with name "' . $fieldsetName . '" found.')); } $form = $this->form('add', array($model, $fieldsetStructure), function ($form) use($model, $structure, $self, $fieldsetName) { $form->validate(); if (!$form->isValid()) { return false; } $data = $form->serialize(); $data["_fieldset"] = $fieldsetName; $structure->add($data); $self->notify(':)'); $self->redirect($model); }); $form->attr('action', panel()->urls()->current() . "?fieldset=" . get("fieldset")); return $this->modal('add', compact('form', 'modalsize')); }
/** * @brief Fetch BHL OCR text * * Fetch OCT text from BHL pagesummaryservice.aspx service, clean it, then store in local * database. If we have already stored text for this page we retrieve local copy. * * @param PageID BHL PageID of page * * @return Cleaned text * */ function bhl_fetch_ocr_text($PageID) { global $db; //$refresh = true; $refresh = false; $text = ''; // Do we have this already in database? $sql = 'SELECT * FROM rdmp_text WHERE (PageID=' . $PageID . ') LIMIT 1'; $result = $db->Execute($sql); if ($result == false) { die("failed {$sql}"); } if ($result->NumRows() == 1 && !$refresh) { $text = $result->fields['ocr_text']; } else { $url = 'http://www.biodiversitylibrary.org/services/pagesummaryservice.ashx?op=FetchPageUrl&pageID=' . $PageID; $url = 'http://www.biodiversitylibrary.org/api2/httpquery.ashx?op=GetPageOcrText&pageid=' . $PageID . '&apikey=' . '0d4f0303-712e-49e0-92c5-2113a5959159' . '&format=json'; $json = get($url); if ($json != '') { $j = json_decode($json); //$text = $j[4]; $text = $j->Result; //$text = utf8_decode($text); $text = bhl_clean_ocr_text($text); bhl_store_ocr_text($PageID, $text); } } return $text; }
function OneQuery($query_key, $text, $limit = 1, $properties = null) { $url = 'http://viaf.org/viaf/search?query=' . urlencode('local.personalNames all "' . $text . '"') . '&httpAccept=' . urlencode('application/rss+xml'); //echo $url . "\n"; $xml = get($url); //echo $xml; if ($xml != '') { $dom = new DOMDocument(); $dom->loadXML($xml); $xpath = new DOMXPath($dom); $xpath->registerNamespace('opensearch', 'http://a9.com/-/spec/opensearch/1.1/'); $xpath_query = "//opensearch:totalResults"; $count = 0; $nodeCollection = $xpath->query($xpath_query); foreach ($nodeCollection as $node) { $count = $node->firstChild->nodeValue; } if ($count > 0) { $xpath_query = "//item/title"; $nodeCollection = $xpath->query($xpath_query); foreach ($nodeCollection as $node) { $hit = new stdclass(); $hit->score = 1; $hit->match = $count == 1; $hit->name = $node->firstChild->nodeValue; $nc = $xpath->query('../guid', $node); foreach ($nc as $n) { $hit->id = str_replace('http://viaf.org/viaf/', '', $n->firstChild->nodeValue); } $this->StoreHit($query_key, $hit); } } } }
function ElemEdit($id, $row) { $fld = get('fld', array(), 'p'); $row = $fld['genform']; $error = ''; sql_query('BEGIN'); if (!$id) { //добавляем форму $form_id = $this->updateForm($row); if (is_int($form_id)) { } else { $error = $form_id; } } else { // редактируем форму $form_id = $this->updateForm($row, $id); if ($form_id == $id) { } else { $error = $form_id; } } if (!$error) { $_id = $this->updateFormElements($form_id, $row); if ($_id !== true) { $error = $_id; } } if ($error) { sql_query('ROLLBACK'); return $error; } else { sql_query('COMMIT'); return 1; } }
function show_help($module = '') { global $system; $result = ''; if (empty($module)) { $module = get('module', 'index'); } $lang = curlang(); $help_dir = DATA_PATH . 'help/' . $lang . '/'; if (LOGGED_IN) { if ($system->checkForRight('HELP')) { $admin_link = ' <a href="' . RCMS_ROOT_PATH . '?module=help&edit=' . $module . '"><img title="' . __('Edit') . '" src="' . IMAGES_PATH . 'skins/edit_small.gif"></a> <a href="#" onClick="if(confirm(\'' . __('Delete') . ': \\n' . str_replace('"', '″', $module) . '?\\n\')) document.location.href = \'' . RCMS_ROOT_PATH . '?module=help&delete=' . $module . '\'"> <img title="' . __('Delete') . '" src="' . IMAGES_PATH . 'skins/trash_small.gif"> </a><br/> '; $add_link = '<a href="' . RCMS_ROOT_PATH . '?module=help&edit=' . $module . '"><img src="' . IMAGES_PATH . 'skins/add_help.png" title="' . __('Add') . ' ' . __('Help') . '" alt="' . __('Add') . ' ' . __('Help') . '" /></a> '; } else { $admin_link = ''; $add_link = ''; } $modulename = $help_dir . make_safe_filename($module); if (file_exists($modulename)) { $help_chapter = file_get_contents($modulename); $result = wf_modal(wf_img(IMAGES_PATH . 'skins/help.png', __('Context help')), __('Context help'), $admin_link . $help_chapter, '', '600', '300', 'accesskey="h"'); } else { $result = $add_link; } } return $result; }
function get_formatted_reference($ipni_id) { global $db; $citation = ''; $sql = 'SELECT * FROM names WHERE Id="' . $ipni_id . '" LIMIT 1'; $result = $db->Execute($sql); if ($result == false) { die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql); } if ($result->NumRows() == 1) { $identifier = ''; $guid = ''; if ($result->fields['doi'] != '') { $guid = $result->fields['doi']; } if ($guid == '') { if ($result->fields['jstor'] != '') { $guid = 'http://www.jstor.org/stable/' . $result->fields['jstor']; } } if ($guid != '') { $url = 'http://localhost/~rpage/microcitation/www/darwincore.php?guid=' . $guid; $json = get($url); //echo $json; $obj = json_decode($json); $citation = $obj->html; } } return $citation; }
function pickup() { if (get('subpage') != '') { $p = "pickup_" . get('subpage'); $this->page = new $p(); } }
public function __construct($data) { $this->keyboard = get($data, 'keyboard', []); $this->resize_keyboard = get($data, 'resize_keyboard', true); $this->one_time_keyboard = get($data, 'one_time_keyboard', true); $this->selective = get($data, 'selective', false); }
public function __construct() { if (!template_session::is_admin() and !template_session::is_editor()) { if (get('ajax')) { exit(RUDE_AJAX_ACCESS_VIOLATION); } return false; } switch (get('task')) { case 'remove': $status = departments::remove(get('id')); break; case 'add': $status = departments::add(get('name')); break; case 'edit': $status = departments::edit(get('id'), get('name')); break; default: $status = false; break; } if (get('ajax')) { if ($status) { exit(RUDE_AJAX_OK); } else { exit(RUDE_AJAX_ERROR); } } return true; }
public static function login($redirect = '/') { if (self::user()) { go(url($redirect)); } self::kill(); $password = get('password'); $username = get('username'); if (empty($username) || empty($password)) { return false; } // try to find the user $account = self::load($username); if (!$account) { return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password')); } // check for matching usernames if (str::lower($account->username()) != str::lower($username)) { return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password')); } // check for a matching password if (!self::checkPassword($account, $password)) { return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password')); } // generate a random token $token = str::random(); // add the username. $account->token = $token; // store the token in the cookie // and the user data in the session cookie::set('authFrontend', $token, 60 * 60 * 24); s::set('authFrontend.' . $token, $account->username()); go(url($redirect)); }
function hostmaster() { if (get('subpage') != '') { $p = "hostmaster_" . get('subpage'); $this->page = new $p(); } }
public function __construct(Board $board, array $path) { parent::__construct($board); $topLinks = div('', 'topLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']'); if (!$board->isSwfBoard()) { $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']'); } $this->appendToBody($topLinks); $this->appendToBody(el('h2', 'Board Search')); try { $method = $path[3] ?? ""; if (method_exists(self::class, $method)) { $this->perPage = (int) get('perpage', 250); $this->page = (int) get('page', 0); $this->start = $this->perPage * $this->page; $result = $this->{$path[3]}($path[4] ?? NULL); $this->appendToBody(div($result->count . ' results.', 'centertext')); $pages = $this->makePageSelector($result->count); $this->appendToBody($pages); $i = $this->start + 1; foreach ($result->result as $post) { $this->appendToBody(div($i++ . " >>", 'sideArrows') . PostRenderer::renderPost($post)); } $this->appendToBody($pages); } else { $this->appendToBody("<h3>Invalid search parameter '{$method}' provided</h3>"); } } catch (Exception $e) { $this->appendToBody("<h3>Error: {$e->getMessage()}</h3>"); } $this->appendToBody('<hr>' . $topLinks); }
/** * Creates a new Uniform instance. * * @param string $id The unique ID of this form. * @param array $options Array of uniform options, including the actions. */ public function __construct($id, $options) { if (empty($id)) { throw new Error('No Uniform ID was given.'); } $this->id = $id; $this->erroneousFields = array(); $this->options = array('guard' => a::get($options, 'guard', 'honeypot'), 'honeypot' => a::get($options, 'honeypot', 'website'), 'required' => a::get($options, 'required', array()), 'validate' => a::get($options, 'validate', array()), 'actions' => a::get($options, 'actions', array())); // required fields will also be validated by default $this->options['validate'] = a::merge($this->options['validate'], $this->options['required']); // initialize output array with the output of the plugin itself $this->actionOutput = array('_uniform' => array('success' => false, 'message' => '')); // the token is stored as session variable until the form is sent // successfully $this->token = s::get($this->id); if (!$this->token) { $this->generateToken(); } // get the data to be sent (if there is any) $this->data = get(); if ($this->requestValid()) { // remove uniform specific fields from form data unset($this->data['_submit']); if (empty($this->options['actions'])) { throw new Error('No Uniform actions were given.'); } if ($this->dataValid()) { // uniform is done, now it's the actions turn $this->actionOutput['_uniform']['success'] = true; } } else { // generate new token to spite the bots }:-) $this->generateToken(); } }
function send($id) { $form = is_array($id) ? $id : get($id); $results = results($id); if (!$results) { return false; } if (!is_array($form['template']) || !strlen($form['template']['recipient'])) { return false; } $smarty = new \Smarty(); $smarty->compile_check = true; $smarty->debugging = false; foreach ($results as $nm => $val) { $smarty->assign($nm, $val); } $mail = new \PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->Subject = $smarty->fetch('string:' . $form['template']['subject']); $addresses = explode(',', $form['template']['recipient']); foreach ($addresses as $a) { $mail->AddAddress(trim($a)); } $mail->MsgHTML($smarty->fetch('string:' . $form['template']['body'])); return $mail->Send(); }
public function mainAction() { $model = new PageModel(); $modelProfile = new ProfileModel(); $this->view->ladder_list = $modelProfile->getTopLadder(5); $this->view->last_reg_list = $modelProfile->getLastRegistered(5); $this->view->last_matches = $modelProfile->getLastMatchesList(5); $act = Request::getUri(0); $id = intval(Request::getUri(1)); if ($act == 'read' && $id > 0) { redirect(SITE_URL . 'main/readblog?pid=' . $id); // echo SITE_URL.'main/readblog'; $news = $model->getNews($id, Lang::$language); if (!$news) { error404(); } $this->view->news = $content; // $news; $this->view->title = $title; //$news->name; } else { Pagination::calculate(get('page'), 10, $model->countNews(Lang::$language)); $this->view->newsList = $model->getAllNews(Lang::$language, Pagination::$start, Pagination::$end); $this->view->title = Lang::translate('MAIN_TITLE'); } }
function output_onpost_form_contact() { global $construct, $main, $db, $lang; $main->header->hide = TRUE; $main->menu->hide = TRUE; $main->footer->hide = TRUE; $from = $db->get('username, email', 'users', "id = '" . $main->userdata->user . "'"); $to_db = $db->get('email', 'users INNER JOIN users_nodes ON users_nodes.user_id = users.id', "users_nodes.node_id = " . intval(get('node')) . ($_POST['email_to_type'] == 'owner' ? " AND users_nodes.owner = 'Y'" : "")); $node = $db->get('name, id', 'nodes', "id = " . intval(get('node'))); $to = array(); for ($i = 0; $i < count($to_db); $i++) { array_push($to, $to_db[$i]['email']); } $to = implode(', ', $to); $subject = $lang['email']['node_contact']['subject_prefix'] . stripslashes($_POST['email_subject']) . $lang['email']['node_contact']['subject_suffix']; $body = $lang['email']['node_contact']['body_prefix'] . stripslashes($_POST['email_body']) . $lang['email']['node_contact']['body_suffix']; $body = str_replace("##username##", $from[0]['username'], $body); $body = str_replace("##node_name##", $node[0]['name'], $body); $body = str_replace("##node_id##", $node[0]['id'], $body); $ret = @sendmail($to, $subject, $body, $from[0]['username'], $from[0]['email'], TRUE); if ($ret) { $main->message->set_fromlang('info', 'message_sent'); } else { $main->message->set_fromlang('error', 'generic'); } }
function get_friend_diaryland($uri) { if ($entry = get_cached($uri)) { return array($entry['date'] => $entry); } else { $page = get($uri); if (strlen($page) == 0) { print "No data at {$uri}\n"; return array(); } else { if (!preg_match('!(\\d+-\\d+-\\d+)\\s*-\\s*(\\d+:\\d+)\\s*(p\\.m\\.|a\\.m\\.).*?(<P>.*?)<P><A[^>]*>previous!ms', $page, $matches)) { print "Couldn't extract entry from {$uri}\n"; mail_entry("*****@*****.**", "DiaryLand Entry Breaks Parser... more at 10.", $entryuri, "{$page}"); return array(); } else { $time = explode(':', $matches[2]); if ($matches[3] == 'p.m.') { $time[0] += 12; } $time = join(":", $time); $date = $matches[1] . " " . $time; $data = $matches[4]; $friend_uri = $uri; $uri = $uri . "/{$date}"; $entry = compact('date', 'data', 'uri', 'friend_uri'); put_cache(array($entry)); return array($date => $entry); } } } }
public function structure($id, $fieldName, $context) { $page = empty($id) ? site() : page($id); if (!$page) { throw new Exception('The page could not be found'); } $blueprint = blueprint::find($page); $field = null; $fields = $context == 'file' ? $blueprint->files()->fields() : $blueprint->fields(); // make sure to get fields by case insensitive field names foreach ($fields as $f) { if (strtolower($f->name) == strtolower($fieldName)) { $field = $f; } } if (!$field) { throw new Exception('The field could not be found'); } $fields = new Blueprint\Fields($field->fields(), $page); $fields = $fields->toArray(); foreach ($fields as $key => $field) { if ($field['type'] == 'textarea') { $fields[$key]['buttons'] = false; } } $form = new Form($fields, null, $fieldName); $form->save = get('_id') ? l('fields.structure.save') : l('fields.structure.add'); return view('editor/structure', array('page' => $page, 'form' => $form)); }
function confirm($cashid) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($cashid, "num", 1, 20, "Invalid Reference number."); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class=err>" . $e["msg"]; } $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } # Connect to database db_Connect(); $sql = "SELECT * FROM pettycashbook WHERE cashid = '{$cashid}' AND div = '" . USER_DIV . "'"; $cashRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve cashbook entry details from database.", SELF); if (pg_numrows($cashRslt) < 1) { $OUTPUT = "<li clss=err>Requisistion not found in Cubit."; return $OUTPUT; } $cash = pg_fetch_array($cashRslt); # Get account name for the account involved $accRslt = get("core", "accname,accnum,topacc", "accounts", "accid", $cash['accid']); $acc = pg_fetch_array($accRslt); // Layout $confirm = "<h3>Cancel Requisistion</h3>\r\n\t<h4>Confirm entry</h4>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<form action='" . SELF . "' method=post>\r\n\t<input type=hidden name=key value=cancel>\r\n\t<input type=hidden name=cashid value='{$cash['cashid']}'>\r\n\t<tr><th>Field</th><th>Value</th></tr>\r\n\t<tr class='bg-odd'><td>Date</td><td>{$cash['date']}</td></tr>\r\n\t<tr class='bg-even'><td>Paid to</td><td>{$cash['name']}</td></tr>\r\n\t<tr class='bg-odd'><td>Details</td><td><pre>{$cash['det']}</pre></td></tr>\r\n\t<tr class='bg-even'><td>Amount</td><td>" . CUR . " {$cash['amount']}</td></tr>\r\n\t<tr class='bg-odd'><td>Account</td><td>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</td></tr>\r\n\t<tr><td><br></td></tr>\r\n\t<tr><td\t><input type=button value='« Back' onClick='javascript:history.back()'></td><td align=right><input type=submit value='Cancel »'></td></tr>\r\n\t</table></form>\r\n\t<p>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='pettycashbook-view.php'>View Petty Cash Requisitions</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>"; return $confirm; }
/** * Get index * @return \ZendSearch\Lucene\Index */ private function index() { if (!isset(self::$index)) { $analyzer = new CaseInsensitive(); if ($this->config()->exists('zend_search', 'stop_words')) { $stop_word_filter = new StopWords(); $words = $this->getRealPath($this->config()->get('zend_search', 'stop_words')); if ($words !== false) { $stop_word_filter->loadFromFile($words); } else { throw new \InvalidArgumentException('Path not found'); } $analyzer->addFilter($stop_word_filter); } if ($this->config()->exists('zend_search', 'morphy_dicts')) { $morphy_dicts = $this->getRealPath($this->config()->get('zend_search', 'morphy_dicts')); if ($morphy_dicts !== false) { $analyzer->addFilter(new Morphy($morphy_dicts, $this->config()->getCharset())); } else { throw new \InvalidArgumentException('Path not found'); } } Analyzer::setDefault($analyzer); Lucene::setResultSetLimit($this->limit); QueryParser::setDefaultEncoding($this->config()->getCharset()); $index = $this->config() - get('zend_search', 'index'); $path = $this->getRealPath($index); self::$index = $path ? Lucene::open($path) : Lucene::create($index); } return self::$index; }