Example #1
0
<?php

include 'vendor/autoload.php';
use M3uParser\M3uParser;
$obj = new M3uParser();
$files = glob('m3u/*.m3u');
$a = [];
foreach ($files as $file) {
    $data = $obj->parseFile($file);
    foreach ($data as $entry) {
        $suffix = '';
        $normalizedChannelName = normalizeChannelName($entry->getName());
        $normalizedChannelKey = normalizeChannelKey($normalizedChannelName);
        // check if URL is valid
        if (!validUrl($entry->getPath())) {
            echo "'{$normalizedChannelName}' does not have a valid URL; skipping." . PHP_EOL;
            continue;
        }
        // check for duplicate channel names
        if (isset($a[$normalizedChannelKey])) {
            if ($a[$normalizedChannelKey]['path'] == $entry->getPath()) {
                echo "Skipping duplicate entry for '{$normalizedChannelName}'." . PHP_EOL;
                continue;
            }
            // distinguish them by URL hash
            $suffix = ' | ' . sha1($entry->getPath());
        }
        $a[$normalizedChannelKey . $suffix] = ['name' => $normalizedChannelName . $suffix, 'path' => $entry->getPath()];
    }
}
ksort($a);
    $query = mysqli_query($con, $sql);
    $numrows = mysqli_num_rows($query);
    if ($numrows > 0) {
        echo "This evaluation is complete.\n\t\t<br><br>\n\t\t<a href='index.php'>Click here to go back</a>";
        exit;
    }
}
function validUrl($con, $logid, $sub, $st)
{
    $sql = "SELECT * FROM student_results JOIN users ON users.logid='{$logid}' WHERE subj='{$sub}' AND subjteacher='{$st}'";
    $query = mysqli_query($con, $sql);
    $numrows = mysqli_num_rows($query);
    if ($numrows > 0) {
        return true;
    }
    echo "ERROR";
    exit;
}
$sub = mysqli_real_escape_string($con, $_POST['sub']);
$st = mysqli_real_escape_string($con, $_POST['st']);
$gtotal = mysqli_real_escape_string($con, $_POST['gtotal']);
$logid = $_SESSION['logid'];
$userid = $_SESSION['userid'];
$sql = "";
if (validUrl($con, $_SESSION['logid'], $sub, $st)) {
    preventEdit($con, $_SESSION['logid'], $sub, $st);
}
$sql = "UPDATE student_results SET score=" . $gtotal . " WHERE subj='{$sub}' AND subjteacher='{$st}' AND studentkey='{$userid}'";
$query = mysqli_query($con, $sql);
echo 'correct';
mysqli_close($con);
Example #3
0
    $numrows = mysqli_num_rows($query);
    if ($numrows > 0) {
        return true;
    }
    echo "ERROR";
    exit;
}
//ONLY OPTIMIZED FOR FACULTY; PLEASE CHANGE LATER ACCORDINGLY E.G. ADD CHECKS FOR UTYPE
if (!isset($_GET['evtype']) or !isset($_GET['eval']) or !isset($_GET['q'])) {
    echo "ERROR";
    exit;
}
$evtype = mysqli_real_escape_string($con, $_GET['evtype']);
$eval = mysqli_real_escape_string($con, $_GET['eval']);
$quest = mysqli_real_escape_string($con, $_GET['q']);
if (validUrl($con, $evtype, $eval, $quest)) {
    preventEdit($con, $_SESSION['logid'], $evtype, $quest);
}
$sql = "SELECT percent, content FROM {$quest}";
$query = mysqli_query($con, $sql);
$numrows = mysqli_num_rows($query);
if ($numrows == 0) {
    echo "No questions";
    exit;
}
$category = "";
$count = 0;
$eval = urlencode($eval);
$putbackbtn = 0;
while ($row = mysqli_fetch_array($query)) {
    if ($row[0] > 0) {
Example #4
0
require_once 'simplepie.inc';
$config = parse_ini_file('tricklepost.ini');
$feeds = parse_ini_file('feeds.ini', true);
$connection = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_passwd']) or die('Could not connect: ' . mysql_error());
mysql_select_db('tricklepost') or die('Could not select database');
foreach ($feeds as $feed) {
    $feed_data = new SimplePie();
    $feed_data->set_feed_url($feed['uri']);
    $feed_data->enable_cache(false);
    $feed_data->init();
    $feed_data->handle_content_type();
    print "Reading feed: {$feed['uri']} ...\n";
    foreach ($feed_data->get_items() as $item) {
        // make sure the item's URL is good
        $plink = $item->get_permalink();
        if (validUrl($plink)) {
            insertItem($item, $feed['uri'], $feed['username'], $feed['password'], $feed['endpoint']);
        }
    }
}
mysql_close($connection);
print "Done.\n";
function insertItem($item, $feedsource, $username, $password, $endpoint)
{
    global $connection;
    $title = $item->get_title();
    $permalink = $item->get_permalink();
    $itemdate = $item->get_date();
    // Don't bother with incomplete items
    if (empty($title) || empty($permalink) || empty($itemdate)) {
        return;