コード例 #1
0
ファイル: client.php プロジェクト: anboto/xtreamer-web-sdk
/**
 * @return String/FALSE on error
 * @desc Writes and uploaded file into a temp file and returns the name of that file for future
 *       use. Returns false if there is an error.
 */
function open_from_client()
{
    global $javascript_msg;
    // Create a temporary file where we will copy the uploaded one to
    $temp_file = 'temp/' . date('YmdHis') . '.wp';
    if ($local_file = @fopen($temp_file, 'w')) {
        // Make sure that the file parsing function exists, or grab code for it
        if (!function_exists('parse_file')) {
            require_once 'common.php';
        }
        // Get the uploaded file, open it, then write it into the temp file
        if ($uploaded = parse_file($_FILES['file']['tmp_name'])) {
            @fwrite($local_file, $uploaded);
            fclose($local_file);
            // Return the name of the temp file for use in opening (from server now)
            return $temp_file;
        } else {
            $javascript_msg = '@Could not read \'' . $temp_file . '\' or it is empty.';
            return false;
        }
    } else {
        $javascript_msg = '@Could not create temporary file. Check the permissions on webpad\'s temporary folder.';
        return false;
    }
}
コード例 #2
0
ファイル: metadata.php プロジェクト: bet0x/smartstrap
function compile_markdown_files_metadata($folder, $output_file)
{
    $data = array();
    foreach (file_list($folder) as $file) {
        $data[$file] = parse_file($file);
        $data[$file]['link'] = generate_link($file);
        unset($data[$file]['content']);
    }
    $data_before = <<<EOT
<?php
/*
===== This file is auto-generated. It contains the compiled metadata from the markdown. =====
*/

function compiled_metadata(\$file = null) {
\$data = 
EOT;
    $data_after = <<<EOT
;
\tif (\$file == null || !isset(\$data[\$file])) {
\t\treturn \$data;
\t} else {
\t\treturn \$data[\$file];
\t}
}
EOT;
    $complete_data = $data_before . var_export($data, true) . $data_after;
    $file_handle = fopen($output_file, "w");
    if ($file_handle == false) {
        die('Could not open compiled file to write.');
    }
    if (!fwrite($file_handle, $complete_data)) {
        die('Could not write to file');
    }
}
コード例 #3
0
function movies_storing($db, $filename = "movies.csv")
{
    if (check_file($filename)) {
        $collection = $db->createCollection("movies");
        $i = parse_file($collection, get_data($filename));
        echo $i . " movies successfully stored !\n";
    }
}
コード例 #4
0
function movies_storing($db, $argv)
{
    if (sizeof($argv) == 3) {
        $filename = $argv[2];
    } else {
        if (sizeof($argv) == 2) {
            $filename = "movies.csv";
        } else {
            echo "Error: Invalid number of arguments.\n";
            echo "Usage: ./etna_movies.php movies_storing [filename.csv].\n";
            return 0;
        }
    }
    if (check_file($filename)) {
        $collection = $db->createCollection("movies");
        $i = parse_file($collection, get_data($filename));
        echo $i . " movies successfully stored !\n";
    }
}
コード例 #5
0
ファイル: http.php プロジェクト: anboto/xtreamer-web-sdk
/**
 * @return String/FALSE on error
 * @param String $url
 * @desc Attempts to request a URL and parse the response into a string, which is opened as a file.
 */
function open_from_http($url)
{
    global $javascript_msg;
    // Make sure this is a valid URL
    if (strpos($url, 'http://') === false) {
        $javascript_msg = '@Invalid URL. Please enter a full web address, starting with http://';
        return false;
    }
    // Make sure that the file parsing function exists, or grab code for it
    if (!function_exists('parse_file')) {
        require_once 'common.php';
    }
    // Now parse the URL and get it as a string
    if ($contents = parse_file($url)) {
        return $contents;
    } else {
        $javascript_msg = '@Could not load \'' . stripslashes($url) . '\'.';
        return false;
    }
}
コード例 #6
0
ファイル: index.php プロジェクト: horrabin/opendb
function display_patch_list($title, $patchdir)
{
    global $ADMIN_TYPE;
    echo "<h3>" . $title . "</h3>";
    $filelist = get_file_list('./admin/patch_facility/sql/' . $patchdir, 'sql');
    $sqllist = NULL;
    if (is_not_empty_array($filelist)) {
        for ($i = 0; $i < count($filelist); $i++) {
            $parsedfile_r = parse_file($filelist[$i]);
            $sqllist[] = array('sqlfile' => $filelist[$i], 'name' => initcap(str_replace('_', ' ', $parsedfile_r['name'])));
        }
        if (is_not_empty_array($sqllist)) {
            echo "<table>";
            echo "<tr class=\"navbar\">" . "<th>Patch</th>" . "<th>SQL File</th>" . "<th></th>" . "<th></th>" . "</tr>";
            for ($i = 0; $i < count($sqllist); $i++) {
                echo "<tr class=\"oddRow\">" . "<td>" . $sqllist[$i]['name'] . "</td>" . "<td>" . $sqllist[$i]['sqlfile'] . "</td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=previewsql&mode=job&title=" . urlencode($sqllist[$i]['sqlfile']) . "&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "&preview=true\" target=\"_new\">Preview</a></td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=installsql&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "\">Install</a></td>" . "</tr>";
            }
            echo "</table>";
        }
    }
}
コード例 #7
0
ファイル: ftp.php プロジェクト: anboto/xtreamer-web-sdk
/**
 * @return String/FALSE on error
 * @param String $server
 * @param String $port
 * @param String $pasv
 * @param String $username
 * @param String $password
 * @param String $file
 * @desc Connects to an FTP server, requests the specified file, writes it to
 *       a temporary location and then loads it into a string.
 */
function open_from_ftp($server, $port = '', $pasv, $username, $password, $file)
{
    global $javascript_msg;
    // Set the port we're using
    $port = isset($port) && $port != '' ? $port : 0;
    // Connect to FTP Server
    if ($ftp = @ftp_connect($server, $port)) {
        // Log in using details provided
        if ($logged_in = @ftp_login($ftp, $username, $password)) {
            // Set PASV mode
            ftp_pasv($ftp, $pasv);
            // Create a temporary file, and get the remote file contents into it.
            $temp_file = 'temp/' . date('YmdHis') . '.wp';
            if ($local_file = @fopen($temp_file, 'wt')) {
                if (@ftp_fget($ftp, $local_file, $file, FTP_ASCII)) {
                    @ftp_quit($ftp);
                    fclose($local_file);
                    // Make sure that the file parsing function exists, or grab code for it
                    if (!function_exists('parse_file')) {
                        require_once 'common.php';
                    }
                    $string = parse_file($temp_file);
                    return $string;
                } else {
                    $javascript_msg = '@Could not get the file from the FTP Server.';
                    return false;
                }
            } else {
                $javascript_msg = '@Could not create temporary file. Check the permissions on webpad\'s temporary folder.';
                return false;
            }
        } else {
            $javascript_msg = '@Authentication failed on FTP Server \'' . $server . '\'.';
            return false;
        }
    } else {
        $javascript_msg = '@Could not connect to FTP Server \'' . $server . '\'.';
        return false;
    }
}
コード例 #8
0
ファイル: server.php プロジェクト: anboto/xtreamer-web-sdk
/**
 * @return String/FALSE on error
 * @param String $file
 * @desc Parses a file and returns it as a string.
 */
function open_from_server($file)
{
    global $javascript_msg, $config;
    // Confirm we should be opening this, or die
    verify_secure_file($file, $config['home_dir']);
    // Make sure that the file parsing function exists, or grab code for it
    if (!function_exists('parse_file')) {
        require_once 'common.php';
    }
    // Get the file and return it if we can
    $contents = parse_file($file);
    // If there's something there (even if it's an empty string)
    if ($contents !== false) {
        $javascript_msg = 'File opened successfully.';
        return $contents;
    } else {
        $javascript_msg = '@Could not open file \'' . stripslashes(basename($file)) . '\'.';
        $_SESSION['filename'] = '';
        $_SESSION['display_filename'] = '';
        return false;
    }
}
コード例 #9
0
ファイル: UPP_Mes_uploads.php プロジェクト: Bagu/Uploadile
        redirect($url, $lang_uploadile['err_delete']);
    }
} elseif (isset($_FILES['fichier']) and $_FILES['fichier'] != NULL and $_FILES['fichier']['error'] == 0) {
    // On vérifie les extansions
    $extension_multiple = explode('.', $_FILES['fichier']['name']);
    if (count($extension_multiple) == '2') {
        $extensions_valides = explode(',', $pun_config['o_uploadile_laws'] . ',' . strtoupper($pun_config['o_uploadile_laws']));
        $extension_upload = substr(strrchr($_FILES['fichier']['name'], '.'), 1);
        if (in_array($extension_upload, $extensions_valides)) {
            // On vérifie la taille maximale
            if ($_FILES['fichier']['size'] <= $maxsize) {
                // On vérifie l'espace alloué
                if ($_FILES['fichier']['size'] + $user_plugile['upload'] <= $limit) {
                    $upload = $user_plugile['upload'] + $_FILES['fichier']['size'];
                    $fichier = explode('.', $_FILES['fichier']['name']);
                    $fichier = parse_file($fichier[0]) . '.' . $fichier[1];
                    $fichier_name_temp = $_FILES['fichier']['tmp_name'];
                    $dir = 'img/members/' . $id . '/';
                    if (is_file($dir . $fichier)) {
                        $fichier = date('dmY\\-Hi', time()) . '_' . $fichier;
                    }
                    if (!is_dir('img/members/')) {
                        mkdir('img/members', 0755);
                    }
                    if (!is_dir($dir)) {
                        mkdir('img/members/' . $id, 0755);
                    }
                    move_uploaded_file($fichier_name_temp, $dir . $fichier);
                    // Miniaturisation des images si demandées
                    if ($pun_config['o_uploadile_thumb'] == '1') {
                        $hauteur_destination = $pun_config['o_uploadile_thumb_size'];
コード例 #10
0
function get_reports(&$reports, &$files)
{
    global $start_date;
    global $end_date;
    note("Starting file requests.");
    // Work through reports until we have pulled all of them
    foreach ($reports as $index => $report) {
        $json = get_json($report['request']['@reportUri']);
        if ($json['@reportReady'] != "false") {
            //Set report file name
            $report_file = "{$REPORT}/" . "report_" . $report['ref_name'] . "_" . $end_date . ".gz";
            // Get the report
            $file = get_file($report['request']['@reportUri'], $report_file);
            note("Got file {$file} for Game: " . $report['game_id'] . ", Client: " . $report['client_id']);
            // Are we writing this to a CSV?
            if (!array_key_exists('x', $options)) {
                // Write to a CSV file - split sessions and events
                $output_file_sessions = "{$CSV}/" . $report['ref_name'] . "_" . $end_date . '_sessions.csv';
                $output_file_events = "{$CSV}/" . $report['ref_name'] . "_" . $end_date . '_events.csv';
                $fhs = fopen($output_file_sessions, 'w') or die("ERROR: Could not open session output file.\n");
                $fhe = fopen($output_file_events, 'w') or die("ERROR: Could not open events output file.\n");
                note("File {$file} parsing started for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                $rc = parse_file($file, $report['game_id'], $report['client_id'], $options);
                // Remove this entry
                if ($rc != FALSE) {
                    note("File {$file} parsing complete for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                    $files[] = array('game_id' => $report['game_id'], 'client_id' => $report['client_id'], 'file' => $file);
                    unset($reports[$index]);
                }
                fclose($fhs);
                fclose($fhe);
            } else {
                note("File {$file} was not parsed for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                unset($reports[$index]);
            }
        } else {
            note("File not ready for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
        }
    }
}
コード例 #11
0
ファイル: download.php プロジェクト: anboto/xtreamer-web-sdk
<?php

require_once 'admin/configuration.php';
require_once 'admin/authentication.php';
require_once 'locations/common.php';
// Send headers to force a named file download
header('Content-disposition: attachment; filename="' . urldecode($_REQUEST['f']) . '"');
// If the file exists, dump the contents
if (is_file('temp/' . urldecode($_REQUEST['t']))) {
    // Get temp file
    $str = parse_file('temp/' . urldecode($_REQUEST['t']));
    // Fix linebreaks for destination
    // Windows
    if (stristr($_SERVER['HTTP_USER_AGENT'], 'win') !== false) {
        $str = str_replace("\n", "\r\n", $str);
    } else {
        if (stristr($_SERVER['HTTP_USER_AGENT'], 'mac') !== false) {
            $str = str_replace("\n", "\r", $str);
        }
    }
    // Others can stay with \n
    echo $str;
}
exit;
コード例 #12
0
/**
 * Imports an exercise in QTI format if the XML structure can be found in it
 * @param array $file
 * @return an array as a backlog of what was really imported, and error or debug messages to display
 */
function import_exercise($file)
{
    global $exercise_info;
    global $element_pile;
    global $non_HTML_tag_to_avoid;
    global $record_item_body;
    // used to specify the question directory where files could be found in relation in any question
    global $questionTempDir;
    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2';
    $baseWorkDir = $archive_path;
    if (!is_dir($baseWorkDir)) {
        mkdir($baseWorkDir, api_get_permissions_for_new_directories(), true);
    }
    $uploadPath = '/';
    // set some default values for the new exercise
    $exercise_info = array();
    $exercise_info['name'] = preg_replace('/.zip$/i', '', $file);
    $exercise_info['question'] = array();
    $element_pile = array();
    // create parser and array to retrieve info from manifest
    $element_pile = array();
    //pile to known the depth in which we are
    //$module_info = array (); //array to store the info we need
    // if file is not a .zip, then we cancel all
    if (!preg_match('/.zip$/i', $file)) {
        return 'UplZipCorrupt';
    }
    // unzip the uploaded file in a tmp directory
    if (!get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath)) {
        return 'UplZipCorrupt';
    }
    // find the different manifests for each question and parse them.
    $exerciseHandle = opendir($baseWorkDir);
    //$question_number = 0;
    $file_found = false;
    $operation = false;
    $result = false;
    $filePath = null;
    // parse every subdirectory to search xml question files
    while (false !== ($file = readdir($exerciseHandle))) {
        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
            // Find each manifest for each question repository found
            $questionHandle = opendir($baseWorkDir . '/' . $file);
            while (false !== ($questionFile = readdir($questionHandle))) {
                if (preg_match('/.xml$/i', $questionFile)) {
                    $result = parse_file($baseWorkDir, $file, $questionFile);
                    $filePath = $baseWorkDir . $file;
                    $file_found = true;
                }
            }
        } elseif (preg_match('/.xml$/i', $file)) {
            // Else ignore file
            $result = parse_file($baseWorkDir, '', $file);
            $filePath = $baseWorkDir . '/' . $file;
            $file_found = true;
        }
    }
    if (!$file_found) {
        return 'NoXMLFileFoundInTheZip';
    }
    if ($result == false) {
        return false;
    }
    $doc = new DOMDocument();
    $doc->load($filePath);
    $encoding = $doc->encoding;
    // 1. Create exercise.
    $exercise = new Exercise();
    $exercise->exercise = $exercise_info['name'];
    $exercise->save();
    $last_exercise_id = $exercise->selectId();
    if (!empty($last_exercise_id)) {
        // For each question found...
        foreach ($exercise_info['question'] as $question_array) {
            //2. Create question
            $question = new Ims2Question();
            $question->type = $question_array['type'];
            $question->setAnswer();
            $question->updateTitle(formatText($question_array['title']));
            //$question->updateDescription($question_array['title']);
            $type = $question->selectType();
            $question->type = constant($type);
            $question->save($last_exercise_id);
            $last_question_id = $question->selectId();
            //3. Create answer
            $answer = new Answer($last_question_id);
            $answer->new_nbrAnswers = count($question_array['answer']);
            $totalCorrectWeight = 0;
            foreach ($question_array['answer'] as $key => $answers) {
                $split = explode('_', $key);
                $i = $split[1];
                // Answer
                $answer->new_answer[$i] = formatText($answers['value']);
                // Comment
                $answer->new_comment[$i] = isset($answers['feedback']) ? formatText($answers['feedback']) : null;
                // Position
                $answer->new_position[$i] = $i;
                // Correct answers
                if (in_array($key, $question_array['correct_answers'])) {
                    $answer->new_correct[$i] = 1;
                } else {
                    $answer->new_correct[$i] = 0;
                }
                $answer->new_weighting[$i] = $question_array['weighting'][$key];
                if ($answer->new_correct[$i]) {
                    $totalCorrectWeight = $answer->new_weighting[$i];
                }
            }
            $question->updateWeighting($totalCorrectWeight);
            $question->save($last_exercise_id);
            $answer->save();
        }
        // delete the temp dir where the exercise was unzipped
        my_delete($baseWorkDir . $uploadPath);
        return $last_exercise_id;
    }
    return false;
}
コード例 #13
0
</p>
<h2>Source</h2>
<p>If you click <a href="<?php 
echo $_SERVER['PHP_SELF'] . "?source";
?>
">here</a> you will see the source of the <tt>parse_file()</tt> and the helper function <tt>tidyline()</tt>.
</p>

<h2>Parsed file follows:</h2>
<?php 
require_once 'parse.php';
$file = "Inverza280.spm";
$fileContents = file_get_contents($file);
/*
 * Call parse_file, which does the heavy lifting of parsing
 * the file, then pass the output to json_encode to output 
 * a json interpretation of the file, then to print_r to
 * dump the json to the browser
 * 
 * Note: JSON_PRETTY_PRINT requires php 5.4.0 or higher but
 * is only needed to make the output more human readable
 */
echo '<pre>';
print_r(json_encode(parse_file($fileContents), JSON_PRETTY_PRINT));
echo '</pre>';
?>
<hr>
<p>End of file</p>
</body>
</html>
コード例 #14
0
function show_register($d)
{
    global $dir, $files, $cats, $names, $PAGE, $DATA, $this_page, $link;
    $d = "{$dir}/regmem{$d}.xml";
    if (!in_array($d, $files)) {
        $d = $files[0];
    }
    $d_iso = preg_replace("#{$dir}/regmem(.*?)\\.xml#", '$1', $d);
    $d_pretty = format_date($d_iso, LONGDATEFORMAT);
    $d = file_get_contents($d);
    $data = array();
    parse_file($d, 'only', $data);
    $this_page = 'regmem_date';
    $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, {$d_pretty}");
    $PAGE->stripe_start();
    print $link;
    ?>
<p>This page shows the Register of Members' Interests as released on <?php 
    echo $d_pretty;
    ?>
, in alphabetical order by MP.
<?php 
    if ($d_iso > '2002-05-14') {
        ?>
<a href="./?f=<?php 
        echo $d_iso;
        ?>
">Compare this edition with the one before it</a></p><?php 
    }
    ?>
<div id="regmem">
<?php 
    uksort($data, 'by_name_ref');
    foreach ($data as $person_id => $v) {
        $out = '';
        foreach ($v as $cat_type => $vv) {
            $out .= cat_heading($cat_type, false);
            $d = array_key_exists('only', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['only'] : '';
            $out .= prettify($d) . "\n";
        }
        if ($out) {
            print '<div class="block">';
            print '<h2><a name="' . $person_id . '"></a>' . $names[$person_id] . ' - ';
            print '<a href="?p=' . $person_id . '">Register history</a> | ';
            print '<a href="http://www.theyworkforyou.com/mp/?pid=' . $person_id . '">MP\'s page</a>';
            print '</h2> <div class="blockbody">';
            print "\n{$out}";
            print '</div></div>';
        }
    }
    print '</div>';
}
コード例 #15
0
<?php

function parse_file($file)
{
    /**
     *	Grabing contents from file
     */
    $handle = fopen($file, 'r');
    $content = fread($handle, filesize($file));
    $content = trim($content);
    fclose($handle);
    /**
     *	splitting the string into an array of lines
     * 	Removing first line on title from the array
     */
    $content_lines = explode(PHP_EOL, $content);
    array_shift($content_lines);
    /**
     *	Explode the lines of content into an tempary info array.
     *	
     *	Use the temaray info array to  create an associatave array and push onto parks
     */
    $parks_array = [];
    foreach ($content_lines as $line) {
        $info_array = explode('","', $line);
        $parks_array[] = ['name' => substr($info_array[0], 1), 'location' => $info_array[2], 'date_established' => date("Y-m-d", strtotime($info_array[3])), 'area' => $info_array[4], 'description' => substr($info_array[6], 0, -1)];
    }
    return $parks_array;
}
$parks_array = parse_file('parks.csv');
// print_r($parks_array[0]);
コード例 #16
0
ファイル: code_quality.php プロジェクト: erico-deh/ocPortal
                if (is_integer($key) && $key != 0) {
                    $to_use_multi[] = $val;
                }
            }
        } else {
            $to_use_multi = explode(':', $_to_use);
        }
    }
    foreach ($to_use_multi as $to_use) {
        //		$to_use=str_replace('\\','/',$to_use);
        $full_path = ($OCPORTAL_PATH == '' ? '' : $OCPORTAL_PATH . (substr($OCPORTAL_PATH, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR)) . $to_use;
        if (strpos(file_get_contents($full_path), '/*CQC: No check*/') !== false) {
            echo 'SKIP: ' . $to_use . cnl();
            continue;
        }
        check(parse_file($full_path));
    }
}
echo 'FINAL Done!';
// Do the actual code quality check
function check($structure)
{
    global $GLOBAL_VARIABLES, $CURRENT_CLASS, $OK_EXTRA_FUNCTIONS;
    $GLOBAL_VARIABLES = array();
    $OK_EXTRA_FUNCTIONS = $structure['ok_extra_functions'];
    $CURRENT_CLASS = '__global';
    global $LOCAL_VARIABLES;
    $LOCAL_VARIABLES = reinitialise_local_variables();
    if ($GLOBALS['OK_EXTRA_FUNCTIONS'] == '') {
        foreach ($structure['functions'] as $function) {
            if ($GLOBALS['OK_EXTRA_FUNCTIONS'] != '') {
コード例 #17
0
        xml_parse_into_struct($parser, $data, $values, $tags);
        xml_parser_free($parser);
        // проход через структуры
        foreach ($tags as $key => $val) {
            if ($key == "data") {
                $molranges = $val;
                // каждая смежная пара значений массивов является верхней и
                // нижней границей определения
                for ($i = 0; $i < count($molranges); $i += 2) {
                    $offset = $molranges[$i] + 1;
                    $len = $molranges[$i + 1] - $offset;
                    $tdb[] = parseString(array_slice($values, $offset, $len));
                }
            } else {
                continue;
            }
        }
        return $tdb;
    } else {
        exit('Не удалось открыть файл japancar_krasnoyarsk.xml.');
    }
}
$result = parse_file();
$file = fopen('price.csv', 'w');
$foto = fopen('fotolist.txt', 'w');
foreach ($result as $line) {
    fputcsv($file, (array) $line);
    fwrite($foto, $line->photo_name . "\n");
}
fclose($file);
fclose($foto);
コード例 #18
0
ファイル: code.php プロジェクト: anboto/xtreamer-web-sdk
/**
 * @return String
 * @desc Gets the contents of the selected post and returns it as a string.
 */
function blosxom_open()
{
    return parse_file($_SESSION['plugin_identifier']);
}
コード例 #19
0
function parse_file_zme($filePath)
{
    $lengthArray = array(3, 11, 11, 6, 10, 19, 12, 4, 2, 2, 6, 10, 4, 12, 13, 13, 15, 15, 1, 12, 2, 135);
    return parse_file($filePath, $lengthArray);
}
コード例 #20
0
ファイル: lms-cashimport-bgz.php プロジェクト: Akheon23/lms
                $props = $rows->getChildren();
                $props->rewind();
                while ($props->valid()) {
                    switch ($props->key()) {
                        case "id":
                            $fileid = strval($props->current());
                            break;
                        case "file_name":
                            $filename = strval($props->current());
                    }
                    $props->next();
                }
                if (!empty($fileid) && !empty($filename)) {
                    $contents = get_file_contents($fileid);
                    if ($contents) {
                        parse_file($filename, $contents);
                    }
                }
            }
            $rows->next();
        }
    }
    $xml->next();
}
$lastchange = intval(ConfigHelper::getConfig('finances.bgz_password_lastchange', 0));
if (!$lastchange || time() - $lastchange > 30 * 86400) {
    if (!$quiet) {
        printf("Changing BGZ password ... ");
    }
    $oldpass = ConfigHelper::getConfig('finances.bgz_password');
    $newpassarray = str_split($oldpass);
コード例 #21
0
ファイル: po4locale.php プロジェクト: jcisio/po4locale
<?php

/**
 * Replace button/menu/window... text with its translation in software
 * so that there is consistence between the manual and the software itself.
 *
 * Written by jcisio, 2010, licensed under GPLv2
 */
$T = array();
$LOCALE = isset($argv[1]) ? $argv[1] : 'vi';
foreach (glob('../rosetta-lucid/' . $LOCALE . '/LC_MESSAGES/*.po') as $filename) {
    parse_file($filename);
}
$T2 = array();
foreach ($T as $key => $values) {
    $T2[$key] = max_key($values);
}
$c = count($T);
$before = memory_get_usage();
unset($T);
$after = memory_get_usage();
$data = file_get_contents('po/' . $LOCALE . '.po');
$data = preg_replace_callback('#^msgstr .+?(?=\\n\\n)#ms', 'po4locale_match', $data);
file_put_contents('po/' . $LOCALE . '-new.po', $data);
printf("%d strings, %d KB used, %d title replaced.\n\n", $c, ($before - $after) / 1024, po4locale_item_replace());
function parse_file($filename)
{
    global $T;
    $data = file($filename);
    $k = 0;
    for ($k = 0, $l = count($data); $k < $l; $k++) {
コード例 #22
0
        $rc = FALSE;
        while ($rc == FALSE) {
            while ($report['@reportReady'] == "false" && $count <= 100) {
                //Wait 60 seconds
                debugger("Report Not Ready : Waiting 5 mins. Count is {$count}.");
                echo "NOTE: " . date("Y-m-d H:i:s") . ": Report Not Ready for {$start_date} to {$end_date}. Waiting 5 mins... Count is : {$count}.\n";
                sleep(300);
                $report = get_json($value['@reportUri']);
                $count++;
            }
            $file = get_file($value['@reportUri'], $report_file);
            echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} parsing started for {$start_date} to {$end_date}.\n";
            if (!array_key_exists('x', $options)) {
                $fhs = fopen($output_file_sessions, 'w') or die("ERROR: Could not open session output file.\n");
                $fhe = fopen($output_file_events, 'w') or die("ERROR: Could not open events output file.\n");
                $rc = parse_file($file, $row['game_id'], $row['device_id'], $options);
                fclose($fhs);
                fclose($fhe);
                echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} parsing complete for {$start_date} to {$end_date}.\n";
            } else {
                echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} was not parsed for {$start_date} to {$end_date}.\n";
                $rc = TRUE;
            }
        }
    } else {
        echo "NOTE: " . date("Y-m-d H:i:s") . ": Could not get a valid report for {$file} for {$start_date} to {$end_date}.\n";
    }
}
mysqli_free_result($results[0]);
mysqli_close($db);
function debugger($msg)
コード例 #23
0
ファイル: json_dump.php プロジェクト: rjevansatari/Analytics
require_once 'inc/config.php';
//check options
//d-debug
//s-startdate
//e-enddate
//z-gzip input
//r-resource
//k-api key
//g-game id
//c-client id
//u-only do sessions (no events)
//x-do not parse file, only x-tract
$options = getopt("ds:e:z:r:k:g:c:o:u:x");
if (array_key_exists('z', $options)) {
    $file = $options['z'];
    parse_file($file);
    exit;
} else {
    die("ERROR: No input file passed. Exiting...");
}
function parse_file($file)
{
    # Do we have a zipped file or not?
    $buffer = '';
    if (substr($file, -3, 3) == '.gz') {
        $gz = @gzopen($file, 'rb');
        if ($gz) {
            # Check to see if we got a report
            # Check to make sure we have a valid file
            # Read the file
            while (!gzeof($gz)) {
コード例 #24
0
<?php

ob_start();
include_once 'config.php';
include_once 'utils.php';
$filename = "data-" . date('Y-m-d H:i:s') . time() . '.csv';
foreach ($files_read as $file => $name) {
    $parse_file_output = parse_file($base_path . $file);
    download_file($parse_file_output, $name . '_All_Queries');
    $hashed_data = get_column_group_by($parse_file_output, 'hash');
    $hashed_output = array();
    $i = 0;
    foreach ($hashed_data as $key => $val) {
        //selecting only the first occurence
        $hashed_output[$i] = $val[0];
        $hashed_output[$i]['query_count'] = count($val);
        $i++;
    }
    download_file($hashed_output, $name . '_unique_Queries');
}
コード例 #25
0
        $j++;
    }
    // locId int(10) unsigned NOT NULL,
    // country char(2) NOT NULL,
    // region char(2) NOT NULL,
    // city varchar(50),
    // postalCode char(5) NOT NULL,
    // latitude float,
    // longitude float,
    // dmaCode integer,
    // areaCode integer,
    /**
     *	Explode the lines of content into an tempary info array.
     *	
     *	Use the temaray info array to  create an associatave array and push onto parks
     */
    // $parks_array = [];
    // foreach($content_lines as $line) {
    // 	$info_array = explode('","',$line);
    // 	$parks_array [] = [
    // 		'name' => substr($info_array[0],1),
    // 		'location' => $info_array[2],
    // 		'date_established' => date("Y-m-d",strtotime($info_array[3])),
    // 		'area' => $info_array[4],
    // 		'description' => substr($info_array[6],0,-1)
    // 	];
    // }
    return $errors;
}
$geo_array = parse_file('GeoLiteCity-Location.csv');
print_r($erros);
コード例 #26
0
ファイル: Parser.php プロジェクト: tommiu/phpjoern_mirror
/**
 * Parses and generates ASTs for all PHP files buried within a
 * directory.
 *
 * @param $path        Path to the directory
 * @param $csvexporter A CSV exporter instance to use for exporting
 *                     the ASTs of all parsed files.
 * @param $top         Boolean indicating whether this call
 *                     corresponds to the top-level call of the
 *                     function. We wouldn't need this if I didn't
 *                     insist on the root directory of a project
 *                     getting node index 0. But, I do insist.
 *
 * @return If the directory corresponding to the function call finds
 *         itself interesting, it stores a directory node for itself
 *         and this function returns the index of that
 *         node. Otherwise, returns -1. A directory finds itself
 *         interesting if it contains PHP files, or if one of its
 *         child directories finds itself interesting. -- As a special
 *         case, the root directory of a project (corresponding to the
 *         top-level call) always finds itself interesting and always
 *         stores a directory node for itself.
 */
function parse_dir($path, $csvexporter, $top = true) : int
{
    // save any interesting directory/file indices in the current folder
    $found = [];
    // if the current folder finds itself interesting, we will create a
    // directory node for it and return its index
    $dirnode = $top ? $csvexporter->store_dirnode(basename($path)) : -1;
    $dhandle = opendir($path);
    // iterate over everything in the current folder
    while (false !== ($filename = readdir($dhandle))) {
        $finfo = new SplFileInfo(build_path($path, $filename));
        if ($finfo->isFile() && $finfo->isReadable() && strtolower($finfo->getExtension()) === 'php') {
            $found[] = parse_file($finfo->getPathname(), $csvexporter);
        } else {
            if ($finfo->isDir() && $finfo->isReadable() && $filename !== '.' && $filename !== '..') {
                if (-1 !== ($childdir = parse_dir($finfo->getPathname(), $csvexporter, false))) {
                    $found[] = $childdir;
                }
            }
        }
    }
    // if the current folder finds itself interesting...
    if (!empty($found)) {
        if (!$top) {
            $dirnode = $csvexporter->store_dirnode(basename($path));
        }
        foreach ($found as $i => $nodeindex) {
            $csvexporter->store_rel($dirnode, $nodeindex, "DIRECTORY_OF");
        }
    }
    closedir($dhandle);
    return $dirnode;
}
コード例 #27
0
ファイル: index.php プロジェクト: bet0x/smartstrap
<?php

// THESE ARE THE THINGS TO CHANGE, THEY ARE JUST USED IN THE TEMPLATE
$info = array('title' => 'SmartStrap', 'description' => 'Simple and enjoyable blogging.', 'menu_list' => array('Archived Content' => '/archive'));
date_default_timezone_set('UTC');
require './libs/smarty/Smarty.class.php';
require './libs/markdown.php';
require './libs/metadata.php';
$smarty = new Smarty();
$smarty->setTemplateDir('./template/');
$smarty->setCompileDir('./cache/templates_c/');
$smarty->setCacheDir('./cache/cache/');
$vars = parse_file(get_file_path($_GET['path']));
$vars['info'] = $info;
$vars['info']['url'] = 'http://' . $_SERVER["SERVER_NAME"];
$vars['files'] = compiled_metadata();
foreach ($vars as $key => $value) {
    $smarty->assign($key, $value);
}
if (isset($_GET['feed']) && $_GET['feed'] == 'rss') {
    header("Content-type: application/rss+xml");
    $vars['xml_header'] = '<?xml version="1.0" encoding="utf-8"?>';
    $smarty->display('rss.tpl');
} else {
    $smarty->display('index.tpl');
}
コード例 #28
0
function parse()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if ($timepid < 14) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $sock = new sockets();
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    $time = $unix->file_time_min($TimeFile);
    if (!$GLOBALS["FORCE"]) {
        if ($time < 1440) {
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $f = $unix->DirFiles("/var/log/squid", "[0-9]+_QUOTASIZE\\.db");
    $export_path = "/home/artica/squid/dbExport";
    @mkdir($export_path, 0755, true);
    while (list($filename, $none) = each($f)) {
        preg_match("#([0-9]+)_#", $filename, $re);
        $xdate = $re[1];
        echo "{$filename} ( {$xdate} )\n";
        if ($SquidPerformance > 1) {
            if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
                continue;
            }
            @unlink("/var/log/squid/{$filename}");
            continue;
        }
        if (!parse_file("/var/log/squid/{$filename}", $xdate)) {
            continue;
        }
        if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
            continue;
        }
        @unlink("/var/log/squid/{$filename}");
    }
}
コード例 #29
0
ファイル: lms-cashimport.php プロジェクト: itav/lms
$ih = @imap_open("{" . ConfigHelper::getConfig('cashimport.server') . "}INBOX", ConfigHelper::getConfig('cashimport.username'), ConfigHelper::getConfig('cashimport.password'));
if (!$ih) {
    die("Cannot connect to mail server!" . PHP_EOL);
}
$posts = imap_search($ih, ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.use_seen_flag', true)) ? 'UNSEEN' : 'ALL');
if (!empty($posts)) {
    foreach ($posts as $postid) {
        $post = imap_fetchstructure($ih, $postid);
        if ($post->type == 1) {
            $parts = $post->parts;
            //print_r($parts);
            foreach ($parts as $partid => $part) {
                if ($part->ifdisposition && strtoupper($part->disposition) == 'ATTACHMENT' && $part->type == 0) {
                    $fname = $part->dparameters[0]->value;
                    $msg = imap_fetchbody($ih, $postid, $partid + 1);
                    if ($part->encoding == 3) {
                        $msg = imap_base64($msg);
                    }
                    if (ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.use_seen_flag', true))) {
                        imap_setflag_full($ih, $postid, "\\Seen");
                    }
                    parse_file($fname, $msg);
                    if (ConfigHelper::checkValue(ConfigHelper::getConfig('cashimport.autocommit', false))) {
                        commit_cashimport();
                    }
                }
            }
        }
    }
}
imap_close($ih);
コード例 #30
0
ファイル: version.php プロジェクト: Three20/Backend
<?php

array_shift($argv);
$mode = null;
foreach ($argv as $arg) {
    $filename = $arg . 'issues.json';
    if (file_exists($filename)) {
        parse_file($filename, $mode);
    } else {
        $mode = $arg;
    }
}
function parse_file($filename, $mode)
{
    $issues = json_decode(file_get_contents($filename), TRUE);
    if (!$mode || $mode == 'count') {
        echo count($issues['issues']);
    } else {
        if ($mode == 'grid') {
            echo '<div class="grid" id="issues">' . "\n";
            foreach (array_reverse($issues['issues']) as $issue) {
                echo '  <div class="row">' . "\n";
                echo '  <a class="col-4" href="http://github.com/' . $issue['user'] . '">';
                echo '<img width="72" height="72" align="center" src="http://www.gravatar.com/avatar/' . $issue['gravatar_id'] . '?s=72&amp;d=http://three20.info/gfx/team/silhouette.gif" />';
                echo '</a>' . "\n";
                echo '  <a class="col-4-fill-3" href="http://github.com/facebook/three20/issues/issue/' . $issue['number'] . '"><div class="info">';
                echo '<div class="title">' . $issue['title'] . '</div>';
                echo '<div class="date">' . $issue['created_at'] . '</div>';
                echo '</div></a>' . "\n";
                echo '  <div class="clearfix"></div>' . "\n";
                echo '  </div> <!-- .row -->' . "\n";