예제 #1
0
function addCount($fileName, $id)
{
    $json = readJson($fileName);
    if (empty($json[$id])) {
        $json[$id] = 1;
    } else {
        $json[$id] = $json[$id] + 1;
    }
    writeJson($fileName, $json);
}
예제 #2
0
<?php

/**
 * @file 上边气泡图
 * @author zhangxuanjian
 */
function readJson($module)
{
    $filePath = dirname(__FILE__) . '/' . $module . '.json';
    $json = file_get_contents($filePath);
    $p = json_decode($json, true);
    return $p;
}
$tplData['testjson'] = readJson('./data/test');
$tplData['test'] = 'test';
예제 #3
0
 $theme = readJson($themePath);
 // Add current year for copyrights.
 $theme['year'] = date('Y');
 // Add UUID for sublime themes.
 $theme['uuid'] = generateUuid($theme['theme']['name']);
 if (!isset($theme['ui_bg'])) {
     $theme['ui_bg'] = $theme['background'];
 }
 // Include non-hashed colours.
 $theme = hashLessify($theme);
 // Iterate patterns.
 foreach (globArray($patternDirs) as $patternPath) {
     // This is a good place to show progress.
     echo '.';
     // Load the pattern configuration JSON.
     $patternConfig = readJson($patternPath);
     // Build a path to the pattern source.
     $sourcePath = str_replace('.json', '.pattern', $patternPath);
     // Load the pattern source from disk.
     $patternSource = file_get_contents($sourcePath);
     // Use 'Twig' to render the theme from theme data.
     $result = renderTwig($patternSource, $theme);
     // Build the write path stub from pattern config.
     $writePath = $outputDir . '/' . $patternConfig['folder'] . '/';
     // If a theme config has a directory set...
     if (isset($theme['theme']['dir'])) {
         // ... append it to the write path.
         $writePath .= $theme['theme']['dir'] . '/';
     }
     // Ensure that the directory exists.
     @mkdir($writePath, 0777, true);
예제 #4
0
    echo "Usage: {$argv['0']} <json_dir>\n\n";
    exit(-1);
}
$db = new mysqli("p:localhost", "trend", "", "assembly");
// Check connection
if ($db->connect_error) {
    echo "Connection failed: " . $db->connect_error;
    exit(-1);
}
$db->set_charset("utf8");
//readJson('1904016.json', $db);
$dir = $argv[1];
$d = dir($dir);
while (false !== ($entry = $d->read())) {
    if (!is_dir("{$dir}/{$entry}") && endsWith($entry, ".json")) {
        readJson("{$dir}/{$entry}", $db);
    }
}
function readJson($jsonfile, $db)
{
    $str = file_get_contents($jsonfile);
    $json = json_decode($str, true);
    //print_r ($json);
    $bill = new Bill($json);
    //print $bill->toString();
    if ($bill->link_id === "") {
        echo "Bill ID Needed for {$entry}!";
        exit(-1);
    }
    $bill->insert($db);
    // Let's work on the actors
예제 #5
0
 /**
  * 执行请求处理
  */
 public function doService()
 {
     $config = $this->config;
     if (!empty($config['json'])) {
         if (isAssoc($config['json'])) {
             foreach ($config['json'] as $key => $file) {
                 $this->assign($key, readJson($file));
             }
         } else {
             foreach ($config['json'] as $file) {
                 $this->assignJsonFile($file);
             }
         }
     }
     // 固定变量
     if (!empty($config['var'])) {
         $this->assign($config['var']);
     }
     if (!empty($config['tplData'])) {
         $this->assign('tplData', $config['tplData'], true);
     }
     if (!empty($config['extData'])) {
         $this->assign('extData', $config['extData'], true);
     }
     if (!empty($config['paramData'])) {
         $this->assign('paramData', $config['paramData'], true);
     }
     $templateVars = $this->smarty->getTemplateVars();
     $this->doModifyData($templateVars);
     if (!empty($config['tplPath'])) {
         $tplPath = preg_replace('#^[/\\\\]+#', '', $config['tplPath']);
         $this->display($config['tplPath']);
     }
 }