Пример #1
0
function skype_history($threshold = 60, $since = "Last Monday")
{
    $calls = SkypeHistory_Call::getCalls();
    $since = strtotime($since);
    $table = new Console_Table();
    $table->setHeaders(array('Date', 'Time', 'Duration', '<>', 'Participants'));
    $types = array('INCOMING_PSTN' => '<-', 'INCOMING_P2P' => '<-', 'OUTGOING_PSTN' => '->', 'OUTGOING_P2P' => '->');
    $previous_date = NULL;
    $total_duration = 0;
    printf("Gathering skype call history, this may take a few seconds.\n");
    foreach ($calls as $i => $id) {
        $call = new SkypeHistory_Call($id);
        // Bail out once the cutoff is reached.
        if ($call->timestamp < $since) {
            break;
        }
        if ($call->duration < $threshold) {
            continue;
        }
        $participants = array();
        $participants[] = $call->PARTNER_DISPNAME;
        if ($call->conf_participants_count > 1) {
            for ($j = 1; $j < (int) $call->conf_participants_count; $j++) {
                $p = $call->getProperty("CONF_PARTICIPANT {$j}");
                // drewstephens0815 OUTGOING_P2P FINISHED Andrew Stephens
                list($nick, $type, $status, $display_name) = explode(" ", $p, 4);
                $participants[] = $display_name;
            }
        }
        $date = date('D M d,Y', (int) $call->timestamp);
        if ($date == $previous_date) {
            $date = '';
        } else {
            if (!empty($previous_date)) {
                $table->addSeparator();
            }
            $previous_date = $date;
        }
        $total_duration += (int) $call->duration;
        $table->addRow(array($date, date('g:ia', (int) $call->timestamp), format_interval($call->duration), $types[$call->type], format_participants($participants)));
        printf("\r%s", str_repeat('.', $i));
    }
    printf("\r");
    print $table->getTable();
    printf("Number of calls: %s\n", count($calls));
    printf("Total duration: %s\n", format_interval($total_duration));
}
 /**
  * Display final results
  *
  * Display final results, when data source parsing is over.
  *
  * @access public
  * @return void
  * @since  version 1.8.0b3 (2008-06-07)
  */
 function display()
 {
     $o = $this->args['output-level'];
     $info = $this->parseData;
     $hdr = array();
     $src = $this->_parser->dataSource;
     if (isset($this->args['dir'])) {
         $dir = $this->args['dir'];
         $hdr[] = 'Files';
     } elseif (isset($this->args['file'])) {
         $file = $this->args['file'];
         $hdr[] = 'File';
     } elseif (isset($this->args['string'])) {
         $string = $this->args['string'];
         $hdr[] = 'Source code';
     } elseif ($src['dataType'] == 'directory') {
         $dir = $src['dataSource'];
         $hdr[] = 'Files';
     } elseif ($src['dataType'] == 'file') {
         $file = $src['dataSource'];
         $hdr[] = 'File';
     } else {
         $string = $src['dataSource'];
         $hdr[] = 'Source code';
     }
     $table = new Console_Table();
     $f = 0;
     if ($o & 16) {
         $hdr[] = 'Version';
         $f++;
     }
     if ($o & 1) {
         $hdr[] = 'C';
         $f++;
     }
     if ($o & 2) {
         $hdr[] = 'Extensions';
         $filter2 = array(&$this, '_splitExtname');
         $table->addFilter($f + 1, $filter2);
         $f++;
     }
     if ($o & 4) {
         if ($o & 8) {
             $hdr[] = 'Constants/Tokens';
         } else {
             $hdr[] = 'Constants';
         }
         $f++;
     } else {
         if ($o & 8) {
             $hdr[] = 'Tokens';
             $f++;
         }
     }
     $table->setHeaders($hdr);
     $filter0 = array(&$this, '_splitFilename');
     $table->addFilter(0, $filter0);
     if ($o > 3 && $o < 16 || $o > 19) {
         $filter3 = array(&$this, '_splitConstant');
         $table->addFilter($f, $filter3);
     }
     $ext = implode("\r\n", $info['extensions']);
     $const = implode("\r\n", array_merge($info['constants'], $info['tokens']));
     if (isset($dir)) {
         $ds = DIRECTORY_SEPARATOR;
         $dir = str_replace(array('\\', '/'), $ds, $dir);
         $data = array($dir . $ds . '*');
     } elseif (isset($file)) {
         $data = array($file);
     } else {
         $data = array('<?php ... ?>');
     }
     if ($o & 16) {
         if (empty($info['max_version'])) {
             $data[] = $info['version'];
         } else {
             $data[] = implode("\r\n", array($info['version'], $info['max_version']));
         }
     }
     if ($o & 1) {
         $data[] = $info['cond_code'][0];
     }
     if ($o & 2) {
         $data[] = $ext;
     }
     if ($o & 4) {
         if ($o & 8) {
             $data[] = $const;
         } else {
             $data[] = implode("\r\n", $info['constants']);
         }
     } else {
         if ($o & 8) {
             $data[] = implode("\r\n", $info['tokens']);
         }
     }
     $table->addRow($data);
     unset($info['max_version']);
     unset($info['version']);
     unset($info['classes']);
     unset($info['functions']);
     unset($info['extensions']);
     unset($info['constants']);
     unset($info['tokens']);
     unset($info['cond_code']);
     $ignored = $info['ignored_files'];
     $all_functions = array();
     unset($info['ignored_files']);
     unset($info['ignored_functions']);
     unset($info['ignored_extensions']);
     unset($info['ignored_constants']);
     // summarize : print only summary for directory without files details
     if ($this->args['summarize'] === false && isset($dir)) {
         foreach ($info as $file => $info) {
             if (is_numeric($file[0])) {
                 // extra information available only when debug mode is on
                 $all_functions[$file] = $info;
                 continue;
             }
             if ($info === false) {
                 continue;
                 // skip this (invalid) file
             }
             $ext = implode("\r\n", $info['extensions']);
             $const = implode("\r\n", array_merge($info['constants'], $info['tokens']));
             $file = str_replace(array('\\', '/'), $ds, $file);
             $table->addSeparator();
             $data = array($file);
             if ($o & 16) {
                 if (empty($info['max_version'])) {
                     $data[] = $info['version'];
                 } else {
                     $data[] = implode("\r\n", array($info['version'], $info['max_version']));
                 }
             }
             if ($o & 1) {
                 $data[] = $info['cond_code'][0];
             }
             if ($o & 2) {
                 $data[] = $ext;
             }
             if ($o & 4) {
                 if ($o & 8) {
                     $data[] = $const;
                 } else {
                     $data[] = implode("\r\n", $info['constants']);
                 }
             } else {
                 if ($o & 8) {
                     $data[] = implode("\r\n", $info['tokens']);
                 }
             }
             $table->addRow($data);
         }
     } else {
         foreach ($info as $file => $info) {
             if (is_numeric($file[0])) {
                 // extra information available only when debug mode is on
                 $all_functions[$file] = $info;
             }
         }
     }
     $output = $table->getTable();
     // verbose level
     $v = isset($this->args['verbose']) ? $this->args['verbose'] : 0;
     // command line resume
     if ($v & 1) {
         $output .= "\nCommand Line resume :\n\n";
         $table = new Console_Table();
         $table->setHeaders(array('Option', 'Value'));
         $filter0 = array(&$this, '_splitOption');
         $table->addFilter(0, $filter0);
         $filter1 = array(&$this, '_splitValue');
         $table->addFilter(1, $filter1);
         if (is_array($this->args)) {
             foreach ($this->args as $key => $raw) {
                 if ($key == 'summarize') {
                     $raw = $raw === true ? 'TRUE' : 'FALSE';
                 }
                 if (is_array($raw)) {
                     $raw = implode(', ', $raw);
                 }
                 $contents = array($key, $raw);
                 $table->addRow($contents);
             }
         }
         $output .= $table->getTable();
     }
     // parser options resume
     if ($v & 2) {
         $output .= "\nParser options :\n\n";
         $table = new Console_Table();
         $table->setHeaders(array('Option', 'Value'));
         $filter0 = array(&$this, '_splitOption');
         $table->addFilter(0, $filter0);
         $filter1 = array(&$this, '_splitValue');
         $table->addFilter(1, $filter1);
         $opts = $this->_parser->options;
         if (is_array($opts)) {
             foreach ($opts as $key => $raw) {
                 if ($key == 'debug' || $key == 'recurse_dir' || $key == 'is_string') {
                     $raw = $raw === true ? 'TRUE' : 'FALSE';
                 }
                 if (substr($key, -6) == '_match') {
                     $val = array_values($raw[1]);
                     array_unshift($val, $raw[0]);
                     $raw = implode("\r\n", $val);
                 } else {
                     if (is_array($raw)) {
                         $raw = implode("\r\n", $raw);
                     }
                 }
                 $contents = array($key, $raw);
                 $table->addRow($contents);
             }
         }
         $output .= $table->getTable();
     }
     // extra information
     if ($v & 4) {
         $output .= "\nDebug:\n\n";
         $table = new Console_Table();
         $table->setHeaders(array('Version', 'Function', 'Extension', 'PECL'));
         foreach ($all_functions as $version => $functions) {
             foreach ($functions as $func) {
                 $table->addRow(array($version, $func['function'], $func['extension'], isset($func['pecl']) ? $func['pecl'] === true ? 'yes' : 'no' : ''));
             }
         }
         $output .= $table->getTable();
     }
     echo $output;
 }
Пример #3
0
 /**
  * Parse Directory Input
  *
  * @return void
  * @access private
  * @since  0.8.0
  */
 function _parseDir()
 {
     $info = $this->parseDir($this->dir, $this->options);
     if ($info === false) {
         $err = 'No valid files into directory "' . $this->dir . '". Please check your spelling and try again.';
         $this->_printUsage($err);
         return;
     }
     $table = new Console_Table();
     $table->setHeaders(array('Path', 'Version', 'Extensions', 'Constants/Tokens'));
     $filter = array(&$this, '_splitFilename');
     $table->addFilter(0, $filter);
     $ext = implode("\r\n", $info['extensions']);
     $const = implode("\r\n", $info['constants']);
     $dir = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $this->dir);
     $table->addRow(array($dir . DIRECTORY_SEPARATOR . '*', $info['version'], $ext, $const));
     unset($info['max_version']);
     unset($info['version']);
     unset($info['extensions']);
     unset($info['constants']);
     $ignored = $info['ignored_files'];
     unset($info['ignored_files']);
     foreach ($info as $file => $info) {
         if ($info === false) {
             continue;
             // skip this (invalid) file
         }
         $ext = implode("\r\n", $info['extensions']);
         $const = implode("\r\n", $info['constants']);
         $file = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $file);
         $table->addSeparator();
         $table->addRow(array($file, $info['version'], $ext, $const));
     }
     $output = $table->getTable();
     // verbose level
     $v = $this->args->getValue('v');
     // command line resume
     if ($v & 1) {
         $output .= "\nCommand Line resume :\n\n";
         $table = new Console_Table();
         $table->setHeaders(array('Option', 'Value'));
         $opts = $this->args->getValues();
         if (is_array($opts)) {
             foreach ($opts as $key => $raw) {
                 if (is_array($raw)) {
                     $raw = implode(', ', $raw);
                 }
                 $contents = array($key, $raw);
                 $table->addRow($contents);
             }
         }
         $output .= $table->getTable();
     }
     // parser options resume
     if ($v & 2) {
         $output .= "\nParser options :\n\n";
         $table = new Console_Table();
         $table->setHeaders(array('Option', 'Value'));
         $opts = $this->options;
         if (is_array($opts)) {
             foreach ($opts as $key => $raw) {
                 if ($key == 'debug' || $key == 'recurse_dir') {
                     $raw = $raw === true ? 'TRUE' : 'FALSE';
                 }
                 if (is_array($raw)) {
                     $raw = implode("\r\n", $raw);
                 }
                 $contents = array($key, $raw);
                 $table->addRow($contents);
             }
         }
         $output .= $table->getTable();
     }
     echo $output;
 }
Пример #4
0
 /**
  * Show documentation for a shell.
  * Usage:
  * wpmvc Help Shell <shell_name> [command_name]
  * wpmvc Help Shell Generate
  * wpmvc Help Shell Generate Scaffold
  * @param mixed $args
  * @return null 
  */
 public function shell($args)
 {
     list($name, $method) = $args;
     if (empty($name)) {
         $this->out('No shell given');
         return;
     }
     try {
         $shell = $this->get_shell_meta($name);
     } catch (Exception $ex) {
         $this->out('Error:');
         $this->out($ex->getMessage());
         return;
     }
     $this->nl();
     $this->out(Console_Color::convert('%UShells > %n%U%9' . $shell->title . '%n'));
     $this->nl();
     $this->out($shell->doc);
     $this->nl(2);
     $this->out('Commands:');
     $table = new Console_Table(CONSOLE_TABLE_ALIGN_LEFT, ' ', 1, null, true);
     if ($method == 'default') {
         $method = '(default)';
     }
     if (!empty($method) && !empty($shell->methods[$method])) {
         $table->addRow(array(Console_Color::convert('%9' . $method . '%n'), $shell->methods[$method]));
     } else {
         foreach ($shell->methods as $method => $doc) {
             $table->addRow(array(Console_Color::convert('%9' . $method . '%n'), $doc));
             $table->addSeparator();
         }
     }
     $this->out($table->getTable());
 }
Пример #5
0
 /**
  * custom user info
  */
 public static function userInfo()
 {
     if (!self::debug()) {
         return;
     }
     if (empty(self::$DATA[self::USER])) {
         return;
     }
     $tbl = new Console_Table();
     $tbl->setHeaders(array('key', 'value', 'src'));
     $cnt = 0;
     foreach (self::$DATA[self::USER] as $row) {
         if ($cnt > 0) {
             $tbl->addSeparator();
         }
         $tbl->addRow($row);
         $cnt++;
     }
     echo PHP_EOL . $tbl->getTable() . PHP_EOL;
 }