function exportBibutils($result, $program) { global $contentTypeCharset; // these variables are defined in 'ini.inc.php' global $convertExportDataToUTF8; // Get the absolute path for the bibutils package: // (function 'getExternalUtilityPath()' is defined in 'include.inc.php') $bibutilsPath = getExternalUtilityPath("bibutils"); // Generate and serve a MODS XML file of ALL records: // (function 'modsCollection()' is defined in 'modsxml.inc.php') $recordCollection = modsCollection($result); // Write the MODS XML data to a temporary file: $tempFile = writeToTempFile($recordCollection); // Set input and output encoding: if ($convertExportDataToUTF8 == "no" and $contentTypeCharset != "UTF-8") { $inputEncodingArg = " -i iso8859_1"; $outputEncodingArg = " -o iso8859_1"; } else { $inputEncodingArg = " -i utf8"; $outputEncodingArg = " -o utf8"; } // Pass this temp file to the bibutils utility for conversion: $outputFile = convertBibutils($bibutilsPath, $tempFile, $program, $inputEncodingArg, $outputEncodingArg); unlink($tempFile); // Read the resulting output file and return the converted data: $resultString = readFromFile($outputFile); unlink($outputFile); return $resultString; }
function deleteConfig($configFile) { unlink("/grip-config/" . $configFile); $running = readFromFile("running"); $startup = readFromFile("startup"); if ($configFile == $running) { writeToFile("running", ""); } if ($configFile == $startup) { writeToFile("startup", ""); } }
function combos($data, $colRules, $noOfRows, $noOfCols, $startTime, $gridName, &$counter = 0, $group = array(), $val = null, $i = 0) { if (isset($val)) { array_push($group, $val); } if ($i >= count($data)) { // $group = Indexes for all rows $row = array(); for ($j = 0; $j < $noOfRows; $j++) { array_push($row, readFromFile($gridName, $j, $group[$j])); } $counter++; if ($counter >= 1000000) { if ($counter % 1000000 == 0) { echo $counter . " (" . (microtime_float() - $startTime) . ")" . PHP_EOL; } } // // if($counter > 5000) { // if(($counter % 5000) == 0) { // sleep(2); // echo "Sleeping for 2 seconds ... snore".PHP_EOL; // } // } //var_dump($row); //var_dump($group); if (checkSuccess($row, $colRules, $noOfRows, $noOfCols)) { echo "<div style=\"float:right\">Solution Found<br />"; $endTime = microtime_float(); echo "END:" . $endTime . "<br />"; echo "START:" . $startTime . "<br />"; echo " - Time taked " . ($endTime - $startTime) . "</div>"; exit; } } else { foreach ($data[$i] as $v) { combos($data, $colRules, $noOfRows, $noOfCols, $startTime, $gridName, $counter, $group, $v, $i + 1); } } }
require_once 'smartydef.php'; $handle = opendir(REPORTDIR); $smarty->assign('groups', $organs); $smarty->assign('this', 'edit.php'); if (isset($_GET['organ']) && checkOrgan($_GET['organ'])) { $smarty->assign("read", checkReadPerms($_GET['organ'])); $smarty->assign("write", checkWritePerms($_GET['organ'])); $smarty->assign("admin", checkAdminPerms($_GET['organ'])); } //post /get? if (!isset($_POST['text']) && isset($_GET['file']) && isset($_GET['organ'])) { // read file if (checkOrgan($_GET['organ'])) { if (checkFilename($_GET['file']) && checkReadPerms($_GET['organ'])) { //input validation: get organ $text = readFromFile($_GET['organ'], $_GET['file']); $smarty->assign('text', $text); $smarty->assign('organ', $_GET['organ']); $smarty->assign('file', $_GET['file']); } else { if ($_GET['file'] == 'template' && checkReadPerms($_GET['organ'])) { $smarty->assign('text', readTemplate($_GET['organ'])); $smarty->assign('organ', $_GET['organ']); $smarty->assign('file', $_GET['file']); } else { if ($_GET['file'] == 'email' && checkReadPerms($_GET['organ'])) { $smarty->assign('text', readEmailTemplate($_GET['organ'])); $smarty->assign('organ', $_GET['organ']); $smarty->assign('file', $_GET['file']); } else { if ($_GET['file'] == 'resolutions.txt' && checkReadPerms($_GET['organ'])) {
} //Now the appropriate functions will be called. //Create a Table. if ($cTable && $conn != "" && !$dryrun) { //If we have a connection, and we need to create a table... createTable($conn); //Create the table. } else { if ($cTable && $conn == "" && $dryrun) { //If we're on a dry run we cannot make a table. fwrite(STDOUT, "\n[ERROR]: Cannot alter the Database on a dry run (--dry_run)"); } } //Read in and insert into DB. if ($fileName != "" && !$cTable && $conn != "" && !$dryrun) { readFromFile($conn, $fileName, $dryrun); } //Read in and display details. if ($dryrun && !$cTable && $conn == "") { if ($fileName != "") { readFromFile($conn, $fileName, $dryrun); } else { fwrite(STDOUT, "\n[ERROR]: Dry run(--dry_run) is TRUE but no file name(--file) given."); } } //Close the connection if we have one. if ($conn != "") { $conn->close(); } //Linux and Windows differ (Windows automatically puts a \n whereas Linux does not). fwrite(STDOUT, "\n");
} $timesArray = explode("\n", $file); $times = ""; for ($i = 0; $i < count($timesArray); $i++) { $times .= $timesArray[$i] . ","; } echo "@Read times from backup,"; echo $times; } catch (Exception $e) { echo $e->getMessage(); } } try { $flight = "devote_" . $_POST["flight"]; $data = ""; $con = connect($flight); $query = "SELECT * FROM seconds WHERE 1"; $statement = $con->prepare($query); $statement->execute(); while ($result = $statement->fetchObject()) { $data .= $result->mid_utc . ","; } if ($data == "") { throw new Exception($_POST["flight"]); } echo $data; } catch (PDOException $e) { echo "!" . $e->getMessage(); } catch (Exception $e) { echo readFromFile($e->getMessage()); }
${'bing' . $i} = array(); readFromFile(${'bing' . $i}, $bingDirectory, $fileName); //getMetrics getMetrics($mainMetrics, $goldStandardArr, "bing", $query, $queryNumber, ${'bing' . $i}); ${'blekko' . $i} = array(); readFromFile(${'blekko' . $i}, $blekkoDirectory, $fileName); //getMetrics getMetrics($mainMetrics, $goldStandardArr, "blekko", $query, $queryNumber, ${'blekko' . $i}); ${'google' . $i} = array(); readFromFile(${'google' . $i}, $googleDirectory, $fileName); //getMetrics getMetrics($mainMetrics, $goldStandardArr, "google", $query, $queryNumber, ${'google' . $i}); ${'aggregated' . $i} = array(); readFromFile(${'aggregated' . $i}, $aggregatedDirectory, $fileName); //getMetrics getMetrics($mainMetrics, $goldStandardArr, "aggregated", $query, $queryNumber, ${'aggregated' . $i}); ${'weighted' . $i} = array(); readFromFile(${'weighted' . $i}, $weightedDirectory, $fileName); //getMetrics getMetrics($mainMetrics, $goldStandardArr, "weighted", $query, $queryNumber, ${'weighted' . $i}); } //Call Function to calculate the Mean Average Precision getMaps($mapScores, $mainMetrics); //DISPLAY THE RESULTS displayMetrics($mainMetrics, $mapScores); //function in metrics.php //WRITE THE METRICS SCORES TO FILES writeToFile($mainMetrics, "metrics/evaluationScores", "mainMetrics"); writeToFile($mapScores, "metrics/evaluationScores", "mapScores"); //WRITE THE METRICS TO CSV FILE writeToCSV($mainMetrics, $mapScores, "metrics/evaluationScores", "combinedMetrics");
//and display include 'metrics/functions/evaluate.php'; } else { include 'metrics/functions/readFromFile.php'; //enable reading from file //read metrics from file $mainMetrics = array(); //array to populate with main metrics scores $mainMetricsLocation = "metrics/evaluationScores"; $mainMetricsFilename = "mainMetrics.txt"; $mapScores = array(); //array to populate with map scores $mapLocation = "metrics/evaluationScores"; $mapFilename = "mapScores.txt"; readFromFile($mainMetrics, $mainMetricsLocation, $mainMetricsFilename); readFromFile($mapScores, $mapLocation, $mapFilename); //and display displayMetrics($mainMetrics, $mapScores); } } } /** * Function takes in metrics and map scores arrays, and displays contents * * @param array $mainMetrics array to display * @param array $mapScores array to display * * @return void */ function displayMetrics($mainMetrics, $mapScores) {
function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return (double) $usec + (double) $sec; } $result = array(); $combination = array(); $startTime = microtime_float(); $possibleRows = array(); $NO_OF_ROWS = $NO_OF_ROWS; $allRows = array(); for ($i = 0; $i < $NO_OF_ROWS; $i++) { $count = getRowCountFromFile($gridName, $i); $instance = array(); for ($j = 0; $j < $count; $j++) { $value = readFromFile($gridName, $i, $j); array_push($instance, $value); } array_push($allRows, $instance); } newImprovedCombo($allRows, $colRules, $NO_OF_ROWS, $NO_OF_COLS, $startTime); function writeToFile($gridName, $row, $data) { $myFile = "files/" . $gridName . "-" . $row . ".txt"; for ($i = 0; $i < count($data); $i++) { file_put_contents($myFile, $data[$i] . PHP_EOL, FILE_APPEND); } } function readFromFile($gridName, $row, $index) { $myFile = "files/" . $gridName . "-" . $row . ".txt";
$arr = file("chat.txt"); foreach ($arr as $k=>$v){ echo $v."</br>"; } } if (($_SESSION["login"] != "") && ($_SESSION["pass"] != "")){ $f = fopen("chat.txt","a+t"); if(($_POST["msg"] != "") && $_POST["msg"] != " "){ $str = "<span style='color:red;'>".date("j/m/y H:i")." </span><b style='color:blue;'>".$_SESSION["login"].":</b> ".strip_tags((trim($_POST["msg"])))."<br/>"; fwrite($f, $str); fclose($f); } readFromFile(); } else { readFromFile(); echo "<style type='text/css'> #forma{ display:none; } #registr{ display:block; } </style>"; } ?> </div> <form id="forma" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post"> <textarea id="msg" name="msg" placeholder="Введите текст"></textarea>
if ($_FILES) { $fileName = $_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["tmp_name"], "/grip-config/" . $fileName); startGRIP($fileName); //Start GRIP with new config writeToFile("running", $fileName); //Write status to file echo "200"; } if ($_POST) { if ($_POST["list"]) { $files = scandir("/grip-config"); array_splice($files, 0, 2); //Remove the first 2 'files' - . and .. $startup = readFromFile("startup"); $running = readFromFile("running"); $filesMod; $i = 0; foreach ($files as $file) { $filesMod[$i] = array("name" => $file); if ($file == $startup) { $filesMod[$i]["startup"] = true; } if ($file == $running) { $filesMod[$i]["running"] = true; } $i++; } $filesMod = json_encode($filesMod); echo $filesMod; }
<?php require_once 'lib.php'; require_once 'data.php'; error_reporting(E_ERROR | E_NOTICE | E_PARSE | E_WARNING); ini_set('display_errors', 1); $data = file_exists('ads.txt') ? readFromFile('ads.txt') : ''; if (!empty($_POST)) { $id = isset($_POST['id']) ? $_POST['id'] : ''; if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($data[$id])) { $data[$id] = $_POST; } else { $data[] = $_POST; } } elseif (isset($_GET['del'])) { unset($data[$_GET['del']]); } elseif (isset($_GET['edit']) && !isset($_GET['action'])) { $id = $_GET['edit']; $formParam = prepareAd($data[$id]); } if (!isset($formParam)) { $formParam = prepareAd(); } require_once 'form.php'; saveFile('ads.txt', $data);
<?php define('ROOT_PATH', realpath(dirname(__FILE__)) . '/'); require_once 'vendor/autoload.php'; require_once 'src/config.php'; require_once 'src/google.php'; require_once 'src/spreadsheet.php'; require_once 'src/insert.php'; //----------------------------------------------------------------------------- $entries = readFromFile(ROOT_PATH . $iniSettings['bug_file']); if (count($entries) == 0) { echo "No Entries"; exit; } //----------------------------------------------------------------------------- $accessToken = getAccessToken($client); $spreadsheet = getSpreadsheet($accessToken, $iniSettings['sheet_title']); $worksheetFeed = $spreadsheet->getWorksheets(); $worksheet = $worksheetFeed->getByTitle('Reported Typos'); //----------------------------------------------------------------------------- $results = insertLine($worksheet, $entries); echo json_encode($results);
default: $res = "123"; $fname = "default"; } //On gere un cache si ADE plante $fname .= ".ics"; exec($ADE2ICS . " -s " . $FAC . " -l " . $LOGIN . " -p '" . $PWD . "' -n " . $res, $output); /* En cas d'erreur (contenu vide), on renvoie les infos contenues dans le cache. */ $calContent = ""; for ($i = 0; $i < sizeof($output); $i++) { $calContent .= $output[$i]; } //A virer pour livraison, permet de tester le bon fonctionnement du cache #$calContent=""; if (isCompleteVCalendar($calContent)) { createFolder($CACHE_DIR); writeToFile($CACHE_DIR . "/" . $fname, $calContent); } else { //!\\ //Ici, si le cache n'a pas été crée un erreur sera levée. //Ne devrais jamais se produire si le déploiement prévois de créer les fichiers cache. $calContent = readFromFile($CACHE_DIR . "/" . $fname); } //On pose le mime type header('Content-type: text/calendar; charset=utf-8'); echo $calContent; } else { echo "No ressource setted !\n"; }
// put full path to Smarty.class.php require_once 'smartydef.php'; require 'defines.php'; require 'lib.php'; function remove_intern_tags($text) { return preg_replace(INTERN_REGEX, "", $text); } $smarty->assign('this', 'publish.php'); if (isset($_GET['file']) && isset($_GET['organ'])) { if (checkOrgan($_GET['organ']) && checkFilename($_GET['file']) && checkAdminPerms($_GET['organ'])) { $organ = $_GET['organ']; $folder = REPORTDIR . SUBUNPUBLISHED . $organ . '/'; $path = $folder . $_GET['file']; if (is_file($path)) { $text = readFromFile($organ, $_GET['file']); //remove [intern][/intern] $text = remove_intern_tags($text); if (isset($_GET['rly'])) { pandocToHTML($path, REPORTDIR . SUBPUBLISHED . $_GET['organ'] . "/" . $_GET['file'] . ".html"); pandocToPDF($path, REPORTDIR . SUBPUBLISHED . $_GET['organ'] . "/" . $_GET['file'] . ".pdf"); //resolution collection $conclusions = array(); preg_match_all(";\\[beschluss\\](.*?)\\[/beschluss\\];s", $text, $conclusions); foreach ($conclusions[0] as $key => $con) { $str = substr($con, 11, -12); file_put_contents(REPORTDIR . SUBPUBLISHED . $_GET['organ'] . ".resolutions.txt", $_GET['file'] . ": " . $str . "\n", FILE_APPEND); } // remove "[beschluss]" tags str_replace("[beschluss]", "", $text); str_replace("[/beschluss]", "", $text);
// no file was uploaded $errors["uploadFile"] = "You must select a file for upload."; break; case 6: $errors["uploadFile"] = "Missing a temporary folder."; break; default: // a default error, just in case! :) $errors["uploadFile"] = "There was a problem with your upload."; break; } } } if (!empty($uploadFile) && !empty($tmpFilePath)) { // Get file contents: $fileData = readFromFile($tmpFilePath); // function 'readFromFile()' is defined in 'execute.inc.php' if (!empty($fileData)) { // Data from any successfully uploaded file will override data pasted into the 'sourceText' text entry field $sourceText = $fileData; } } // -------------------------------------------------------------------- // PRE-PROCESS DATA INPUT: // In case of a latin1-based database, attempt to convert UTF-8 data to refbase markup & latin1: // NOTE: For a latin1-based database, data pasted into the 'sourceText' text entry field will be always returned in ISO-8859-1 encoding (see notes above function // 'decodeHTML()' below). However, data that were received via a file upload (or from a client such as Bookends) will have the encoding of the original file // (which may be UTF-8 encoded). if ($contentTypeCharset == "ISO-8859-1" and detectCharacterEncoding($sourceText) == "UTF-8") { // function 'detectCharacterEncoding()' is defined in 'include.inc.php' $sourceText = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $sourceText, "UTF-8");