Пример #1
0
function usage()
{
    fprintf(STDERR, "Usage: php midigrep.php -f <midi_file> [-r] {-c <channels> | -C <channels>}\n");
    fprintf(STDERR, "ex) php midigrep.php -f in.mid -c 1\n");
    fprintf(STDERR, "ex) php midigrep.php -f in.mid -c 1,2\n");
    fprintf(STDERR, "ex) php midigrep.php -f in.mid -C 15,16\n");
}
Пример #2
0
function registerUser($userName, $userMail, $userPasswd, $salt)
{
    $fileMail = fopen("database/email", "a+");
    if ($fileMail) {
        mkdir("database/users/{$userName}", 0755);
        mkdir("database/users/{$userName}/tasks", 0755);
        $fileName = fopen("database/users/{$userName}/{$userName}.usr", "a+");
        if ($fileName) {
            $filePasswd = fopen("database/passwd", "a+");
            if ($filePasswd) {
                /* creating user file in database */
                /* registering e-mail adress in database */
                fprintf($fileMail, "{$userMail}\n");
                fprintf($fileName, "{$userName}:{$userMail}\n");
                /* registering user's password in database */
                $PasswdCrypt = sha1(sha1("{$userPasswd}") . $salt);
                fprintf($filePasswd, "{$userName}:{$PasswdCrypt}\n");
                fclose($fileName);
            } else {
                rmdir("database/users/{$userName}");
                rmdir("database/users/{$userName}/tasks");
            }
            fclose($fileMail);
        } else {
            rmdir("database/users/{$userName}");
            rmdir("database/users/{$userName}/tasks");
        }
        fclose($filePasswd);
    }
}
Пример #3
0
 /**
  * @param mixed $data A Traversable of CModel or a CModel where data will be fetch from
  * @param array $attributes Attribute names of CModel to be exported.
  * @param bool $endApplication Application will be ended if true. false to keep going and export more data. Defautls to TRUE.
  * @param integer $endLineCount Number of newlines to append below this data. Defaults to 0.
  */
 public function exportCSV($data, $attributes = array(), $endApplication = true, $endLineCount = 0)
 {
     if ($this->isExportRequest()) {
         $this->sendHeaders();
         $fileHandle = fopen('php://output', 'w');
         if ($data instanceof CActiveDataProvider) {
             $this->csvRowHeaders($fileHandle, $attributes, $data->model);
             $this->csvRowModels($fileHandle, new CDataProviderIterator($data, 150), $attributes);
         } else {
             if (is_array($data) && current($data) instanceof CModel) {
                 $this->csvRowHeaders($fileHandle, $attributes, current($data));
                 $this->csvRowModels($fileHandle, $data, $attributes);
             } else {
                 if (is_array($data) && is_string(current($data))) {
                     fputcsv($fileHandle, $data, $this->csvDelimiter, $this->csvEnclosure);
                 } else {
                     if ($data instanceof CModel) {
                         $this->csvModel($fileHandle, $data, $attributes);
                     }
                 }
             }
         }
         fprintf($fileHandle, str_repeat("\n", $endLineCount));
         fclose($fileHandle);
         if ($endApplication) {
             Yii::app()->end(0, false);
             exit(0);
         }
     }
 }
Пример #4
0
function do_app($app)
{
    // enumerate the host_app_versions for this app,
    // joined to the host
    $db = BoincDb::get();
    $query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class " . " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version " . " where host_app_version.app_version_id = app_version.id " . " and app_version.appid = {$app->id} " . " and et_n > 0  and et_avg > 0 " . " and host.id = host_app_version.host_id";
    $result = $db->do_query($query);
    $a = array();
    while ($x = _mysql_fetch_object($result)) {
        if (is_gpu($x->plan_class)) {
            $av = $x->on_frac;
            if ($x->gpu_active_frac) {
                $av *= $x->gpu_active_frac;
            } else {
                $av *= $x->active_frac;
            }
        } else {
            $av = $x->on_frac * $x->active_frac;
        }
        $a[] = 1 / $x->et_avg * $av;
    }
    _mysql_free_result($result);
    sort($a);
    $n = count($a);
    $f = fopen("../../size_census_" . $app->name, "w");
    for ($i = 1; $i < $app->n_size_classes; $i++) {
        $k = (int) ($i * $n / $app->n_size_classes);
        fprintf($f, "%e\n", $a[$k]);
    }
    fclose($f);
}
Пример #5
0
 /**
  * Execute the command
  */
 function execute()
 {
     $stderr = fopen('php://stdout', 'w');
     $locales = AppLocale::getAllLocales();
     $dbConn = DBConnection::getConn();
     foreach ($locales as $locale => $localeName) {
         fprintf($stderr, "Checking {$localeName}...\n");
         $oldTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->oldTag);
         $newTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->newTag);
         if ($oldTemplatesText === false || $newTemplatesText === false) {
             fprintf($stderr, "Skipping {$localeName}; could not fetch.\n");
             continue;
         }
         $oldEmails = $this->parseEmails($oldTemplatesText);
         $newEmails = $this->parseEmails($newTemplatesText);
         foreach ($oldEmails['email_text'] as $oi => $junk) {
             $key = $junk['attributes']['key'];
             $ni = null;
             foreach ($newEmails['email_text'] as $ni => $junk) {
                 if ($key == $junk['attributes']['key']) {
                     break;
                 }
             }
             if ($oldEmails['subject'][$oi]['value'] != $newEmails['subject'][$ni]['value']) {
                 echo "UPDATE email_templates_default_data SET subject='" . $dbConn->escape($newEmails['subject'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND subject='" . $dbConn->escape($oldEmails['subject'][$oi]['value']) . "';\n";
             }
             if ($oldEmails['body'][$oi]['value'] != $newEmails['body'][$ni]['value']) {
                 echo "UPDATE email_templates_default_data SET body='" . $dbConn->escape($newEmails['body'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND body='" . $dbConn->escape($oldEmails['body'][$oi]['value']) . "';\n";
             }
         }
     }
     fclose($stderr);
 }
Пример #6
0
 function eputsf()
 {
     $args = func_get_args();
     $fmt = array_shift($args);
     fprintf(STDERR, $fmt, $args);
     fprintf(STDERR, "%s", PHP_EOL);
 }
Пример #7
0
function ctx_log_msg($func, $text, $type)
{
    global $_context_log;
    if ($_context_log) {
        fprintf($_context_log, "%f %s %d %d %s %s %s\n", microtime(true), php_uname('n'), posix_getpid(), posix_getpid(), $type, $func, $text);
    }
}
Пример #8
0
function usage()
{
    global $argv;
    fprintf(STDERR, "Usage: %s -u <URL> -n <requests> -c <concurrency> -e (use libevent)\n", $argv[0]);
    fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n");
    exit(-1);
}
Пример #9
0
/**
 * Simple tail program using the inotify extension
 * Usage: ./tail.php file
 */
function main_loop($file, $file_fd)
{
    $inotify = inotify_init();
    if ($inotify === false) {
        fprintf(STDERR, "Failed to obtain an inotify instance\n");
        return 1;
    }
    $watch = inotify_add_watch($inotify, $file, IN_MODIFY);
    if ($watch === false) {
        fprintf(STDERR, "Failed to watch file '%s'", $file);
        return 1;
    }
    while (($events = inotify_read($inotify)) !== false) {
        echo "Event received !\n";
        foreach ($events as $event) {
            if (!($event['mask'] & IN_MODIFY)) {
                continue;
            }
            echo stream_get_contents($file_fd);
            break;
        }
    }
    // May not happen
    inotify_rm_watch($inotify, $watch);
    fclose($inotify);
    fclose($file_fd);
    return 0;
}
Пример #10
0
 /**
  * processList - 
  */
 function processList()
 {
     //$filename = 'titlelisting.txt';
     $fp = fopen(self::RPT_FILENAME, 'w');
     if ($fp) {
         $this->fp = $fp;
     }
     //select nid, title from node order by title;
     //$sql = 'SELECT nid, title FROM node ORDER BY title, nid LIMIT 50';
     //$sql = "SELECT nid, title FROM node WHERE TYPE = 'biblio' ORDER BY title, nid LIMIT 500";
     //SELECT n.nid, n.title FROM node AS n JOIN biblio AS b ON (b.nid = n.nid) WHERE b.biblio_label LIKE '%Pensoft%' AND n.type = 'biblio' ORDER BY n.title, n.nid LIMIT 10;
     $sql = "SELECT nid, title FROM node WHERE TYPE = 'biblio' ORDER BY title, nid";
     //$sql = "SELECT n.nid, n.title FROM node AS n JOIN biblio AS b ON (b.nid = n.nid) WHERE b.biblio_label LIKE '%Pensoft%' AND n.type = 'biblio' ORDER BY n.title, n.nid";
     $titleList = $this->dbi->fetch($sql);
     foreach ($titleList as $titleItem) {
         //$msg = '' . $titleItem['nid'] . ' ' . (trim($titleItem['title']) ? $titleItem['title'] : 'NO TITLE') . ' ';
         $msg = '' . $titleItem['nid'] . (strlen($titleItem['nid']) == 6 ? '' : ' ') . ' ' . (trim($titleItem['title']) ? $titleItem['title'] : 'NO TITLE') . ' ';
         fprintf($this->fp, '%s', $msg);
         fprintf($this->fp, '%s', PHP_EOL);
     }
     if ($this->fp) {
         fclose($this->fp);
     }
     echo date('YmdHis');
 }
Пример #11
0
function export($is_user, $dir)
{
    $n = 0;
    $filename = $is_user ? "{$dir}/user_work" : "{$dir}/team_work";
    $f = fopen($filename, "w");
    if (!$f) {
        die("fopen");
    }
    $is_user ? fprintf($f, "<users>\n") : fprintf($f, "<teams>\n");
    $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id");
    while ($n <= $maxid) {
        $m = $n + 1000;
        if ($is_user) {
            $items = BoincUser::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
        } else {
            $items = BoincTeam::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
        }
        foreach ($items as $item) {
            export_item($item, $is_user, $f);
        }
        $n = $m;
    }
    $is_user ? fprintf($f, "</users>\n") : fprintf($f, "</teams>\n");
    fclose($f);
    system("gzip -f {$filename}");
}
function write_row($handle, $row)
{
    foreach ($row as $key => $value) {
        $row[$key] = preg_replace("/\"/", "\"\"", $value);
    }
    fprintf($handle, "\"%s\"\n", implode("\",\"", $row));
}
Пример #13
0
 public function write($message, $sev = 0)
 {
     $tag;
     if ($sev < $this->debugLevel) {
         return;
     }
     date_default_timezone_set("GMT");
     switch ($sev) {
         case 0:
             $tag = "notice";
             break;
         case 1:
             $tag = "warn";
             break;
         case 3:
             $tag = "error";
             break;
         case 9:
             $tag = "security";
             break;
         default:
             $tag = "notice";
             break;
     }
     $message = sprintf("[%s] [%s] [ppg] [session:%s] [prog:%s] : %s", date('D M d H:i:s Y'), $tag, $this->sessId, $this->caller, $message);
     fprintf($this->errorHandle, "%s\n", $message);
 }
Пример #14
0
 /**
  * @inheritdoc
  */
 public function prepare()
 {
     if ($this->utf8Encoding) {
         fprintf($this->getStream(), chr(0xef) . chr(0xbb) . chr(0xbf));
     }
     return $this;
 }
Пример #15
0
 function createcfg($type = null)
 {
     $term = \Cherry\Cli\Console::getAdapter();
     if (!$type) {
         fprintf(STDERR, "No such config. Try " . Ansi::setUnderline() . "list-configs" . Ansi::clearUnderline() . "\n");
         return 1;
     }
     $args = func_get_args();
     $type = $args[0];
     $opts = $this->parseOpts(array_slice($args, 1), array('verbose' => '+verbose', 'dest' => 'to:', 'force' => '+force'));
     if ($type) {
         $this->data = new TemplateStrings();
         $this->data->htmlroot = exec('pwd');
         $this->data->environment = 'prodution';
         $tpl = (require CHERRY_LIB . '/share/configs/' . $type . '.php');
         $meta = parse_ini_file(CHERRY_LIB . '/share/configs/' . $type . '.ini', true);
         if (empty($opts['dest'])) {
             $out = $meta['config']['dest'];
         } else {
             $out = $opts['dest'];
         }
         fprintf(STDOUT, "Writing %s...\n", $out);
         if (file_exists($out)) {
             if (empty($opts['force']) || $opts['force'] == 0) {
                 fprintf(STDERR, "Error: File already exists! To replace use +force\n");
                 return 1;
             }
         }
         file_put_contents($out, trim($tpl) . "\n");
     }
 }
Пример #16
0
 /**
  * Lists all ClientEmployee models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ClientEmployeeSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (isset($_GET['download'])) {
         $datetime_start = str_replace('\'', '', $_GET['datetime_start']);
         $datetime_end = str_replace('\'', '', $_GET['datetime_end']);
         $filename = Yii::$app->getRuntimePath() . "/员工会员推广排行榜-" . $datetime_start . '到' . $datetime_end . '.csv';
         $fh = fopen($filename, 'w');
         fprintf($fh, "排名,会员推广数量,员工姓名,电话,营业厅" . PHP_EOL);
         $i = 1;
         \Yii::warning('yjhu:' . $datetime_start);
         $rows = \app\models\MUser::getMemberPromotionTopList(0, 5000, $datetime_start . ' 00:00:00', $datetime_end . ' 23:59:59');
         foreach ($rows as $row) {
             $staff = \app\models\MStaff::findOne(['scene_id' => $row['scene_pid']]);
             fprintf($fh, $i++ . ',');
             fprintf($fh, $row['members'] . ',');
             fprintf($fh, $staff->name . ',');
             fprintf($fh, $staff->mobile . ',');
             fprintf($fh, (empty($staff->office) ? '' : $staff->office->title) . PHP_EOL);
         }
         fclose($fh);
         Yii::$app->response->sendFile($filename);
         return;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Пример #17
0
function failure()
{
    // this is why error_get_last() should return a stdClass object
    $error = error_get_last();
    fprintf(STDERR, "FAILURE: %s\n", $error["message"]);
    exit(-1);
}
Пример #18
0
 public function execute()
 {
     curl_setopt_array($this->hcurl, [CURLOPT_VERBOSE => 1, CURLOPT_HEADER => 1, CURLOPT_AUTOREFERER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_MAXREDIRS => 10]);
     switch ($this->method) {
         case 'head':
             curl_setopt_array($this->hcurl, [CURLOPT_NOBODY => 1]);
             break;
         case 'get':
             curl_setopt_array($this->hcurl, [CURLOPT_RETURNTRANSFER => 1]);
             break;
         case 'post':
             curl_setopt_array($this->hcurl, [CURLOPT_RETURNTRANSFER => 1]);
             break;
         case 'put':
             break;
         default:
             fprintf(STDERR, "Bad request method: %s\n", $this->method);
     }
     $response = curl_exec($this->hcurl);
     // Then, after your curl_exec call:
     $header_size = curl_getinfo(${$this}->hcurl, CURLINFO_HEADER_SIZE);
     $header = substr($response, 0, $header_size);
     $this->resheaders = explode("\r\n", $header);
     $this->resbody = substr($response, $header_size);
     $this->resmeta = curl_getinfo($this->hcurl);
     $this->rescode = curl_getmeta($this->hcurl, CURLINFO_HTTP_CODE);
 }
Пример #19
0
 /**
  * Dump an array of Paths
  *
  * @param mixed $paths a single Path object or an array of Path objects
  * @param stream $handle
  */
 public function dump($paths, $handle)
 {
     if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
         throw new Exception("Not a stream resource");
     }
     if (!is_array($paths)) {
         $paths = array($paths);
     }
     $nodes = array();
     $rels = array();
     foreach ($paths as $path) {
         if (!$path instanceof Path) {
             throw new Exception("Not a Path");
         }
         $pathNodes = $path->getNodes();
         foreach ($pathNodes as $node) {
             $nodes[$node->getId()] = $node;
         }
         $pathRels = $path->getRelationships();
         foreach ($pathRels as $rel) {
             $rels[$rel->getId()] = $rel;
         }
     }
     foreach ($nodes as $id => $node) {
         $properties = $node->getProperties();
         $format = $properties ? "(%s)\t%s\n" : "(%s)\n";
         fprintf($handle, $format, $id, json_encode($properties));
     }
     foreach ($rels as $id => $rel) {
         $properties = $rel->getProperties();
         $format = "(%s)-[%s:%s]->(%s)";
         $format .= $properties ? "\t%s\n" : "\n";
         fprintf($handle, $format, $rel->getStartNode()->getId(), $id, $rel->getType(), $rel->getEndNode()->getId(), json_encode($properties));
     }
 }
Пример #20
0
 protected function parseOpts(array $args, array $rules)
 {
     $out = array();
     for ($optidx = 0; $optidx < count($args); $optidx++) {
         $opt = $args[$optidx];
         $matched = false;
         foreach ($rules as $name => $rule) {
             if ($rule[strlen($rule) - 1] == ':') {
                 $rulestr = substr($rule, 0, strlen($rule) - 1);
                 if ($opt == $rulestr) {
                     $out[$name] = $args[$optidx + 1];
                     $optidx++;
                     $matched = true;
                 }
             } elseif ($rule[0] == '+') {
                 if ($opt == $rule) {
                     $out[$name] = true;
                     $matched = true;
                 }
             }
         }
         if (!$matched) {
             fprintf(STDERR, "Unknown option: %s\n", $opt);
         }
     }
     return $out;
 }
Пример #21
0
 public function doCommand()
 {
     $startWith = $this->param('startWith', 0);
     $incrementBy = $this->param('incrementBy', 1);
     fprintf(STDOUT, "Start With %d and increment by %d\n", $startWith, $incrementBy);
     return $startWith + $incrementBy;
 }
Пример #22
0
 function run_idf($path)
 {
     $f = fopen($path, 'w');
     $max = 1;
     $min = 1;
     foreach ($this->m_Keywords->m_Table as $word => $record) {
         if ($this->isIgnored($record)) {
             continue;
         }
         $count = $record['count'];
         if ($max < $count) {
             $max = $count;
         }
     }
     foreach ($this->m_Keywords->m_Table as $word => $record) {
         if ($this->isIgnored($record)) {
             continue;
         }
         $index = $record['index'];
         $count = $record['count'];
         if (!$index || !$count) {
             continue;
         }
         $rate = log($max / $count) / log($max / $min);
         fprintf($f, "%d,%f,%s\n", $index, $rate, $word);
     }
     fclose($f);
 }
 public static function render_exception_trace(Exception $e)
 {
     fprintf(STDERR, get_class($e) . ' thrown at ' . date('c') . PHP_EOL);
     fprintf(STDERR, $e->getMessage() . PHP_EOL);
     $trace = $e->getTrace();
     if (count($trace) > 0) {
         fprintf(STDERR, 'Exception trace:' . PHP_EOL . PHP_EOL);
         foreach ($trace as $data) {
             fprintf(STDERR, '----------------------------------------' . PHP_EOL);
             $keys = array_keys($data);
             sort($keys);
             foreach ($keys as $key) {
                 fprintf(STDERR, "{$key}: ");
                 if (is_array($data[$key])) {
                     foreach ($data[$key] as $datum) {
                         fprintf(STDERR, '    ');
                         if (is_numeric($datum) || is_string($datum)) {
                             fprintf(STDERR, '"' . $datum . '"');
                         }
                         fprintf(STDERR, PHP_EOL);
                     }
                 } else {
                     if (strtolower($key) == 'file') {
                         $formatted_filename = new Formatting_FileName($data[$key]);
                         fprintf(STDERR, $formatted_filename->get_pretty_name());
                     } else {
                         fprintf(STDERR, '    ');
                         fprintf(STDERR, '' . $data[$key] . PHP_EOL);
                     }
                 }
             }
             fprintf(STDERR, '----------------------------------------' . PHP_EOL);
         }
     }
 }
 public function run($args)
 {
     if (count($args) != 1) {
         $this->usageError('Please supply the path to valuesets.json');
     }
     $data = json_decode(file_get_contents($args[0]));
     $value_sets = array();
     foreach ($data->feed->entry as $entry) {
         $content = $entry->content;
         if (@$content->experimental || $content->status == 'retired' || !isset($content->define) || !preg_match('|^http://hl7.org/fhir|', $content->define->system)) {
             continue;
         }
         $name = $this->toConstantName($content->name);
         $value_sets[$name] = array('system' => $content->define->system, 'desc' => $this->normaliseDesc($content->description), 'values' => $this->parseConcepts($name, $content->define->concept));
     }
     $f = fopen(Yii::app()->basePath . '/helpers/FhirValueSet.php', 'w');
     fprintf($f, "<?php\n\n// Auto-generated by %s\n\nclass FhirValueSet\n{\n", __CLASS__);
     foreach ($value_sets as $value_set) {
         fprintf($f, "\t// %s\n\t// %s\n\n", $value_set['system'], $value_set['desc']);
         foreach ($value_set['values'] as $name => $value) {
             fprintf($f, "\tconst %s = '%s';", $name, $value['value']);
             if ($value['desc']) {
                 fprintf($f, '  // %s', $value['desc']);
             }
             fprintf($f, "\n");
         }
         fprintf($f, "\n\n");
     }
     fprintf($f, "}\n");
     fclose($f);
 }
 public function yybegin($state)
 {
     $this->_yy_state = $state;
     if ($this->yyTraceFILE) {
         fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
     }
 }
Пример #26
0
 /**
  * Lists all MOrder models.
  * @return mixed
  */
 public function actionIndex($userid)
 {
     $searchModel = new MOrderSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $userid);
     if (isset($_GET['download'])) {
         $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'order' . "-{$date}.csv";
         $fh = fopen($filepathname, 'w');
         //在写入数据之前先把bom头写到文件里
         fwrite($fh, "");
         fprintf($fh, "订单号, 商品, 订单时间, 订单状态, 用户姓名, 联系电话\n");
         if (Yii::$app->user->identity->role == 1) {
             $orders = MOrder::find()->all();
         } else {
             $orders = MOrder::find()->where(['userid' => $userid])->all();
         }
         if (!empty($orders)) {
             foreach ($orders as $order) {
                 $status = $order->status == 1 ? "已申请" : "已处理";
                 fprintf($fh, "%s, %s, %s, %s, %s, %s\n", $order->oid, $order->title, $order->create_time, $status, $order->username, $order->usermobile);
             }
         }
         fclose($fh);
         iconv("UTF-8", "GB2312", "{$filepathname}");
         Yii::$app->response->sendFile($filepathname);
         return;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Пример #27
0
function check($request)
{
    $response = new CustomFieldResponse();
    $response->fields = array();
    #### debug ####
    $fp = fopen('out.txt', 'w');
    $output = var_export($request, true);
    ###############
    $response->response = '[accepted]';
    $truefields = array('termsandconditions');
    $fields = array();
    foreach ($request->customFieldRequest->fields->CustomField as $field) {
        $fields[$field->name] = $field->value;
    }
    foreach ($truefields as $rf) {
        if ($fields[$rf] != "true") {
            $response->response = '[invalid]';
            $invalidField = new CustomField();
            $invalidField->name = $rf;
            $invalidField->value = "customField.error." . $rf;
            $output .= var_export($invalidField, true);
            array_push($response->fields, $invalidField);
        }
    }
    $output .= var_export($fields, true);
    $output .= var_export($response, true);
    if ($response->response == '[invalid]') {
        fprintf($fp, '%s', "BEGIN\n" . $output . "\nEND\n");
        return array("customFieldResponse" => $response);
    }
    return array("customFieldResponse" => $response);
}
Пример #28
0
 /**
  * {@inheritdoc}
  */
 public function open()
 {
     $this->file = fopen($this->filename, 'w', false);
     if (true === $this->withBom) {
         fprintf($this->file, chr(0xef) . chr(0xbb) . chr(0xbf));
     }
 }
Пример #29
0
function debugPrint($var, $file = '')
{
    $more_info = '';
    if (is_string($var)) {
        $more_info = 'size: ' . strlen($var);
    } elseif (is_bool($var)) {
        $more_info = 'val: ' . ($var ? 'true' : 'false');
    } elseif (is_null($var)) {
        $more_info = 'is null';
    } elseif (is_array($var)) {
        $more_info = count($var);
    }
    if ($file === true) {
        $file = '/tmp/logDebug';
    }
    if (strlen($file) > 0) {
        $f = fopen($file, "a");
        ob_start();
        echo date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "\n";
        print_r($var);
        echo "\n\n";
        $output = ob_get_clean();
        fprintf($f, "%s", $output);
        fclose($f);
    } else {
        echo "<pre>" . date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "</pre>";
        echo "<pre>";
        print_r($var);
        echo "</pre>";
    }
}
Пример #30
0
	/**
	 * Prints help info
	 *
	 * @param \BackupStore $store
	 * @return boolean return status
	 * @author : Rafał Trójniak rafal@trojniak.net
	 */
	function run(\BackupStore $store)
	{
		fprintf(STDERR,"Options :\n");
		foreach($this->config as $com){
			list($short,$long,$description)=$com;
			$options=array();
			$param=null;
			if(count($com)>=4){
				$param=$com[3];
				if(strpos($short,'::')!==false)
				{
					$param="[$param]";
				}
				$param='='.$param;
				$short=trim($short,':');
				$long=trim($long,':');
			}
			if(!is_null($short)){
				$options[]='-'.$short;
			}
			if(!is_null($long)){
				$options[]='--'.$long;
			}
			fprintf(STDERR,"\t".implode('|',$options)."$param\t$description\n");
		}
		return false;
	}