function write_array($arr, $semicolon = true) { $data = array(); foreach ($arr as $k => $v) { if (is_array($v)) { $v = write_array($v, false); } else { $v = "'" . addslashes($v) . "'"; } if (!is_int($k)) { $k = "'" . addslashes($k) . "' => "; } else { $k = null; } $data[] = "{$k}{$v}"; } $data = "array(\r\n " . implode(",\r\n ", $data) . "\r\n)"; $semicolon && ($data .= ';'); return $data; }
fwrite($f, serialize($array)); fclose($f); } $f = fopen("cuda_result_log", "r"); $i = 0; while (!feof($f)) { $str = fgets($f); list($val_time, $rec_time, $resultid, $hostid, $userid, $teamid, $claimed, $granted, $desc) = sscanf($str, "%d %d %d %d %d %d %f %f %s"); add_to_array($hosts, $hostid, $granted); add_to_array($users, $userid, $granted); add_to_array($teams, $teamid, $granted); add_to_array($descs, $desc, $granted); if ($rec_time) { $day = date("Y n j", $rec_time); add_to_array($days, $day, $granted); } $i++; if ($i % 10000 == 0) { echo "{$i}\n"; } } uasort($hosts, "compare"); uasort($users, "compare"); uasort($teams, "compare"); uasort($descs, "compare"); write_array($hosts, "cuda_hosts.dat", 100); write_array($users, "cuda_users.dat", 100); write_array($teams, "cuda_teams.dat", 100); write_array($descs, "cuda_models.dat", 0); write_array($days, "cuda_days.dat", 0);
<?php foreach (read_dir(ROOT . 'app/helpers/') as $helper) { $helpers[] = str_replace('_helper', '', $helper); } $contents = '<?php $helpers = ' . write_array($helpers) . ' ?>'; file_put_contents(SYSROOT . 'data/app_helpers.php', $contents); to_index('Helpers file updated');
<?php $ctrls = read_folders(ROOT . 'app/controllers/'); write_system_data_file('app_controllers', write_system_data_array($ctrls, 'controllers')); foreach (read_dir(ROOT . 'app/helpers/') as $helper) { $helpers[] = str_replace('_helper', '', $helper); } $contents = '<?php $helpers = ' . write_array($helpers) . ' ?>'; file_put_contents(SYSROOT . 'data/app_helpers.php', $contents); $mdls = read_dir(ROOT . 'app/models/'); $contents = '<?php $models = ' . write_array($mdls) . ' ?>'; file_put_contents(SYSROOT . 'data/app_models.php', $contents); to_index('All files updated');
} fclose($fp); return $ret; } $file = 'b.csv'; $data = read_csv($file); $ret = array(); foreach ($data as $item) { $a = strtolower($item[0]); $a = str_replace(' ', '', $a); $l = mb_strlen($a); for ($i = 1; $i <= $l; $i++) { $sa = mb_substr($a, 0, $i); if (!isset($ret[$sa])) { $ret[$sa] = array(); } $ret[$sa][] = $item[0]; } $a = strtolower($item[1]); $a = str_replace(' ', '', $a); $l = mb_strlen($a); for ($i = 1; $i <= $l; $i++) { $sa = mb_substr($a, 0, $i); if (!isset($ret[$sa])) { $ret[$sa] = array(); } $ret[$sa][] = $item[0]; } } write_array(__DIR__ . '/../config/suggest.php', $ret);
$fp = fopen($file, "r"); while (!feof($fp)) { $line = trim(fgets($fp)); $ret[] = explode(',', $line); } fclose($fp); return $ret; } $file = 'd.csv'; $data = read_csv($file); $ret = array('brand' => array(), 'series' => array()); foreach ($data as $item) { if (isset($item[3])) { $b = explode('|', $item[3]); foreach ($b as $bb) { if (!isset($ret['brand'][$bb]) && !empty($bb)) { $ret['brand'][$bb] = $item[2]; } } } if (isset($item[1])) { $a = explode('|', $item[1]); foreach ($a as $aa) { if (!isset($ret['series'][$aa]) && !isset($ret['brand'][$aa]) && !empty($aa)) { $ret['series'][$aa] = $item[0] . '|' . $item[2]; } } } } write_array(__DIR__ . '/../config/keyword.php', $ret);