/** * Recursively processes a path and extracts JSDoc comment data from * every .js file it finds. * @param $path */ function recurse($path) { $fList = scandir($path); foreach ($fList as $key => $val) { switch ($val) { case '.': case '..': // Ignore these entries break; default: if (is_dir($path . '/' . $val)) { // The entry is a folder so recurse it recurse($path . '/' . $val); } else { // The entry is a file, check if it's a .js file if (substr($val, strlen($val) - 3, 3) === '.js') { // Process the JS file echo 'Processing JavaScript file: ' . $path . '/' . $val . '<BR>'; $data = parseFile($path . '/' . $val); processData($data, $path . '/' . $val, $val); } } break; } } }
function parseFiles() { global $db; global $types; mysqli_query($db, "TRUNCATE TABLE `es_prices`"); mysqli_query($db, "TRUNCATE TABLE `es_stations`"); foreach ($types as $name) { parseFile($name); } }
function recursiveSearch($directory) { $files = scandir($directory); foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; } $full_path = $directory . '/' . $file; if (is_dir($full_path)) { recursiveSearch($full_path); } else { parseFile($full_path); } } }
/** * Parses a directory for files, recursively * @param $path string The folder to start processing */ function parseDir($path) { foreach (glob($path) as $filename) { if (strpos($filename, ".coffee")) { parseFile($filename); } else { if (strpos($filename, ".css")) { parseFile($filename); } else { if (strpos($filename, ".") == "") { parseDir($filename . "/*"); } } } } }
function itparse($option = array()) { /* Get file-list that should be parsed. */ $arrFiles = glob(__DOC_PATH__ . '/*.{txt}', GLOB_BRACE); usort($arrFiles, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); /* */ $counter = 0; foreach ($arrFiles as $file) { $arrResult = InventoryPurge::where("filename", $file)->get(); if (count($arrResult)) { $processed = 0; try { $processed = $arrResult[0]->processed; } catch (Exception $e) { } if ($processed) { continue; } continue; } $purge = new InventoryPurge(); echo "Parsing " . $file . "<br>"; if (parseFile($file)) { echo "Succesfully parsed.<br>"; $purge->filename = $file; $purge->processed = 1; $purge->save(); /* Delete parsed file... */ //delete($file); } else { echo "Failed to parsed " . $file . "<br>"; } } echo "All files processed."; }
function recurse($path) { global $AR, $needsUpgrade; $dh = opendir($path); $files = array(); $nlsFiles = array(); $dirs = array(); $objectID = pathToObjectID($path); while (is_resource($dh) && false !== ($file = readdir($dh))) { if ($file != "." && $file != "..") { $f = $path . $file; if (is_file($f) && $file[0] == '_') { $files[] = $file; } else { if (is_dir($f) && $file != "CVS" && $file != ".svn") { $dirs[] = $f . "/"; } } } } closedir($dh); foreach ($files as $file) { $info = parseFile($file); $nlsFiles[$info['file']][$info['nls']] = $info; } unset($files); foreach ($nlsFiles as $basefile => $nlsData) { if (count($nlsData)) { $needsUpgrade[$objectID] = '' . $objectID; } } unset($nlsFiles); foreach ($dirs as $dir) { recurse($dir); } unset($dirs); }
$parameters[] = explode(",", "gnfs,106,5,59,2000,6.0e-4,0.25,200,15,15000,2000,2500000,2500000,26,26,49,49,2.6,2.6,150000,4000000,300"); $parameters[] = explode(",", "gnfs,110,5,61,2000,1.5e-4,0.3,250,15,50000,2400,3200000,3200000,27,27,50,50,2.6,2.6,100000,4000000,300"); $parameters[] = explode(",", "gnfs,112,5,61,2000,1.6e-4,0.25,250,15,50000,2800,3500000,3500000,27,27,50,50,2.6,2.6,100000,4000000,300"); $parameters[] = explode(",", "gnfs,118,5,63,2000,2.6e-5,0.28,250,20,50000,3600,4500000,4500000,27,27,50,50,2.4,2.4,60000,4000000,300"); $parameters[] = explode(",", "gnfs,122,5,65,2000,1.0e-5,0.28,250,20,50000,3600,5000000,5000000,27,27,50,50,2.4,2.4,60000,4000000,300"); $parameters[] = explode(",", "gnfs,126,5,67,2000,5.0e-6,0.28,250,20,50000,3600,5400000,5400000,27,27,51,51,2.5,2.5,60000,4000000,300"); if (count($argv) != 2 && count($argv) != 3) { echo "Usage: " . $argv[0] . " [-i] number.fb\n"; exit(1); } if (count($argv) == 3) { define('INFO_MODE', 1); } else { define('INFO_MODE', 0); } $number = parseFile($argv[1 + INFO_MODE]); $chosen = getChosenParameters($number); populateObject($number, $chosen); $estimatedMinRelations = getMinRels($number, $chosen); printSiever($number); if (!INFO_MODE) { writeJobFile($number, str_replace(".fb", ".job", $argv[1 + INFO_MODE])); echo "Wrote job file: " . str_replace(".fb", ".job", $argv[1 + INFO_MODE]) . "\n"; } function valueofline($lookfor, $contents) { $ret = -256; for ($i = 0; $i < count($contents); $i++) { if (stripos(strtolower(trim($contents[$i])), strtolower($lookfor)) === 0) { $contents[$i] = str_replace(" ", " ", $contents[$i]); $ret = explode(" ", trim($contents[$i]));
$files[] = $dir . $file; } break; case "dir": $files = array_merge($files, findFiles($dir . $file)); break; } } closedir($dh); } } return $files; } $files = findFiles($source); foreach ($files as $file) { parseFile($file); } function parseFile($file) { $skip = array("<?php", "?>"); $b = basename($file, ".php"); //if(!is_numeric($b)) //return; $data = file_get_contents($file); $lines = explode("\n", $data); $out = array(); foreach ($lines as $line) { $line = trim($line); if (!strlen($line) || in_array($line, $skip)) { continue; }
<?php //require_once($_SERVER["DOCUMENT_ROOT"] . "/resources/lib/simplehtmldom/simple_html_dom.php"); require_once $_SERVER["DOCUMENT_ROOT"] . "/resources/mysql/connect.php"; $docID = $_GET["d"]; $baseURL = urldecode($_GET["b"]); $originalSubject = urldecode($_GET["s"]); if (!isset($docID) || !isset($baseURL) || !isset($_GET["s"])) { die; } echo "doc ID: " . $docID . " base URL: " . $baseURL . " "; parseFile($_SERVER["DOCUMENT_ROOT"] . "/documents/" . $docID . ".html", $baseURL, $docID); deleteFile($docID); function parseFile($path, $baseUrl, $docID) { echo " parse file "; $content = file_get_contents($path, true); $title = getTitle($content); deleteFacts($title); $GLOBALS["paragraphs"] = array(); $contentParse = $content; while ($contentParse != null) { $contentParse = parseText($contentParse); } echo "got paragraphs, "; $paragraphs = $GLOBALS["paragraphs"]; $factsExist = count($paragraphs) > 0; logSubject($title, $factsExist); foreach ($paragraphs as $text) { logFact($text, $title, $docID); }
$schemaRoot = __DIR__ . "/../resources/schema"; $publishRoot = __DIR__ . "/../resources/api/schema"; $directoryIterator = new RecursiveDirectoryIterator($schemaRoot); $iterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { /** * @var $file SplFileInfo */ if ($file->getExtension() == 'json') { $schemaPath = $file->getPath(); $publishPath = str_replace($schemaRoot, $publishRoot, $schemaPath); if (!file_exists($publishPath)) { mkdir($publishPath, 0777, true); echo "Creating {$publishPath}\n"; } $parsedContent = parseFile($file); file_put_contents($publishPath . '/' . $file->getFilename(), $parsedContent); } } function parseFile($file) { $content = file_get_contents($file); $json = json_decode($content, true); array_walk_recursive($json, 'replaceToken'); return json_encode($json, JSON_UNESCAPED_SLASHES); } function replaceToken(&$item) { if (preg_match('/oe:(\\w+\\.)+\\w+/', $item)) { $item = str_replace('.', '/', $item); $item = str_replace('oe:', BASE_URL . '/', $item) . '.json#';
$result = str_ireplace('%require%', 'require_once(\'' . $className . '.require.php\');' . PHP_EOL, $dummy); } else { echo "It's a required class\n"; $result = str_ireplace('%require%', '', $dummy); $require[] = $className; } echo 'Write class file for ' . $className . "\n"; $newPath = 'Google/Api/Ads/AdWords/' . $version . '/classes/' . $className . '.php'; file_put_contents($newPath, str_ireplace('%code%', $classCode, $result)); //$code = str_ireplace($mecho "Right new class " . $className . "\n";atches[0][$i], "", $code); } } $requireCode = ''; foreach ($require as $className) { echo 'Add require ' . $className . "\n"; $requireCode .= 'require_once(\'' . $className . '.php\');' . PHP_EOL; } echo 'Write required file for ' . $baseClassName . "\n"; file_put_contents('Google/Api/Ads/AdWords/' . $version . '/classes/' . $baseClassName . '.require.php', '<?php' . PHP_EOL . $requireCode); //unlink($path); } $version = 'v201605'; $dummy = file_get_contents('Dummy.php.txt'); $handle = opendir('Google/Api/Ads/AdWords/' . $version . '/'); $files = readdir($handle); while (false !== ($entry = readdir($handle))) { if (strpos($entry, 'Service.php')) { $path = 'Google/Api/Ads/AdWords/' . $version . '/' . $entry; parseFile($version, $path, str_ireplace('.php', '', $entry), $dummy); } }
if (isset($resname_base[$id]) == false) { echo 'missing in base: ' . $id . ' [' . $name . ']<br />'; continue; } if ($resname_base[$id] != $name) { echo 'difference: ' . $id . ' french[' . $name . '] base[' . $resname_base[$id] . ']<br />'; continue; } } die('done'); */ // Assume that french resnames are more complete? $itemnames_fr = parseFile('D:/Games/data/french/idnum2itemresnametable.txt'); $itemnames_base = parseFile('D:/Games/data/idnum2itemresnametable.txt'); // English and french card resnames are equal $cardnames = parseFile('D:/Games/data/english/num2cardillustnametable.txt'); echo 'names done, copy files<br />'; // Names cached, rename files $baseItem = 'D:/Games/data/texture/유저인터페이스/item/'; $baseCollection = 'D:/Games/data/texture/유저인터페이스/collection/'; $baseCard = 'D:/Games/data/texture/유저인터페이스/cardbmp/'; $targetItem = 'D:/Xampp/htdocs/roprice/templates/images/ragnarok/item/'; $targetCollection = 'D:/Xampp/htdocs/roprice/templates/images/ragnarok/collection/'; $targetCard = 'D:/Xampp/htdocs/roprice/templates/images/ragnarok/card/'; foreach ($cardnames as $itemID => $filename) { copyFile($itemID, $filename, $baseCard, $targetCard); } echo 'cards done, copy base files<br />'; foreach ($itemnames_fr as $itemID => $filename) { $result = copyFile($itemID, $filename, $baseItem, $targetItem); // File not found, try base name
$path = getcwd() . "/" . $path; //echo "Path is: ".getcwd().$path."\n"; $pos = strpos($path, '.'); if ($pos !== false) { parseFile($path); } else { $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($objects as $name => $object) { //echo $object->getFilename()."<br>"; $ext = ""; $ar3 = explode('.', $object->getFilename()); if (Count($ar3) > 1) { $ext = $ar3[1]; } if (in_array($ext, $extensions)) { parseFile($object->getPathname()); } } } } usort($index, 'cmpStr'); fwrite($fh, "<div class='index'><ul>"); foreach ($index as $item) { fwrite($fh, "<li><a href='#el_" . $item[1] . "'>" . $item[0] . "</a></li>"); } fwrite($fh, "</ul></div>"); fwrite($fh, "</body></html>"); // close File fclose($fh); } // sort index
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path()))); require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); Zend_Registry::set('bootstrap', $application->getBootstrap()); $application->getBootstrap()->bootstrap('OSSAutoLoader'); $application->getBootstrap()->bootstrap('doctrine2'); $em = $application->getBootstrap()->getResource('doctrine2'); $config = $application->getOption('resources'); //Checking if file path is given if (!isset($argv[1])) { echo "ERROR: Missing file path.\n"; exit(1); } //Parsing file $switches = parseFile($argv[1]); if (!$switches) { echo "No switches found\n"; exit(1); } $vlan = loadVlan(PEERING_LAN_NAME, $em); if (!$vlan) { echo "ERROR: VLAN '" . PEERING_LAN_NAME . "' could not be loaded - please create it.\n"; exit(1); } //$name is equal to $port['switch'] $cnt = 0; foreach ($switches as $name => $switch) { $sw = loadSwitch($name, $em); if (!$sw) { echo "ERROR: switch {$name} was not found. Skipping ports related to this switch.\n";
$key = str_replace(" ", "+", $records[$i][$columnNamesToGet[0]]); $value = preg_replace('/^' . chr(163) . '?\\s?(.*?)/i', '$1', $records[$i][$columnNamesToGet[1]]); $results[$key] = $value; } return $results; } return false; } set_time_limit(60); //path to upload to //$path = dirname($PATH_TRANSLATED) . "/upload/"; //filename $filenameOnTemp = $HTTP_POST_FILES['file']['tmp_name']; // column names to get. The first element will be the key in the array $columnNamesToGet = array('Search Term', 'Total Cost'); $resource = parseFile($filenameOnTemp, $columnNamesToGet); // write to the camnpaign_resources db if ($resource != false) { //check whether record exists $result = phpAds_dbQuery("SELECT resourceid FROM " . $phpAds_config['tbl_campaign_resources'] . " WHERE campaignid=" . $campaignid); if (phpAds_dbNumRows($result) > 0) { phpAds_dbQuery("UPDATE " . $phpAds_config['tbl_campaign_resources'] . "\n\t\t\t\t\t\t\t\t\tSET resource = '" . serialize($resource) . "' \n\t\t\t\t\t\t\t\t\tWHERE campaignid = " . $campaignid . "\n\t\t\t\t\t\t\t\t\tLIMIT 1") or die; } else { phpAds_dbQuery("INSERT " . ($phpAds_config['insert_delayed'] ? 'DELAYED' : '') . " \n\t\t\t\t\t\t\t\t\tINTO " . $phpAds_config['tbl_campaign_resources'] . "\n\t\t\t\t\t\t\t\t\t\t(campaignid,\n\t\t\t\t\t\t\t\t\t\t resource)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t(" . $campaignid . ",\n\t\t\t\t\t\t\t\t\t\t'" . serialize($resource) . "')") or die; } } } // build stats array // get banner ids for this campaign $res_banners = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tbannerid,\n\t\t\t\tdescription,\n\t\t\t\tactive\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tWHERE\n\t\t\t\tcampaignid = " . $campaignid); // check whether external data for this campaign exists
echo "It's a base class\n"; $result = str_ireplace("%require%", "require_once('" . $className . ".require.php');" . PHP_EOL, $dummy); } else { echo "It's a required class\n"; $result = str_ireplace("%require%", "", $dummy); $require[] = $className; } echo "Write class file for " . $className . "\n"; $newPath = "Google/Api/Ads/AdWords/v201406/classes/" . $className . ".php"; file_put_contents($newPath, str_ireplace("%code%", $classCode, $result)); //$code = str_ireplace($mecho "Right new class " . $className . "\n";atches[0][$i], "", $code); } } $requireCode = ""; foreach ($require as $className) { echo "Add require " . $className . "\n"; $requireCode .= "require_once('" . $className . ".php');" . PHP_EOL; } echo "Write required file for " . $baseClassName . "\n"; file_put_contents("Google/Api/Ads/AdWords/v201406/classes/" . $baseClassName . ".require.php", "<?php" . PHP_EOL . $requireCode); //unlink($path); } $dummy = file_get_contents("Dummy.php.txt"); $handle = opendir('Google/Api/Ads/AdWords/v201406/'); $files = readdir($handle); while (false !== ($entry = readdir($handle))) { if (strpos($entry, "Service.php")) { $path = "Google/Api/Ads/AdWords/v201406/" . $entry; parseFile($path, str_ireplace(".php", "", $entry), $dummy); } }
/** CMT 글쓰기 폼 파싱 * @class view * @param $data: DB 데이터 $mode: return 모드 * @return */ function parseCmtWrite(&$data, $mode = '', $ret = 0) { global $mini; iss($data['tag']); // 원하지 않는 출력정보 지우기 unset($data['history_vote']); unset($data['history_hit']); unset($data['title']); $target_post = !empty($data['target_post']) ? $data['target_post'] : 0; if ($mode != 'insert') { unset($data['target_post']); unset($data['pass']); unset($data['reply']); unset($data['parent']); } // 대상 댓글 입력 /* if ($mode == 'insert') { $data['reply'] = end(getStr($data['parent'])); unset($data['parent']); } */ // decode foreach ($data as $key => $val) { str($data[$key], 'decode'); if ($mode != 'insert') { $data[$key] = str_replace(array("\r\n", "\n"), array("\n", "<!--nl2br-->"), $data[$key]); } } // 필터링 해제 filter($data['ment'], 'decode'); $data['ment'] = str_replace("<br /><!--n-->", "\n", $data['ment']); // tag if ($data['tag']) { $data['tag'] = implode(", ", getStr($data['tag'])); } // 파일(댓글 수정일때) $data['is_file'] = 0; unset($file); $file = sql("\n\t\t\tq: SELECT * FROM {$mini['name']['file']} WHERE mode='comment' and target_post={$target_post} and ((target=0 and (ip='{$mini['ip']}' or target_member=" . (!empty($mini['member']['no']) ? $mini['member']['no'] : "0") . ")) or target={$data['no']})\n\t\t\tmode: array\n\t\t"); if (!empty($file)) { $data['is_file'] = 1; $data['file_data'] = array(); // 파일 링크 만들기 foreach ($file as $key => $val) { $tmp_no = $key + 1; $data["url_file{$tmp_no}"] = "{$mini['dir']}download.php?mode=view&no={$val['no']}"; $data["link_file{$tmp_no}"] = "href='{$mini['dir']}download.php?no={$val['no']}'"; $data['file_data'][$tmp_no] = parseFile($val, 1); } unset($file); } // 링크 if (!empty($data['link'])) { $data['link'] = unserialize($data['link']); str($data['link'], 'decode'); } // 추가필드 if (!empty($data['field'])) { $data['field'] = unserialize($data['field']); str($data['field'], 'decode'); } if ($ret) { return $data; } }
function parseTypeMap($file, &$table) { global $debug; if ($debug >= 1) { echo "*** DEBUG *** Entering parseTypeMap().\n"; echo "*** DEBUG *** Parsing file \"{$file}\".\n"; } parseFile('callbackTypeMap', $file, $table); // Make sure we have this entry. $table['void'] = 'GLvoid'; if ($debug >= 2) { var_dump($table); } if ($debug >= 1) { echo "*** DEBUG *** Leaving parseTypeMap().\n"; } }
require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); Zend_Registry::set('bootstrap', $application->getBootstrap()); $application->getBootstrap()->bootstrap('OSSAutoLoader'); $application->getBootstrap()->bootstrap('doctrine2'); $em = $application->getBootstrap()->getResource('doctrine2'); $config = $application->getOption('resources'); $countries = OSS_Countries::getCountriesArray(); //Checking if file path is given if (!isset($argv[1])) { echo "ERROR: Usage: member-sync.php <data.csv>\n"; exit(1); } //Parsing file $origin_members = parseFile($argv[1]); if (!$origin_members) { echo "No members found\n"; exit(1); } //$key is equal to $member['as_number'] $cnt = 0; foreach ($origin_members as $key => $member) { $cust = createUpdateCustomer($member, $em); createUpdateRegistrationDetails($cust, $member, $em, $countries); createUpdateBilingDetails($cust, $member, $em, $countries); createUpdateContacts($cust, $member, $em); createUpdateNotes($cust, $member, $em); if (++$cnt % 10 == 0) { $em->flush(); }
$list[] = $res; } fclose($handle); //print_r($list); if ($list) { $reserveModel = ReservesModelFactory::getInstance(ReservesModelFactory::TYPE_TSERVICE_ORDER); $empData = $reserveModel->getEmpByReserveIds($ids); print_r($empData); /* foreach ($list as $data) { if (!isset($empData[$data['id']])) { continue; } $data['employer']['login'] = $empData[$data['id']]['login']; $data['employer']['uid'] = $empData[$data['id']]['uid']; try { $doc = new DocGenReserves($data); $doc->generateFactura(); } catch (Exception $e) { require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/log.php'); $log = new log('reserves_docs/' . SERVER . '-%d%m%Y.log'); $log->trace(sprintf("Order Id = %s: %s", $data['id'], $e->getMessage())); } } */ } } parseFile('f_77054c9e522f0cac.csv'); exit;
* We have a valid line. */ buildHosts($targets, $elements, $ver); } /* while(!feof($fin)) */ fclose($fin); } } if (!($fout = fopen($output, "w"))) { die("Failed to open {$output} for writing.\n"); } else { foreach ($v1_targetfiles as $input) { parseFile($targets, $input, 1); } foreach ($v2_targetfiles as $input) { parseFile($targets, $input, 2); } foreach ($targets as $rname => $host_array) { fwrite($fout, "host {$rname} {\n"); fwrite($fout, "\tcommunity " . $host_array['community'] . ";\n"); fwrite($fout, "\tsnmpver " . $host_array['snmpver'] . ";\n"); foreach ($host_array['targets'] as $oid => $oid_array) { fwrite($fout, "\ttarget {$oid} {\n"); foreach ($oid_array as $key => $val) { if (!strcmp($key, "descr")) { fwrite($fout, "\t\t{$key} \"{$val}\";\n"); } else { fwrite($fout, "\t\t{$key} {$val};\n"); } } fwrite($fout, "\t};\n");
</tr> <tr> <td> <table border="0" cellpadding="3" cellspacing="0" bordercolor="#333333" align="center"> <tr bgcolor="#E1E1E1"> <td align="center" nowrap> </td> <td align="center" nowrap> </td> <td align="center" nowrap><div align="left"><strong><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif"> TCP/IP </font></strong></div></td> </tr> <? $cor = 0; $num_registro = 1; $cont_ativado = 0; $cont_desativado = 0; $result = parseFile(); foreach ($result as $arr) { ?> <tr <? if ($cor) { echo 'bgcolor="#E1E1E1"'; } ?>> <td nowrap><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><? echo $num_registro; ?> </font></div></td> <td> <? $arr['port'] = strtolower(trim($arr['port'])); if ($arr['port'] == 'closed') { $checkbox = '<img src="/cacic2/imgs/unchecked.gif">'; $alerta = '<img src="/cacic2/imgs/alerta_vermelho.gif">'; $cont_desativado++; } else if ($arr['port'] == 'open') { $checkbox = '<img src="/cacic2/imgs/checked.gif">'; $alerta = '<img src="/cacic2/imgs/alerta_verde.gif">'; $cont_ativado++;
function downloadFile() { global $HTTP_POST_FILES; $charset = isset($_REQUEST["iso8859"]) && $_REQUEST["iso8859"] != "off" ? "ISO-8859-1" : "UTF-8"; $str = parseFile(true); if ($str != "") { $fn = isset($HTTP_POST_FILES['file']) && $HTTP_POST_FILES['file']['name'] != '' ? $HTTP_POST_FILES['file']['name'] : "phpStylist.php"; header("Expires: Wed, 20 Jun 2007 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-Type: text/plain; charset=" . $charset); header('Content-Disposition: attachment; filename="' . $fn . '";'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Transfer-Encoding: binary"); } echo $str; exit; }
$localId = intval($localId); $replacement = bcadd($base, $localId); $newQuery = $startSplit . $replacement . ";\n"; fwrite($fileWriteHandle, $newQuery); } } } else { continue; } } } } fclose($fileHandle); fclose($fileWriteHandle); } parseFile(); updateDatabase(); /* $returnStatus = true; $lab_config_id = $_REQUEST['lid']; $backup_folder = $_REQUEST['backup_path']; # Perform backup of current version before reverting? $do_currbackup = false; if($_REQUEST['do_currbackup'] == 'Y') $do_currbackup = true; if($do_currbackup === true) { if(!BackupLib::performBackup($lab_config_id, getcwd() ) === true) { # Backup of current version failed.
$outputStream = fopen($outputFilename, 'w'); if (!$outputStream) { _error('Error creating local file'); } } while (!feof($inputStream)) { $bytesWritten = 0; $data = fread($inputStream, 1024); if (!$config['fake']) { $bytesWritten = fwrite($outputStream, $data); } else { $bytesWritten = strlen($data); } if (false === $bytesWritten) { _error('Error writing data to file'); } $realSize += $bytesWritten; } $result = parseFile($outputFilename, $inputFileType); //$result = make($sql); if (!$config['fake']) { fclose($outputStream); } } else { _error('Error reading input'); } if ($realSize != $size) { _error('The actual size differs from the declared size in the headers'); } _log(sprintf("[raw] Uploaded %s, %s, %d byte(s)", $fileName, $mimeType, $realSize)); _response(true, 'OK', $result);
function processBatch() { global $argv; if (is_array($argv)) { $options = $argv; } elseif (is_array($_SERVER['argv'])) { $options = $_SERVER['argv']; } elseif (is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) { $options = $GLOBALS['HTTP_SERVER_VARS']['argv']; } //get default config settings $config = json_decode(file_get_contents(__DIR__ . '/working_temp.json')); /*foreach($config as $key=>$value){ $_REQUEST[$key] = $value; }*/ //supress notices (because I'm lazy) error_reporting(E_ERROR | E_WARNING | E_PARSE); foreach ($options as $index => $option) { if ($option == "--help") { echo "phpStylist v0.8 by Mr. Milk\n"; echo "usage: phpStylist source_file options\n\n"; echo "Indentation and General Formatting:\n"; echo "--indent_size n\n"; echo "--indent_with_tabs\n"; echo "--keep_redundant_lines\n"; echo "--space_inside_parentheses\n"; echo "--space_outside_parentheses\n"; echo "--space_after_comma\n\n"; echo "Operators:\n"; echo "--space_around_assignment\n"; echo "--align_var_assignment\n"; echo "--space_around_comparison\n"; echo "--space_around_arithmetic\n"; echo "--space_around_logical\n"; echo "--space_around_colon_question\n\n"; echo "Functions, Classes and Objects:\n"; echo "--line_before_function\n"; echo "--line_before_curly_function\n"; echo "--line_after_curly_function\n"; echo "--space_around_obj_operator\n"; echo "--space_around_double_colon\n\n"; echo "Control Structures:\n"; echo "--space_after_if\n"; echo "--else_along_curly\n"; echo "--line_before_curly\n"; echo "--add_missing_braces\n"; echo "--line_after_break\n"; echo "--space_inside_for\n"; echo "--indent_case\n\n"; echo "Arrays and Concatenation:\n"; echo "--line_before_array\n"; echo "--vertical_array\n"; echo "--align_array_assignment\n"; echo "--space_around_double_arrow\n"; echo "--vertical_concat\n"; echo "--space_around_concat\n\n"; echo "Comments:\n"; echo "--line_before_comment_multi\n"; echo "--line_after_comment_multi\n"; echo "--line_before_comment\n"; echo "--line_after_comment\n"; exit; } if ($index == 1) { $config->file = $option; } elseif ($index == 2) { $config->outFile = $option; } elseif ($option == "--indent_size") { $config->indent_size = $options[$index + 1]; } elseif ($index > 0 && $options[$index - 1] != "indent_size") { $config->{substr($option, 2)} = true; } } $config->download = 2; $str = parseFile(true, $config); if (isset($config->outFile)) { file_put_contents($config->outFile, $str); } else { echo $str; } exit; }
<?php include 'include/functions.php'; $blade_names = array(); $blade_values = array(); $case_names = array(); $rubber_names = array(); $rubber_values = array(); $case_values = array(); parseFile("data/blades/wood_blades.txt", $blade_names, $blade_values); parseFile("data/blades/composite_blades.txt", $blade_names, $blade_values); parseFile("data/rubbers/inverted.txt", $rubber_names, $rubber_values); parseFile("data/rubbers/pips_out.txt", $rubber_names, $rubber_values); parseFile("data/cases/cases.txt", $case_names, $case_values); ?> <html> <head> <link href="css/bootstrap.css" rel="stylesheet" media="screen"> <script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.js"></script> </head> <body> <?php $blade = $_GET['blade']; $blade_handle = $_GET['blade_handle']; $blade_price = $blade_values[$blade]; $black_rubber = $_GET['black_rubber']; $black_rubber_thickness = $_GET['black_rubber_thickness']; $black_rubber_price = $rubber_values[$black_rubber]; $red_rubber = $_GET['red_rubber']; $red_rubber_thickness = $_GET['red_rubber_thickness'];
/** * Parse file * * @param SplFileInfo $file File handler * @return bool */ function parseFile($file, $funcOverload = "") { global $existingFunctions, $constants, $constants_comments, $variables, $classes, $isInterface, $versions; if (substr($file->getFilename(), -4) != '.xml') { return false; } if (substr($file->getFilename(), 0, 9) == 'entities.') { return false; } $string = file_get_contents($file->getPathname()); $isInterface = strpos($string, '<phpdoc:classref') !== false && strpos($string, '&reftitle.interfacesynopsis;') !== false; $string = preg_replace('#(?:(&|>|<)|&[A-Za-z\\.0-9-_]+;)#', '$1', $string); $removeSections = array(); $removeSections[] = 'apd.installwin32'; $removeSections[] = 'intl.intldateformatter-constants.calendartypes'; foreach ($removeSections as $i) { $string = preg_replace('#' . preg_quote('<section xml:id="' . $i . '">') . '.*?</section>#s', '', $string); } echo "reading documentation from {$file->getPathname()}\n"; $xml = simplexml_load_string($string, "SimpleXMLElement", LIBXML_NOCDATA); if ($file->getFilename() == 'versions.xml') { foreach ($xml->xpath('/versions/function') as $f) { $attrs = $f->attributes(); $versions[strtolower($attrs['name'])] = (string) $attrs['from']; } return; } $xml->registerXPathNamespace('db', 'http://docbook.org/ns/docbook'); $xml->registerXPathNamespace('phpdoc', 'http://php.net/ns/phpdoc'); if ($vars = $xml->xpath('//phpdoc:varentry//db:refnamediv')) { foreach ($vars as $var) { foreach ($var->refname as $i) { $i = (string) $i; if (isset($variables[$i])) { $v = $variables[$i]; } else { $v = array(); } if (substr($i, 0, 1) != '$') { continue; } if (substr($i, -13) == ' [deprecated]') { $i = substr($i, 0, -13); $v['deprecated'] = true; } else { $v['deprecated'] = false; } $v['desc'] = (string) $var->refpurpose; $variables[$i] = $v; } } } if ($vars = $xml->xpath("//phpdoc:varentry[@xml:id='language.variables.superglobals']//db:member/db:varname")) { foreach ($vars as $var) { $variables[(string) $var]['superglobal'] = true; } } if (isset($xml->variablelist)) { foreach ($xml->variablelist->varlistentry as $i => $varlistentry) { if ($c = (string) $varlistentry->term->constant) { if (!isset($constants[$c])) { if (strpos($c, '=')) { $c = substr($c, 0, strpos($c, '=')); } $ctype = $varlistentry->term->type; if (!$ctype) { $ctype = $varlistentry->term->link; } $constants[$c] = (string) $ctype; } } } } // handle constants.xml with different layout as those above if (!isset($xml->variablelist) && $file->getFilename() == 'constants.xml' && $xml->xpath("//db:constant")) { $consts = $xml->xpath("//db:entry"); foreach ($consts as $i => $p) { if (isset($p->constant)) { if (!isset($p->type)) { // default to integer constants $p->type = 'integer'; } else { // check for comment // next entry is the value of the constant which is followed by the comment if (isset($consts[$i + 2]) && !$consts[$i + 2]->children()) { $comment = $consts[$i + 2]->asXml(); if (!empty($comment)) { $constants_comments[(string) $p->constant] = $comment; } } } $constants[(string) $p->constant] = (string) $p->type; } } } else { if (!isset($xml->variablelist) && $file->getFilename() == 'commandline.xml') { // yay for non-unified xml structures :-X $consts = $xml->xpath("//db:row"); foreach ($consts as $i => $p) { $constant = ""; // default to integer constants $type = "integer"; if (isset($p->entry[0]) && isset($p->entry[0]->constant)) { $constant = trim((string) $p->entry[0]->constant); if (isset($p->entry[0]->constant->type)) { $type = (string) $p->entry[0]->constant->type; } } if (empty($constant)) { continue; } // check for comment // next entry is the comment if (isset($p->entry[1])) { $comment = $p->entry[1]->para->asXml(); if (!empty($comment)) { $constants_comments[$constant] = $comment; } } $constants[$constant] = $type; } } } if ($list = $xml->xpath('//db:sect2[starts-with(@xml:id, "reserved.classes")]/db:variablelist/db:varlistentry')) { foreach ($list as $l) { $classname = newClassEntry((string) $l->term->classname); $classes[$classname]['desc'] = removeTag($l->listitem->asXML(), 'listitem'); } } $cEls = $xml->xpath('//db:classsynopsis/db:classsynopsisinfo'); if ($cEls) { foreach ($cEls as $class) { $class->registerXPathNamespace('db', 'http://docbook.org/ns/docbook'); $className = (string) $class->ooclass->classname; if (!$className) { continue; } $className = newClassEntry($className); if ($extends = $class->xpath('//db:ooclass')) { foreach ($extends as $c) { if ($c->modifier == 'extends') { $classes[$className]['extends'] = (string) $c->classname; } } } if ($interfaces = $class->xpath('//db:oointerface/db:interfacename')) { foreach ($interfaces as $if) { $classes[$className]['implements'][] = (string) $if; } } if ($paras = $xml->xpath('//db:section[starts-with(@xml:id, "' . $className . '")]/db:para')) { foreach ($paras as $p) { $classes[$className]['desc'] .= "\n" . (string) $p; } } } } if (!isset($xml->refsect1)) { return false; } $desc = getDocumentation($xml); $addedSomething = false; // file could contain function + property if (isset($xml->refsect1->classsynopsis) && isset($xml->refsect1->classsynopsis->fieldsynopsis)) { $class = (string) $xml->refsect1->classsynopsis->ooclass->classname; foreach ($xml->refsect1->classsynopsis->fieldsynopsis as $synopsis) { newPropertyEntry($class, $synopsis->varname, $desc, $synopsis->type); $addedSomething = true; } } if (isset($xml->refsect1->methodsynopsis)) { foreach ($xml->refsect1->methodsynopsis as $synopsis) { newMethodEntry('global', $synopsis->methodname, $funcOverload, $synopsis, $desc, $xml); $addedSomething = true; } } if (isset($xml->refsect1->classsynopsis) && isset($xml->refsect1->classsynopsis->methodsynopsis)) { $methodsynopsis = $xml->refsect1->classsynopsis->methodsynopsis; newMethodEntry($xml->refsect1->classsynopsis->ooclass->classname, $methodsynopsis->methodname, $funcOverload, $methodsynopsis, $desc, $xml); $addedSomething = true; } if (!$addedSomething && isset($xml->refnamediv->refpurpose->function)) { // This is function alias $functionName = (string) $xml->refnamediv->refname; $aliasName = (string) $xml->refnamediv->refpurpose->function; $baseFileName = dirname($file->getPathname()) . '/' . str_replace('_', '-', $aliasName) . '.xml'; if ($baseFileName == $file->getPathname() || !file_exists($baseFileName)) { return false; } parseFile(new SplFileInfo($baseFileName), $functionName); $addedSomething = true; } return $addedSomething; }
} if (array_key_exists($key, $hostDict) && !in_array($value, $hostDict[$key])) { array_push($hostDict[$key], $value); } } $index++; } } #========= Main Logic ======================= # download admon result pages foreach ($admon_url_list as $name => $url) { downloadPage("./temp/{$name}", $url); } # read values in html file parseFile("./temp/click", "click"); parseFile("./temp/anti", "antifrauder"); parseResinImprFile("./temp/resin-impr"); $trArray = array(); $selectArray = array(); foreach ($hostDict as $name => $hosts) { foreach ($hosts as $host) { if ($name == "click") { $script_file = "./click.sh"; } else { if ($name == "antifrauder") { $script_file = "./antifrauder.sh"; } else { if ($name == "AD_EXCHANGE.bid") { $script_file = "./dsp.sh"; } else { if ($name == "eadc_left") {
/* * This script parses a .csv file into an SQL file. * */ function parseFile($filePath) { //this will keep parsed records $records = array(); //parse file $row = 0; if (($handle = fopen($filePath, "r")) !== FALSE) { //echo '<tr>'; while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) { $num = count($data); //echo "\n$num fields in line $row: \n"; for ($c = 0; $c < $num; $c++) { //echo $data[$c] . "\t"; } $record = array('id' => $data[0], 'email' => $data[1], 'password' => $data[2], 'name' => $data[3]); #if ($row > 1) { //just skip the column name $records[] = $record; #} $row++; } fclose($handle); //echo '</tr>'; } return $records; } $records = parseFile('users.csv'); print_r($records);