示例#1
1
 public function afterExample(ExampleEvent $event)
 {
     $total = $this->stats->getEventsCount();
     $counts = $this->stats->getCountsHash();
     $percents = array_map(function ($count) use($total) {
         return round($count / ($total / 100), 0);
     }, $counts);
     $lengths = array_map(function ($percent) {
         return round($percent / 2, 0);
     }, $percents);
     $size = 50;
     asort($lengths);
     $progress = array();
     foreach ($lengths as $status => $length) {
         $text = $percents[$status] . '%';
         $length = $size - $length >= 0 ? $length : $size;
         $size = $size - $length;
         if ($length > strlen($text) + 2) {
             $text = str_pad($text, $length, ' ', STR_PAD_BOTH);
         } else {
             $text = str_pad('', $length, ' ');
         }
         $progress[$status] = sprintf("<{$status}-bg>%s</{$status}-bg>", $text);
     }
     krsort($progress);
     $this->printException($event, 2);
     $this->io->writeTemp(implode('', $progress) . ' ' . $total);
 }
示例#2
0
 function special()
 {
     $page_title = strtolower($this->request->params['wikipage']);
     switch ($page_title) {
         // show pages index, sorted by title
         case 'page_index':
         case 'date_index':
             // eager load information about last updates, without loading text
             $this->Wiki->WikiPage->recursive = -1;
             $options = array('conditions' => array('WikiPage.wiki_id' => $this->Wiki->field('id')), 'fields' => 'WikiPage.*, WikiContent.updated_on', 'joins' => array(array("type" => 'LEFT', "table" => 'wiki_contents', "alias" => 'WikiContent', "conditions" => 'WikiContent.page_id=WikiPage.id')), 'order' => 'WikiPage.title');
             //'order' => 'Content.updated_on DESC');
             $pages = $this->Wiki->WikiPage->find('all', $options);
             $this->set('pages', $pages);
             // 以下、viewのための整形
             foreach ($pages as $page) {
                 $day = date('Y-m-d', strtotime($page['WikiContent']['updated_on']));
                 $pages_by_date[$day][] = $page;
             }
             krsort($pages_by_date);
             $this->set('pages_by_date', $pages_by_date);
             break;
         case 'export':
             $this->render("export_multiple");
             // temporary implementation. fixme.
             return;
             break;
         default:
             // requested special page doesn't exist, redirect to default page
             $this->redirect(array('controller' => 'wiki', 'action' => 'index', 'project_id' => $this->request->params['project_id'], 'wikipage' => null));
             break;
     }
     $this->render("special_{$page_title}");
 }
function Filllogs()
{
    $logsFile = $GLOBALS["LOG_FILE"];
    $t = explode("\n", @file_get_contents($logsFile));
    krsort($t);
    echo @implode("\n", $t);
}
 /**
  * Tests adding, getting, and order of priorities.
  *
  * @covers ::addProvider
  * @covers ::getSortedProviders
  * @covers ::getProvider
  * @covers ::isGlobal
  */
 public function testAuthenticationCollector()
 {
     $providers = [];
     $global = [];
     $authentication_collector = new AuthenticationCollector();
     $priorities = [2, 0, -8, 10, 1, 3, -5, 0, 6, -10, -4];
     foreach ($priorities as $priority) {
         $provider_id = $this->randomMachineName();
         $provider = new TestAuthenticationProvider($provider_id);
         $providers[$priority][$provider_id] = $provider;
         $global[$provider_id] = rand(0, 1) > 0.5;
         $authentication_collector->addProvider($provider, $provider_id, $priority, $global[$provider_id]);
     }
     // Sort the $providers array by priority (highest number is lowest priority)
     // and compare with AuthenticationCollector::getSortedProviders().
     krsort($providers);
     // Merge nested providers from $providers into $sorted_providers.
     $sorted_providers = [];
     foreach ($providers as $providers_priority) {
         $sorted_providers = array_merge($sorted_providers, $providers_priority);
     }
     $this->assertEquals($sorted_providers, $authentication_collector->getSortedProviders());
     // Test AuthenticationCollector::getProvider() and
     // AuthenticationCollector::isGlobal().
     foreach ($sorted_providers as $provider) {
         $this->assertEquals($provider, $authentication_collector->getProvider($provider->providerId));
         $this->assertEquals($global[$provider->providerId], $authentication_collector->isGlobal($provider->providerId));
     }
 }
示例#5
0
 /**
  * Compose and get order full history.
  * Consists of the status history comments as well as of invoices, shipments and creditmemos creations
  * @return array
  */
 public function getFullHistory()
 {
     $order = $this->getOrder();
     $history = array();
     foreach ($order->getAllStatusHistory() as $orderComment) {
         $history[$orderComment->getEntityId()] = $this->_prepareHistoryItem($orderComment->getStatusLabel(), $orderComment->getIsCustomerNotified(), $orderComment->getCreatedAtDate(), $orderComment->getComment());
     }
     foreach ($order->getCreditmemosCollection() as $_memo) {
         $history[$_memo->getEntityId()] = $this->_prepareHistoryItem($this->__('Credit memo #%s created', $_memo->getIncrementId()), $_memo->getEmailSent(), $_memo->getCreatedAtDate());
         foreach ($_memo->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Credit memo #%s comment added', $_memo->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getShipmentsCollection() as $_shipment) {
         $history[$_shipment->getEntityId()] = $this->_prepareHistoryItem($this->__('Shipment #%s created', $_shipment->getIncrementId()), $_shipment->getEmailSent(), $_shipment->getCreatedAtDate());
         foreach ($_shipment->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Shipment #%s comment added', $_shipment->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getInvoiceCollection() as $_invoice) {
         $history[$_invoice->getEntityId()] = $this->_prepareHistoryItem($this->__('Invoice #%s created', $_invoice->getIncrementId()), $_invoice->getEmailSent(), $_invoice->getCreatedAtDate());
         foreach ($_invoice->getCommentsCollection() as $_comment) {
             $history[$_comment->getEntityId()] = $this->_prepareHistoryItem($this->__('Invoice #%s comment added', $_invoice->getIncrementId()), $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
         }
     }
     foreach ($order->getTracksCollection() as $_track) {
         $history[$_track->getEntityId()] = $this->_prepareHistoryItem($this->__('Tracking number %s for %s assigned', $_track->getNumber(), $_track->getTitle()), false, $_track->getCreatedAtDate());
     }
     krsort($history);
     return $history;
 }
示例#6
0
 public function events()
 {
     $this->document->setTitle("America Travel Info");
     $this->load->model('index/index');
     global $LANGUAGE;
     $this->data['TEXT'] = $LANGUAGE;
     $language = $this->session->data['language'];
     //header banner
     $data = array("language_id" => $language);
     $eventsList = $this->model_index_index->getEvents($data);
     if (!isset($_GET['id'])) {
         $this->data['eventLast'] = $eventsList[0];
     } else {
         if (is_numeric($_GET['id'])) {
             $data['id'] = $_GET['id'];
             $this->data['eventLast'] = $this->model_index_index->getEventOne($data);
         }
     }
     // var_dump($this->data['eventLast']);
     // var_dump($eventsList);
     $result = array();
     foreach ($eventsList as $key => $e) {
         $result[$e['category']][] = $e;
     }
     krsort($result);
     // var_dump($result);
     $this->data['result'] = $result;
     $data['start'] = 0;
     $data['limit'] = 5;
     $events5 = $this->model_index_index->getEvents($data);
     $this->data['events5'] = $events5;
     $this->template = 'index/events.tpl';
     $this->children = array('common/footer', 'common/header');
     $this->response->setOutput($this->render());
 }
示例#7
0
 public function listeners($eventName = null)
 {
     // Return all events in a sorted priority order
     if ($eventName === null) {
         foreach (array_keys($this->listeners) as $eventName) {
             if (empty($this->sorted[$eventName])) {
                 $this->listeners($eventName);
             }
         }
         return $this->sorted;
     }
     // Return the listeners for a specific event, sorted in priority order
     if (empty($this->sorted[$eventName])) {
         $this->sorted[$eventName] = [];
         if (isset($this->listeners[$eventName])) {
             krsort($this->listeners[$eventName], SORT_NUMERIC);
             foreach ($this->listeners[$eventName] as $listeners) {
                 foreach ($listeners as $listener) {
                     $this->sorted[$eventName][] = $listener;
                 }
             }
         }
     }
     return $this->sorted[$eventName];
 }
示例#8
0
 function parse_template_bean($string, $bean_name, &$focus)
 {
     $repl_arr = array();
     foreach ($focus->field_defs as $field_def) {
         if ($field_def['type'] == 'enum' && isset($field_def['options'])) {
             $translated = translate($field_def['options'], $bean_name, $focus->{$field_def}['name']);
             if (isset($translated) && !is_array($translated)) {
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $translated;
             } else {
                 // unset enum field, make sure we have a match string to replace with ""
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = '';
             }
         } else {
             $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $focus->{$field_def}['name'];
         }
     }
     // end foreach()
     krsort($repl_arr);
     reset($repl_arr);
     foreach ($repl_arr as $name => $value) {
         if ($value != '' && is_string($value)) {
             $string = str_replace("\${$name}", $value, $string);
         } else {
             $string = str_replace("\${$name}", ' ', $string);
         }
     }
     return $string;
 }
示例#9
0
 /**
  * Retrieve accept types understandable by requester in a form of array sorted by quality in descending order.
  *
  * @return string[]
  */
 public function getAcceptTypes()
 {
     $qualityToTypes = [];
     $orderedTypes = [];
     foreach (preg_split('/,\\s*/', $this->getHeader('Accept')) as $definition) {
         $typeWithQ = explode(';', $definition);
         $mimeType = trim(array_shift($typeWithQ));
         // check MIME type validity
         if (!preg_match('~^([0-9a-z*+\\-]+)(?:/([0-9a-z*+\\-\\.]+))?$~i', $mimeType)) {
             continue;
         }
         $quality = '1.0';
         // default value for quality
         if ($typeWithQ) {
             $qAndValue = explode('=', $typeWithQ[0]);
             if (2 == count($qAndValue)) {
                 $quality = $qAndValue[1];
             }
         }
         $qualityToTypes[$quality][$mimeType] = true;
     }
     krsort($qualityToTypes);
     foreach ($qualityToTypes as $typeList) {
         $orderedTypes += $typeList;
     }
     return empty($orderedTypes) ? [self::DEFAULT_ACCEPT] : array_keys($orderedTypes);
 }
示例#10
0
文件: user.php 项目: vNative/vnative
 /**
  * Function will calculate the top publisher results
  * from the performance table
  * @return  Array of Top Earners
  */
 public static function topEarners($users, $dateQuery = [], $count = 10)
 {
     $pubClicks = [];
     $result = [];
     foreach ($users as $u) {
         $perf = \Performance::calculate($u, $dateQuery);
         $clicks = $perf['clicks'];
         if ($clicks === 0) {
             continue;
         }
         if (!array_key_exists($clicks, $pubClicks)) {
             $pubClicks[$clicks] = [];
         }
         $pubClicks[$clicks][] = AM::toObject(['name' => $u->name, 'clicks' => $clicks]);
     }
     if (count($pubClicks) === 0) {
         return $result;
     }
     krsort($pubClicks);
     array_splice($pubClicks, $count);
     $i = 0;
     foreach ($pubClicks as $key => $value) {
         foreach ($value as $u) {
             $result[] = $u;
             $i++;
             if ($i >= $count) {
                 break 2;
             }
         }
     }
     return $result;
 }
示例#11
0
文件: css.php 项目: gipix/azm
/**
 * Add the custom CSS editor to the admin menu.
 */
function siteorigin_custom_css_admin_menu()
{
    add_theme_page(__('Custom CSS', 'vantage'), __('Custom CSS', 'vantage'), 'edit_theme_options', 'siteorigin_custom_css', 'siteorigin_custom_css_page');
    if (current_user_can('edit_theme_options') && isset($_POST['siteorigin_custom_css_save'])) {
        check_admin_referer('custom_css', '_sononce');
        $theme = basename(get_template_directory());
        // Sanitize CSS input. Should keep most tags, apart from script and style tags.
        $custom_css = siteorigin_custom_css_clean(filter_input(INPUT_POST, 'custom_css'));
        $current = get_option('siteorigin_custom_css[' . $theme . ']');
        if ($current === false) {
            add_option('siteorigin_custom_css[' . $theme . ']', $custom_css, '', 'no');
        } else {
            update_option('siteorigin_custom_css[' . $theme . ']', $custom_css);
        }
        // If this has changed, then add a revision.
        if ($current != $custom_css) {
            $revisions = get_option('siteorigin_custom_css_revisions[' . $theme . ']');
            if (empty($revisions)) {
                add_option('siteorigin_custom_css_revisions[' . $theme . ']', array(), '', 'no');
                $revisions = array();
            }
            $revisions[time()] = $custom_css;
            // Sort the revisions and cut off any old ones.
            krsort($revisions);
            $revisions = array_slice($revisions, 0, 15, true);
            update_option('siteorigin_custom_css_revisions[' . $theme . ']', $revisions);
        }
    }
}
示例#12
0
 /**
  * 整理品牌
  * 所有品牌全部显示在一级类目下,不显示二三级类目
  * @param array $brand_c_list
  * @return array
  */
 private function _tidyBrand($brand_c_list)
 {
     $brand_listnew = array();
     $brand_class = array();
     $brand_r_list = array();
     if (!empty($brand_c_list) && is_array($brand_c_list)) {
         $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
         foreach ($brand_c_list as $key => $brand_c) {
             $gc_array = $this->_getTopClass($goods_class, $brand_c['class_id']);
             if (empty($gc_array)) {
                 if ($brand_c['show_type'] == 1) {
                     $brand_listnew[0]['text'][] = $brand_c;
                 } else {
                     $brand_listnew[0]['image'][] = $brand_c;
                 }
                 $brand_class[0]['brand_class'] = '其他';
             } else {
                 if ($brand_c['show_type'] == 1) {
                     $brand_listnew[$gc_array['gc_id']]['text'][] = $brand_c;
                 } else {
                     $brand_listnew[$gc_array['gc_id']]['image'][] = $brand_c;
                 }
                 $brand_class[$gc_array['gc_id']]['brand_class'] = $gc_array['gc_name'];
             }
             //推荐品牌
             if ($brand_c['brand_recommend'] == 1) {
                 $brand_r_list[] = $brand_c;
             }
         }
     }
     krsort($brand_class);
     krsort($brand_listnew);
     return array('brand_listnew' => $brand_listnew, 'brand_class' => $brand_class, 'brand_r_list' => $brand_r_list);
 }
示例#13
0
 public function orderTags(&$tags, $order)
 {
     switch ($order) {
         case 'alpha':
             usort($tags, create_function('$a, $b', 'return strcmp($a->name, $b->name);'));
             break;
         case 'ralpha':
             usort($tags, create_function('$a, $b', 'return strcmp($b->name, $a->name);'));
             break;
         case 'acount':
             krsort($tags);
             $tags = array_merge($tags);
             break;
         case 'ocount':
             $this->_count_sort($tags);
             break;
         case 'icount':
             krsort($tags);
             $this->_count_sort($tags);
             break;
         case 'random':
             shuffle($tags);
             break;
     }
 }
示例#14
0
 public static function getPhrases()
 {
     static $phrases;
     if (!$phrases) {
         $filename = dirname(__FILE__) . '/Data/phrases.cnf';
         if (!file_exists($filename)) {
             throw new Exception("Missing file '{$file}'.");
         }
         $data = file_get_contents($filename);
         // remove comments and empty lines
         $data = preg_replace('/^#(.*)$/m', '', $data);
         $data = preg_replace('/^\\s*\\n/m', '', $data);
         $data = trim($data);
         $data = preg_split('/^\\[([0-9.]+)\\](?:\\s*([0-9+-]+))$/m', $data, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
         //var_dump($data); exit;
         $phrases = array();
         for ($i = 0; $i < count($data); $i += 3) {
             $code = $data[$i];
             $sort = (double) $data[$i + 1];
             $rows = explode("\n", trim($data[$i + 2]));
             if (!isset($phrases[$sort])) {
                 $phrases[$sort] = array();
             }
             $phrases[$sort][$code] = $rows;
         }
         krsort($phrases, SORT_NUMERIC);
         //var_dump($phrases); exit;
     }
     return $phrases;
 }
示例#15
0
 /**
  * Add a route to the collection.
  *
  * @param \Cake\Routing\Route\Route $route The route object to add.
  * @param array $options Additional options for the route. Primarily for the
  *   `_name` option, which enables named routes.
  * @return void
  */
 public function add(Route $route, array $options = [])
 {
     $this->_routes[] = $route;
     // Explicit names
     if (isset($options['_name'])) {
         $this->_named[$options['_name']] = $route;
     }
     // Generated names.
     $name = $route->getName();
     if (!isset($this->_routeTable[$name])) {
         $this->_routeTable[$name] = [];
     }
     $this->_routeTable[$name][] = $route;
     // Index path prefixes (for parsing)
     $path = $route->staticPath();
     if (empty($this->_paths[$path])) {
         $this->_paths[$path] = [];
         krsort($this->_paths);
     }
     $this->_paths[$path][] = $route;
     $extensions = $route->extensions();
     if ($extensions) {
         $this->extensions($extensions);
     }
 }
示例#16
0
 /**
  * 签名生成
  * @var string
  */
 public static function sign($data = array(), $key, $exchange_rule = "")
 {
     $sign = "";
     if (!empty($exchange_rule)) {
         //加密使用
         $encryptArr = array();
         $encryptArr['~partner_order~'] = $data['partner_order'];
         $encryptArr['~username~'] = $data['username'];
         $encryptArr['~AppId~'] = $data['AppId'];
         $encryptArr['~ServerId~'] = $data['ServerId'];
         $encryptArr['~amount~'] = $data['amount'];
         $search = array_keys($encryptArr);
         $replace = array_values($encryptArr);
         $sign = str_replace($search, $replace, $exchange_rule);
     } else {
         if (!empty($data['sign'])) {
             unset($data['sign']);
         }
         krsort($data);
         foreach ($data as $k => $v) {
             $sign .= $v;
         }
     }
     return md5($sign . $key);
 }
示例#17
0
 public static function pastWorks()
 {
     $directory = "./img/works/";
     $images = glob($directory . "*.jpg");
     $products = array();
     /* get all the products, then sort them into categories and order them by their name (number) */
     foreach ($images as $key => $image) {
         $imageName = str_replace(array('./img/works/', '.jpg'), '', $image);
         $parts = explode('_', $imageName);
         $num = $parts[0];
         $type = $parts[1];
         $products[$type][intval($num)] = new Product(null, $key, null, null, null, $image, $type);
     }
     /* reverse the product arrays (so largest number, i.e. most recent, is first) */
     $max = 0;
     $finalProducts = array();
     foreach ($products as &$category) {
         krsort($category);
         $category = array_values($category);
         $max = max(array_keys($category)) > $max ? max(array_keys($category)) : $max;
     }
     /* add them all into a final array */
     for ($i = 0; $i <= $max; $i++) {
         foreach ($products as $p) {
             if (isset($p[$i])) {
                 $finalProducts[] = $p[$i];
             }
         }
     }
     return $finalProducts;
 }
示例#18
0
function PrintDiff($pagename) {
  global $DiffHTMLFunction,$DiffShow,$DiffStartFmt,$TimeFmt,
    $DiffEndFmt,$DiffRestoreFmt,$FmtV, $LinkFunctions;
  $page = ReadPage($pagename);
  if (!$page) return;
  krsort($page); reset($page);
  $lf = $LinkFunctions;
  $LinkFunctions['http:'] = 'LinkSuppress';
  $LinkFunctions['https:'] = 'LinkSuppress';
  SDV($DiffHTMLFunction, 'DiffHTML');
  foreach($page as $k=>$v) {
    if (!preg_match("/^diff:(\d+):(\d+):?([^:]*)/",$k,$match)) continue;
    $diffclass = $match[3];
    if ($diffclass=='minor' && $DiffShow['minor']!='y') continue;
    $diffgmt = $FmtV['$DiffGMT'] = $match[1];
    $FmtV['$DiffTime'] = strftime($TimeFmt,$diffgmt);
    $diffauthor = @$page["author:$diffgmt"]; 
    if (!$diffauthor) @$diffauthor=$page["host:$diffgmt"];
    if (!$diffauthor) $diffauthor="unknown";
    $FmtV['$DiffChangeSum'] = htmlspecialchars(@$page["csum:$diffgmt"]);
    $FmtV['$DiffHost'] = @$page["host:$diffgmt"];
    $FmtV['$DiffAuthor'] = $diffauthor;
    $FmtV['$DiffId'] = $k;
    $html = $DiffHTMLFunction($pagename, $v);
    if ($html===false) continue;
    echo FmtPageName($DiffStartFmt,$pagename);
    echo $html;
    echo FmtPageName($DiffEndFmt,$pagename);
    echo FmtPageName($DiffRestoreFmt,$pagename);
  }
  $LinkFunctions = $lf;
}
 /**
  * @param \TYPO3\Flow\Object\ObjectManagerInterface $objectManager
  * @return array Array of sorted operations and array of final operation names
  * @Flow\CompileStatic
  * @throws \TYPO3\Eel\FlowQuery\FlowQueryException
  */
 public static function buildOperationsAndFinalOperationNames($objectManager)
 {
     $operations = array();
     $finalOperationNames = array();
     $reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class);
     $operationClassNames = $reflectionService->getAllImplementationClassNamesForInterface(\TYPO3\Eel\FlowQuery\OperationInterface::class);
     /** @var $operationClassName OperationInterface */
     foreach ($operationClassNames as $operationClassName) {
         $shortOperationName = $operationClassName::getShortName();
         $operationPriority = $operationClassName::getPriority();
         $isFinalOperation = $operationClassName::isFinal();
         if (!isset($operations[$shortOperationName])) {
             $operations[$shortOperationName] = array();
         }
         if (isset($operations[$shortOperationName][$operationPriority])) {
             throw new FlowQueryException(sprintf('Operation with name "%s" and priority %s is already defined in class %s, and the class %s has the same priority and name.', $shortOperationName, $operationPriority, $operations[$shortOperationName][$operationPriority], $operationClassName), 1332491678);
         }
         $operations[$shortOperationName][$operationPriority] = $operationClassName;
         if ($isFinalOperation) {
             $finalOperationNames[$shortOperationName] = $shortOperationName;
         }
     }
     foreach ($operations as &$operation) {
         krsort($operation, SORT_NUMERIC);
     }
     return array($operations, $finalOperationNames);
 }
 /**
  * 快递查询
  */
 public function detail()
 {
     $data['id'] = $_GET['id'];
     $vo = $this->db->where($data)->find();
     $this->assign('vo', $vo);
     if (!$vo) {
         $this->error('物流信息不存在');
     }
     $dir = get_dir($vo['id']);
     if (file_exists(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php')) {
         $list = (include C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php');
     } else {
         include C('PUBLIC_INCLUDE') . "kuaidi.class.php";
         $kuaidi = new kuaidi();
         $list = $kuaidi->query($vo['shipping_code'], $vo['shipping_no']);
         krsort($list['data']);
         mk_dir(C('DATA_CACHE_PATH') . '/delivery/');
         if ($list['state'] == 3) {
             mk_dir(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/');
             F('list', $list, C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/');
         }
     }
     if ($list) {
         $list['count'] = count($list['data']);
     } else {
         $list['message'] = $kuaidi->error;
     }
     if (!$list) {
         $this->error($kuaidi->getError());
     } else {
         $result['data'] = $list;
         $result['notice'] = '查询成功';
         ajaxSucReturn($result);
     }
 }
示例#21
0
 function debug_backtrace()
 {
     $skipfunc[] = 'discuz_error->debug_backtrace';
     $skipfunc[] = 'discuz_error->db_error';
     $skipfunc[] = 'discuz_error->template_error';
     $skipfunc[] = 'discuz_error->system_error';
     $skipfunc[] = 'db_mysql->halt';
     $skipfunc[] = 'db_mysql->query';
     $skipfunc[] = 'DB::_execute';
     $show = $log = '';
     $debug_backtrace = debug_backtrace();
     krsort($debug_backtrace);
     foreach ($debug_backtrace as $k => $error) {
         $file = str_replace(DISCUZ_ROOT, '', $error['file']);
         $func = isset($error['class']) ? $error['class'] : '';
         $func .= isset($error['type']) ? $error['type'] : '';
         $func .= isset($error['function']) ? $error['function'] : '';
         if (in_array($func, $skipfunc)) {
             break;
         }
         $error[line] = sprintf('%04d', $error['line']);
         $show .= "<li>[Line: {$error['line']}]" . $file . "({$func})</li>";
         $log .= !empty($log) ? ' -> ' : '';
         $file . ':' . $error['line'];
         $log .= $file . ':' . $error['line'];
     }
     return array($show, $log);
 }
示例#22
0
 public function __construct($em, $securedRoutes)
 {
     $this->em = $em;
     // set longest element of the same route first
     $this->securedRoutes = $securedRoutes;
     krsort($securedRoutes, SORT_NATURAL | SORT_STRING);
 }
示例#23
0
/**
 * 取得今天要顯示的圖片
 * @return 圖片的完整路徑 (含檔名)
 *     FALSE: 找不到圖片
 **/
function getTodayImage($orgimg)
{
    global $chroot, $imgext;
    $dir = $chroot;
    $now = date('Ymd');
    $imglst = array();
    foreach (array_keys($imgext) as $ext) {
        foreach (glob($dir . "*.{$ext}") as $filename) {
            $name = basename($filename, ".{$ext}");
            if (!is_numeric($name) || strlen($name) != 8) {
                continue;
            }
            if (strcmp($now, $name) < 0) {
                continue;
            }
            $imglst[$name] = $filename;
        }
    }
    if (count($imglst) <= 0) {
        setCache($orgimg);
        return FALSE;
    } else {
        krsort($imglst);
        $img = array_shift($imglst);
        setCache($img);
        return $img;
    }
}
示例#24
0
 public function get_mails(Request $request)
 {
     $mbox = imap_open("{email.mindfiresolutions.com:143}INBOX", "*****@*****.**", "1mfmail2016#") or die("can't connect: " . imap_last_error());
     $MC = imap_check($mbox);
     $count = 0;
     $count_total = $MC->Nmsgs;
     $last_page = $count_total % 10;
     $this->number_of_pages = ($count_total - $last_page) / 10;
     $this->result = imap_fetch_overview($mbox, "1:{$MC->Nmsgs}", 0);
     $i = 0;
     foreach ($this->result as $overview) {
         $message = imap_fetchbody($mbox, $overview->msgno, 1.1);
         $this->msg[$i] = $message;
         $i++;
         \Cache::put($overview->msgno, $overview->subject, 5);
     }
     krsort($this->result);
     /*This sorting does not help.Please use only rsort.*/
     $str[0] = 'success';
     $result_json = array();
     $result_json['val'] = $this->result;
     $result_json['num'] = $this->number_of_pages;
     $result_json['total'] = $count_total;
     return response()->json($result_json);
 }
示例#25
0
文件: umtag.php 项目: philum/cms
function ummoay_build($p, $o)
{
    req('art,tri,pop,spe');
    reqp('msqarts');
    $tmp = ummoay_template();
    $r = req_arts_y($p);
    $rtg = list_tags();
    if ($r) {
        foreach ($r as $k => $v) {
            list($id, $day, $msg, $cat, $tag, $lk) = $v;
            $day = clean_day_tw($day);
            $msg = format_txt($msg, '', '');
            $lnk = lka(urlread($id));
            $pop = lj('', 'popup_trckpop___' . $id, picto('forum', 16));
            $rb[$day] = array('suj' => $cat, 'day' => mkday($day, 'Y/m/d'), 'msg' => $msg, 'url' => $lk, 'open' => popart($id, 'articles') . ' ' . $pop, 'tag' => $rc = $rtg[$id]);
        }
    }
    krsort($rb);
    foreach ($rb as $k => $v) {
        $rd[nms(100)] .= template_build($tmp, $v);
        $rc = $v['tag'];
        if ($rc) {
            foreach ($rc as $kb => $vb) {
                $rd[$kb] .= template_build($tmp, $v);
            }
        }
    }
    return make_tabs($rd);
}
示例#26
0
/**
 * 获取地区父级路径路径
 * @param $parentid 父级ID
 * @param $keyid 菜单keyid
 * @param $callback json生成callback变量
 * @param $result 递归返回结果数组
 * @param $infos
 */
function ajax_getpath($parentid, $keyid, $callback, $result = array(), $infos = array())
{
    $keyid = intval($keyid);
    $parentid = intval($parentid);
    if (!$infos) {
        $datas = getcache($keyid, 'linkage');
        $infos = $datas['data'];
    }
    if (array_key_exists($parentid, $infos)) {
        $result[] = iconv(CHARSET, 'utf-8', $infos[$parentid]['name']);
        return ajax_getpath($infos[$parentid]['parentid'], $keyid, $callback, $result, $infos);
    } else {
        if (count($result) > 0) {
            krsort($result);
            $jsonstr = json_encode($result);
            echo trim_script($callback) . '(', $jsonstr, ')';
            exit;
        } else {
            $result[] = iconv(CHARSET, 'utf-8', $datas['title']);
            $jsonstr = json_encode($result);
            echo trim_script($callback) . '(', $jsonstr, ')';
            exit;
        }
    }
}
 /**
  * @param $db DatabaseBase
  * @return mixed
  */
 public function doQuery($db)
 {
     $ids = array_map('intval', $this->ids);
     $live = $db->select(array('revision', 'page', 'user'), array_merge(Revision::selectFields(), Revision::selectUserFields()), array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), __METHOD__, array('ORDER BY' => 'rev_id DESC'), array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
     if ($live->numRows() >= count($ids)) {
         // All requested revisions are live, keeps things simple!
         return $live;
     }
     // Check if any requested revisions are available fully deleted.
     $archived = $db->select(array('archive'), '*', array('ar_rev_id' => $ids), __METHOD__, array('ORDER BY' => 'ar_rev_id DESC'));
     if ($archived->numRows() == 0) {
         return $live;
     } elseif ($live->numRows() == 0) {
         return $archived;
     } else {
         // Combine the two! Whee
         $rows = array();
         foreach ($live as $row) {
             $rows[$row->rev_id] = $row;
         }
         foreach ($archived as $row) {
             $rows[$row->ar_rev_id] = $row;
         }
         krsort($rows);
         return new FakeResultWrapper(array_values($rows));
     }
 }
 /**
  * Retrieves the overrides data
  *
  * @param		boolean	True if all overrides shall be returned without considering pagination, defaults to false
  *
  * @return	array		Array of objects containing the overrides of the override.ini file
  *
  * @since		2.5
  */
 public function getOverrides($all = false)
 {
     // Get a storage key
     $store = $this->getStoreId();
     // Try to load the data from internal storage
     if (!empty($this->cache[$store])) {
         return $this->cache[$store];
     }
     // Parse the override.ini file in oder to get the keys and strings
     $filename = constant('JPATH_' . strtoupper($this->getState('filter.client'))) . DS . 'language' . DS . 'overrides' . DS . $this->getState('filter.language') . '.override.ini';
     $strings = LanguagesHelper::parseFile($filename);
     // Consider the odering
     if ($this->getState('list.ordering') == 'text') {
         if (strtoupper($this->getState('list.direction')) == 'DESC') {
             arsort($strings);
         } else {
             asort($strings);
         }
     } else {
         if (strtoupper($this->getState('list.direction')) == 'DESC') {
             krsort($strings);
         } else {
             ksort($strings);
         }
     }
     // Consider the pagination
     if (!$all && $this->getState('list.limit') && $this->getTotal() > $this->getState('list.limit')) {
         $strings = array_slice($strings, $this->getStart(), $this->getState('list.limit'), true);
     }
     // Add the items to the internal cache
     $this->cache[$store] = $strings;
     return $this->cache[$store];
 }
示例#29
0
 public function ipv6_compress($ip)
 {
     $ip = HelperFunctions::ipv6_expand($ip);
     $p = explode(":", $ip);
     $ranges = array();
     $i = 0;
     for ($i = 0; $i < 8; $i++) {
         $p[$i] = intval($p[$i]);
         $count = 0;
         for ($j = $i; $j < 8; $j++) {
             if (intval($p[$j]) !== 0 && $count !== 0) {
                 break;
             } else {
                 if (intval($p[$j]) === 0) {
                     $count++;
                 }
             }
         }
         $ranges[$count] = $i;
     }
     krsort($ranges);
     $s = each($ranges);
     $start = $s['value'];
     $length = $s['key'];
     if ($length === 0) {
         return implode(":", $p);
     } else {
         $part1 = implode(":", array_slice($p, 0, $start));
         $part2 = implode(":", array_slice($p, $start + $length));
         return implode("::", array($part1, $part2));
     }
 }
示例#30
0
 /**
  * Get newest IssueM issue
  *
  * @since 1.0.0
  *
  * @param string $orderby 
  * @return int $id
  */
 function get_newest_issuem_issue_id($orderby = 'issue_order')
 {
     $issues = array();
     $count = 0;
     $issuem_issues = get_terms('issuem_issue');
     foreach ($issuem_issues as $issue) {
         $issue_meta = get_option('issuem_issue_' . $issue->term_id . '_meta');
         // If issue is not a Draft, add it to the archive array;
         if (!empty($issue_meta) && !empty($issue_meta['issue_status']) && ('Live' === $issue_meta['issue_status'] || current_user_can(apply_filters('see_issuem_draft_issues', 'manage_issues')))) {
             switch ($orderby) {
                 case "issue_order":
                     if (!empty($issue_meta['issue_order'])) {
                         $issues[$issue_meta['issue_order']] = $issue->term_id;
                     } else {
                         $issues['-' . ++$count] = $issue->term_id;
                     }
                     break;
                 case "name":
                     $issues[$issue_meta['name']] = $issue->term_id;
                     break;
                 case "term_id":
                     $issues[$issue->term_id] = $issue->term_id;
                     break;
             }
         } else {
             $issues['-' . ++$count] = $issue->term_id;
         }
     }
     krsort($issues);
     return array_shift($issues);
 }