Example #1
0
        if (isset($_REQUEST['term'])) {
            doFind(false);
        } else {
            doFind(true);
        }
        break;
    case 'sql':
        doSQL();
        break;
    case 'variables':
        doVariables();
        break;
    case 'processes':
        doProcesses();
        break;
    case 'locks':
        doLocks();
        break;
    case 'export':
        doExport();
        break;
    case 'signal':
        doSignal();
        break;
    default:
        if (adminActions($action, 'database') === false) {
            doSQL();
        }
        break;
}
$misc->printFooter();
                while ($row = mysql_fetch_array($result)) {
                    $sessions[$index] = array("sessionId" => $row["sessionId"], "title" => $row["title"], "mediaPath" => retM3U8("session-" . $row["sessionId"] . ".mp4"));
                    $index++;
                }
            }
            echo json_encode(array("exchangeDataState" => constant("RESPONSE_RETRIEVE_MOVIES"), "sessionsInServer" => $sessions));
        });
        break;
    case constant("REQUEST_PLAYLIST_ANDROID"):
        doSQL(function ($con) {
            $result = mysql_query("select sessionId,title,isEnd from Session");
            $vodSessions = array();
            $liveSessions = array();
            $vodIndex = 0;
            $liveIndex = 0;
            if (!$result) {
            } else {
                while ($row = mysql_fetch_array($result)) {
                    if ($row["isEnd"] == 1) {
                        $vodSessions[$vodIndex] = array("sessionId" => $row["sessionId"], "title" => $row["title"], "mediaPath" => retMPD("session-" . $row["sessionId"] . ".mp4", $row["sessionId"]));
                        $vodIndex++;
                    } else {
                        $liveSessions[$liveIndex] = array("sessionId" => $row["sessionId"], "title" => $row["title"], "mediaPath" => retMPD("session-" . $row["sessionId"] . ".mp4", $row["sessionId"]));
                        $liveIndex++;
                    }
                }
            }
            echo json_encode(array("exchangeDataState" => constant("RESPONSE_RETRIEVE_MOVIES"), "vodSessions" => $vodSessions, "liveSessions" => $liveSessions));
        });
        break;
}
            // 	$sessionId=0;
            //	}
            echo json_encode(array('exchangeDataState' => constant('RESPONSE_UPLOAD_SESSION_ID'), 'sessionId' => $sessionId));
        });
        break;
    case constant("REQUEST_TO_UPLOAD"):
        $target_dir = "./video_repo/";
        $upload_file = $_FILES["uploadFile"];
        //$target_path = $target_dir . basename($request->{"segmentName"});
        $file_name = "session-" . $request->{'sessionId'} . ".mp4_" . $request->{'segmentId'};
        $target_path = $target_dir . $file_name;
        if (move_uploaded_file($upload_file["tmp_name"], $target_path)) {
            doSQL(function ($con) use(&$request, &$target_path, &$upload_file, &$file_name) {
                $result = mysql_query("INSERT INTO Segment(segmentId,sessionId,path,duration,timeScale,lengthInSecond,isEnd) VALUES('" . $request->{"segmentId"} . "','" . $request->{"sessionId"} . "','" . $file_name . "','" . $request->{"duration"} . "','" . $request->{"timeScale"} . "','" . $request->{"lengthInSecond"} . "','" . $request->{"isEnd"} . "')");
                if (!$result) {
                    echo json_encode(array('exchangeDataState' => constant("RESPONSE_UPLOAD_FAIL")));
                } else {
                    doTranscode($target_path, $request->{"lengthInSecond"}, $request->{"isEnd"});
                    if ($request->{"isEnd"} == 1) {
                        mysql_query("UPDATE Session set isEnd=1 where sessionId = " . $request->{"sessionId"});
                    }
                    echo json_encode(array('exchangeDataState' => constant("RESPONSE_UPLOAD_SUCCESS")));
                }
            });
        } else {
            echo json_encode(array('exchangeDataState' => constant("RESPONSE_UPLOAD_FAIL")));
        }
        break;
    default:
        echo "error";
}
Example #4
0
<?php

require '../../phpinclude/init.php';
// get, check and clean inputs
$email = check_text_input($_POST['email'], 1, 255, "Email", "/public/signin.php?err");
$password = check_text_input($_POST['password'], 1, 32, "Password", "/public/signin.php?err");
dbconnect(0);
// email exists?
$result = doSQL("select userID, password from users where email=?;", $email) or die("ERR");
if (!is_array($result)) {
    // error, email inexistent
    header("Location: /public/signin.php?err=1");
    exit;
}
// get password
$row = $result[0];
// check hash
$passwordok = 0;
if (crypt($password, $row['password']) === $row['password']) {
    $passwordok = 1;
}
if ($passwordok == 0) {
    // error, password wrong
    header("Location: /public/signin.php?err=1");
    exit;
}
// sign in
sessionstart($row['userID']);
header("Location: /account/index.php?signin=1");
Example #5
0
    do_err($erraddr3, "Email in use");
}
// check username still available
$result = doSQL("select * from users where username=?;", $username) or do_err($erraddr1, "Database Error");
if (is_array($result)) {
    // no, exists, quit
    do_err($erraddr1, "Username in use");
}
// check recaptcha
$rcc = $_POST["rcc"];
$rcr = $_POST["rcr"];
$rch = base64_decode($_POST["rch"]);
$rcstr = $_SERVER["REMOTE_ADDR"] . "836429" . $rcc . "7364528" . $rcr;
if (!(crypt($rcstr, $rch) === $rch)) {
    do_err($erraddrrc, "The reCAPTCHA was wrong " . $rcerr);
}
// hash password
// create a random salt
$salt = "\$2y\$10\$" . bin2hex(openssl_random_pseudo_bytes(22));
// Hash the password with the salt
$hash = crypt($password, $salt);
// insert user
$result = doSQL("insert into users (username, password, email) values (?, ?, ?);", $username, $hash, $email) or do_err($erraddr3, "Database Error");
$nid = $db->insert_id;
// signin
sessionstart($nid);
// jump
header('Location: ../account/index.php?signup=1');
?>

Example #6
0
</head>
<body>

<center>

<br><h2>Sending Email...</h2>

<?php 
// send test email
$to = $_GET['predef'];
if (isset($_GET['dyn'])) {
    if (!($_GET['dyn'] == "")) {
        $to = $_GET['dyn'];
    }
}
$result = doSQL("insert into sendemails (userID, sendto, sendfrom, sendsubject, sendmessage) values (?, ?, ?, ?, ?)", 1, $to, $global_sendemailfrom, "Admin Email Test", "Testing 123...") or die("Error");
?>

Sent to <?php 
echo $to;
?>

<br><br>

Check the sendemails database table.

<br><br>

</center>

Example #7
0
    $sql = doSQL("select count(*) as tot from snsnotifications where messageid=?", $messageid) or die("error1");
    $tot = 0;
    if (!is_array($sql)) {
        $tot = 0;
    } else {
        $tot = $sql[0]['tot'];
        $tot = $tot == "" ? 0 : $tot;
    }
    if ($tot > 0) {
        exit;
    }
    // new message
    $subject = "";
    if (isset($msg['Subject'])) {
        $subject = $msg['Subject'];
    }
    $message = "";
    if (isset($msg['Message'])) {
        $message = $msg['Message'];
    }
    $result = json_decode($message, true);
    if ($result['notificationType'] == "Complaint") {
        $emailaddr = $result['complaint']['complainedRecipients'][0]['emailAddress'];
        doSQL("insert into snsnotifications (messageid, subject, message, email) values (?, ?, ?, ?);", $messageid, $subject, $message, $emailaddr) or die("error2");
        $nid = $db->insert_id;
        doSQL("update users set emailcomplaint=? where email=?;", $nid, $emailaddr) or die("error3");
        exit;
    }
    // if we get here nothing has been inserted to snsnotifications, insert for posterity
    doSQL("insert into snsnotifications (messageid, subject, message, email) values (?, ?, ?, ?);", $messageid, $subject, $message, "") or die("error4");
}
Example #8
0
<?php

// an example of how to do a scheduled page
// this page is 'cron'ed in aws/ami/admin/install_admin_template.php
// output is piped to a log file (/var/log/ataglance.log)
// with /usr/bin/logger
// can be called without signing in
$signin = 1;
require "../init.php";
// these will be sent to the log file
ini_set("show_errors", 1);
// do a listing of log files
$logdir = "/var/log/";
$logs = array("adminhttpderr.log", "webhttpderr.log", "javamail.log", "adminhttpd.log", "webhttpd.log", "ataglance.log");
foreach ($logs as $log) {
    $output = shell_exec('ls -lart ' . $logdir . $log . ' 2>&1');
    $msg .= $output . "\n";
    $output = shell_exec('tail -n 3 ' . $logdir . $log . ' 2>&1');
    $msg .= $output . "\n\n";
}
// send them in an email
$result = doSQL("insert into sendemails (userID, sendto, sendfrom, sendsubject, sendmessage) values (?, ?, ?, ?, ?)", 1, $global_sendemailfrom, $global_sendemailfrom, "At A Glance", $msg) or die("Error");
// send a message to the logfile
echo "At a glance done";
{
    if (is_array($nresult)) {
        echo "<table border=1 cellspacing=0 cellpadding=5>";
        $keys = array_keys($nresult[0]);
        echo "<tr bgcolor='cccccc'>";
        foreach ($keys as $key) {
            echo "<td>" . $key . "</td>";
        }
        echo "</tr>";
        foreach ($nresult as $row) {
            echo "<tr>";
            foreach ($row as $value) {
                echo "<td>" . $value . "</td>";
            }
            echo "</tr>";
        }
        echo "</table><br>";
    } else {
        echo "<table border=1 cellspacing=0 cellpadding=5><tr bgcolor='cccccc'><td>{$ntablename} No Data</td></tr></table><br>";
    }
}
// read the slow queries table
$result = doSQL("select * from mysql.slow_log order by start_time asc;") or die("Query failed : " . mysql_error());
printtable($result, "slow_log");
?>

</center>

</body>
</html>
function sendemail($nuserID, $nto, $nsubject, $nmessage)
{
    global $global_sendemailfrom;
    // check not bouncer or complainer
    $result = doSQL("select emailbounce, emailcomplaint from users where userID=?;", $nuserID) or do_std_err("Error getting mail details");
    if (!is_array($result)) {
        do_std_err("Error getting mail details");
    }
    if ($result[0]['emailbounce'] > 0) {
        do_std_err("Email has Bounced previous emails");
    }
    if ($result[0]['emailcomplaint'] > 0) {
        do_std_err("Email has Complained about previous emails");
    }
    // send
    $emsg = $nmessage . "\n\nThanks\n";
    $result = doSQL("insert into sendemails (userID, sendto, sendfrom, sendsubject, sendmessage) values (?, ?, ?, ?, ?)", $nuserID, $nto, $global_sendemailfrom, $nsubject, $emsg) or do_std_err("Error sending mail");
}
Example #11
0
function sessionend($nuserID)
{
    // session can at most last x seconds, eg 1 week = 604800 seconds
    global $global_sessionmaxtime;
    // send 2 dud cookies
    setcookie("TOKEN1", "0", time() + $global_sessionmaxtime, "/");
    setcookie("TOKEN2", "0", time() + $global_sessionmaxtime, "/");
    // wipe data in the database
    $result = doSQL("update users set sessiontoken1='', sessiontoken2='', sessionipaddress='', sessionuseragent='', sessionlastdateSQL=now() where userID=?;", $nuserID) or die("ERR");
    return array();
}
    echo "EMPTY";
    exit;
}
if (strlen($username) > 16) {
    echo "LONG";
    exit;
}
$illegal = check_legal_chars($username);
if ($illegal == "Illegal Input") {
    echo "ILL";
    exit;
}
// check any reserved words
if (in_array(strtolower($username), $global_reserved_usernames)) {
    echo "TAKEN";
    exit;
}
// username exists?
dbconnect(0);
$result = doSQL("select * from users where username=?;", $username) or die("ERR");
if (is_array($result)) {
    // exists
    echo "TAKEN";
} else {
    // available
    if ($submit == 1) {
        echo "SUB";
    } else {
        echo "AVAIL";
    }
}
<?php

require "helper.php";
$queryString = $_SERVER["QUERY_STRING"];
$strings = explode("_", $queryString);
$quality = $strings[0];
$sessionId = $strings[1];
$segmentId = $strings[2];
doSQL(function ($con) use(&$quality, &$sessionId, &$segmentId) {
    $result = mysql_query("select isEnd from Segment where sessionId={$sessionId} and segmentId= {$segmentId}");
    if (!$result) {
        echo json_encode(array('exchangeDataState' => constant("WAITING")));
    } else {
        if (mysql_num_rows($result) == 0) {
            echo json_encode(array('exchangeDataState' => constant("WAITING")));
        } else {
            $mp4URL = "http://pilatus.d1.comp.nus.edu.sg/~team01/video_repo/{$quality}/session-{$sessionId}.mp4_{$segmentId}.mp4";
            $result = mysql_fetch_array($result);
            if ($result["isEnd"] == 0) {
                echo json_encode(array("exchangeDataState" => constant("PLAYABLE"), "mp4URL" => $mp4URL));
            } else {
                echo json_encode(array("exchangeDataState" => constant("PLAYABLE_WITH_END"), "mp4URL" => $mp4URL));
            }
        }
    }
});