Example #1
0
/**
 * Output an image together with last modified header.
 *
 * @param string $file as path to the image.
 * @param boolean $verbose if verbose mode is on or off.
 */
function outputImage($file, $verbose)
{
    $info = getimagesize($file);
    !empty($info) or errorMessage("The file doesn't seem to be an image.");
    $mime = $info['mime'];
    $lastModified = filemtime($file);
    $gmdate = gmdate("D, d M Y H:i:s", $lastModified);
    if ($verbose) {
        verbose("Memory peak: " . round(memory_get_peak_usage() / 1024 / 1024) . "M");
        verbose("Memory limit: " . ini_get('memory_limit'));
        verbose("Time is {$gmdate} GMT.");
    }
    if (!$verbose) {
        header('Last-Modified: ' . $gmdate . ' GMT');
    }
    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
        if ($verbose) {
            verbose("Would send header 304 Not Modified, but its verbose mode.");
            exit;
        }
        //die(strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) . " not modified $lastModified");
        header('HTTP/1.0 304 Not Modified');
    } else {
        if ($verbose) {
            verbose("Would send header to deliver image with modified time: {$gmdate} GMT, but its verbose mode.");
            exit;
        }
        header('Content-type: ' . $mime);
        readfile($file);
    }
    exit;
}
function verboseFail($text, $success)
{
    if ($success) {
        verbose($text);
    } else {
        echo "<span class=\"error\">" . $text . "</span>\n";
    }
}
Example #3
0
function report($text, $isErrror = false)
{
    global $report, $force, $cms_language, $content;
    $text = $isErrror ? '<span class="atm-red">' . $text . '</span>' : '<strong>' . $text . '</strong>';
    verbose($text);
    if ($isErrror && !$force) {
        $send = '<br />
		======' . $cms_language->getMessage(MESSAGE_PAGE_END_OF_INSTALL) . '======';
        $content .= $send;
        echo $content;
        exit;
    }
}
 private function start()
 {
     verbose('Running ' . $this->getImageName() . '...');
     $cmd = 'sudo docker run -v ' . $this->directory . '/www:/var/www -p ' . $this->getPort() . ':80';
     if (ArgParser::isInteractiveMode()) {
         $cmd .= ' -i -t ' . $this->getImageName() . ' /bin/bash';
         new Command($cmd, true);
     } else {
         $cmd .= ' -d ' . $this->getImageName();
         $command = new Command($cmd);
         if ($command->exitCode !== 0) {
             throw new Exception('Error running container');
         }
         out($this->getImageName() . ' running successfully at: http://localhost:' . $this->getPort());
     }
 }
function analyseResourceCalendarXML($string, $pimfile)
{
    verbose("Analyzing Resource Calendar XML for File '" . $pimfile . "'");
    $translator_phPIMap = array("pimfile", "uid", "summary", "from", "to");
    $translator_XML = array($pimfile, "uid", "summary", "start-date", "end-date");
    $xmlread = new MiniXMLDoc();
    $xmlread->fromString($string);
    $rootArray = $xmlread->toArray();
    print_r($rootArray);
    unset($GLOBALS["tmp"]["flattenArray"]);
    $ar = flattenArray($rootArray);
    print_r($ar);
    for ($i = 0; $i < count($translator_XML); $i++) {
        $ar[$translator_phPIMap[$i]] = $rootArray[$translator_XML[$i]];
    }
    return $ar;
}
function analyseResourceTodo($folder)
{
    $d = opendir($folder);
    while ($f = readdir($d)) {
        if ($f != "." && $f != ".." && str_replace(".svn", "", $f) != "") {
            $pimfile = str_replace("//", "/", $folder . "/" . $f);
            $fp = fopen($pimfile, "r");
            $c = "";
            while (!feof($fp)) {
                $c .= fgets($fp, 9999);
            }
            fclose($fp);
            $c = str_replace("\r", "\n", $c);
            $c = str_replace("\n\n", "\n", $c);
            verbose("Analysing '" . $pimfile . "'");
            $c = explode("\n", $c);
            for ($i = 0; $i < count($GLOBALS["fields"]["todo"]); $i++) {
                if ($GLOBALS["fields"]["todo"][$i] != "pimfile") {
                    ${$GLOBALS["fields"]["todo"][$i]} = "";
                }
            }
            for ($i = 0; $i < count($c); $i++) {
                if (strtoupper(substr($c[$i], 0, 4)) == "UID:") {
                    $x = explode(":", $c[$i]);
                    $uid = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 3)) == "DUE") {
                    $x = explode(":", $c[$i]);
                    $due = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
                }
                if (strtoupper(substr($c[$i], 0, 7)) == "SUMMARY") {
                    $x = explode(":", $c[$i]);
                    $summary = $x[1];
                }
            }
            $id = count($GLOBALS["restree"]["todo"]);
            for ($i = 0; $i < count($GLOBALS["fields"]["todo"]); $i++) {
                $GLOBALS["restree"]["todo"][$id][$GLOBALS["fields"]["todo"][$i]] = ${$GLOBALS["fields"]["todo"][$i]};
            }
            $GLOBALS["restree"]["todo"][$id][internalid] = $id;
        }
    }
}
Example #7
0
function main($argc, $argv)
{
    if ($argc < 2 || $argc > 3) {
        usage($argv[0]);
    }
    // Als '-v' is meegegeven tijdens het starten, ga in verbose mode
    if ($argv[1] == '-v') {
        verbose(true);
        $argc--;
        array_shift($argv);
    } else {
        verbose(false);
    }
    // Reader voor de XML-bestanden
    $reader = new KnowledgeBaseReader();
    // Parse een xml-bestand (het eerste argument) tot knowledge base
    $state = $reader->parse($argv[1]);
    // Start de solver, dat ding dat kan infereren
    $solver = new Solver();
    // leid alle goals in de knowledge base af.
    $goals = $state->goals;
    // Begin met de doelen die we hebben op de goal stack te zetten
    foreach ($goals as $goal) {
        $state->goalStack->push($goal->name);
    }
    // Zo lang we nog vragen kunnen stellen, stel ze
    while (($question = $solver->solveAll($state)) instanceof AskedQuestion) {
        $answer = cli_ask($question);
        if ($answer instanceof Option) {
            $state->apply($answer->consequences, Yes::because("User answered '{$answer->description}' to '{$question->description}'"));
        }
    }
    // Geen vragen meer, print de gevonden oplossingen.
    foreach ($goals as $goal) {
        printf("%s: %s\n", $goal->description, $goal->answer($state)->description);
    }
}
Example #8
0
File: quiz.php Project: p2004a/CTF
function evaluate($question, $answer)
{
    eval('$x=' . filter($answer));
    $res = " " . $question[0];
    for ($i = 1; $i < strlen($question); ++$i) {
        if ($question[$i] == "X" and is_numeric($question[$i - 1])) {
            $res .= "*X";
        } else {
            $res .= $question[$i];
        }
    }
    $res = preg_replace("/(\\d+|X)\\s*\\^\\s*(.*?)\\s/", "pow(\$1,\$2)", $res);
    $res = str_replace("X", '$x', $res);
    $question = filter($res);
    if (!$question) {
        return null;
    }
    $question = str_replace("=", '==', $question);
    if (verbose()) {
        echo $question . PHP_EOL;
    }
    eval('$res=' . $question);
    return $res;
}
Example #9
0
$GLOBALS["isVerbose"] = $argv[2] == "--verbose" ? true : false;
if (!$filePtr) {
    die_usage("Error : file not found.");
}
$csv = array_map('str_getcsv', $filePtr);
$total = 0;
$success = 0;
foreach ($csv as $key => $row) {
    $address = trim($row[0]);
    $address = str_replace(';', ' ', $address);
    $address = preg_replace('!\\s+!', ' ', $address);
    verbose("Looking for : {$address}");
    $geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false');
    $geo = json_decode($geo, true);
    if ($geo['status'] = 'OK') {
        $success++;
        verbose("Found !");
        $latitude = $geo['results'][0]['geometry']['location']['lat'];
        $longitude = $geo['results'][0]['geometry']['location']['lng'];
        verbose("Longitude : {$longitude}");
        verbose("Latitude : {$latitude}");
        csv_line("{$latitude};{$longitude}");
    } else {
        verbose("Not found !");
        csv_line(";");
    }
    $total++;
    sleep(1);
}
verbose("Result : {$success} / {$total} founded.");
$games = json_decode($json, true);
$iso = $games[$id]['iso'];
$title = $games[$id]['title'];
echo "<p>";
/* mount the virtual iso */
verbose("Attempting to mount {$title} in \"{$mountfuse}\"");
mount($iso);
/* list all files */
$files = listFiles($iso);
verbose("Cleaning \"{$patch}\"");
clean($patch);
verbose("Initialising \"{$patch}\"");
init($patch);
verbose("Duplicating file structure in \"{$patch}\"");
createSymlinkStructure($files);
verbose("Collecting XML files");
$compatiblexmls = getCompatibleXML($id);
foreach ($compatiblexmls as $compatiblexml) {
    $xml = simplexml_load_file($compatiblexml);
    foreach ($_POST as $option => $patchesraw) {
        if (!empty($patchesraw)) {
            $patches = explode(";", $patchesraw);
            foreach ($patches as $patch) {
                $patchnode = $xml->xpath("./patch[@id='{$patch}']");
                if (count($patchnode) > 0) {
                    foreach ($patchnode[0] as $replacementnode) {
                        switch ($replacementnode->getName()) {
                            case "file":
                                filePatch($replacementnode['disc'], $replacementnode['external']);
                                break;
                            case "folder":
function analyseResourceContact($folder)
{
    $d = opendir($folder);
    while ($f = readdir($d)) {
        if ($f != "." && $f != ".." && str_replace(".svn", "", $f) != "") {
            $pimfile = str_replace("//", "/", $folder . "/" . $f);
            $fp = fopen($pimfile, "r");
            $c = "";
            while (!feof($fp)) {
                $c .= fgets($fp, 9999);
            }
            fclose($fp);
            $c = str_replace("\r", "\n", $c);
            $c = str_replace("\n\n", "\n", $c);
            verbose("Analysing '" . $pimfile . "'");
            $c = explode("\n", $c);
            for ($i = 0; $i < count($GLOBALS["fields"]["contact"]); $i++) {
                if ($GLOBALS["fields"]["contact"][$i] != "pimfile") {
                    ${$GLOBALS["fields"]["contact"][$i]} = "";
                }
            }
            for ($i = 0; $i < count($c); $i++) {
                if (strtoupper(substr($c[$i], 0, 4)) == "UID:") {
                    $x = explode(":", $c[$i]);
                    $uid = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 2)) == "N:") {
                    $x = explode(":", $c[$i]);
                    $x = explode(";", $x[1]);
                    $surname = $x[0];
                    $firstname = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 5)) == "BDAY:") {
                    $x = explode(":", $c[$i]);
                    $birthday = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
                }
                if (strtoupper(substr($c[$i], 0, 6)) == "EMAIL:") {
                    $x = explode(":", $c[$i]);
                    $email = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "URL:") {
                    $x = explode(":", $c[$i]);
                    $url = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 6)) == "TITLE:") {
                    $x = explode(":", $c[$i]);
                    $title = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "ORG:") {
                    $x = explode(":", $c[$i]);
                    $organization = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 5)) == "NOTE:") {
                    $x = explode(":", $c[$i]);
                    $note = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "TEL;") {
                    $x = explode(";", $c[$i]);
                    for ($y = 0; $y < count($x); $y++) {
                        $nr = explode(":", $x[$y]);
                        switch ($nr[0]) {
                            case "TYPE=HOME":
                                $telephone = $nr[1];
                                break;
                            case "TYPE=VOICE":
                                $mobilephone = $nr[1];
                                break;
                            case "TYPE=CELL":
                                $cellphone = $nr[1];
                                break;
                            case "TYPE=FAX":
                                $fax = $nr[1];
                                break;
                        }
                    }
                }
            }
            $id = count($GLOBALS["restree"]["contact"]);
            for ($i = 0; $i < count($GLOBALS["fields"]["contact"]); $i++) {
                $GLOBALS["restree"]["contact"][$id][$GLOBALS["fields"]["contact"][$i]] = ${$GLOBALS["fields"]["contact"][$i]};
            }
            $GLOBALS["restree"]["contact"][$id][internalid] = $id;
        }
    }
}
}
if (RetrieveVar("calorientation", "0111")) {
    $_SESSION["calorientation"] = RetrieveVar("calorientation", "0111");
} elseif ($_SESSION["calorientation"] == "") {
    $_SESSION["calorientation"] = TimeStamp(0);
}
$time = TimeStamp2Time($_SESSION["calorientation"]);
$prevyear = date("YmdHis", mktime(0, 0, 0, date("m", $time), date("d", $time), date("Y", $time) - 1));
$prevmonth = date("YmdHis", mktime(0, 0, 0, date("m", $time) - 1, date("d", $time), date("Y", $time)));
$nextyear = date("YmdHis", mktime(0, 0, 0, date("m", $time), date("d", $time), date("Y", $time) + 1));
$nextmonth = date("YmdHis", mktime(0, 0, 0, date("m", $time) + 1, date("d", $time), date("Y", $time)));
$GLOBALS["calendar"]["month"] = date("m", $time);
$GLOBALS["calendar"]["start"] = date("YmdHis", mktime(0, 0, 0, date("m", $time), 1, date("Y", $time)));
$GLOBALS["calendar"]["end"] = date("YmdHis", mktime(23, 59, 59, date("m", $time), date("t", $time), date("Y", $time)));
verbose("Orientiert an Timestamp: " . $time . ", Monat ist " . $GLOBALS["calendar"]["month"]);
verbose("Monat geht von " . $GLOBALS["calendar"]["start"] . " bis " . $GLOBALS["calendar"]["end"]);
$selection = $GLOBALS["restree"]["calendar"];
$selection1 = filterResources($selection, "to", $GLOBALS["calendar"]["start"], ">=", null);
$selection1x = filterResources($selection1, "to", $GLOBALS["calendar"]["end"], "<=", null);
$selection2 = filterResources($selection, "from", $GLOBALS["calendar"]["end"], "<=", null);
$selection2x = filterResources($selection2, "from", $GLOBALS["calendar"]["start"], ">=", null);
$selection = mergeSelections($selection1x, $selection2x);
for ($i = 0; $i < count($selection); $i++) {
    $hasevent[date("j", TimeStamp2Time($selection[$i]["from"]))] = true;
}
append("<table border=\"1\" id=\"minical\" name=\"minical\">\n");
append("     <tr class=\"calnavi\">\n");
append("          <td>&nbsp;</td>\n");
append("          <td><a href=\"?module=calendar&calorientation=" . $prevyear . "\">&lt;&lt;</a></td>\n");
append("          <td><a href=\"?module=calendar&calorientation=" . $prevmonth . "\">&lt;</a></td>\n");
append("          <td colspan=\"3\">\n" . "               <a href=\"?module=calendar&calrange=month\">\n" . $GLOBALS["calendar"]["month"] . " " . date("M", $time) . "</a>\n" . "          </td>\n");
Example #13
0
        }
    }
    if ($version) {
        file_put_contents("{$css_dest}/min.bundle-v{$version}.css", $mergedCss);
    } else {
        file_put_contents("{$css_dest}/min.bundle.css", $mergedCss);
    }
    if ($css_header_file) {
        $csshdrt = "{$mini_css_conditional_if}\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{$http_css}/min.bundle";
        if ($version) {
            $csshdrt .= "-v{$version}";
        }
        $csshdrt .= ".css\" />\n{$mini_css_conditional_else}\n{$csshdr}{$mini_css_conditional_end}\n";
        file_put_contents($css_header_file, $csshdrt);
    }
    verbose(" done\n\n");
}
if ($version && !$js_header_file) {
    echo "\n\n****** VERSION NUMBER WAS SPECIFIED - DON'T FORGET TO UPDATE HEADER FILES!! ******\n\n";
}
function verbose($msg)
{
    global $verbose;
    if ($verbose) {
        print $msg;
    }
}
function print_version($mini = true)
{
    echo "\nMinify V" . VERSION . "- A JS and CSS minifier for projects using the Smarty PHP templating engine\n\nCopyright (c) 2010 - 2012, Open Source Solutions Limited, Dublin, Ireland - http://www.opensolutions.ie\nReleased under the BSD License.\n";
    if (!$mini) {
Example #14
0
function filePatch($disc, $external)
{
    global $sd;
    global $patchfiles;
    if (file_exists($patchfiles . $disc)) {
        unlink($patchfiles . $disc);
    }
    symlink($sd . $external, $patchfiles . $disc);
    verbose("Linked \"{$sd}{$external}\" to \"{$patchfiles}{$disc}\"");
}
Example #15
0
     $files = get_directory_list($olddir);
     if (empty($files)) {
         continue;
     }
     // Create new user directory
     if (!($newdir = make_user_directory($userid))) {
         // some weird directory - do not stop the upgrade, just ignore it
         continue;
     }
     // Move contents of old directory to new one
     if (file_exists($olddir) && file_exists($newdir)) {
         $restored = false;
         foreach ($files as $file) {
             if (!file_exists($newdir . '/' . $file)) {
                 copy($olddir . '/' . $file, $newdir . '/' . $file);
                 verbose("Moved {$olddir}/{$file} into {$newdir}/{$file}");
                 $restored = true;
             }
         }
         if ($restored) {
             $restored_count++;
         }
     } else {
         notify("Could not move the contents of {$olddir} into {$newdir}!");
         $result = false;
         break;
     }
 }
 if ($settings['eolchar'] == '<br />') {
     print_box_start('generalbox centerpara');
 }
/**
 * Attempts to delete all generated test data. A few conditions are required for this to be successful:
 *   1. If a database-prefix has been given, tables with this prefix must exist
 *   2. If a data prefix has been given (e.g. test_), test data must contain this prefix in their unique identifiers (not PKs)
 * The first method is safest, because it will not interfere with existing tables, but you have to create all the tables yourself.
 */
function data_cleanup()
{
    global $settings, $tables, $DB;
    if ($settings['quiet']) {
        ob_start();
    }
    if (!is_null($settings['database-prefix']) && isset($tables)) {
        // Truncate test tables if a specific db prefix was given
        foreach ($tables as $table_name) {
            // Don't empty a few tables
            if (!in_array($table_name, array('modules', 'block'))) {
                if ($DB->delete_records($table_name)) {
                    verbose("Truncated table {$table_name}");
                } else {
                    verbose("Could not truncate table {$table_name}");
                    if (!$settings['ignore-errors']) {
                        die;
                    }
                }
            }
        }
    } else {
        // Delete records in normal tables if no specific db prefix was given
        $courses = $DB->get_records_select('course', "idnumber LIKE ?", array("{$settings['data-prefix']}%"), null, 'id');
        if (is_array($courses) && count($courses) > 0) {
            foreach ($courses as $course) {
                if (!delete_course($course->id, false)) {
                    verbose("Could not delete course {$course->id} or some of its associated records from the database.");
                    if (!$settings['ignore-errors']) {
                        die;
                    }
                } else {
                    verbose("Deleted course {$course->id} and all associated records from the database.");
                }
            }
        }
        verbose("Deleting test users (permanently)...");
        if (!$DB->delete_records_select('user', "username LIKE ?", array("{$settings['data-prefix']}%"))) {
            verbose("Error deleting users from the database");
            if (!$settings['ignore-errors']) {
                die;
            }
        }
    }
    if ($settings['quiet']) {
        ob_end_clean();
    }
}
 function get_direction_to_append($cid)
 {
     verbose(2, "ENTERING function get_direction_to_append().");
     verbose(2, "-- cid is " . $cid);
     $circle_lvl = 1;
     $max_const_per_level = 4;
     if ($cid > 4) {
         while ($max_const_per_level < $cid) {
             $circle_lvl += 2;
             $max_const_per_level += $circle_lvl * 4;
         }
         $max_const_from_previous_level = $max_const_per_level - $circle_lvl * 4;
     } else {
         $max_const_from_previous_level = 0;
     }
     $direction = ($cid - $max_const_from_previous_level) / $circle_lvl;
     verbose(2, "-- circle_lvl is " . $circle_lvl);
     verbose(2, "-- max_const_from_previous_level is " . $max_const_from_previous_level);
     verbose(2, "-- direction is " . $direction);
     if ($direction < 1) {
         verbose(1, "-- new constellation will be appended ABOVE\n");
         return "HOCH";
     } elseif ($direction < 2) {
         verbose(1, "-- new constellation will be appended RIGHT\n");
         return "RECHTS";
     } elseif ($direction < 3) {
         verbose(1, "-- new constellation will be appended BELOW\n");
         return "RUNTER";
     } else {
         verbose(1, "-- new constellation will be appended LEFT\n");
         return "LINKS";
     }
 }
Example #18
0
File: msql.php Project: philum/cms
function msql_adm($msql = '')
{
    //echo br();
    $root = sesm('root', 'msql/');
    $auth = $_SESSION['auth'];
    $ath = 6;
    //auth_level_mini
    $wsz = define_s('wsz', 700);
    $msql = $msql ? $msql : $_GET['msql'];
    $_SESSION['page'] = $_GET['page'] ? $_GET['page'] : 1;
    #boot
    if ($msql && $msql != '=') {
        $url = sesm('url', '/msql/');
        $ra = msql_boot($msql);
        $_SESSION['msql_boot'] = $ra;
        list($bases, $base, $dirs, $dir, $prefixes, $prefix, $files, $table, $version, $folder, $node) = $ra;
        //build url
        $murl = sesm('murl', murl($base, $dir, $prefix, $table, $version));
        //b/d/p_t_v
        $basename = $root . $folder . $node;
        $is_file = is_file($basename . '.php');
        $lk = sesm('lk', $url . $folder . $node . gpage());
        $folder = $root . $folder;
        //conformity
        msql_adm_head($lk, $base, $prefix, $table, $version);
    }
    $def = ajx($_POST['def'] ? $_POST['def'] : $_GET['def'], 1);
    if ($_GET['see']) {
        $ret[] = verbose($ra, 'dirs');
    }
    //auth
    if ($base == 'users' && $prefix == $_SESSION['USE']) {
        $_SESSION['ex_atz'] = 1;
    }
    if ($auth >= $ath && $_SESSION['ex_atz'] or $auth >= 6) {
        $authorized = true;
    }
    $lkb = $lk . '&';
    #load
    //reqp('msql'); $msq=new msql($base,$node); if($is_file)$defs=$msq->load();
    if (get('repair')) {
        msql_repair($folder, $node);
    }
    //old
    if ($is_file) {
        $defs = read_vars($folder, $node, $defsb);
    }
    //if(!$defs)$ret[]=verbose($ra,'');
    if ($defs['_menus_']) {
        $defsb['_menus_'] = $defs['_menus_'];
    }
    //save
    if ($def && !$defs[$def]) {
        $_POST['add'] = $def;
    }
    if (($_POST['def'] or $_POST['add']) && $authorized) {
        list($defs, $def) = save_defs($folder, $node, $defs, $def, $base);
    }
    //savb
    if ($_GET['sav']) {
        save_vars($folder, $node . '_sav', $defs, 1);
    }
    //create
    if ($_GET['create'] && $authorized) {
        $prefix = normaliz_c($_POST['prfx']);
        $table = normaliz_c($_POST['hbname']);
        if ($_POST['hbnb'] && $_POST['hbnb'] != 'version') {
            $version = $_POST['hbnb'];
        }
        if (!$_POST['hbnb']) {
            $version = '';
        }
        if (is_numeric($_POST['nbc'])) {
            $defsb['_menus_'] = '';
            $nbc = $_POST['nbc'];
            $nbc = $nbc > 1 ? $nbc : 1;
            for ($i = 1; $i <= $nbc; $i++) {
                $defsb['_menus_'][] = 'col_' . $i;
            }
        } elseif ($defs['_menus_']) {
            $defsb['_menus_'] = $defs['_menus_'];
        } else {
            $defsb['_menus_'] = array('');
        }
        $node = mnod($prefix, $table, $version);
        if ($folder && $prefix) {
            read_vars($folder, $node, $defsb);
        }
        relod(sesm('url') . murl_build('', '', $prefix, $table, $version));
    }
    #modifs
    //save_modif
    $do = find_command();
    if ($do && $auth >= $ath) {
        $defs = msql_modifs($defs, $defsb, $folder, $prefix . '_' . $table, $node, $basename, $do);
    }
    #render
    $lh = sesmk('msqlang');
    #-menus
    if (!$_GET['def']) {
        $ret['menus'] = msql_menus($ra);
    }
    //auth(3) &&
    if (!$_GET['def']) {
        //called
        #-files
        //add
        if (auth(4)) {
            $ret['fls'] = lkc('txtblc', $lkb . 'new==', pictxt('add', $lh[9][0])) . ' ';
        }
        if ($table && $authorized && $prefix && $is_file) {
            //$defs &&
            $ret['fls'] .= lkc('txtx', $lkb . 'sav==', $lh[2][0]) . ' ';
            if (is_file($basename . '_sav.php')) {
                $ret['fls'] .= lkc('txtx', $lkb . 'restore==', $lh[3][0]) . ' ';
            }
            $ret['fls'] .= lj_goto('import_defs', 5);
            //$ret['fls'].=lj_goto('import_old','');
            $ret['fls'] .= lj_goto('import_keys', 17);
            $ret['fls'] .= lj_goto('merge_defs', 6);
            $ret['fls'] .= lj_goto('append_update', 7);
            $ret['fls'] .= lj_goto('append_values', 8);
        } else {
            $ret['fls'] .= $bckp;
        }
        if ($files[$prefix] && ($auth > $ath or $prefix == $_SESSION['USE'])) {
            if ($auth >= $ath && $table && $prefix && $is_file) {
                $ret['fls'] .= lkc('txtx', $lkb . 'del_table==', $lh[10][0]) . ' ';
                $ret['fls'] .= ljb('txtblc', 'delfile', $lkb . 'del_file==', $lh[11][0]) . ' ';
                //$ret['fls'].=lkc('txtyl',$lkb.'del_file==',$lh[11][0]).' ';
                if (!$defs or isset($defs[0])) {
                    $ret['fls'] .= lkc('txtyl', $lkb . 'repair==', $lh[12][0]) . ' ';
                }
            }
        }
        if ($ret['fls']) {
            $ret['fls'] .= br();
        }
        //$ret['fls']=divc('menu',$ret['fls']);
        //new
        if ($_GET['new']) {
            $ret['fls'] .= newbase($base, $prefix, $table, $version);
        }
        #-util
        if ($table && $authorized && $prefix && $is_file) {
            $ret['utl'] .= lkc('txtblc', $lkb . 'def=_menus_', $lh[1][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'reset_menus==', $lh[22][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'del_menus==', $lh[23][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'add_keys==', $lh[24][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'del_keys==', $lh[25][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'def=_menus_&add_col==', $lh[14][0]) . ' ';
            $ret['utl'] .= lj_goto('del_col', 15);
            if ($is_file) {
                $ret['utl'] .= lkc('txtx" title="' . $lh[13][1], $lkb . 'repair_cols==', $lh[13][0]) . br();
            }
            if ($base != 'system' && is_file(sesm('root') . 'system/' . $node . '.php')) {
                $ret['utl'] .= lkc('txtblc', $lkb . 'update==', $lh[26][0]) . ' ';
            }
            $ret['utl'] .= lj_goto('sort_table', 19);
            if ($table != 'restrictions' && $table != 'params') {
                $ret['utl'] .= lkc('txtx', $lkb . 'reorder==', $lh[20][0]) . ' ';
            }
            $ret['utl'] .= lj_goto('permut', 21);
            $ret['utl'] .= lkc('txtx', $lkb . 'edit_conn==', $lh[16][0]) . ' ';
            $ret['utl'] .= lkc('txtx" title="' . $lh[6][1], $lkb . 'inject_defs==', $lh[18][0]) . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'edit_csv==', 'csv') . ' ';
            $ret['utl'] .= lkc('txtx', $lkb . 'json==', 'json') . ' ';
            if (auth(6)) {
                $ret['utl'] .= lkc('txtx', $lkb . 'export_mysql==', 'sql') . ' ';
            }
            if (auth(6)) {
                $ret['utl'] .= lkc('txtx', $lkb . 'create_mysql==', 'create mysql') . ' ';
            }
            $ret['utl'] .= lj('txtx', 'popup_msql___lang_helps_msql', '?');
        }
        #-fieldset
        if ($ret['fls'] . $ret['utl']) {
            $ret['utils'] = divc('menu', $ret['fls'] . $ret['utl']);
        }
        $ret['fls'] = $ret['utl'] = '';
        //if($ret['nfo'])$ret['nfo'].=br();
    }
    //called
    #-infos
    if ($table && $is_file) {
        $ret['nfo'] = lkc('popsav', $lk, $murl) . ' ';
        $wurl = $_SERVER['HTTP_HOST'] . '/msql/' . $murl;
        $ret['nfo'] .= lj('popbt', 'popup_text___' . ajx($wurl) . '_weburl_console', pictit('link', 'web url'));
        $wcon = '[' . $murl . $kdef . ($def ? ':' . $def : '') . ':microsql]';
        $ret['nfo'] .= lj('popbt', 'popup_text___' . ajx($wcon) . '_connector_console', pictit('conn', 'connector'));
        $ret['nfo'] .= lkt('popbt', '/plug/microxml.php?table=' . $murl, pictit('rss', 'xml')) . ' - ';
        $ret['nfo'] .= btn('txtsmall2', count($defs) . ' ' . plurial(count($defs), 116)) . ' - ';
        if ($is_file) {
            $ret['nfo'] .= btn('txtsmall2', fsize($basename . '.php')) . ' - ';
        }
        $ret['nfo'] .= btn('txtsmall2', ftime($basename . '.php')) . ' ';
        $ret['nfo'] .= msq_search($murl);
    }
    if ($ret['nfo']) {
        $ret['nfo'] = divc('menu', $ret['nfo']);
    }
    //entries
    //if($defs)$ret['edt'].=slctmenuder($defs,$def?$def:'_menus_');
    //add
    if ($is_file && $authorized && !$_GET['called'] && $defs && !$_GET['def']) {
        $ret['edt'] .= divc('menu', f_inp_add($defs, $defsb, $def)) . br();
    }
    //edit
    //echo verbose($ra,'');
    if ($def && $defs[$def]) {
        $ret['edt'] .= f_inp_m($defs, $defsb['_menus_'], $def);
    }
    //edit_conn
    if ($_GET['edit_conn'] == '=') {
        if ($defs) {
            foreach ($defs as $k => $v) {
                $v = str_replace(array('|', '¬'), array(':BAR:', ':LINE:'), $v);
                $edittable .= implode('|', $v) . '¬' . "\n";
            }
        }
        //(!is_numeric($k)?$k.'|':'')
        $ret[] = divc('', 'paste a table as created by transductor from html table :: use "|" for cells and "¬" for lines of cells') . form($lkb . 'def=' . $def, txarea('import_conn', $edittable, 60, 14) . br() . checkbox('aid', 'ok', 'auto_increment', '1') . input2('submit', 'save', 'import', 'txtbox')) . hr() . br();
    }
    //array
    if ($_GET['inject_defs'] == '=') {
        $datas = str_replace(array('<' . '?php', '?' . '>'), '', read_file($basename . '.php'));
        $ret[] = divc('', 'paste $r[1]=array(1,2,3)') . form($lkb, txarea('inject_defs', $datas, 60, 14) . br() . input2('submit', 'replace', 'replace', 'txtbox') . input2('submit', 'inject', 'inject', 'txtbox') . checkbox('mono', '1', 'key=>value', '') . checkbox('sql', '1', 'mysql', '')) . hr() . br();
    }
    //export_mysql
    if ($_GET['create_mysql'] == '=' && auth(6)) {
        $ok = plugin_func('mysql', 'import_msql', $defs, $node);
        $ret[] = divc('txtalert', 'create table ' . $node . ': ' . $ok);
    }
    if ($_GET['export_mysql'] == '=' && auth(6)) {
        $ret[] = txarea('', mysqlrb($defs), 60, 40);
    }
    //csv
    if ($_GET['edit_csv'] == '=') {
        foreach ($defs as $k => $v) {
            if ($v) {
                $edittable .= $k . ':' . (is_array($v) ? implode(',', $v) : htmlentities($v)) . "\n";
            }
        }
        $ret[] = divc('', 'paste csv using "," for cells and lines for rows') . form($lkb . 'def=' . $def, txarea('edit_csv', $edittable, 60, 14) . br() . checkbox('aid', 'ok', 'auto_increment', '1') . input2('submit', 'save', 'import', 'txtbox')) . hr() . br();
    }
    //csv
    if ($_GET['json'] == '=') {
        foreach ($defs as $k => $v) {
            if ($v) {
                $edittable .= '"' . $k . '":' . (is_array($v) ? '["' . implode('","', $v) . '"]' : '"' . htmlentities($v[0])) . '",';
            }
        }
        $ret[] = txarea('edit_csv', '{' . $edittable, 60, 14) . '}' . br();
    }
    //see_table
    if ($defs && !$_GET['def']) {
        // && (!$def or $_POST['save'])//called
        $out = divd('editmsql', draw_table($defs, $murl, ''));
        $ret[] = $out . br();
    } else {
        $ret[] = divd('editmsql', '');
    }
    if ($auth > 6) {
        $ret[] = lkc('txtx', $lkb . 'backup_msql==', 'backup') . ' ';
    }
    if ($_GET['backup_msql']) {
        $ret[] = backup_msql();
    }
    return divd('content', implode('', $ret));
}
// Build our array of files we need to parse
$files = array();
foreach ($output as $file) {
    if (strlen($file) > 2) {
        $file = substr($file, 2);
        if (is_file($file)) {
            $parts = pathinfo($file);
            if (!isset($parts['extension']) || !in_array($parts['extension'], $php_extensions)) {
                verbose("Not a known php extension for file: '{$file}'");
                continue;
            }
            verbose("Checking PHP Syntax for: '{$file}'...");
            $output = array();
            exec('/usr/bin/php -l ' . escapeshellarg($file), $output, $retval);
            if ($retval === 0) {
                verbose("  Successfully passed PHP Lint Check!");
            } else {
                echo "PHP Parsing Error Detected in file '{$file}'\n----------";
                echo implode("\n", $output) . "\n----------\n";
                $fail = TRUE;
            }
        }
    }
}
// If any file failed, return failure so it doesn't commit
if ($fail) {
    exit(255);
}
exit(0);
/**
 * Verbose output if enabled
Example #20
0
         }
         $serp_data['keyword'] = $keyword;
         $serp_data['cc'] = $country_data['cc'];
         $serp_data['lc'] = $country_data['lc'];
         $serp_data['result_count'] = $result_count;
         store_cache($serp_data, $search_string, $page, $country_data);
         // store results into local cache
     }
     if ($process_result != "PROCESS_SUCCESS_MORE") {
         break;
     }
     // last page
     if (!$load_all_ranks) {
         for ($n = 0; $n < $result_count; $n++) {
             if (strstr($results[$n]['url'], $test_website_url)) {
                 verbose("Located {$test_website_url} within search results.{$NL}");
                 break;
             }
         }
     }
 }
 // scrape clause
 $result_count = $serp_data['result_count'];
 for ($ref = 0; $ref < $result_count; $ref++) {
     $rank++;
     $rank_data[$keyword][$rank]['title'] = $serp_data[$ref]['title'];
     $rank_data[$keyword][$rank]['url'] = $serp_data[$ref]['url'];
     $rank_data[$keyword][$rank]['host'] = $serp_data[$ref]['host'];
     //$rank_data[$keyword][$rank]['desc']=$serp_data['desc'']; // not really required
     if (strstr($rank_data[$keyword][$rank]['url'], $test_website_url)) {
         $info = array();
<h1>Patching..</h1>
<?php 
$id = $_POST['id'];
unset($_POST['id']);
$json = file_get_contents($library);
$games = json_decode($json, true);
$iso = $games[$id]['iso'];
$title = $games[$id]['title'];
$compatiblexmls = getCompatibleXML($id);
echo "<p>";
/* mount the virtual iso */
verbose("Attempting to mount {$title} in \"{$mountfuse}\"");
mount($iso);
verbose("Cleaning \"{$patch}\"");
clean($patch);
verbose("Initialising \"{$patch}\"");
init($patch);
$base = directoryScanRecursive($mountfiles, true, false, "files");
$replacements = array();
foreach ($compatiblexmls as $compatiblexml) {
    $xmlraw = str_replace('{$__maker}', substr($id, 4, 5), str_replace('{$__region}', $id[3], str_replace('{$__gameid}', substr($id, 0, 2), file_get_contents($compatiblexml))));
    $xml = simplexml_load_string($xmlraw);
    $root = "";
    if (isset($xml["root"])) {
        $root = $xml["root"];
    }
    foreach ($_POST as $option => $patchesraw) {
        if (!empty($patchesraw)) {
            $patches = explode(";", $patchesraw);
            foreach ($patches as $patchunique) {
                $patchnode = $xml->xpath("./patch[@id='{$patchunique}']");
Example #22
0
<?php

include '../util.php';
include '../solver.php';
include '../reader.php';
include '../formatter.php';
function _encode($data)
{
    return base64_encode(gzcompress(serialize($data)));
}
function _decode($data)
{
    return unserialize(gzuncompress(base64_decode($data)));
}
verbose(!empty($_GET['verbose']));
class WebLogger implements Logger
{
    public $messages = array(array());
    public function __wakeup()
    {
        $this->messages[] = array();
    }
    public function write($format, $arguments, $level)
    {
        $arguments = array_map(function ($arg) {
            return '<tt>' . Template::html(to_debug_string($arg)) . '</tt>';
        }, $arguments);
        $this->messages[count($this->messages) - 1][] = [$level, vsprintf($format, $arguments)];
    }
}
class WebFrontend
Example #23
0
                echo "Error: The temporary file '" . $tmpfile . "' could not be saved.\n";
                exit(1);
            }
            system("echo -ne '\\033[01;34m'; diff -u " . $file . " " . $tmpfile . " 2>&1; echo -ne '\\033[00m'");
            break;
        case "source":
            echo $source;
            break;
    }
}
if ($command == "replace") {
    if ($replaced) {
        verbose("Replaced " . $replaced . " files.\n");
    }
    if ($cache != $cache_orig) {
        verbose("Write cache file " . CACHEFILE . "\n");
        if (!file_put_contents(CACHEFILE, serialize($cache))) {
            echo "Warning: The cache file '" . CACHEFILE . "' could not be saved.\n";
        }
    }
}
/////////////////// FUNCTIONS //////////////////////
/**
 * Output script status messages
 */
function verbose($msg)
{
    if ($GLOBALS['verbose']) {
        echo $msg;
    }
}
Example #24
0
                                folderScrape($replacements, $index, $externalfull, $recursive, false, $prefix, $externalfull);
                                break;
                            case "memory":
                                $memorypatch = true;
                                break;
                            case "dolphiidol":
                                $dolphiidol = $sd . $root . "/" . $replacementnode['external'];
                                break;
                        }
                    }
                } else {
                    echo "Error: patch with id '{$patchunique}' does not exist.";
                }
            }
        }
    }
    if ($memorypatch) {
        verbose("Memory patches applied.");
        memoryPatch(realpath($compatiblexml), $patchsys . $maindol, realpath($sd . $root));
    }
}
copyDolphiiDol($dolphiidol);
//print_r_pre(directoryScan($patchfiles, false, false));
//print_r_pre($base);
//print_r_pre($replacements);
print_r_pre(array_replace($base, $replacements));
//print_r_pre($index);
verbose("Mirroring original folder structure");
createSymlinkStructure(array_replace($base, $replacements));
?>
</div>
function sigterm_handler($signo)
{
    global $forcestop;
    $forcestop = true;
    verbose("Signal {$signo} catched");
}
Example #26
0
$failures = 0;
$runs = 0;
foreach (find_files(getcwd(), '/\\.test\\.php$/') as $filename) {
    chdir(dirname($filename));
    $path = realpath(dirname(__FILE__) . '/../lib') . PATH_SEPARATOR . ini_get("include_path");
    $xml = shell_exec('php -d include_path=' . escapeshellarg($path) . ' ' . escapeshellarg(basename($filename)) . ' -x');
    verbose("-------------------------------------------\n");
    verbose("Running suite: " . $filename . "\n");
    $doc = new DomDocument();
    if (@$doc->loadXml($xml)) {
        $q = new DomXpath($doc);
        $passes += $q->query('//pass')->length;
        $failures += $q->query('//fail')->length;
        foreach ($q->query('//fail') as $fail) {
            verbose($fail->nodeValue . "\n");
        }
        verbose($q->query('//pass')->length . " passes, ");
        verbose($q->query('//fail')->length . " failures" . "\n");
    } else {
        $failures += 1;
        verbose($xml);
    }
    $runs++;
}
verbose("===========================================\n");
if ($failures == 0) {
    echo "Done .. OK\n";
} else {
    echo "Done .. {$runs} tests completed with {$passes} passes and {$failures} failures.\n";
    exit(1);
}
// Build our array of files we need to parse
$files = array();
foreach ($output as $file) {
    if (strlen($file) > 2) {
        $file = substr($file, 2);
        if (is_file($file)) {
            $parts = pathinfo($file);
            if (!isset($parts['extension']) || !in_array($parts['extension'], $xml_extensions)) {
                verbose("Not a known XML extension for file: '{$file}'");
                continue;
            }
            verbose("Checking XML Syntax for: '{$file}'...");
            $output = array();
            exec($xmllintpath . ' --noout ' . escapeshellarg($file), $output, $retval);
            if ($retval === 0) {
                verbose("  Successfully passed XML Lint Check!");
            } else {
                echo "XML Parsing Error Detected in file '{$file}'\n----------";
                echo implode("\n", $output) . "\n----------\n";
                $fail = TRUE;
            }
        }
    }
}
// If any file failed, return failure so it doesn't commit
if ($fail) {
    exit(255);
}
exit(0);
/**
 * Verbose output if enabled
Example #28
0
function rotate_proxy()
{
    global $PROXY;
    global $ch;
    global $NL;
    $max_errors = 3;
    $success = 0;
    while ($max_errors--) {
        $res = proxy_api("rotate");
        // will fill $PROXY
        $ip = "";
        if ($res <= 0) {
            verbose("API error: Proxy API connection failed (Error {$res}). trying again soon..{$NL}{$NL}");
            sleep(21);
            // retry after a while
        } else {
            verbose("API success: Received proxy IP {$PROXY['external_ip']} on port {$PROXY['port']}{$NL}");
            $success = 1;
            break;
        }
    }
    if ($success) {
        $ch = new_curl_session($ch);
        return 1;
    } else {
        return "API rotation failed. Check license, firewall and API credentials.{$NL}";
    }
}
Example #29
0
    parse_str($_SERVER['QUERY_STRING'], $query);
    unset($query['verbose']);
    unset($query['v']);
    unset($query['nocache']);
    unset($query['nc']);
    unset($query['json']);
    $url1 = '?' . htmlentities(urldecode(http_build_query($query)));
    $url2 = '?' . urldecode(http_build_query($query));
    echo <<<EOD
<!doctype html>
<html lang=en>
<meta charset=utf-8>
<title>CImage verbose output</title>
<style>body{background-color: #ddd}</style>
<a href={$url1}><code>{$url1}</code></a><br>
<img src='{$url1}' />
<pre id="json"></pre>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
window.getDetails = function (url, id) {
  \$.getJSON(url, function(data) {
    element = document.getElementById(id);
    element.innerHTML = "filename: " + data.filename + "\\nmime type: " + data.mimeType + "\\ncolors: " + data.colors + "\\nsize: " + data.size + "\\nwidth: " + data.width + "\\nheigh: " + data.height + "\\naspect-ratio: " + data.aspectRatio + ( data.pngType ? "\\npng-type: " + data.pngType : '');
  });
}
</script>
<script type="text/javascript">window.getDetails("{$url2}&json", "json")</script>
EOD;
}
$img->log("Incoming arguments: " . print_r(verbose(), 1))->setSaveFolder($cachePath)->useCache($useCache)->setSource($srcImage, $imagePath)->setOptions(array('newWidth' => $newWidth, 'newHeight' => $newHeight, 'aspectRatio' => $aspectRatio, 'keepRatio' => $keepRatio, 'cropToFit' => $cropToFit, 'fillToFit' => $fillToFit, 'crop' => $crop, 'area' => $area, 'upscale' => $upscale, 'scale' => $scale, 'rotateBefore' => $rotateBefore, 'autoRotate' => $autoRotate, 'bgColor' => $bgColor, 'palette' => $palette, 'filters' => $filters, 'sharpen' => $sharpen, 'emboss' => $emboss, 'blur' => $blur, 'convolve' => $convolve, 'rotateAfter' => $rotateAfter, 'outputFormat' => $outputFormat, 'dpr' => $dpr))->loadImageDetails()->initDimensions()->calculateNewWidthAndHeight()->setSaveAsExtension($saveAs)->setJpegQuality($quality)->setPngCompression($compress)->useOriginalIfPossible($useOriginal)->generateFilename($cachePath)->useCacheIfPossible($useCache)->load()->preResize()->resize()->postResize()->setPostProcessingOptions($postProcessing)->save()->linkToCacheFile($aliasTarget)->output();
Example #30
0
function process_language($lang)
{
    global $voices;
    global $options;
    if (is_dir($options['w'] . '/' . $lang) == false) {
        verbose('Create directory "' . $options['w'] . '/' . $lang . '" ...');
        mkdir($options['w'] . '/' . $lang);
    }
    foreach ($voices as $line => $voice_entry) {
        if (array_key_exists('type', $voice_entry) && $voice_entry['type'] == 'sound') {
            verbose("Processing soundfile \"" . $voice_entry['filename'] . "\" ... ");
            process_sound($voice_entry, $lang);
        } else {
            if ($voice_entry[$lang] != '') {
                verbose("Processing [{$lang}] entry {$line} \"" . $voice_entry[$lang] . "\"... ");
                process_voice($voice_entry, $lang);
            } else {
                process_sound($voice_entry, $lang);
            }
        }
    }
}