public function process($parentRule) { static $thisFunction; if (!$thisFunction) { $thisFunction = new Functions(array('this' => 'CssCrush\\fn__this')); } if (!$this->skip) { // this() function needs to be called exclusively because it is self referencing. $context = (object) array('rule' => $parentRule); $this->value = $thisFunction->apply($this->value, $context); if (isset($parentRule->declarations->data)) { $parentRule->declarations->data += array($this->property => $this->value); } $context = (object) array('rule' => $parentRule, 'property' => $this->property); $this->value = Crush::$process->functions->apply($this->value, $context); } // Whitespace may have been introduced by functions. $this->value = trim($this->value); if ($this->value === '') { $this->valid = false; return; } $parentRule->declarations->queryData[$this->property] = $this->value; $this->indexFunctions(); }
public function __construct($str) { static $templateFunctions; if (!$templateFunctions) { $templateFunctions = new Functions(); } $str = Template::unTokenize($str); // Parse all arg function calls in the passed string, // callback creates default values. $self = $this; $captureCallback = function ($str) use(&$self) { $args = Functions::parseArgsSimple($str); $position = array_shift($args); // Match the argument index integer. if (!isset($position) || !ctype_digit($position)) { return ''; } // Store the default value. $defaultValue = isset($args[0]) ? $args[0] : null; if (isset($defaultValue)) { $self->defaults[$position] = $defaultValue; } // Update argument count. $argNumber = (int) $position + 1; $self->argCount = max($self->argCount, $argNumber); return "?a{$position}?"; }; $templateFunctions->register['#'] = $captureCallback; $templateFunctions->register['arg'] = $captureCallback; $this->string = $templateFunctions->apply($str); }
function write_div_table_display_records($order = null, $order_type = null) { $data['stocks'] = $this->Stocks_model->get_all_display($order, $order_type); $functions = new Functions(); $link_to_screen = base_url() . 'inventory/stocks'; return $functions->display_data_table($data['stocks'], $link_to_screen, $this); }
public function actionGetAddress() { $value = $_POST['val']; $function = new Functions(); $address = $function->getAddress($value); $this->renderPartial('getAddress', array('address' => $address)); }
function do_update() { $Q[] = "ALTER TABLE exp_members ADD `ignore_list` text not null AFTER `sig_img_height`"; /* * ------------------------------------------------------ * Add Edit Date and Attempt to Intelligently Set Values * ------------------------------------------------------ */ require PATH_CORE.'core.localize'.EXT; $LOC = new Localize(); $Q[] = "ALTER TABLE exp_templates ADD `edit_date` int(10) default 0 AFTER `template_notes`"; $Q[] = "UPDATE exp_templates SET edit_date = '".$LOC->now."'"; $query = $this->EE->db->query("SELECT item_id, MAX(item_date) as max_date FROM `exp_revision_tracker` GROUP BY item_id"); if ($query->num_rows() > 0) { foreach($query->result_array() as $row) { $Q[] = "UPDATE exp_templates SET edit_date = '".$DB->escape_str($row['max_date'])."' WHERE template_id = '".$DB->escape_str($row['item_id'])."'"; } } /* * ------------------------------------------------------ * Add Hash for Bulletins and Set For Existing Bulletins * ------------------------------------------------------ */ $Q[] = "ALTER TABLE `exp_member_bulletin_board` ADD `hash` varchar(10) default '' AFTER `bulletin_date`"; $Q[] = "ALTER TABLE `exp_member_bulletin_board` ADD INDEX (`hash`)"; $query = $this->EE->db->query("SELECT DISTINCT bulletin_date, bulletin_message, sender_id FROM `exp_member_bulletin_board`"); if ($query->num_rows() > 0) { require PATH_CORE.'core.functions'.EXT; $FNS = new Functions(); foreach($query->result_array() as $row) { $Q[] = "UPDATE exp_member_bulletin_board SET hash = '".$DB->escape_str($FNS->random('alpha', 10))."' WHERE bulletin_date = '".$DB->escape_str($row['bulletin_date'])."' AND bulletin_message = '".$DB->escape_str($row['bulletin_message'])."' AND sender_id = '".$DB->escape_str($row['sender_id'])."'"; } } // run the queries foreach ($Q as $sql) { $this->EE->db->query($sql); } return TRUE; }
public function actionAddAddr() { $func = new Functions(); if (isset($_POST['addresses'])) { foreach ($_POST['addresses'] as $key => $val) { $id = $func->createReestr($val, $_POST['id']); $model[$key] = Yii::app()->db->createCommand()->select()->from('reestrAddr r')->join('addresses adr', 'adr.addressesID = r.addressId')->where('r.reestrAddrId = :id', array(':id' => $id))->queryRow(); } } $this->renderPartial('partial/addAddr', array('model' => $model)); }
public function genPls() { $read = new Functions(); $channel = $read->openFile(); foreach ($channel as $key => $value) { $read->getServerInfo($value); $name = $read->name; $this->genRam($read->chan, $read->ip, $read->port); $this->genAsx($read->chan, $read->ip, $read->port); $this->genM3u($read->chan, $read->ip, $read->port, $name); } echo 'Generowanie plikow playlist zakonczone sukcesem.'; }
public static function expandAliases($str) { $process = Crush::$process; if (!$process->selectorAliases || !preg_match($process->selectorAliasesPatt, $str)) { return $str; } while (preg_match_all($process->selectorAliasesPatt, $str, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { $alias_call = end($m); $alias_name = strtolower($alias_call[1][0]); $start = $alias_call[0][1]; $length = strlen($alias_call[0][0]); $args = array(); // It's a function alias if a start paren is matched. if (isset($alias_call[2])) { // Parse argument list. if (preg_match(Regex::$patt->parens, $str, $parens, PREG_OFFSET_CAPTURE, $start)) { $args = Functions::parseArgs($parens[2][0]); // Amend offsets. $paren_start = $parens[0][1]; $paren_len = strlen($parens[0][0]); $length = $paren_start + $paren_len - $start; } } $str = substr_replace($str, $process->selectorAliases[$alias_name]($args), $start, $length); } return $str; }
function amchroot_edit($domain, $mode) { $cmd = "amh module AMChroot-1.1 admin edit,{$domain},{$mode}"; $cmd = Functions::trim_cmd($cmd); exec($cmd, $tmp, $status); return !$status; }
function module_delete($name) { $cmd = "amh module {$name} delete y"; $cmd = Functions::trim_cmd($cmd); exec($cmd, $tmp, $status); return !$status; }
public static function checkDate($date, $class) { //check if set and date null //return error if (!isset($class->date) && $date == null) { //return error code and msg if there is no date set; $error = Functions::error(100, "Date is not set"); } else { if ($date == null) { //set date from class $date = $class->date; } } //check if format is right $date = date_create_from_format('d.m.Y', $date); //if format is not correct if ($date == false) { $error = Functions::error(100, "Date is not in right format (d.m.Y)"); } //get format back, no clock needed $date = date_format($date, 'd.m.Y'); //return right date //date in function getData('date') is more imporatant than set date in class return $date; }
/** * Discovers all the annotations of a given class file * * @param string $class a class file * @return array */ public static function discover($class) { try { if (!file_exists($class)) { throw new Exception($class . " does not exist"); } $text = file($class, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $annotations = array(); $currentAnnotations = array(); foreach ($text as $key => $line) { if (strpos($line, "* @annotation") !== false) { $currentAnnotations[] = trim(str_replace("* @annotation", "", $line)); } else { $functionName = ""; if (count($currentAnnotations) > 0 && Annotation::discoverFunctionName($line, $functionName)) { $annotations[$functionName] = $currentAnnotations; $currentAnnotations = array(); } unset($text[$key]); } } return $annotations; } catch (Exception $e) { Functions::dump($e->getMessage()); return NULL; } }
public static function get_metadata($url) { $xml = Functions::lookup_with_cache($url, array('validation_regex' => 'xmlns:')); $simple_xml = simplexml_load_string($xml); $params = array(); $dcterms = $simple_xml->children("http://dublincore.org/documents/dcmi-terms/"); $dwc = $simple_xml->children("http://digir.net/schema/conceptual/darwin/2003/1.0"); $params['source'] = (string) $dcterms->identifier; $data_object = $simple_xml->dataObject; $dcterms = $data_object->children("http://dublincore.org/documents/dcmi-terms/"); $params['citation'] = (string) $dcterms->bibliographicCitation; $params['identifier'] = (string) $dcterms->identifier; $params['data_type'] = "http://purl.org/dc/dcmitype/Text"; $params['mime_type'] = "text/html"; $params['license'] = "not applicable"; $params['agents'] = array(); foreach ($data_object->agent as $agent) { $agent_name = (string) $agent; $attr = $agent->attributes(); $agent_role = (string) @$attr['role']; $params['agents'][] = array($agent_name, $agent_role); } print_r($xml); // print_r($params); echo "\n\n\n"; }
public function init() { parent::init(); // Create new field in your users table for store dashboard preference // Set table name, user ID field name, user preference field name $this->setTableParams('dashboard_page', 'user_id', 'title'); // set array of portlets $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4)))); //set content BEFORE dashboard $this->setContentBefore(); // uncomment the following to apply jQuery UI theme // from protected/components/assets/themes folder $this->applyTheme('ui-lightness'); // uncomment the following to change columns count //$this->setColumns(4); // uncomment the following to enable autosave $this->setAutosave(true); // uncomment the following to disable dashboard header $this->setShowHeaders(false); // uncomment the following to enable context menu and add needed items /* $this->menu = array( array('label' => 'Index', 'url' => array('index')), ); */ }
function loop_resolve_list($list_text) { // Resolve the list of items for iteration. // Either a generator function or a plain list. $items = array(); $list_text = Crush::$process->functions->apply($list_text); $generator_func_patt = Regex::make('~(?<func>range|color-range) {{parens}}~ix'); if (preg_match($generator_func_patt, $list_text, $m)) { $func = strtolower($m['func']); $args = Functions::parseArgs($m['parens_content']); switch ($func) { case 'range': $items = call_user_func_array('range', $args); break; default: $func = str_replace('-', '_', $func); if (function_exists("CssCrush\\loop_{$func}")) { $items = call_user_func_array("CssCrush\\loop_{$func}", $args); } } } else { $items = Util::splitDelimList($list_text); } return $items; }
public static function getPublicFile($name = "index.php", $template = "", $lang = "") { if ($filename = Functions::getPublicFileURL($name, $template, $lang)) { return file_get_contents($filename); } return false; }
public static function Instance() { if (self::$_instance === false) { self::$_instance = new Functions(); } return self::$_instance; }
function fleaditlater_plugin_displayEvents(&$myUser) { $mysqli = new MysqlEntity(); $query = $mysqli->customQuery('SELECT le.id,le.title,le.link FROM `' . MYSQL_PREFIX . 'event` le INNER JOIN `' . MYSQL_PREFIX . 'plugin_feaditlater` fil ON (le.id=fil.event)'); if ($query != null) { echo '<aside class="fleaditLaterMenu"> <h3 class="left">' . _t('P_FLEADITLATER_TOREAD') . '</h3> <ul class="clear"> <li> <ul> '; while ($data = $query->fetch_array()) { echo '<li> <img src="plugins/fleaditlater/img/read_icon.png"> <a title="' . $data['link'] . '" href="' . $data['link'] . '" target="_blank"> ' . Functions::truncate($data['title'], 38) . ' </a> <button class="right" onclick="fleadItLater(' . $data['id'] . ',\'delete\',this)" style="margin-left:5px;margin-top:5px;"> <span title="' . _t('P_FLEADITLATER_MARK_AS_READ') . '" alt="' . _t('P_FLEADITLATER_MARK_AS_READ') . '">' . _t('P_FLEADITLATER_MARK_AS_READ_SHORT') . '</span> </button> </li>'; } echo '</ul> </li> </ul> </aside>'; } }
/** * try { * $input = \itcube\Input::Instance(); * } catch (Exception $e) { * echo $e->getMessage() . "\n"; * } */ public function __construct() { global $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER; $this->properties = array(); $this->server = $_SERVER; if (isset($_POST) && Functions::array_count($_POST) > 0) { foreach ($_POST as $key => $val) { $this->properties['POST'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_GET) && Functions::array_count($_GET) > 0) { foreach ($_GET as $key => $val) { $this->properties['GET'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_COOKIE) && Functions::array_count($_COOKIE) > 0) { foreach ($_COOKIE as $key => $val) { $this->properties['COOKIE'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_FILES) && Functions::array_count($_FILES) > 0) { foreach ($_FILES as $key => $val) { $this->properties['FILES'][$this->_clean_key($key)] = $this->_clean_val($val); } } }
public function __invoke($object) { foreach ($this->_functions as $function) { $object = Functions::call($function, $object); } return $object; }
public function setPattern($useAll = false) { if ($useAll) { $this->register = self::$builtins + $this->register + csscrush_add_function(); } $this->pattern = Functions::makePattern(array_keys($this->register)); }
public function __construct(array $param = array()) { $def_param = array('upload_dir' => Q_PATH . '/uploads/', 'max_file_count' => 1000, 'branches' => 2, 'pattern' => ''); $upload_param = Functions::arr_union($def_param, $param); $this->upload_dir = $upload_param['upload_dir']; $this->max_file_count = $upload_param['max_file_count']; $this->branches = $upload_param['branches']; //сложность надумана, все зависит от инодов df -i и tune2fs -l /dev/hda1 и df -Ti switch ($upload_param['pattern']) { case 'bigint': $this->max_file_count = 512; $this->branches = 6; break; case 'int': $this->max_file_count = 216; $this->branches = 3; break; case 'mediumint': $this->max_file_count = 204; $this->branches = 2; break; case 'smallint': $this->max_file_count = 182; $this->branches = 1; break; } $this->del_id(); }
function Module_JSON($db) { $card_id = Functions::Post_Int('card_id'); $normal = Functions::Post_Int('normal'); $gold = Functions::Post_Int('gold'); if (!Functions::Card_Load_Id($db, $card_id, $card)) { return JSON_Response_Error('#Error#', 'Failed to load card'); } if ($normal < 0 or !is_int($normal)) { return JSON_Response_Error('#Error#', 'Invalid normal value'); } if ($gold < 0 or !is_int($gold)) { return JSON_Response_Error('#Error#', 'Invalid normal value'); } if ($card['rarity'] == 'Legendary') { $card['normal'] = $normal > 1 ? 1 : $normal; $card['gold'] = $gold > 1 ? 1 : $gold; } else { $card['normal'] = $normal > 2 ? 2 : $normal; $card['gold'] = $gold > 2 ? 2 : $gold; } if (!Functions::Card_Update($db, $card)) { return JSON_Response_Global_Error(); } return JSON_Response_Success(); }
function getReplaceChars($object, $name = "") { switch ($name) { case "products": return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%PICTURE%%" => $object->getPicture()); break; case "gallery": return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%PICTURE%%" => $object->getFirstPicture(), "%%LIEN%%" => Functions::getDefaultURL() . "portfolio/" . $object->getId() . "_" . str_replace(" ", "_", $object->getName())); break; case "improve": return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%CONTENT%%" => $object->getContent(), "%%PICTURE%%" => $object->getPicture()); break; case "improve1": return array("%%ID%%" => $object->getId()); break; case "slide": return array("%%PICTURE%%" => $object->getPicture()); break; case "category": $product = Models::getProductObject(); $product->fetchProductByCategoryId($object->getId()); return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%CATEGORY_URL%%" => Functions::getDefaultURL() . "product/" . str_replace(" ", "_", $object->getName()), "%%PICTURE%%" => $object->getPicture(), "%%LOGO%%" => $object->getLogo(), "%%DESCRIPTION%%" => $object->getDescription(), "%%COUNT%%" => $product->getCount(), "%%SELECTED%%" => defined("CATEGORY_NAME") && $object->getIdFromName(str_replace("_", " ", CATEGORY_NAME)) == $object->getId() ? "selected" : ""); break; } return array(); }
private function process_pages($recs) { foreach ($recs as $rec) { // if($rec->title != "42194843") continue; //debug only // if($rec->title != "42194845") continue; //debug only // if($rec->title != "33870179") continue; //debug only --with copyrightstatus // if($rec->title != "13128418") continue; //debug only --with licensor (13128418, 30413122) // if($rec->title != "42194845") continue; //debug only --without licensor if ($rec->title != "16059324") { continue; } //debug only echo "\n" . $rec->title; $url = $this->wikipedia_api . "?action=query&titles=" . urlencode($rec->title) . "&format=json&prop=revisions&rvprop=content"; $json = Functions::lookup_with_cache($url, array('expire_seconds' => true)); //this expire_seconds should always be true $arr = json_decode($json, true); foreach (@$arr['query']['pages'] as $page) { if ($val = @$page['revisions'][0]['*']) { if ($data = self::parse_wiki_content($val)) { // if(isset($data['Taxa Found in Page (tabular)']['NameConfirmed'])) self::create_archive($data); if (isset($data['Taxa Found in Page']['text'])) { self::create_archive($data); } else { echo "\n[no taxa found for wiki: " . $data['Page Summary']['PageID'] . "]\n"; } } } } } }
public function set($request = array()) { $this->request = $request; $this->html = Functions::getHTMLObject(); $this->html->setCommonArray(array("%%DEFAULT_TITLE%%" => "ARENALUB S.A.R.L", "%%HTTP_URL%%" => Functions::getDefaultURL(), "%%DESIGN_DIR%%" => Functions::getTemplateDir() . "design/", "%%PLUGINS_DIR%%" => Functions::getTemplateDir() . "plugins/", "%%CSS_DIR%%" => Functions::getTemplateDir() . "design/css/", "%%INDEX%%" => Functions::getDefaultURL() . $this->getLanguage() . "/")); $this->html->setCommonArray(array("%%LANGUAGE_SELECT%%" => $this->html->getFilteredText(Functions::getPublicFile("language.html")))); }
function load_xml_string() { $file_contents = ""; debug("Please wait, downloading resource document..."); if (preg_match("/^(.*)\\.(gz|gzip)\$/", $this->xml_path, $arr)) { $path_parts = pathinfo($this->xml_path); $filename = $path_parts['basename']; $temp_dir = create_temp_dir() . "/"; debug("temp file path: " . $temp_dir); if ($file_contents = Functions::get_remote_file($this->xml_path, array('timeout' => 172800))) { $temp_file_path = $temp_dir . "/" . $filename; $TMP = fopen($temp_file_path, "w"); fwrite($TMP, $file_contents); fclose($TMP); shell_exec("gunzip -f {$temp_file_path}"); $this->xml_path = $temp_dir . str_ireplace(".gz", "", $filename); debug("xml path: " . $this->xml_path); } else { debug("Connector terminated. Remote files are not ready."); return false; } echo "\n {$temp_dir} \n"; $file_contents = Functions::get_remote_file($this->xml_path, array('timeout' => 172800)); recursive_rmdir($temp_dir); // remove temp dir echo "\n temporary directory removed: [{$temp_dir}]\n"; } return $file_contents; }
function get_all_taxa($data_dump_url = false) { $labels = self::get_headers(); if ($data_dump_url) { $this->data_dump_url = $data_dump_url; } if ($temp_filepath = Functions::save_remote_file_to_local($this->data_dump_url, array('timeout' => 4800, 'download_attempts' => 5))) { $not80 = 0; $i = 0; foreach (new FileIterator($temp_filepath, true) as $line_number => $line) { if ($line) { $record = self::prepare_row_data(trim($line), $labels); if (count($record) != 80) { $not80++; // means invalid CSV row, needs attention by provider echo "\n investigate: invalid CSV row, needs attention by provider [" . count($record) . "]"; print_r($record); } else { if (@$record['SCIENTIFIC_NAME']) { $i++; debug("{$i}. " . $record['SCIENTIFIC_NAME'] . " [" . count($record) . "]\n"); self::parse_record_element($record); } } } } debug("\n not 80: {$not80} \n"); $this->create_archive(); } }
/** * Removes any unwanted characters from a given value * * @param Mixed $value a scalar or array value to be escaped * @return Mixed */ public static function escapeComplete($value) { if (is_array($value)) { return array_map("Functions::escapeComplete", $value); } return Functions::escapeComplete($value); }
/** * This function will return an associative array of all Glyphs equipped on the character. * * Associative Array Format: * "name" - Name of Glyph * "type" = Major, Minor, or Prime * "url" - URL of the Glyph * "itemNumber" - Unique item number of the Glyph. * * @return - An Associative Array. */ public function getGlyphs($character, $server) { $cacheFileName = Functions::getCacheDir().'talents_'.$character.'.html'; $contents = Functions::getPageContents($this->talentURLBuilder($character, $server), $cacheFileName); $dom = Functions::loadNewDom($contents); $xpath = new DomXPath($dom); $glyphTypes = array("major", "minor", "prime"); $glyphArray = array(); foreach($glyphTypes as $gT) { $glyphNames = $xpath->query('//div[@class="character-glyphs-column glyphs-'.$gT.'"]/ul/li[@class="filled"]/a/span[@class="name"]'); $glyphLinks = $xpath->query('//div[@class="character-glyphs-column glyphs-'.$gT.'"]/ul/li[@class="filled"]/a/@href'); $ctr = 0; foreach($glyphNames as $g) { $itemNumber = explode("/", $glyphLinks->item($ctr)->nodeValue); $tmpArray = array( "name" => trim(utf8_decode($g->nodeValue)), "type" => $gT, "url" => $glyphLinks->item($ctr)->nodeValue, "itemNumber" => $itemNumber[4] ); array_push($glyphArray, $tmpArray); $ctr++; } } return $glyphArray; }