function getEventbriteEvents($eb_keywords, $eb_city, $eb_proximity)
{
    global $eb_app_key;
    $xml_url = "https://www.eventbrite.com/xml/event_search?...&within=50&within_unit=M&keywords=" . $eb_keywords . "&city=" . $eb_city . "&date=This+month&app_key=" . $eb_app_key;
    echo $xml_url . "<br />";
    $xml = simplexml_load_file($xml_url);
    $count = 0;
    // loop over events from eventbrite xml
    foreach ($xml->event as $event) {
        // add event if it doesn't already exist
        $event_query = mysql_query("SELECT * FROM events WHERE id_eventbrite={$event->id}") or die(mysql_error());
        if (mysql_num_rows($event_query) == 0) {
            echo $event_id . " ";
            // get event url
            foreach ($event->organizer as $organizer) {
                $event_organizer_url = $organizer->url;
            }
            // get event address
            foreach ($event->venue as $venue) {
                $event_venue_address = $venue->address;
                $event_venue_city = $venue->city;
                $event_venue_postal_code = $venue->postal_code;
            }
            // get event title
            $event_title = str_replace(array("\r\n", "\r", "\n"), ' ', $event->title);
            // add event to database
            mysql_query("INSERT INTO events (id_eventbrite, \n                                      title,\n                                      created, \n                                      organizer_name, \n                                      uri, \n                                      start_date, \n                                      end_date, \n                                      address\n                                      ) VALUES (\n                                      '{$event->id}',\n                                      '" . parseInput($event_title) . "',\n                                      '" . strtotime($event->created) . "',\n                                      '" . trim(parseInput($event->organizer->name)) . "',\n                                      '{$event_organizer_url}',\n                                      '" . strtotime($event->start_date) . "',\n                                      '" . strtotime($event->end_date) . "',\n                                      '{$event_venue_address}, {$event_venue_city}, {$event_venue_postal_code}'\n                                      )") or die(mysql_error());
        }
        $count++;
    }
}
Beispiel #2
0
function run_pre_input_addons(&$convoArr, $say)
{
    global $format;
    $convoArr = checkIP($convoArr);
    if ($format == 'html') {
        $say = parseInput($say);
    }
    return $say;
}
Beispiel #3
0
 }
 if (in_array($domain, $exceptions)) {
     echo "{$wiki}: SKIPPING! This wiki is listed as an exception in the Rallout Plan!\n";
     continue;
 }
 if (!in_array($lang, $allowedLanguages)) {
     echo "{$wiki}: SKIPPING! Wiki's language ({$lang}) is not on the allowed languaes list.\n";
     continue;
 }
 if (!isset($options['yes'])) {
     $response = null;
     // repeat until we get a valid response
     while (is_null($response)) {
         echo "{$wiki}: Are you sure you want to switch to Oasis? [yes/no] ";
         $input = fgets(STDIN);
         $response = parseInput($input);
     }
     if (!$response) {
         // user answered no
         echo "{$wiki}: SKIPPING (because you said so)\n";
         continue;
     } else {
         echo "{$wiki}: PROCEEDING\n";
     }
 }
 WikiFactory::setVarByName('wgDefaultSkin', $id, 'oasis');
 WikiFactory::clearCache($id);
 // purge varnishes
 if (!isset($options['nopurge'])) {
     $cmd = "pdsh -g all_varnish varnishadm -T :6082 'purge req.http.host == \"" . $domain . "\"'";
     passthru($cmd);
         $place[address] .= $place['zip'] ? ($place[address] ? ', ' : '') . $place['zip'] : '';
         $place[address] .= $place['country'] ? ($place[address] ? ', ' : '') . (isset($countries_arr[$place['country']]) ? $countries_arr[$place['country']] : $place['country']) : '';
         $types_arr[$place[type]][] = $place;
         $org_array[] = $place['organization_id'];
         $count[$place[type]]++;
         $marker_id++;
         $place_query = mysql_query("SELECT id FROM places WHERE sg_organization_id='" . $place['organization_id'] . "' LIMIT 1") or die(mysql_error());
         // organization doesn't exist, add it to the db
         if (mysql_num_rows($place_query) == 0) {
             mysql_query("INSERT INTO places (approved,\n                                          title, \n                                          type,\n                                          lat,\n                                          lng,\n                                          address,\n                                          uri,\n                                          description,\n                                          sg_organization_id\n                                          ) VALUES (\n                                          '1', \n                                          '" . parseInput($place['name']) . "', \n                                          '" . parseInput($place['type']) . "', \n                                          '" . parseInput($place['latitude']) . "', \n                                          '" . parseInput($place['longitude']) . "', \n                                          '" . parseInput($place['address']) . "',\n                                          '" . parseInput($place['url']) . "',\n                                          '" . parseInput($place['description']) . "',\n                                          '" . parseInput($place['organization_id']) . "'\n                                          )") or die(mysql_error());
             // organization already exists, update it with new info if necessary
         } else {
             if (mysql_num_rows($place_query) == 1) {
                 $place_info = mysql_fetch_assoc($place_query);
                 if ($place_info['title'] != $place['name'] || $place_info['type'] != $place['type'] || $place_info['lat'] != $place['latitude'] || $place_info['lng'] != $place['longitude'] || $place_info['address'] != $place['address'] || $place_info['uri'] != $place['url'] || $place_info['description'] != $place['description']) {
                     mysql_query("UPDATE places SET title='" . parseInput($place['name']) . "',\n                                           type='" . parseInput($place['type']) . "',\n                                           lat='" . parseInput($place['latitude']) . "',\n                                           lng='" . parseInput($place['longitude']) . "',\n                                           address='" . parseInput($place['address']) . "',\n                                           uri='" . parseInput($place['url']) . "',\n                                           description='" . parseInput($place['description']) . "'\n                                           WHERE sg_organization_id='" . parseInput($place['organization_id']) . "' LIMIT 1");
                 }
             }
         }
     }
     // delete any old markers that have already been deleted on SG
     $org_array = implode(",", $org_array);
     $deleted = mysql_query("DELETE FROM places WHERE sg_organization_id NOT IN ({$org_array})") or die(mysql_error());
     // update settings table with the timestamp for this sync
     mysql_query("UPDATE settings SET sg_lastupdate='" . time() . "'");
     // show errors if there were any issues
 } catch (Exception $e) {
     echo "<div class='error'>";
     print_r($e);
     echo "</div>";
     exit;
//Parameters extracted:
/*
CrossPG, ThroughBallsPG, LongBallsPG, ShortPassPG
*/
require 'helper.php';
//<div id="stage-situation-stats" class="ws-panel stat-table">
//remember to click on passes
$urls = array();
$urls[] = "passes_serieA_";
$urls[] = "passes_premier_";
$urls[] = "passes_liga_";
$urls[] = "passes_bundesliga_";
echo '<div class="row"><div class="col-md-6">';
foreach ($urls as $url) {
    for ($year = 2010; $year <= 2015; $year++) {
        $league_id = setLeagueId($url);
        $html = file_get_html($url . $year . ".html");
        echo "<br><b>Parsing Stats from " . $url . $year . ".html </b><br>";
        $table = $html->getElementById("stage-passes-grid");
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Cross Per Game", "td[class=cr]", $table, $dataArray, "Sporty", 0, "number");
        parseInput($conn, "Through Balls Per Game", "td[class=tb]", $table, $dataArray, "Sporty", 0, "number");
        parseInput($conn, "Long Balls Per Game", "td[class=lb]", $table, $dataArray, "Sporty", 0, "number");
        parseInput($conn, "Short Pass Per Game", "td[class=sp]", $table, $dataArray, "Sporty", 0, "number");
        echo "<br><b>Done Parsing Stats from " . $url . $year . ".html </b> <br>";
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";
echo '<a href="home.html#seven" class="btn btn-info" role="button">Continue</a>';
echo '</div></div>';
//<div id="stage-team-stats" class="ws-panel stat-table">
//remember to click on difensive offensive
*/
require 'helper.php';
//Select leagues to parse
$urls = array();
$urls[] = "stats_serieA_";
$urls[] = "stats_premier_";
$urls[] = "stats_liga_";
$urls[] = "stats_bundesliga_";
echo '<div class="row"><div class="col-md-6">';
foreach ($urls as $url) {
    for ($year = 2010; $year <= 2015; $year++) {
        $league_id = setLeagueId($url);
        $html = file_get_html($url . $year . ".html");
        echo "<br><b>Parsing Stats from " . $url . $year . ".html </b><br>";
        //summary
        $table = $html->getElementById("statistics-team-table-summary")->childNodes(0);
        //Summary
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots Per Game", "td[class=shotsPerGame]", $table, $dataArray, "Offensive", 1, "number");
        parseInput($conn, "Ball Possession", "td[class=possession]", $table, $dataArray, "Sporty", 0, "percentage");
        parseInput($conn, "Pass Success", "td[class=passSuccess]", $table, $dataArray, "Sporty", 0, "percentage");
        parseInput($conn, "Red Cards", "span[class=red-card-box]", $table, $dataArray, "Sporty", 0, "number");
        echo "<br><b>Done Parsing Stats from " . $url . $year . ".html </b> <br>";
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";
echo '<a href="home.html#four" class="btn btn-info" role="button">Continue</a>';
echo '</div></div>';
/*
gamesWon, gamesDrawn, gamesLost, goalsScored, goalsAgainst

//<div id="standings-11369" style="display: block;">
*/
require 'helper.php';
$urls = array();
$urls[] = "results_serieA_";
$urls[] = "results_premier_";
$urls[] = "results_liga_";
$urls[] = "results_bundesliga_";
echo '<div class="row"><div class="col-md-6">';
foreach ($urls as $url) {
    for ($year = 2010; $year <= 2015; $year++) {
        $league_id = setLeagueId($url);
        $html = file_get_html($url . $year . ".html");
        echo "<br><b>Parsing Stats from " . $url . $year . ".html </b><br>";
        $dataArray = getTeams($conn, $html, $year, $league_id, "team");
        parseInput($conn, "Games Won", "td[class=w]", $html, $dataArray, "Sporty", 1, "number");
        parseInput($conn, "Games Drawn", "td[class=d]", $html, $dataArray, "Sporty", 0, "number");
        parseInput($conn, "Games Lost", "td[class=l]", $html, $dataArray, "Sporty", 1, "number");
        parseInput($conn, "Goals Scored", "td[class=gf]", $html, $dataArray, "Offensive", 1, "number");
        parseInput($conn, "Goals Against", "td[class=ga]", $html, $dataArray, "Defensive", 1, "number");
        parseInput($conn, "Rank", "td[class=o]", $html, $dataArray, "Sporty", 1, "number");
        echo "<br><b>Done Parsing Stats from results" . $url . $year . ".html </b> <br>";
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";
echo '<a href="home.html#three" class="btn btn-info" role="button">Continue</a>';
echo '</div></div>';
</form>
<script>
    document.getElementById('start-index').value = "<?php 
echo htmlentities($_POST['start-index']);
?>
";
    document.getElementById('end-index').value = "<?php 
echo htmlentities($_POST['end-index']);
?>
";
</script>
<div>
    <?php 
if (!empty($_POST['start-index']) && !empty($_POST['end-index'])) {
    $startIndex = parseInput($_POST['start-index']);
    $endIndex = parseInput($_POST['end-index']);
    if (isValidInteger($startIndex) && isValidInteger($endIndex)) {
        if ($startIndex <= $endIndex) {
            for ($i = $startIndex; $i <= $endIndex; $i++) {
                if (isPrime($i)) {
                    ?>
                        <span class="prime"><?php 
                    echo $i;
                    ?>
</span>
                    <?php 
                } else {
                    echo $i;
                }
                if ($i !== $endIndex) {
                    echo ", ";
Beispiel #9
0
        $pattern = str_repeat('*', mb_strlen($censorWord));
        $text = str_ireplace($censorWord, $pattern, $text);
    }
    return $text;
}
define("TEXT", "text");
define("BANNEDWORDS", "banned-words");
define("WHOLEWORDS", "whole-words");
if (!empty($_POST[TEXT]) && !empty($_POST[BANNEDWORDS])) {
    $inputText = $_POST[TEXT];
    $inputBanedWords = mb_strtolower($_POST[BANNEDWORDS], 'UTF-8');
    $bannedWords = preg_split('/\\P{L}+/u', parseInput($inputBanedWords), -1, PREG_SPLIT_NO_EMPTY);
    if (isset($_POST['whole-words'])) {
        $result = censorWords(parseInput($inputText), $bannedWords);
    } else {
        $result = censorSequence(parseInput($inputText), $bannedWords);
    }
} else {
    $result = '';
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Text Filter</title>
    <link rel="stylesheet" href="styles/style.css"/>
</head>
<body>
<main>
    <form action="" method="post">
Beispiel #10
0
function parseRequired(&$formValues)
{
    global $fNameError, $lNameError, $emailError, $phoneError, $companyError, $programmingError, $skillError;
    define("INVALID_DATA", "* Invalid data provided!");
    define("MISSING_DATA", "* Field must have a value!");
    if (empty($_POST["fname"])) {
        $fNameError = MISSING_DATA;
        return false;
    } else {
        $fname = parseInput($_POST["fname"]);
        if (!isValid($fname)) {
            $fNameError = INVALID_DATA;
            return false;
        }
        $formValues['fname'] = $fname;
    }
    if (empty($_POST["lname"])) {
        $lNameError = MISSING_DATA;
        return false;
    } else {
        $lname = parseInput($_POST["lname"]);
        if (!isValid($lname)) {
            $lNameError = INVALID_DATA;
            return false;
        }
    }
    $formValues['lname'] = $lname;
    if (empty($_POST["email"])) {
        $emailError = MISSING_DATA;
        return false;
    } else {
        $email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL);
        if (!$email) {
            $emailError = INVALID_DATA;
            return false;
        }
    }
    $formValues['email'] = $email;
    if (empty($_POST["company"])) {
        $companyError = MISSING_DATA;
        return false;
    } else {
        $company = parseInput($_POST["company"]);
        if (!preg_match('/[A-Za-z0-9 ]/', $company)) {
            $companyError = INVALID_DATA;
            return false;
        }
    }
    $formValues['company'] = $company;
    if (empty($_POST["phone"])) {
        $phoneError = MISSING_DATA;
        return false;
    } else {
        $phone = parseInput($_POST["phone"]);
        if (!preg_match('/^\\+?[\\d\\s-]*$/', $phone)) {
            $phoneError = INVALID_DATA;
            return false;
        }
    }
    $formValues['phone'] = $phone;
    $programmingLangs = $_POST["programming"];
    foreach ($programmingLangs as $language) {
        if (empty($language)) {
            $programmingError = MISSING_DATA;
            return false;
        } else {
            if (!isValid($language)) {
                $programmingError = INVALID_DATA;
                return false;
            }
        }
    }
    $formValues['programming'] = $programmingLangs;
    $skillLangs = $_POST["skill"];
    foreach ($skillLangs as $language) {
        if (empty($language)) {
            $skillError = MISSING_DATA;
            return false;
        } else {
            if (!isValid($language)) {
                $skillError = INVALID_DATA;
                return false;
            }
        }
    }
    $formValues['skill'] = $skillLangs;
    if (!empty($_POST['gender'])) {
        $formValues['gender'] = $_POST['gender'];
    } else {
        $formValues['gender'] = 'unknown';
    }
    $formValues['birthday'] = $_POST['birthday'];
    $formValues['nationality'] = $_POST['nationality'];
    $formValues['company-from'] = $_POST['company-from'];
    $formValues['company-to'] = $_POST['company-to'];
    $formValues['level'] = $_POST['level'];
    $formValues['comprehension'] = $_POST['comprehension'];
    $formValues['reading'] = $_POST['reading'];
    $formValues['writing'] = $_POST['writing'];
    $formValues['category'] = [];
    if (isset($_POST['catA'])) {
        $formValues['category'][] = $_POST['catA'];
    }
    if (isset($_POST['catB'])) {
        $formValues['category'][] = $_POST['catB'];
    }
    if (isset($_POST['catC'])) {
        $formValues['category'][] = $_POST['catC'];
    }
    return true;
}
Beispiel #11
0
<?php

include_once "header.php";
// This is used to submit new markers for review.
// Markers won't appear on the map until they are approved.
$owner_name = mysql_real_escape_string(parseInput($_POST['owner_name']));
$owner_email = mysql_real_escape_string(parseInput($_POST['owner_email']));
$title = mysql_real_escape_string(parseInput($_POST['title']));
$type = mysql_real_escape_string(parseInput($_POST['type']));
$address = mysql_real_escape_string(parseInput($_POST['address']));
$uri = mysql_real_escape_string(parseInput($_POST['uri']));
$description = mysql_real_escape_string(parseInput($_POST['description']));
// validate fields
if (empty($title) || empty($type) || empty($address) || empty($uri) || empty($description) || empty($owner_name) || empty($owner_email)) {
    echo "All fields are required - please try again.";
    exit;
} else {
    // if startup genome mode enabled, post new data to API
    if ($sg_enabled) {
        try {
            @($r = $http->doPost("/organization", $_POST));
            $response = json_decode($r, 1);
            if ($response['response'] == 'success') {
                include_once "startupgenome_get.php";
                echo "success";
                exit;
            }
        } catch (Exception $e) {
            echo "<pre>";
            print_r($e);
        }
    <link rel="stylesheet" href="styles/style.css"/>
</head>
<body>
<main>
    <form action="" method="post">
        <div>
            <label for="text">Text: </label>
            <textarea name="text" id="text"></textarea>
        </div>
        <div>
            <label for="word">Word: </label>
            <input type="text" name="word" id="word"/>
        </div>
        <input type="submit" value="Search"/>
    </form>
    <?php 
echo parseInput($result);
?>
</main>
<script>
    document.getElementById('text').value = "<?php 
echo $_POST[TEXT];
?>
";
    document.getElementById('word').value = "<?php 
echo $_POST[WORD];
?>
";
</script>
</body>
</html>
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots Per Game", "td[class=shotsPerGame]", $table, $dataArray, "Sporty");
        parseInput($conn, "Ball Possession", "td[class=possession]", $table, $dataArray, "Sporty");
        parseInput($conn, "Pass Success", "td[class=passSuccess]", $table, $dataArray, "Sporty");
        parseInput($conn, "Red Cards", "span[class=red-card-box]", $table, $dataArray, "Sporty");
        //offensive
        $table = $html->getElementById("statistics-team-table-offensive")->childNodes(0);
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots On Target Per Game", "td[class=shotOnTargetPerGame]", $table, $dataArray, "Sporty");
        parseInput($conn, "Dribbles Won Per Game", "td[class=dribbleWonPerGame]", $table, $dataArray, "Sporty");
        //defensive
        $table = $html->getElementById("statistics-team-table-defensive")->childNodes(0);
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots Conceded Per Game", "td[class=shotsConcededPerGame]", $table, $dataArray, "Sporty");
        parseInput($conn, "Tackles Per Game", "td[class=tacklePerGame]", $table, $dataArray, "Sporty");
        parseInput($conn, "Interceptions Per Game", "td[class=interceptionPerGame]", $table, $dataArray, "Sporty");
        echo "<br><b>Done Parsing Stats from " . $url . $year . ".html </b> <br>";
    }
}
//Function to set the league id by reading the url of the file parsed.
//Notice this means that if the files are not named properly the leagueId will be wrong
function setLeagueId($url)
{
    $id = 0;
    if (strpos($url, 'serieA') !== false) {
        $id = 1;
    } elseif (strpos($url, 'premier') !== false) {
        $id = 2;
    } elseif (strpos($url, 'liga') !== false && strpos($url, 'bundesliga') == false) {
        $id = 3;
    } elseif (strpos($url, 'bundesliga') !== false) {
Beispiel #14
0
require_once './libraries/common.lib.php';
function parseInput()
{
    $arrInput = array();
    $arrHeader = array();
    $arrHeader['CONTENT-TYPE'] = $_SERVER['CONTENT_TYPE'];
    $arrHeader['CONTENT-LENGTH'] = $_SERVER['CONTENT_LENGTH'];
    $arrInput['HEADER'] = $arrHeader;
    $arrInput['INPUT'] = file_get_contents('php://input');
    $arrCstParam = array();
    $arrCstParam['REQUEST_URI'] = $_GET['uri'];
    $arrCstParam['ACTION'] = $_GET['act'];
    $arrInput['CSTPARAM'] = $arrCstParam;
    return $arrInput;
}
$arrInput = parseInput();
// echo 'server: '; print_r($_SERVER); echo '<hr />';
// echo 'parsed input: ';print_r($arrInput); echo '<hr />';
broadCast($pdo, $arrInput);
function broadCast($pdo, $p_arrInput)
{
    if ('select' == $p_arrInput['CSTPARAM']['ACTION']) {
    } elseif ('update' == $p_arrInput['CSTPARAM']['ACTION']) {
        // echo 'array input: '; print_r($p_arrInput); echo '<hr />';
        $strSQL = 'select h.host_ip,i.port_num from service s inner join service_mapping m on s.service_id=m.service_id inner join instance i on m.instance_id=i.instance_id inner join host h on h.host_id=i.host_id where service_name=?';
        $sth = $pdo->prepare($strSQL);
        /*
         * $sth->execute(array( 'jp-office-rent' ));
         */
        $sth->execute(array($p_arrInput['CSTPARAM']['REQUEST_URI']));
        $sth->setFetchMode(PDO::FETCH_ASSOC);
     $levelSpokenProduction->appendChild($levels['spoken_production']);
     $levelWriting->appendChild($levels['writing']);
     $level->appendChild($levelListening);
     $level->appendChild($levelReading);
     $level->appendChild($levelSpokenInteraction);
     $level->appendChild($levelSpokenProduction);
     $level->appendChild($levelWriting);
     $language->appendChild($name);
     $language->appendChild($level);
     $languagelist->appendChild($language);
 }
 // 5) skills
 foreach ($_POST['cv']['skills'] as $skl) {
     $skill = $dom->createElement('skill');
     $skill->setAttribute('type', $skl['type']);
     $skl = parseInput($skl, $dom);
     $skill->appendChild($skl['skill']);
     $skilllist->appendChild($skill);
 }
 //append main nodes
 $dom->appendChild($identification);
 $dom->appendChild($workexperiences);
 $dom->appendChild($educationlist);
 $dom->appendChild($languagelist);
 $dom->appendChild($skilllist);
 //echo htmlentities($dom->saveXML());
 //save XML to file
 fwrite($fp, $dom->saveXML());
 fclose($fp);
 //upload the photo
 if ($_FILES['photo']['tmp_name']) {
{
    $title = ucwords($title);
    $result = "<aside><header><h2>{$title}</h2></header><section><ul>";
    $items = preg_split('/\\P{L}+/u', $input, -1, PREG_SPLIT_NO_EMPTY);
    for ($i = 0; $i < count($items); $i++) {
        $result .= "<li><a href='/'>{$items[$i]}</a></li>";
    }
    return "{$result}</ul></section></aside>";
}
define("CATEGORIES", "categories");
define("TAGS", "tags");
define("MONTHS", "months");
if (!empty($_GET[CATEGORIES]) && !empty($_GET[TAGS]) && !empty($_GET[MONTHS])) {
    $firstSidebar = buildSidebarMenu(CATEGORIES, parseInput($_GET[CATEGORIES]));
    $secondSidebar = buildSidebarMenu(TAGS, parseInput($_GET[TAGS]));
    $thirdSidebar = buildSidebarMenu(MONTHS, parseInput($_GET[MONTHS]));
    $result = $firstSidebar . $secondSidebar . $thirdSidebar;
} else {
    $result = '';
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Word Mapping</title>
    <link rel="stylesheet" href="styles/style.css"/>
</head>
<body>
<main>
    <form action="" method="get">
function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '')
{
    global $modx;
    // process any TV commands in value
    $docid = intval($docid) ? intval($docid) : $modx->documentIdentifier;
    $value = ProcessTVCommand($value, $name, $docid);
    $params = array();
    if ($paramstring) {
        $cp = explode("&", $paramstring);
        foreach ($cp as $p => $v) {
            $v = trim($v);
            // trim
            $ar = explode("=", $v);
            if (is_array($ar) && count($ar) == 2) {
                $params[$ar[0]] = decodeParamValue($ar[1]);
            }
        }
    }
    $id = "tv{$name}";
    switch ($format) {
        case 'image':
            $images = parseInput($value, '||', 'array');
            $o = '';
            foreach ($images as $image) {
                if (!is_array($image)) {
                    $image = explode('==', $image);
                }
                $src = $image[0];
                if ($src) {
                    // We have a valid source
                    $attributes = '';
                    $attr = array('class' => $params['class'], 'src' => $src, 'id' => $params['id'] ? $params['id'] : '', 'alt' => htmlspecialchars($params['alttext']), 'style' => $params['style']);
                    if (isset($params['align']) && $params['align'] != 'none') {
                        $attr['align'] = $params['align'];
                    }
                    foreach ($attr as $k => $v) {
                        $attributes .= $v ? ' ' . $k . '="' . $v . '"' : '';
                    }
                    $attributes .= ' ' . $params['attrib'];
                    // Output the image with attributes
                    $o .= '<img' . rtrim($attributes) . ' />';
                }
            }
            break;
        case "delim":
            // display as delimitted list
            $value = parseInput($value, "||");
            $p = $params['format'] ? $params['format'] : " ";
            if ($p == "\\n") {
                $p = "\n";
            }
            $o = str_replace("||", $p, $value);
            break;
        case "string":
            $value = parseInput($value);
            $format = strtolower($params['format']);
            if ($format == 'upper case') {
                $o = strtoupper($value);
            } else {
                if ($format == 'lower case') {
                    $o = strtolower($value);
                } else {
                    if ($format == 'sentence case') {
                        $o = ucfirst($value);
                    } else {
                        if ($format == 'capitalize') {
                            $o = ucwords($value);
                        } else {
                            $o = $value;
                        }
                    }
                }
            }
            break;
        case "date":
            if ($value != '' || $params['default'] == 'Yes') {
                $timestamp = getUnixtimeFromDateString($value);
                $p = $params['format'] ? $params['format'] : "%A %d, %B %Y";
                $o = strftime($p, $timestamp);
            } else {
                $value = '';
            }
            break;
        case "floater":
            $value = parseInput($value, " ");
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/mootools.js", array('name' => 'mootools', 'version' => '1.1.1', 'plaintext' => false));
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/moodx.js", array('name' => 'moodx', 'version' => '0', 'plaintext' => false));
            $class = !empty($params['class']) ? " class=\"" . $params['class'] . "\"" : "";
            $style = !empty($params['style']) ? " style=\"" . $params['style'] . "\"" : "";
            $o .= "\n<div id=\"" . $id . "\"" . $class . $style . ">" . $value . "</div>\n";
            $o .= "<script type=\"text/javascript\">\n";
            $o .= "\twindow.addEvent('domready', function(){\n";
            $o .= "\t\tvar modxFloat = new MooFloater(\$(\"" . $id . "\"),{\n";
            $o .= "\t\t\twidth: '" . $params['width'] . "',\n";
            $o .= "\t\t\theight: '" . $params['height'] . "',\n";
            $o .= "\t\t\tposition: '" . $params['pos'] . "',\n";
            $o .= "\t\t\tglidespeed: " . $params['gs'] . ",\n";
            $o .= "\t\t\toffsetx: " . intval($params['x']) . ",\n";
            $o .= "\t\t\toffsety: " . intval($params['y']) . "\n";
            $o .= "\t\t});\n";
            $o .= "\t});\n";
            $o .= "</script>\n";
            break;
        case "marquee":
            $value = parseInput($value, " ");
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/mootools.js", array('name' => 'mootools', 'version' => '1.1.1', 'plaintext' => false));
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/moodx.js", array('name' => 'moodx', 'version' => '0', 'plaintext' => false));
            $class = !empty($params['class']) ? " class=\"" . $params['class'] . "\"" : "";
            $style = !empty($params['style']) ? " style=\"" . $params['style'] . "\"" : "";
            $o .= "\n<div id=\"" . $id . "\"" . $class . $style . "><div id=\"marqueeContent\">" . $value . "</div></div>\n";
            $o .= "<script type=\"text/javascript\">\n";
            $o .= "\twindow.addEvent('domready', function(){\n";
            $o .= "\t\tvar modxMarquee = new MooMarquee(\$(\"" . $id . "\"),{\n";
            $o .= "\t\t\twidth: '" . $params['width'] . "',\n";
            $o .= "\t\t\theight: '" . $params['height'] . "',\n";
            $o .= "\t\t\tspeed: " . $params['speed'] . ",\n";
            $o .= "\t\t\tmodifier: " . $params['modifier'] . ",\n";
            $o .= "\t\t\tmousepause: '" . $params['pause'] . "',\n";
            $o .= "\t\t\tdirection: '" . $params['tfx'] . "'\n";
            $o .= "\t\t});\n";
            $o .= "\t});\n";
            $o .= "</script>\n";
            break;
        case "ticker":
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/mootools.js", array('name' => 'mootools', 'version' => '1.1.1', 'plaintext' => false));
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/mootools/moostick.js?init=false", array('name' => 'moostick', 'version' => '0', 'plaintext' => false));
            $class = !empty($params['class']) ? " class=\"" . $params['class'] . "\"" : "";
            $style = !empty($params['style']) ? " style=\"" . $params['style'] . "\"" : "";
            $o .= "\n<div id=\"" . $id . "\"" . $class . $style . ">\n";
            if (!empty($value)) {
                $delim = $params['delim'] ? $params['delim'] : "||";
                if ($delim == "\\n") {
                    $delim = "\n";
                }
                $val = parseInput($value, $delim, "array", false);
                if (count($val) > 0) {
                    $o .= "    <ul id=\"" . $id . "Ticker\">\n";
                    for ($i = 0; $i < count($val); $i++) {
                        $o .= "        <li id=\"tickerItem{$i}\">" . $val[$i] . "</li>\n";
                    }
                    $o .= "    </ul>\n";
                }
            }
            $o .= "</div>\n";
            $o .= "<script type=\"text/javascript\">\n";
            $o .= "\twindow.addEvent('domready', function(){\n";
            $o .= "\t\tvar modxTicker = new Moostick(\$(\"" . $id . "Ticker\"), true, " . (!empty($params['delay']) ? $params['delay'] : "true") . ")\n";
            $o .= "\t\t\$(\"" . $id . "Ticker\").setStyle('width','" . $params['width'] . "');\n";
            $o .= "\t\t\$(\"" . $id . "Ticker\").setStyle('height','" . $params['height'] . "');\n";
            $o .= "\t});\n";
            $o .= "</script>\n";
            break;
        case "hyperlink":
            $value = parseInput($value, "||", "array");
            for ($i = 0; $i < count($value); $i++) {
                list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
                if (!$url) {
                    $url = $name;
                }
                if ($url) {
                    if ($o) {
                        $o .= '<br />';
                    }
                    $attributes = '';
                    // setup the link attributes
                    $attr = array('href' => $url, 'title' => $params['title'] ? htmlspecialchars($params['title']) : $name, 'class' => $params['class'], 'style' => $params['style'], 'target' => $params['target']);
                    foreach ($attr as $k => $v) {
                        $attributes .= $v ? ' ' . $k . '="' . $v . '"' : '';
                    }
                    $attributes .= ' ' . $params['attrib'];
                    // add extra
                    // Output the link
                    $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? htmlspecialchars($params['text']) : $name) . '</a>';
                }
            }
            break;
        case "htmltag":
            $value = parseInput($value, "||", "array");
            $tagid = $params['tagid'];
            $tagname = $params['tagname'] ? $params['tagname'] : 'div';
            // Loop through a list of tags
            for ($i = 0; $i < count($value); $i++) {
                $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
                if (!$tagvalue) {
                    continue;
                }
                $attributes = '';
                $attr = array('id' => $tagid ? $tagid : $id, 'class' => $params['class'], 'style' => $params['style']);
                foreach ($attr as $k => $v) {
                    $attributes .= $v ? ' ' . $k . '="' . $v . '"' : '';
                }
                $attributes .= ' ' . $params['attrib'];
                // add extra
                // Output the HTML Tag
                $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
            }
            break;
        case "richtext":
            $value = parseInput($value);
            $w = $params['w'] ? $params['w'] : '100%';
            $h = $params['h'] ? $params['h'] : '400px';
            $richtexteditor = $params['edt'] ? $params['edt'] : "";
            $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
            $o .= htmlspecialchars($value);
            $o .= '</textarea></div>';
            $replace_richtext = array($id);
            // setup editors
            if (!empty($replace_richtext) && !empty($richtexteditor)) {
                // invoke OnRichTextEditorInit event
                $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array('editor' => $richtexteditor, 'elements' => $replace_richtext, 'forfrontend' => 1, 'width' => $w, 'height' => $h));
                if (is_array($evtOut)) {
                    $o .= implode("", $evtOut);
                }
            }
            break;
        case "unixtime":
            $value = parseInput($value);
            $o = getUnixtimeFromDateString($value);
            break;
        case "viewport":
            $value = parseInput($value);
            $id = '_' . time();
            if (!$params['vpid']) {
                $params['vpid'] = $id;
            }
            $sTag = "<iframe";
            $eTag = "</iframe>";
            $autoMode = "0";
            $w = $params['width'];
            $h = $params['height'];
            if ($params['stretch'] == 'Yes') {
                $w = "100%";
                $h = "100%";
            }
            if ($params['asize'] == 'Yes' || $params['awidth'] == 'Yes' && $params['aheight'] == 'Yes') {
                $autoMode = "3";
                //both
            } else {
                if ($params['awidth'] == 'Yes') {
                    $autoMode = "1";
                    //width only
                } else {
                    if ($params['aheight'] == 'Yes') {
                        $autoMode = "2";
                        //height only
                    }
                }
            }
            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array('name' => 'viewport', 'version' => '0', 'plaintext' => false));
            $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
            if ($params['class']) {
                $o .= " class='" . $params['class'] . "' ";
            }
            if ($params['style']) {
                $o .= " style='" . $params['style'] . "' ";
            }
            if ($params['attrib']) {
                $o .= $params['attrib'] . " ";
            }
            $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
            $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
            $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
            $o .= ">";
            $o .= $eTag;
            break;
        case "datagrid":
            include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
            $grd = new DataGrid('', $value);
            $grd->noRecordMsg = $params['egmsg'];
            $grd->columnHeaderClass = $params['chdrc'];
            $grd->cssClass = $params['tblc'];
            $grd->itemClass = $params['itmc'];
            $grd->altItemClass = $params['aitmc'];
            $grd->columnHeaderStyle = $params['chdrs'];
            $grd->cssStyle = $params['tbls'];
            $grd->itemStyle = $params['itms'];
            $grd->altItemStyle = $params['aitms'];
            $grd->columns = $params['cols'];
            $grd->fields = $params['flds'];
            $grd->colWidths = $params['cwidth'];
            $grd->colAligns = $params['calign'];
            $grd->colColors = $params['ccolor'];
            $grd->colTypes = $params['ctype'];
            $grd->cellPadding = $params['cpad'];
            $grd->cellSpacing = $params['cspace'];
            $grd->header = $params['head'];
            $grd->footer = $params['foot'];
            $grd->pageSize = $params['psize'];
            $grd->pagerLocation = $params['ploc'];
            $grd->pagerClass = $params['pclass'];
            $grd->pagerStyle = $params['pstyle'];
            $o = $grd->render();
            break;
        case 'htmlentities':
            $value = parseInput($value);
            if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
                // remove delimiter from checkbox and listbox-multiple TVs
                $value = str_replace('||', '', $value);
            }
            $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
            break;
        case 'custom_widget':
            $widget_output = '';
            $o = '';
            /* If we are loading a file */
            if (substr($params['output'], 0, 5) == "@FILE") {
                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
                if (!file_exists($file_name)) {
                    $widget_output = $file_name . ' does not exist';
                } else {
                    $widget_output = file_get_contents($file_name);
                }
            } elseif (substr($params['output'], 0, 8) == '@INCLUDE') {
                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
                if (!file_exists($file_name)) {
                    $widget_output = $file_name . ' does not exist';
                } else {
                    /* The included file needs to set $widget_output. Can be string, array, object */
                    include $file_name;
                }
            } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
                $chunk_name = trim(substr($params['output'], 7));
                $widget_output = $modx->getChunk($chunk_name);
            } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
                $eval_str = trim(substr($params['output'], 6));
                $widget_output = eval($eval_str);
            } elseif ($value !== '') {
                $widget_output = $params['output'];
            } else {
                $widget_output = '';
            }
            if (is_string($widget_output)) {
                $widget_output = str_replace('[+value+]', $value, $widget_output);
                $o = $modx->parseDocumentSource($widget_output);
            } else {
                $o = $widget_output;
            }
            break;
        default:
            $value = parseInput($value);
            if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
                // add separator
                $value = explode('||', $value);
                $value = implode($sep, $value);
            }
            $o = $value;
            break;
    }
    return $o;
}
/*Parser for the stats_league.html files.
Parameters extracted:

ShotsOnTargetPG, dribbleWonPerGame
*/
require 'helper.php';
//Select leagues to parse
$urls = array();
$urls[] = "stats_serieA_";
$urls[] = "stats_premier_";
$urls[] = "stats_liga_";
$urls[] = "stats_bundesliga_";
echo '<div class="row"><div class="col-md-6">';
foreach ($urls as $url) {
    for ($year = 2010; $year <= 2015; $year++) {
        $league_id = setLeagueId($url);
        $html = file_get_html($url . $year . ".html");
        echo "<br><b>Parsing Stats from " . $url . $year . ".html </b><br>";
        //offensive
        $table = $html->getElementById("statistics-team-table-offensive")->childNodes(0);
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots On Target Per Game", "td[class=shotOnTargetPerGame]", $table, $dataArray, "Offensive", 0, "number");
        parseInput($conn, "Dribbles Won Per Game", "td[class=dribbleWonPerGame]", $table, $dataArray, "Offensive", 0, "number");
        echo "<br><b>Done Parsing Stats from " . $url . $year . ".html </b> <br>";
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";
echo '<a href="home.html#six" class="btn btn-info" role="button">Continue</a>';
echo '</div></div>';
Beispiel #19
0
        unlink($compileDir . '/' . $templateFile);
    }
}
$smarty->compile_dir = $compileDir;
createDir($smarty->compile_dir);
$smarty->clear_all_cache();
if (isset($argv[1]) && !empty($argv[1])) {
    $file = $argv[1];
} else {
    $file = 'schema/Schema.xml';
}
$sqlCodePath = '../sql/';
$phpCodePath = '../';
$tplCodePath = '../templates/';
echo "Parsing input file {$file}\n";
$dbXML = parseInput($file);
//print_r( $dbXML );
echo "Extracting database information\n";
$database =& getDatabase($dbXML);
// print_r( $database );
$classNames = array();
echo "Extracting table information\n";
$tables =& getTables($dbXML, $database);
resolveForeignKeys($tables, $classNames);
$tables = orderTables($tables);
//echo "\n\n\n\n\n*****************************************************************************\n\n";
//print_r(array_keys($tables));
//exit(1);
echo "Generating tests truncate file\n";
$truncate = '<?xml version="1.0" encoding="UTF-8" ?>
<!--  Truncate all tables that will be used in the tests  -->
Parameters extracted:

shotsConcededPerGame, tacklePerGame, interceptionPerGame 
*/
require 'helper.php';
//Select leagues to parse
$urls = array();
$urls[] = "stats_serieA_";
$urls[] = "stats_premier_";
$urls[] = "stats_liga_";
$urls[] = "stats_bundesliga_";
echo '<div class="row"><div class="col-md-6">';
foreach ($urls as $url) {
    $league_id = setLeagueId($url);
    for ($year = 2010; $year <= 2015; $year++) {
        $html = file_get_html($url . $year . ".html");
        echo "<br><b>Parsing Stats from " . $url . $year . ".html </b><br>";
        //defensive
        $table = $html->getElementById("statistics-team-table-defensive")->childNodes(0);
        $dataArray = getTeams($conn, $table, $year, $league_id, "tn");
        parseInput($conn, "Shots Conceded Per Game", "td[class=shotsConcededPerGame]", $table, $dataArray, "Defensive", 0, "number");
        parseInput($conn, "Tackles Per Game", "td[class=tacklePerGame]", $table, $dataArray, "Defensive", 0, "number");
        parseInput($conn, "Interceptions Per Game", "td[class=interceptionPerGame]", $table, $dataArray, "Defensive", 0, "number");
        echo "<br><b>Done Parsing Stats from " . $url . $year . ".html </b> <br>";
    }
}
echo '</div><div class="col-md-6">';
echo "Done Parsing<br>";
echo '<a href="home.html#five" class="btn btn-info" role="button">Continue</a>';
echo '</div></div>';