/** * Index * * @param string $request * The request to process * @return array */ public function index($request) { $snapshot_directory = Library::retrieve('snapshot_directory'); if (!$request->is('ajax')) { $snapshots = array(); $handler = @opendir($snapshot_directory); if (!$handler) { return compact('snapshots'); } while (($file = readdir($handler)) !== false) { $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (strpos($file, '.') === 0 || $ext != 'html') { continue; } $snapshots[] = $file; } closedir($handler); rsort($snapshots); return compact('snapshots'); } if (!isset($request->query['snapshot'])) { return ''; } $file = realpath($snapshot_directory) . "/{$request->query['snapshot']}"; return file_exists($file) ? file_get_contents($file) : ''; }
/** *@author Anurag Kabra *This function fetches index_terms from the table and adds it into an array. It also takes care of the ';' seperated user tags */ function getIndexTermsList() { $sql_index_query = "Select DISTINCT index_terms from bank"; include "db.php"; $link = mysql_connect($dbh, $user, $pass); if (!link) { die("Couldnt connect to MySql"); } mysql_select_db("{$db}"); $result_index = mysql_query($sql_index_query, $link) or die(mysql_error()); $array_index = array(); while ($row_index = mysql_fetch_object($result_index)) { $row_data = $row_index->index_terms; $token = trim(strtok($row_data, ";")); while ($token != false) { if (strcasecmp($token, '""') != 0) { if (array_search(trim($token), $array_index) > 0) { } else { array_push($array_index, trim($token)); } } $token = trim(strtok(";")); } } rsort($array_index); return $array_index; }
function get_domain($domain) { global $CFG, $USER, $l10n; if (!isset($USER->locale)) { $USER->locale = $CFG->defaultlocale; } if (!isset($l10n[$domain])) { $l10n[$domain] = array(); } if (isset($l10n[$domain][$USER->locale])) { return $l10n[$domain][$USER->locale]; } else { if (array_key_exists($USER->locale, $CFG->languages_domain_paths[$domain])) { rsort($CFG->languages_domain_paths[$domain][$USER->locale]); foreach ($CFG->languages_domain_paths[$domain][$USER->locale] as $languagedomain) { // Double check if file exists if (file_exists($languagedomain)) { $input = new CachedFileReader($languagedomain); $l10n[$domain][$USER->locale][] = new gettext_reader($input); } } return $l10n[$domain][$USER->locale]; } else { return; } } }
/** * You got to admit, that's pretty funny for a function name :) * What it does is simply trying to delete all the installer files * including this one! */ function DeleteYourself() { /* * >>> IMPORTANT! <<<< * * NOTE: This code only provides you with the ability to completly make the Installer * remove itself from the webserver (if it can). HOWEVER - you can modify this * function to only delete SOME files or some spesific files rather than deleting * everything. * * Example: You have made a very descriptive "step-by-step" guide to how to get * this installer going. The file "installer.php" is only allowed to be * executed directly so this method could only delete that file. Then, * in your guide you could say "Delete the script file installer.php if * the Installer itself is unable to" - rather then saying delete the * Installer folder, which contains 55+ files including images etc. * Just a suggestion :) */ global $config; // Read the base directory for files to delete and sort the array so that the longest // scopes are deleted first - example: base/aaa.txt base/folder/bbb.txt - then bbb.txt // will be the first because it has scope of 2, and aaa.txt has the scope 1 $files = ReadFiles(INST_BASEDIR . INST_RUNFOLDER, $config['self_destruct_filter']); rsort($files); // Get all unique directories into one array and sort by scope as well $dirs = array(); foreach ($files as $file) { if (!isset($dirs[$file['dir']])) { $dirs[$file['dir']] = $file['scope']; } } arsort($dirs); // Success rate is stored $fileDelete = array('success' => 0, 'failed' => 0, 'total' => count($files)); $dirDelete = array('success' => 0, 'failed' => 0, 'total' => count($dirs)); // Begin with deleting the files foreach ($files as $file) { if (unlink($file['dir'] . $file['name'])) { $fileDelete['success']++; } else { $fileDelete['failed']++; } } if ($config['self_destruct_removes_folders']) { // And then delete the directories foreach ($dirs as $dir => $scope) { if (rmdir($dir)) { $dirDelete['success']++; } else { $dirDelete['failed']++; } } } else { // Total reset to zero, so no folder should be // deleted, no success and no failure! $dirDelete['total'] = 0; } // Return back the success of deletion return array('dirs' => $dirDelete, 'files' => $fileDelete); }
/** * Construct +----------------------------------------- * @access public * @param array $config */ public function __construct($config = array()) { if (empty($config['routes'])) { $config['routes'] = array(); } $routes = array_merge($config['routes'], self::$rules); $path_info = $_SERVER['PATH_INFO']; $count = 0; $reg = str_replace('/', '(\\/', trim($path_info, '/'), $count); $pef = str_repeat('){0,1}', $count + 1); preg_match_all("/,\\/({$reg}{$pef}\\//", ',' . implode(',', array_keys($routes)), $matchs); $matchs = array_filter($matchs[0]); rsort($matchs); if (!$matchs) { $matchs = array('//'); } if (!empty($routes['/'])) { $routes['//'] =& $routes['/']; } foreach ($matchs as $v) { if (($r = substr($v, 1)) && isset($routes[$r]) && is_callable($routes[$r]['callback'])) { return call_user_func_array($routes[$r]['callback'], self::params($path_info, $r, $routes[$r]['params'])); } } }
/** * Sets the list of Router classes this ApiRouter uses * * @param array $routers A list of Routers indexed by version */ public function setRouters(array $routers) { $k = array_keys($routers); rsort($k); $this->latestVersion = current($k); $this->routers = $routers; }
function wpb_latest_sticky() { /* Get all sticky posts */ $sticky = get_option('sticky_posts'); /* Sort the stickies with the newest ones at the top */ rsort($sticky); /* Get the 5 newest stickies (change 5 for a different number) */ $sticky = array_slice($sticky, 0, 1); /* Query sticky posts */ $the_query = new WP_Query(array('post__in' => $sticky, 'ignore_sticky_posts' => 1)); // The Loop $arr = array(); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); $arr['permlink'] = get_permalink("", "", false); $arr['title'] = get_the_title("", "", false); $arr['excerpt'] = get_the_excerpt("", "", false); $arr['img_url'] = get_the_post_thumbnail_url(); } } else { // no posts found $arr['excerpt'] = $arr['title'] = $arr['permlink'] = $arr["img_url"] = "404 not found any featured post ! :( "; } /* Restore original Post Data */ wp_reset_postdata(); return $arr; }
function System_Creator($num, $test = NULL) { //Creation and rating of chromosomes of future systems $ratings = array(); $chromosomes = array(); for ($i = 0; $i < $num; $i++) { $chromosome = $this->Random_Chromosome(); $rating = $this->Rate_Chromosome($chromosome); $ratings[] = $rating; $chromosomes[] = $chromosome; } rsort($ratings); foreach ($ratings as $key => $value) { $this->queue[$key] = array('rating' => $value, 'chromosome' => $chromosomes[$key]); } //Spreading energy between most perspective systems in first launch $count = $this->simultaneous_systems_count; $energy_per_system = $this->energy / $count; //Creating systems $threads = new Threads(); for ($i = 0; $i < $count; $i++) { $threads->newThread('D:/web/www/lh/tests/fuzzy/system/system.php', $this->queue[0]); //Delete first element and reindex queue unset($this->queue[0]); $this->queue = array_values($this->queue); } while (false !== ($result = $threads->iteration())) { echo $result . "\r\n"; } //$this->Run_Test($test); }
function ucc_sort_portalpages_for_client($mypages_id, $sort_type = '', $sort = '') { //sorting if (isset($sort_type) && 'date' == strtolower($sort_type)) { //by date if (isset($sort) && 'desc' == strtolower($sort)) { rsort($mypages_id); } else { sort($mypages_id); } } elseif (isset($sort_type) && 'title' == strtolower($sort_type)) { //by alphabetical if (is_array($mypages_id) && $mypages_id) { foreach ($mypages_id as $page_id) { $mypage = get_post($page_id, 'ARRAY_A'); $for_sort[$page_id] = strtolower(nl2br($mypage['post_title'])); } if (isset($sort) && 'desc' == strtolower($sort)) { arsort($for_sort); } else { asort($for_sort); } $mypages_id = array_keys($for_sort); } } return $mypages_id; }
function recentSpectrograms($subnet, $WEBPLOTS, $MINFILES, $MAXDAYS) { # Loop from today and over the $MAXDAYS last days, until at least $MINFILES spectrograms found $filesarray = array(); $time = time() + 1000; # check 1000s ahead in case time is slow on kiska $daysago = 0; do { list($year, $month, $day, $hour, $minute) = epoch2YmdHM($time); $minute = floorminute($minute); $filepath = "{$WEBPLOTS}/{$subnet}/{$year}/{$month}/{$day}/2*.png"; $thisarray = glob($filepath); rsort($thisarray); if (count($thisarray) > 0) { $filesarray = array_merge($filesarray, $thisarray); } $time = $time - 86400; $daysago++; } while (count($filesarray) < $MINFILES && $daysago < $MAXDAYS); rsort($filesarray); $nonzerofilesarray = array(); foreach ($filesarray as $myfile) { $size = filesize($myfile); if ($size > 0) { $nonzerofilesarray[] = $myfile; #print "$myfile<br/>\n"; } } $nonzerofilesarray = array_slice($nonzerofilesarray, 0, $MINFILES); return $nonzerofilesarray; }
static function denormalize($phone) { $p = self::normalize($phone); if (!self::$phones) { self::$phones = (include __DIR__ . '/config/phones.php'); } $config = self::$phones; if (!count($config)) { return $p; } $codes = array_keys($config); rsort($codes); foreach ($codes as $code) { if ($code == mb_substr($p, 0, mb_strlen($code))) { $mask = $config[$code]['mask']; $phone_array = str_split(mb_substr($p, mb_strlen($code))); $mask_array = str_split($mask); foreach ($mask_array as $key => $symbol) { if ('#' == $symbol) { $mask_array[$key] = array_shift($phone_array); } } return implode('', $mask_array); } } return null; }
public function __construct() { /** * 实例化容器,并且保存在此载体中 */ if (empty(static::$app)) { static::$app = new Application(); } /** * 通过反射获取所有父类,并且获取他们的类名,通过这些类名来形成构造函数 * 比如当前类的构造函数为 $this->OBlood() * 切记:Application类不能继承此类 */ $reflectionClass = new \ReflectionClass($this); $constructs[] = $reflectionClass->getShortName(); $parentClass = $reflectionClass->getParentClass(); while ($parentClass != false) { $constructs[] = $parentClass->getShortName(); $parentClass = $parentClass->getParentClass(); } /** * 这里采用倒叙的方式来进行排列, * 主要是以顶级父类为最先执行,一次向下 */ rsort($constructs); foreach ($constructs as $construct) { if (method_exists($this, $construct)) { call_user_func_array([$this, $construct], func_get_args()); } } }
function find_even_max($lines, $regex_match, $regex_replace) { $a = array(); foreach ($lines as $line) { if (!preg_match($regex_match, $line)) { continue; } // Isolate the version and put in an array $slice = preg_replace($regex_replace, "\$1", $line); if ("x{$slice}" == "x{$line}") { continue; } // Skip odd numbered minor versions and minors > 80 list($major, $minor) = explode(".", $slice . ".0", 2); if ($minor % 2 == 1) { continue; } if ($minor > 80) { continue; } array_push($a, $slice); } // SORT_NATURAL requires php-5.4.0 or later rsort($a, SORT_NATURAL); // Max version is at the top return isset($a[0]) ? $a[0] : 0; }
function scandir($directory, $sorting_order = 0) { if (!is_string($directory)) { user_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING); return; } if (!is_int($sorting_order) && !is_bool($sorting_order)) { user_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING); return; } if (!is_dir($directory) || false === ($fh = @opendir($directory))) { user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING); return false; } $files = array(); while (false !== ($filename = readdir($fh))) { $files[] = $filename; } closedir($fh); if ($sorting_order == 1) { rsort($files); } else { sort($files); } return $files; }
public function test(CqmPatient $patient, $beginDate, $endDate) { // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months) $date_array = array(); foreach ($this->getApplicableEncounters() as $encType) { $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate); $date_array = array_merge($date_array, $dates); } // sort array to get the most recent encounter first $date_array = array_unique($date_array); rsort($date_array); // go through each unique date from most recent foreach ($date_array as $date) { // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable $date = date('Y-m-d 23:59:59', strtotime($date)); $beginMinus24Months = strtotime('-24 month', strtotime($date)); $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months); // this is basically a check to see if the patient is an reported as an active smoker on their last encounter if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) { return true; } else { if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) { return false; } else { // nothing reported during this date period, so move on to next encounter } } } return false; }
/** * Lists all Idea entities. * */ public function indexAction() { $em = $this->getDoctrine()->getEntityManager(); $entities = $em->getRepository('TouqIdeasBundle:Idea')->findAll(); rsort($entities); return $this->render('TouqIdeasBundle:Idea:index.html.twig', array('entities' => $entities)); }
function top_ressources_mem_generate() { $sock = new sockets(); $datas = $sock->getfile('dstattopressourcesmem'); $tbl = explode("\n", $datas); if (is_array($tbl)) { while (list($num, $file) = each($tbl)) { if ($file == null) { continue; } if (preg_match('#dstat\\.topmem\\.([0-9]+)\\.(.+?)\\.png#', $file, $re)) { $arr[$re[1]] = "ressources/logs/{$file}"; } else { echo "<br>{$file} !!"; } } } if (!is_array($arr)) { return null; } rsort($arr); while (list($num, $file) = each($arr)) { $images = $images . "<div style='width:525px;padding:3px;margin:3px border:1px solid #CCCCCC;'>" . RoundedLightWhite("<img src='{$file}'>") . "</div><br>"; } return $images; }
public function addCategory() { if (!Phpfox::getService('blog.category')->canAdd()) { return $this->alert(Phpfox::getPhrase('blog.you_have_reached_your_limit')); } $aVals = $this->get('val'); $oBlogCategoryProcess = Phpfox::getService('blog.category.process'); $sCleanUrl = Phpfox::getLib('parse.input')->clean($aVals['add']); if (Phpfox::getService('blog.category')->isPrivateCategory($sCleanUrl, Phpfox::getUserId())) { $this->call('alert("' . Phpfox::getPhrase('blog.already_a_category') . '"); $("#js_add_category").val(""); $("#js_add_category").focus();'); return false; } $aCategories = explode(',', $aVals['add']); $aRows = array(); foreach ($aCategories as $sCategory) { $sCategory = trim($sCategory); $iId = $oBlogCategoryProcess->add($sCategory); $aRows[] = array('category_id' => $iId, 'name' => Phpfox::getLib('parse.input')->clean($sCategory, 255)); } rsort($aRows); foreach ($aRows as $aRow) { Phpfox::getLib('template')->assign(array('aItem' => array('category_id' => $aRow['category_id'], 'name' => $aRow['name'], 'user_id' => Phpfox::getUserId()))); Phpfox::getLib('template')->getTemplate('blog.block.category-form'); } $this->call('$("#js_add_new_category").prepend("' . $this->getContent() . '").highlightFade(); $("#js_category_info").html("' . Phpfox::getPhrase('blog.added') . '").highlightFade().fadeOut(5000); $("#js_add_category").val(""); $Core.loadInit();'); }
function emailListener() { $connection = establishConnection(); $dbConn = establishDBConnection(); $messagestatus = "UNSEEN"; $emails = imap_search($connection, $messagestatus); if ($emails) { rsort($emails); foreach ($emails as $email_number) { // echo "in email loop"; $header = imap_headerinfo($connection, $email_number); $message = imap_fetchbody($connection, $email_number, 1.1); if ($message == "") { $message = imap_fetchbody($connection, $email_number, 1); } $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1)); if (!detectOOOmessage($header->subject, $message, $emailaddress)) { detectBIOmessage($header->subject, $emailaddress); } imap_delete($connection, 1); //this might bug out but should delete the top message that was just parsed } } $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1"); //delete mentors that have been away for more than 24 hours from the away list }
function get_live_list_html($LIVE_LIST, $lang = 'zh-tw') { $l10n = array('en' => array('Live' => 'Live Broadcast', 'Online' => 'On air', 'Over' => 'Over'), 'zh-tw' => array('Live' => '線上直播', 'Online' => '放送中', 'Over' => '已經結束'), 'zh-cn' => array('Live' => '在线观看', 'Online' => '播放中', 'Over' => '放映结束')); rsort($LIVE_LIST); $html = ''; $html .= sprintf("<h1 id=\"Live\">%s</h1>\n", htmlspecialchars($l10n[$lang]['Live'])); $html .= "<div class=\"live\">\n"; foreach ($LIVE_LIST as $idx => &$live) { $html .= " <div class=\"list\">\n"; $html .= "<div>\n"; $formated_from = strftime("%m/%d %R", $live['from']); $formated_to = strftime("%R", $live['to']); $html .= sprintf(" <span>%s - %s</span>\n", htmlspecialchars($formated_from), htmlspecialchars($formated_to)); if ($live['isOnline']) { $html .= sprintf(" <span class=\"online\">%s</span>\n", htmlspecialchars($l10n[$lang]['Online'])); } else { $html .= sprintf(" <span class=\"online end\">%s</span>\n", htmlspecialchars($l10n[$lang]['Over'])); } $html .= "</div>\n"; $html .= sprintf(" <div class=\"title\">%s</div>\n", htmlspecialchars($live['title'])); $html .= sprintf(" <div class=\"speaker\">%s</div>\n", htmlspecialchars($live['speaker'])); if ($live['isOnline']) { $html .= sprintf(" <div class=\"link\"><a href=\"%s\" target=\"_blank\">%s</a></div>\n", htmlspecialchars($live['url']), htmlspecialchars($live['url'])); $html .= sprintf(" <iframe src=\"%s\" frameborder=\"0\" allowfullscreen></iframe>\n", htmlspecialchars($live['url'])); } $html .= " </div>\n"; } $html .= "</div>\n"; // <div class="live"> return $html; }
public function actionImageManager() { $path = "data/editor/image/" . Ibos::app()->user->uid; $action = EnvUtil::getRequest("action"); if ($action == "get") { if (!defined("SAE_TMP_PATH")) { $files = $this->getfiles($path); if (!$files) { return null; } rsort($files, SORT_STRING); $str = ""; foreach ($files as $file) { $str .= "../../../../../../" . $file . "ue_separate_ue"; } echo $str; } else { $st = new SaeStorage(); $num = 0; while ($ret = $st->getList("data", $path, 100, $num)) { foreach ($ret as $file) { if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) { echo $st->getUrl("data", $file) . "ue_separate_ue"; } $num++; } } } } }
function inventory_list($source_dir) { // Open the dir and set the vars $root = opendir($source_dir); $output = array(); while ($file = readdir($root)) { if ($file != ".." && $file[0] != '.' && $file != "Inventory") { //If file is a subdirectory, pop inside if (is_dir($file)) { // Loop through the subdirectory $filestore = array(); $filestore["dir"] = $file; $store = array(); $store["files"] = inventory_list($source_dir . '/' . $file); $filestore = array_merge($filestore, $store); $output[] = $filestore; } else { // Find and spit out only the HTML files if (preg_match('/(.*).html/', $file)) { $output[] = array("filename" => $file); } } } } closedir($root); rsort($output); return $output; }
/** * Gets IMAP content * * @param string $imapHost * @param string $imapUser * @param string $imapPassword * @param \Swiftriver\Core\ObjectModel\Channel $channel * * @return $contentItems[] */ private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel) { $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword); //Open up unseen messages $search = $channel->lastSuccess == null ? "UNSEEN" : "UNSEEN SINCE " . \date("Y-m-d", $channel->lastSuccess); $imapEmails = imap_search($imapResource, $search); $contentItems = array(); if ($imapEmails) { //Put newest emails on top rsort($imapEmails); foreach ($imapEmails as $Email) { //Loop through each email and return the content $email_overview = imap_fetch_overview($imapResource, $Email, 0); if (strtotime(reset($email_overview)->date) < $channel->lastSuccess) { continue; } $email_header_info = imap_header($imapResource, $Email); $email_message = imap_fetchbody($imapResource, $Email, 1); $source_name = \reset($email_overview)->from; $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name); $source->name = $source_name; $source->parent = $channel->id; $source->type = $channel->type; $source->subType = $channel->subType; $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source); $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message)); //the message $item->link = null; $item->date = $email_header_info->udate; $contentItems[] = $item; } } imap_close($imapResource); return $contentItems; }
public function index() { $esta = $this->db->get('establishment', 10); foreach ($esta->result() as $v) { $data = $this->db->query("select * from offers where establishment_id = '" . $v->id . "' AND offer_type IN ('Discount Percentage', 'Discount', 'Cashback Percentage', 'Cashback', 'Reward Points', 'Reward Point Multiplier');"); if ($data->num_rows() > 0) { $cards_val = array(); foreach ($data->result() as $data_row) { $cards_arr = explode(",", $data_row->card_name); $cards_count = count($cards_arr); for ($i = 0; $i < $cards_count; $i++) { $disc_per = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Discount Percentage';")->row(); $disc = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Discount';")->row(); $cashback_per = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Cashback Percentage';")->row(); $cashback = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Cashback';")->row(); $reward_pt = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Reward Points';")->row(); $reward_pt_mul = $this->db->query("select * from offers where establishment_id = '" . addslashes($data_row->establishment_id) . "' AND card_name like '%," . $cards_arr[$i] . ",%' AND offer_type = 'Reward Point Multiplier';")->row(); $value = @$disc_per->amount + @$disc->amount + @$cashback_per->amount + @$cashback->amount + @$reward_pt->amount + @$reward_pt_mul->amount; $cards_val[$cards_arr[$i]] = $value; } } rsort($cards_val); $maxs = array_search(max($cards_val), $cards_val); // $maxs = array_keys($cards_val, max($cards_val)); echo "Card Identity : " . $maxs; echo "<hr />"; $card_data = array("ultimate_card" => $maxs); $this->db->where('id', $est_name); $this->db->update('establishment', $card_data); } } }
function unshorten($content) { include "conf.php"; $dh = opendir($post_dir); if ($dh == False) { echo "Couldent open posts directory"; return 0; } while (false !== ($filename = readdir($dh))) { $files[] = $filename; } $count = 0; //variable that holds how many posts we've printed. rsort($files); foreach ($files as $f) { $hash = md5($f); $hash = substr($hash, 0, 6); if ($hash == $content) { // This file matches the short hash we were looking for - here we enforce a redirect header("Location: /blog.php?p=" . $f); // Assuming no output before this point, will send a HTTP Redirect } } echo "Invalid link"; return False; }
/** * stringifyPayments * Takes an array of payments and generates a legal phrasing of those payments * * @param mixed $payments * @access public * @return void */ public function stringifyPayments($payments) { if (!count($payments)) { return null; } rsort($payments); $uniquePayments = array_unique($payments); $seen = array_combine(array_values($uniquePayments), array_fill(0, count($uniquePayments), 0)); foreach ($payments as $payment) { $seen[$payment]++; } $count = 0; $numTotal = 0; foreach ($seen as $paymentAmount => $num) { $today = $myToday = new \DateTime(); $myToday = new \DateTime(); $commenceDate = !empty($dueDate) ? $dueDate->add(new \DateInterval('P1M'))->format('Y-m-d') : $myToday->add(new \DateInterval('P1M'))->format('Y-m-d'); $dueDate = $today->add(new \DateInterval('P' . $numTotal . 'M')); $numTotal += $num; $dueDateStr = $dueDate->format('m/d/y'); $dueString = $num > 1 ? 'due on the ' . $today->format('jS') . ' day of the month, commencing on' : 'due'; $str = sprintf('%s %s of $%5.2f %s %s', $num, $num < 2 ? 'installment' : 'monthly installments', $paymentAmount, $dueString, $dueDateStr); $clauses[] = $str; } $joinStr = count($clauses) == 2 ? '; thereafter ' : '; '; return join('; ', $clauses); }
function create($sitemap_name = '') { if(!$sitemap_name) $sitemap_name = SS_ADMIN_TO_USERFILE . "/sitemap.xml"; if(empty($sitemap_name)) $sitemap_name = "sitemap_" . $rep_name . ".xml"; $changefreq = array('daily', 'weekly', 'monthly'); $priority = array('0.1', '0.5', '1.0'); $tab_archive = array(); rsort($tab_archive); $xml = simplexml_load_file(SS_ADMIN_TO_USERFILE . '/google/sitemap_base.xml'); //scan bdd $sql = "SELECT * FROM page WHERE etat = 1"; $res = CBdd::select($sql); while($page = mysql_fetch_array($res)) { $url = $xml->addChild('url'); $url->addChild('loc', CUrl::get_urlsite() . "/" . CFunction::formate_chaine(utf8_decode($page['nom']), '-') . "_p" . $page['id']. ".html"); $url->addChild('lastmod', CDate::formate_date($page['date'])); $url->addChild('changefreq', $changefreq[rand(0, 2)]); $url->addChild('priority', $priority[rand(0, 2)]); } $html = $xml->asXML(); file_put_contents($sitemap_name, $html); }
/** * getExported * * @return array */ public function getExported() { $path = ProfileHelper::getPath(); $list = \JFolder::files($path . '/export/sql', '.', false, true); rsort($list); return $list; }
public static function execute(&$Logger, &$Workflow, \sellrtb\workflows\tasklets\popo\AuctionPopo &$AuctionPopo) { // init $AuctionPopo->bid_price_list = array(); $AuctionPopo->adjusted_bid_price_list = array(); $AuctionPopo->adusted_bid_amount_before_private_exchange_markup_list = array(); $RTBPingerList = $AuctionPopo->SelectedPingerList; $result = false; foreach ($RTBPingerList as $method_outer_key => $RTBPinger) { foreach ($RTBPingerList[$method_outer_key]->RtbBidResponse->RtbBidResponseSeatBidList as $outer_key => $RtbBidResponseSeatBid) { foreach ($RTBPingerList[$method_outer_key]->RtbBidResponse->RtbBidResponseSeatBidList[$outer_key]->RtbBidResponseBidList as $key => $RtbBidResponseBid) { self::logBidPrice($Logger, $AuctionPopo, $RTBPingerList[$method_outer_key]->RtbBidResponse->RtbBidResponseSeatBidList[$outer_key]->RtbBidResponseBidList[$key]); $result = true; } } } // grab hashed keys of bid prices $AuctionPopo->bid_price_list = array_keys($AuctionPopo->bid_price_list); $AuctionPopo->adjusted_bid_price_list = array_keys($AuctionPopo->adjusted_bid_price_list); $AuctionPopo->adusted_bid_amount_before_private_exchange_markup_list = array_keys($AuctionPopo->adusted_bid_amount_before_private_exchange_markup_list); // reverse sort so the highest bid is the first item in the array rsort($AuctionPopo->bid_price_list); rsort($AuctionPopo->adjusted_bid_price_list); rsort($AuctionPopo->adusted_bid_amount_before_private_exchange_markup_list); return $result; }
/** * Gets the mail from the inbox * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox. */ function getMail() { $config = Config::current(); if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) { $hostname = '{' . $config->emailblog_server . '}INBOX'; # this isn't working well on localhost $username = $config->emailblog_address; $password = $config->emailblog_pass; $subjpass = $config->emailblog_subjpass; $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error()); $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"'); if ($emails) { rsort($emails); foreach ($emails as $email_number) { $message = imap_body($inbox, $email_number); $overview = imap_headerinfo($inbox, $email_number); imap_delete($inbox, $email_number); $title = htmlspecialchars($overview->Subject); $title = preg_replace($subjpass, "", $title); $clean = strtolower($title); $body = htmlspecialchars($message); # The subject of the email is used as the post title # the content of the email is used as the body # not sure about compatibility with images or audio feathers Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text"); } } # close the connection imap_close($inbox, CL_EXPUNGE); $config->set("emailblog_mail_checked", time()); } }