コード例 #1
2
ファイル: str_pad.php プロジェクト: Toushi/flow
/**
 * utf8::str_pad
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
    if (utf8::is_ascii($str) and utf8::is_ascii($pad_str)) {
        return str_pad($str, $final_str_length, $pad_str, $pad_type);
    }
    $str_length = utf8::strlen($str);
    if ($final_str_length <= 0 or $final_str_length <= $str_length) {
        return $str;
    }
    $pad_str_length = utf8::strlen($pad_str);
    $pad_length = $final_str_length - $str_length;
    if ($pad_type == STR_PAD_RIGHT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr($str . str_repeat($pad_str, $repeat), 0, $final_str_length);
    }
    if ($pad_type == STR_PAD_LEFT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)) . $str;
    }
    if ($pad_type == STR_PAD_BOTH) {
        $pad_length /= 2;
        $pad_length_left = floor($pad_length);
        $pad_length_right = ceil($pad_length);
        $repeat_left = ceil($pad_length_left / $pad_str_length);
        $repeat_right = ceil($pad_length_right / $pad_str_length);
        $pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
        $pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
        return $pad_left . $str . $pad_right;
    }
    trigger_error('utf8::str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
コード例 #2
1
 public function testTooLargeMegaBytes()
 {
     fwrite($this->file, str_repeat('0', 1400000));
     $constraint = new File(array('maxSize' => '1M', 'maxSizeMessage' => 'myMessage'));
     $this->context->expects($this->once())->method('addViolation')->with('myMessage', array('{{ limit }}' => '1 MB', '{{ size }}' => '1.4 MB', '{{ file }}' => $this->path));
     $this->validator->validate($this->getFile($this->path), $constraint);
 }
 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
     }
     $messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
     if ($ids) {
         $ids = array_fuse($ids);
         $missing = array_diff_key($ids, $messages);
         if ($missing) {
             throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
         }
     }
     $last_key = last_key($messages);
     foreach ($messages as $message_key => $message) {
         $info = array();
         $info[] = pht('PROPERTIES');
         $info[] = pht('ID: %d', $message->getID());
         $info[] = pht('Status: %s', $message->getSendStatus());
         $info[] = pht('To: %s', $message->getToNumber());
         $info[] = pht('From: %s', $message->getFromNumber());
         $info[] = null;
         $info[] = pht('BODY');
         $info[] = $message->getBody();
         $info[] = null;
         $console->writeOut('%s', implode("\n", $info));
         if ($message_key != $last_key) {
             $console->writeOut("\n%s\n\n", str_repeat('-', 80));
         }
     }
 }
 public static function tearDownAfterClass()
 {
     if (!self::$timing) {
         echo "\n";
         return;
     }
     $class = get_called_class();
     echo "Timing results : {$class}\n";
     $s = sprintf("%40s %6s %9s %9s %4s\n", 'name', 'count', 'total', 'avg', '% best');
     echo str_repeat('=', strlen($s)) . "\n";
     echo $s;
     echo str_repeat('-', strlen($s)) . "\n";
     array_walk(self::$timing, function (&$value, $key) {
         $value['avg'] = round($value['total'] / $value['count'] * 1000000, 3);
     });
     usort(self::$timing, function ($a, $b) {
         $at = $a['avg'];
         $bt = $b['avg'];
         return $at === $bt ? 0 : ($at < $bt ? -1 : 1);
     });
     $best = self::$timing[0]['avg'];
     foreach (self::$timing as $timing) {
         printf("%40s %6d %7.3fms %7.3fus %4.1f%%\n", $timing['name'], $timing['count'], round($timing['total'] * 1000, 3), $timing['avg'], round($timing['avg'] / $best * 100, 3));
     }
     echo str_repeat('-', strlen($s)) . "\n\n";
     printf("\nTiming compensated for avg overhead for: timeIt of %.3fus and startTimer/endTimer of %.3fus per invocation\n\n", self::$timeItOverhead * 1000000, self::$startEndOverhead * 1000000);
     parent::tearDownAfterClass();
 }
コード例 #5
1
ファイル: subscription.php プロジェクト: q0821/esportshop
 function hikashopSubscriptionType()
 {
     if (!HIKASHOP_PHP5) {
         $acl =& JFactory::getACL();
     } else {
         $acl = JFactory::getACL();
     }
     if (!HIKASHOP_J16) {
         $this->groups = $acl->get_group_children_tree(null, 'USERS', false);
     } else {
         $db = JFactory::getDBO();
         $db->setQuery('SELECT a.*, a.title as text, a.id as value  FROM #__usergroups AS a ORDER BY a.lft ASC');
         $this->groups = $db->loadObjectList('id');
         foreach ($this->groups as $id => $group) {
             if (isset($this->groups[$group->parent_id])) {
                 $this->groups[$id]->level = intval(@$this->groups[$group->parent_id]->level) + 1;
                 $this->groups[$id]->text = str_repeat('- - ', $this->groups[$id]->level) . $this->groups[$id]->text;
             }
         }
     }
     $this->choice = array();
     $this->choice[] = JHTML::_('select.option', 'none', JText::_('HIKA_NONE'));
     $this->choice[] = JHTML::_('select.option', 'special', JText::_('HIKA_CUSTOM'));
     $js = "function updateSubscription(map){\r\n\t\t\tchoice = document.adminForm['choice_'+map];\r\n\t\t\tchoiceValue = 'special';\r\n\t\t\tfor (var i=0; i < choice.length; i++){\r\n\t\t\t\tif (choice[i].checked){\r\n\t\t\t\t\tchoiceValue = choice[i].value;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\thiddenVar = document.getElementById('hidden_'+map);\r\n\t\t\tif(choiceValue != 'special'){\r\n\t\t\t\thiddenVar.value = choiceValue;\r\n\t\t\t\tif(hiddenVar.value == 'none') hiddenVar.value = '';\r\n\t\t\t\tdocument.getElementById('div_'+map).style.display = 'none';\r\n\t\t\t}else{\r\n\t\t\t\tdocument.getElementById('div_'+map).style.display = '';\r\n\t\t\t\tspecialVar = eval('document.adminForm.special_'+map);\r\n\t\t\t\tfinalValue = '';\r\n\t\t\t\tfor (var i=0; i < specialVar.length; i++){\r\n\t\t\t\t\tif (specialVar[i].checked){\r\n\t\t\t\t\t\tfinalValue += specialVar[i].value;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\thiddenVar.value = finalValue;\r\n\t\t\t}\r\n\t\t}";
     if (!HIKASHOP_PHP5) {
         $doc =& JFactory::getDocument();
     } else {
         $doc = JFactory::getDocument();
     }
     $doc->addScriptDeclaration($js);
 }
コード例 #6
0
ファイル: SFTPUserStoryTest.php プロジェクト: Nayar/phpseclib
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$scratchDir = uniqid('phpseclib-sftp-scratch-');
     self::$exampleData = str_repeat('abcde12345', 1000);
     self::$exampleDataLength = 10000;
 }
コード例 #7
0
ファイル: Walker_nav_menu.php プロジェクト: alispx/calibrefx
 function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     if ($args->has_children) {
         $classes[] = 'dropdown';
     }
     $icon_html = '';
     if (isset($item->custom_icon) && !empty($item->custom_icon)) {
         $icon_html = '<i class="' . $item->custom_icon . '"></i><span>&nbsp;&nbsp;</span>';
     }
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $icon_html . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
コード例 #8
0
ファイル: template.php プロジェクト: Satariall/izurit
 /**
  * @param $name
  * @param $property_fields
  * @param $values
  * @return bool|string
  */
 function _ShowGroupPropertyFieldList($name, $property_fields, $values)
 {
     if (!is_array($values)) {
         $values = array();
     }
     $options = "";
     $result = "";
     $bWas = false;
     $sections = ProductSearchComponent::getPropertyFieldSections($property_fields["LINK_IBLOCK_ID"]);
     if (!empty($sections) && is_array($sections)) {
         foreach ($sections as &$section) {
             $options .= '<option value="' . $section["ID"] . '"';
             if (in_array($section["ID"], $values)) {
                 $bWas = true;
                 $options .= ' selected';
             }
             $options .= '>' . str_repeat(" . ", $section["DEPTH_LEVEL"]) . $section["NAME"] . '</option>';
         }
         unset($section);
     }
     $result .= '<select name="' . $name . '[]" size="' . ($property_fields["MULTIPLE"] == "Y" ? "5" : "1") . '" ' . ($property_fields["MULTIPLE"] == "Y" ? "multiple" : "") . '>';
     $result .= '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("SPS_A_PROP_NOT_SET") . '</option>';
     $result .= $options;
     $result .= '</select>';
     return $result;
 }
コード例 #9
0
function getDirectory($path = '.', $level = 0)
{
    $ignore = array('cgi-bin', '.', '..');
    // Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.
    $dh = @opendir($path);
    // Open the directory to the handle $dh
    while (false !== ($file = readdir($dh))) {
        // Loop through the directory
        if (!in_array($file, $ignore)) {
            // Check that this file is not to be ignored
            str_repeat(' ', $level * 4);
            // Just to add spacing to the list, to better
            // show the directory tree.
            if (is_dir("{$path}/{$file}")) {
                // Its a directory, so we need to keep reading down...
                echo "{$path}/{$file};";
                getDirectory("{$path}/{$file}", $level + 1);
                // Re-call this same function but on a new directory.
                // this is what makes function recursive.
            } else {
                echo "{$path}/{$file};";
                // Just print out the filename
            }
        }
    }
    closedir($dh);
    // Close the directory handle
}
 /**
  * Create the markup to start an element.
  *
  * @see Walker::start_el() for description of parameters.
  *
  * @param string $output Passed by reference. Used to append additional
  *        content.
  * @param object $item Menu item data object.
  * @param int $depth Depth of menu item. Used for padding.
  * @param object $args See {@Walker::start_el()}.
  * @param int $id See {@Walker::start_el()}.
  */
 public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     global $_nav_menu_placeholder;
     $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? intval($_nav_menu_placeholder) - 1 : -1;
     $possible_object_id = isset($item->post_type) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
     $possible_db_id = !empty($item->ID) && 0 < $possible_object_id ? (int) $item->ID : 0;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $output .= $indent . '<li>';
     $output .= '<label class="menu-item-title">';
     $output .= '<input type="checkbox" class="menu-item-checkbox';
     if (property_exists($item, 'label')) {
         $title = $item->label;
     }
     $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr($item->object_id) . '" /> ';
     $output .= isset($title) ? esc_html($title) : esc_html($item->title);
     $output .= '</label>';
     if (empty($item->url)) {
         $item->url = $item->guid;
     }
     if (!in_array(array('umnm-menu', 'umnm-' . $item->post_excerpt . '-nav'), $item->classes)) {
         $item->classes[] = 'umnm-menu';
         $item->classes[] = 'umnm-' . $item->post_excerpt . '-nav';
     }
     // Menu item hidden fields
     $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
     $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr($item->object) . '" />';
     $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr($item->menu_item_parent) . '" />';
     $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="custom" />';
     $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr($item->title) . '" />';
     $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr($item->url) . '" />';
     $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr($item->target) . '" />';
     $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="' . esc_attr($item->attr_title) . '" />';
     $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr(implode(' ', $item->classes)) . '" />';
     $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr($item->xfn) . '" />';
 }
コード例 #11
0
ファイル: ProfilerSimple.php プロジェクト: seedbank/old-repo
 function profileOut($functionname)
 {
     global $wgDebugFunctionEntry;
     if ($wgDebugFunctionEntry) {
         $this->debug(str_repeat(' ', count($this->mWorkStack) - 1) . 'Exiting ' . $functionname . "\n");
     }
     list($ofname, , $ortime, $octime) = array_pop($this->mWorkStack);
     if (!$ofname) {
         $this->debug("Profiling error: {$functionname}\n");
     } else {
         if ($functionname == 'close') {
             $message = "Profile section ended by close(): {$ofname}";
             $functionname = $ofname;
             $this->debug("{$message}\n");
             $this->mCollated[$message] = $this->errorEntry;
         } elseif ($ofname != $functionname) {
             $message = "Profiling error: in({$ofname}), out({$functionname})";
             $this->debug("{$message}\n");
             $this->mCollated[$message] = $this->errorEntry;
         }
         $entry =& $this->mCollated[$functionname];
         $elapsedcpu = $this->getTime('cpu') - $octime;
         $elapsedreal = $this->getTime() - $ortime;
         if (!is_array($entry)) {
             $entry = $this->zeroEntry;
             $this->mCollated[$functionname] =& $entry;
         }
         $entry['cpu'] += $elapsedcpu;
         $entry['cpu_sq'] += $elapsedcpu * $elapsedcpu;
         $entry['real'] += $elapsedreal;
         $entry['real_sq'] += $elapsedreal * $elapsedreal;
         $entry['count']++;
     }
 }
コード例 #12
0
ファイル: Scaffold.php プロジェクト: stecj/sime
 protected function _build_belongs($number = 0)
 {
     // Initial tabs
     $tabs = str_repeat(TT, $number);
     $prefix = 'o';
     // Export array
     $belongs = array();
     foreach ($this->_foreigns as $db_column => $foreign) {
         $alias = $this->_camelize($foreign['table']);
         $belongs[$prefix . $alias] = array('model' => $alias, 'foreign_key' => $db_column);
     }
     ob_start();
     var_export($belongs);
     $html = ob_get_clean();
     // Add return
     $html = 'protected $_belongs_to = ' . $html;
     // 'array (' to 'array('
     $html = preg_replace('/array \\(/', 'array(', $html);
     // Remove EOL from subarray start
     $html = preg_replace('/=> \\n  /', '=> ', $html);
     // Replace ' ' with \t
     $html = preg_replace('/  /', TT, $html);
     // Add initial tabs
     $html = preg_replace('/^(.*)$/m', $tabs . '$1', $html);
     return $html . ';';
     //echo '<pre>'.$html;
     //die();
 }
コード例 #13
0
ファイル: ProgressBar.php プロジェクト: kehet/php-cli-utils
 /**
  * Updates bar by printing \r and new bar
  *
  * @param $progress Current value of progress between 0 and value given on constructor
  */
 public function update($progress)
 {
     $this->_times[] = microtime(true);
     $done = $progress == 0 ? 0 : round($progress / $this->_max * $this->_maxLength);
     $left = round((1 - $progress / $this->_max) * $this->_maxLength);
     // current/max
     $output = ' ' . sprintf('%' . strlen($this->_max) . 's/%s', $progress, $this->_max) . ' ';
     // progressbar
     $output .= '[' . str_repeat('=', $done != 0 ? $done - 1 : $done) . ($done > 0 ? '>' : '') . str_repeat('-', $left) . ']';
     // percent
     $output .= ' ' . sprintf('%6.2f', round($progress / $this->_max * 100, 2)) . "%";
     // eta
     // using http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
     // averageSpeed = SMOOTHING_FACTOR * lastSpeed + (1-SMOOTHING_FACTOR) * averageSpeed
     if (count($this->_times) > 2) {
         $lastSpeed = $this->_times[count($this->_times) - 1] - $this->_times[count($this->_times) - 2];
         if ($this->_averageSpeed == -1) {
             $this->_averageSpeed = $lastSpeed;
         }
         $this->_averageSpeed = ProgressBar::SMOOTHING_FACTOR * $lastSpeed + (1 - ProgressBar::SMOOTHING_FACTOR) * $this->_averageSpeed;
         $output .= ' ETA ' . $this->_mtime2str(round($this->_averageSpeed * ($this->_max - $progress)));
         $output .= ' ' . date('H:i:s', time() + round($this->_averageSpeed * ($this->_max - $progress)));
     }
     echo "\r" . $output . '  ';
 }
コード例 #14
0
ファイル: ErrorHandler.php プロジェクト: acrobat/monolog
 public function registerFatalHandler($level = null, $reservedMemorySize = 20)
 {
     register_shutdown_function(array($this, 'handleFatalError'));
     $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
     $this->fatalLevel = $level;
     $this->hasFatalErrorHandler = true;
 }
コード例 #15
0
ファイル: adv_couplebanner.php プロジェクト: v998/discuzx-en
 function getsetting()
 {
     global $_G;
     $settings = array('fids' => array('title' => 'couplebanner_fids', 'type' => 'mselect', 'value' => array()), 'groups' => array('title' => 'couplebanner_groups', 'type' => 'mselect', 'value' => array()), 'position' => array('title' => 'couplebanner_position', 'type' => 'mradio', 'value' => array(array(1, 'couplebanner_position_left'), array(2, 'couplebanner_position_right')), 'default' => 1), 'coupleadid' => array('title' => 'couplebanner_coupleadid', 'type' => 'select', 'value' => array()));
     loadcache(array('forums', 'grouptype'));
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(-1, 'couplebanner_index');
     if (empty($_G['cache']['forums'])) {
         $_G['cache']['forums'] = array();
     }
     foreach ($_G['cache']['forums'] as $fid => $forum) {
         $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')) . $forum['name']);
     }
     foreach ($_G['cache']['grouptype']['first'] as $gid => $group) {
         $settings['groups']['value'][] = array($gid, str_repeat('&nbsp;', 4) . $group['name']);
         if ($group['secondlist']) {
             foreach ($group['secondlist'] as $sgid) {
                 $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 8) . $_G['cache']['grouptype']['second'][$sgid]['name']);
             }
         }
     }
     $query = DB::query('SELECT * FROM ' . DB::table('common_advertisement') . " WHERE type='couplebanner'");
     while ($couple = DB::fetch($query)) {
         $settings['coupleadid']['value'][] = array($couple['advid'], $couple['title']);
     }
     return $settings;
 }
コード例 #16
0
ファイル: banword.php プロジェクト: h3len/Project
 /**
  * 替换屏蔽字
  */
 public function replace()
 {
     $content = trim(urldecode($this->input['banword']));
     $symbol = trim(urldecode($this->input['symbol']));
     if (empty($content)) {
         $this->errorOutput(OBJECT_NULL);
     }
     $data = $this->banword($content);
     if ($data) {
         $replace = array();
         $find = array();
         foreach ($data as $v) {
             if (!empty($symbol) && $symbol != '*') {
                 $replace[] = $symbol;
             } else {
                 if (!empty($v['banwd'])) {
                     $replace[] = $v['banwd'];
                 } else {
                     $replace[] = str_repeat('*', mb_strlen($v['banname'], 'utf-8'));
                 }
             }
             $find[] = $v['banname'];
         }
         $content = str_replace($find, $replace, $content);
     }
     $this->addItem($content);
     $this->output();
 }
コード例 #17
0
 function ss_hide_mail($email)
 {
     $mail_segments = explode("@", $email);
     $half = (int) strlen($mail_segments[0]) / 2;
     $mail_segments[0] = str_repeat("*", $half) . substr($mail_segments[0], $half);
     return implode("@", $mail_segments);
 }
コード例 #18
0
 public static function DumpWorkflow($workflowId)
 {
     global $DB;
     $workflowId = trim($workflowId);
     if (strlen($workflowId) <= 0) {
         throw new Exception("workflowId");
     }
     $dbResult = $DB->Query("SELECT ID, TYPE, MODIFIED, ACTION_NAME, ACTION_TITLE, EXECUTION_STATUS, EXECUTION_RESULT, ACTION_NOTE, MODIFIED_BY " . "FROM b_bp_tracking " . "WHERE WORKFLOW_ID = '" . $DB->ForSql($workflowId) . "' " . "ORDER BY ID ");
     $r = array();
     $level = 0;
     while ($arResult = $dbResult->GetNext()) {
         if ($arResult["TYPE"] == CBPTrackingType::CloseActivity) {
             $level--;
             $arResult["PREFIX"] = str_repeat("&nbsp;&nbsp;&nbsp;", $level > 0 ? $level : 0);
             $arResult["LEVEL"] = $level;
         } elseif ($arResult["TYPE"] == CBPTrackingType::ExecuteActivity) {
             $arResult["PREFIX"] = str_repeat("&nbsp;&nbsp;&nbsp;", $level > 0 ? $level : 0);
             $arResult["LEVEL"] = $level;
             $level++;
         } else {
             $arResult["PREFIX"] = str_repeat("&nbsp;&nbsp;&nbsp;", $level > 0 ? $level : 0);
             $arResult["LEVEL"] = $level;
         }
         $r[] = $arResult;
     }
     return $r;
 }
コード例 #19
0
ファイル: CursorTest.php プロジェクト: simensen/php-rql
 public function run()
 {
     $this->requireDataset('Huge');
     $doc = array('key' => str_repeat("var", 1000));
     $docs = array_fill(0, 5000, $doc);
     // Test 1: Retrieve only the first 100 results. Then delete the cursor. This should trigger a stop message.
     $cursor = r\db('Huge')->table('t5000')->without('id')->run($this->conn);
     $i = 0;
     foreach ($cursor as $val) {
         if (!$this->compareArrays($doc, $val)) {
             echo "Read wrong value.\n";
         }
         if ($i++ >= 100) {
             break;
         }
     }
     unset($cursor);
     // Test 2: Call the cursor's close() method. The cursor should not return any more rows.
     $cursor = r\db('Huge')->table('t5000')->without('id')->run($this->conn);
     $cursor->close();
     if (!$this->compareArrays(array(), $cursor->toArray())) {
         echo "Cursor still returned results after it was closed.\n";
     }
     // Test 3: Retrieve all results. This tests paging.
     $this->checkQueryResult(r\db('Huge')->table('t5000')->without('id'), $docs);
 }
コード例 #20
0
 protected function createRow($items, $aData = array(), $level = 1)
 {
     if ($items->count()) {
         foreach ($items as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             if ($this->getIsTree() && $level > 1) {
                 $aResultTmp['Name'] = str_repeat(" |-- ", $level - 1) . $aResultTmp['Name'];
             }
             $aData[] = $aResultTmp;
             if ($itm->hasChilds()) {
                 $aData = $this->createRow($itm->getChilds(), $aData, $level + 1);
             }
         }
     }
     return $aData;
 }
コード例 #21
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) === 0) {
         $output = "This server is running " . $sender->getServer()->getName() . " version " . $sender->getServer()->getPocketMineVersion() . " 「" . $sender->getServer()->getCodename() . "」 (Implementing API version " . $sender->getServer()->getApiVersion() . " for Minecraft: PE " . $sender->getServer()->getVersion() . " protocol version " . Info::CURRENT_PROTOCOL . ")";
         if (\pocketmine\GIT_COMMIT !== str_repeat("00", 20)) {
             $output .= " [git " . \pocketmine\GIT_COMMIT . "]";
         }
         $sender->sendMessage($output);
     } else {
         $pluginName = implode(" ", $args);
         $exactPlugin = $sender->getServer()->getPluginManager()->getPlugin($pluginName);
         if ($exactPlugin instanceof Plugin) {
             $this->describeToSender($exactPlugin, $sender);
             return true;
         }
         $found = false;
         $pluginName = strtolower($pluginName);
         foreach ($sender->getServer()->getPluginManager()->getPlugins() as $plugin) {
             if (stripos($plugin->getName(), $pluginName) !== false) {
                 $this->describeToSender($plugin, $sender);
                 $found = true;
             }
         }
         if (!$found) {
             $sender->sendMessage("This server is not running any plugin by that name.\nUse /plugins to get a list of plugins.");
         }
     }
     return true;
 }
コード例 #22
0
ファイル: bug67397.php プロジェクト: badlamer/hhvm
function ut_main()
{
    $ret = var_export(ut_loc_get_display_name(str_repeat('*', 256), 'en_us'), true);
    $ret .= "\n";
    $ret .= var_export(intl_get_error_message(), true);
    return $ret;
}
コード例 #23
0
 function _get_select()
 {
     $exclude = array();
     $wlk = $this->_tree_walk_preorder($this->node);
     while (!$wlk['recset']->EOF) {
         $row = $wlk['recset']->fields;
         $exclude[$row['id']] = 'yes';
         $wlk['recset']->MoveNext();
     }
     $mySelect = new CHAW_select($this->key);
     $node = $this->_tree_get_group_root_node($this->usergroup);
     $attributes = array('name');
     $wlk = $this->_tree_walk_preorder($node);
     while ($curr = $this->_tree_walk_next($wlk)) {
         $level = $this->_tree_walk_level($wlk);
         $spaces = str_repeat('--', $level - 1);
         $att = reset($attributes);
         while ($att) {
             if ($level == 0) {
                 $mySelect->add_option('(seleziona cartella)', $wlk['row']['id']);
             } elseif ($wlk['row']['file'] == '' && !isset($exclude[$wlk['row']['id']])) {
                 $mySelect->add_option($spaces . $wlk['row'][$att], $wlk['row']['id']);
             }
             $att = next($attributes);
         }
     }
     return $mySelect;
 }
コード例 #24
0
 /**
  * start_el function.
  * 
  * @access public
  * @param mixed &$output
  * @param mixed $item
  * @param int $depth (default: 0)
  * @param array $args (default: array())
  * @param int $id (default: 0)
  * @return void
  */
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $li_attributes = '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = $args->has_children ? 'dropdown' : '';
     $classes[] = $item->current || $item->current_item_ancestor ? 'active' : '';
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $attributes .= $args->has_children ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= $args->has_children ? ' <b class="caret"></b></a>' : '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
コード例 #25
0
ファイル: BackendStep.php プロジェクト: 0svald/icingaweb2
 public function getSummary()
 {
     $pageTitle = '<h2>' . mt('monitoring', 'Monitoring Backend', 'setup.page.title') . '</h2>';
     $backendDescription = '<p>' . sprintf(mt('monitoring', 'Icinga Web 2 will retrieve information from your monitoring environment' . ' using a backend called "%s" and the specified resource below:'), $this->data['backendConfig']['name']) . '</p>';
     if ($this->data['resourceConfig']['type'] === 'db') {
         $resourceTitle = '<h3>' . mt('monitoring', 'Database Resource') . '</h3>';
         $resourceHtml = '' . '<table>' . '<tbody>' . '<tr>' . '<td><strong>' . t('Resource Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['name'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Database Type') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['db'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Host') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['host'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Port') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['port'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Database Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['dbname'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Username') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['username'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Password') . '</strong></td>' . '<td>' . str_repeat('*', strlen($this->data['resourceConfig']['password'])) . '</td>' . '</tr>';
         if (isset($this->data['resourceConfig']['ssl_key']) && $this->data['resourceConfig']['ssl_key']) {
             $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('SSL Key') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_key'] . '</td>' . '</tr>';
         }
         if (isset($this->data['resourceConfig']['ssl_cert']) && $this->data['resourceConfig']['ssl_cert']) {
             $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('SSL Cert') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_cert'] . '</td>' . '</tr>';
         }
         if (isset($this->data['resourceConfig']['ssl_ca']) && $this->data['resourceConfig']['ssl_ca']) {
             $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('CA') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_ca'] . '</td>' . '</tr>';
         }
         if (isset($this->data['resourceConfig']['ssl_capath']) && $this->data['resourceConfig']['ssl_capath']) {
             $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('CA Path') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_capath'] . '</td>' . '</tr>';
         }
         if (isset($this->data['resourceConfig']['ssl_cipher']) && $this->data['resourceConfig']['ssl_cipher']) {
             $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('Cipher') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_cipher'] . '</td>' . '</tr>';
         }
         $resourceHtml .= '' . '</tbody>' . '</table>';
     } else {
         // $this->data['resourceConfig']['type'] === 'livestatus'
         $resourceTitle = '<h3>' . mt('monitoring', 'Livestatus Resource') . '</h3>';
         $resourceHtml = '' . '<table>' . '<tbody>' . '<tr>' . '<td><strong>' . t('Resource Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['name'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Socket') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['socket'] . '</td>' . '</tr>' . '</tbody>' . '</table>';
     }
     return $pageTitle . '<div class="topic">' . $backendDescription . $resourceTitle . $resourceHtml . '</div>';
 }
コード例 #26
0
 /**
  * Render the information header for the view
  * 
  * @param string $title
  * @param string $title
  */
 public function writeInfo($title, $subtitle, $description = false)
 {
     echo wordwrap(strtoupper($title), 100) . "\n";
     echo wordwrap($subtitle, 100) . "\n";
     echo str_repeat('-', min(100, max(strlen($title), strlen($subtitle)))) . "\n";
     echo wordwrap($description, 100) . "\n\n";
 }
コード例 #27
0
ファイル: IcuResFileDumper.php プロジェクト: nakashu/symfony
 private function writePadding($data)
 {
     $padding = strlen($data) % 4;
     if ($padding) {
         return str_repeat("ª", 4 - $padding);
     }
 }
コード例 #28
0
 protected function renderConfigurationSecret($value)
 {
     if (strlen($value)) {
         return str_repeat('*', strlen($value));
     }
     return '';
 }
コード例 #29
0
function start()
{
    global $spider;
    echo "正在处理中...<br>";
    print str_repeat(" ", 4096);
    ob_flush();
    flush();
    sleep(1);
    $url = "http://www.hao123.com/";
    $spider->url($url);
    $fulltxt = $spider->fulltxt(800);
    $links = $spider->links();
    $sites = $spider->sites();
    //
    //add_sites($sites);
    sleep(2);
    foreach ($links as $value) {
        $num = count(explode($url, $value));
        //echo $value.$num."<br>";
        if ($num == 2) {
            $spider->url($url);
            $sites = $spider->sites();
            add_sites($sites);
            sleep(2);
        }
    }
}
コード例 #30
-7
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth));
     /**
      * Change WP's default classes to match Foundation's required classes
      */
     $class_names = str_replace(array('menu-item-has-children'), array('has-submenu'), $class_names);
     // ==========================
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
     $id = $id ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $class_names . '>';
     $atts = array();
     $atts['title'] = !empty($item->attr_title) ? $item->attr_title : '';
     $atts['target'] = !empty($item->target) ? $item->target : '';
     $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
     $atts['href'] = !empty($item->url) ? $item->url : '';
     $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }