Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('config.php');
- $app_name = "phpMyFB";
- function mySerialize($obj) {
- return base64_encode(gzcompress(serialize($obj)));
- }
- function myUnserialize($txt) {
- return unserialize(gzuncompress(base64_decode($txt)));
- }
- function login_form($showjs = false) {
- global $app_name;
- ?>
- <html>
- <style>
- body,td,th {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 10px;
- color: #000000;
- }
- </style>
- <?php
- if ($showjs == true) {
- echo '<script>alert(\'Invalid Password Specified\');</script>';
- }
- ?>
- <center>
- <h2>Login to <?php echo $app_name; ?> Admin</h2><br/><br/>
- <form method="POST" action="admin.php">
- Password: <input type="password" name="adminpass"> <input type="submit" value="Login">
- </form>
- </center>
- </html>
- <?php
- }
- if (isset($_GET['logout'])) {
- setcookie("devswift_admin",$_POST['adminpass'],time()-3600);
- login_form();
- exit;
- }
- if (isset($_POST['adminpass'])) {
- if ($_POST['adminpass'] == $admin_pass) {
- setcookie("devswift_admin",$_POST['adminpass'],time()+86400);
- $_COOKIE['devswift_admin'] = $admin_pass;
- }
- else
- {
- login_form(true);
- exit;
- }
- }
- if (!isset($_COOKIE['devswift_admin'])) {
- login_form();
- exit;
- }
- else
- {
- if ($_COOKIE['devswift_admin'] != $admin_pass) {
- login_form();
- exit;
- }
- }
- //$lickey = $license_key;
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
- <head>
- <title><?php echo $app_name; ?> Admin</title>
- <style>
- body {
- font-family:"lucida grande", tahoma, verdana, arial, sans-serif;
- font-size: 12px;
- }
- a {
- color: #3b5998;
- text-decoration: none;
- }
- a:hover {
- text-decoration: underline;
- }
- a:visited {
- color: #3b5998;
- }
- td {
- padding-right: 12px;
- }
- </style>
- </head>
- <body>
- <center>
- <table>
- <tr><td colspan=2><h2><?php echo $app_name; ?> Admin Panel</h2></td></tr>
- <tr><td width=200 valign="top">
- <div style="border: 1px solid #3b5998; width: 200px; padding: 15px;">
- <center><font style="font-size: 16px;"><b>Admin Menu</b></font></center><br/>
- <img src="images/applications.png" align=ABSMIDDLE> <a href="?page=apps">Applications</a> (<a href="?page=addapp">Add</a>)<br/><br/>
- <img src="images/image_templates.png" align=ABSMIDDLE> <a href="?page=images">Image Templates</a> (<a href="?page=addimage">Add</a>)<br/><br/>
- <img src="images/domains.png" align=ABSMIDDLE> <a href="?page=domains">Manage Domains</a><br/><br/>
- <img src="images/stats.png" align=ABSMIDDLE> <a href="?page=stats">App Statistics</a><br/><br/>
- <img src="images/spin.png" align=ABSMIDDLE> <a href="?page=spin">App Spinners</a> (<a href="?page=addspin">Add</a>)
- </div></td><td valign="top" width=800 style="padding-left: 5px;">
- <div style="border: 1px solid #3b5998; width: 800px; padding: 15px;">
- <?php
- //$lickey = file_get_contents ("http://devswift.com/phpmyfb-license/checkkey.php?key=".$lickey);
- //if ($lickey != "valid") {
- // echo "Your license key appears to be invalid";
- // exit;
- //}
- if (!isset($_GET['page'])) {
- $query = mysql_query("SELECT COUNT(*) FROM `domains`");
- $row = mysql_fetch_assoc($query);
- if ($row['COUNT(*)'] > 0) {
- $query = mysql_query("SELECT COUNT(*) FROM `images`");
- $row = mysql_fetch_assoc($query);
- if ($row['COUNT(*)'] == 0) {
- $_GET['page'] = "addimage";
- }
- else
- {
- $_GET['page'] = "apps";
- }
- }
- else
- {
- $_GET['page'] = "domains";
- }
- }
- if ($_GET['page'] == "images") {
- if (isset($_GET['del'])) {
- $query = mysql_query("SELECT `id`, `app_name` FROM `apps` WHERE `image` = '".addslashes($_GET['del'])."'");
- if (mysql_affected_rows() < 1) {
- mysql_query("DELETE FROM `images` WHERE `id` = '".addslashes($_GET['del'])."' LIMIT 1");
- }
- else
- {
- echo '<font color="red">Error: Image currently assigned to:<br/><br/>';
- while ($row = mysql_fetch_assoc($query)) { echo stripslashes($row['app_name']).' (ID: '.$row['id'].')<br/>'; }
- echo '<br/></font>';
- }
- }
- echo '<b>Image Templates</b><br/>';
- $query = mysql_query("SELECT * FROM `images`");
- if (mysql_affected_rows() > 0) {
- echo '<br/><table><tr><td><b>ID</b></td><td><b>Name</b></td><td><b>Image</b></td><td> </td></tr>';
- while ($row = mysql_fetch_assoc($query)) {
- echo '<tr><td>'.$row['id'].'</td><td>'.stripslashes($row['name']).'</td>';
- echo '<td><a target="_blank" href="src_images/'.$row['file'].'">'.stripslashes($row['file']).'</a></td>';
- echo '<td><a href="?page=editimage&id='.$row['id'].'"><img src="images/edit.png" border=0 alt="Edit"></a> <a href="?page=images&del='.$row['id'].'" onclick="return confirm(\'Are you sure you want to delete?\');"><img src="images/delete.png" border=0 alt="Delete"></a></td>';
- echo '</tr>';
- }
- echo '</table><br/><br/>';
- }
- else
- {
- echo '<i>No images found in database.</i><br/><br/>';
- }
- }
- if ($_GET['page'] == "addimage") {
- if (isset($_POST['name'])) {
- $error = "";
- if ($_POST['name'] == "") { $error = "You must name the image template"; }
- if ($_FILES['image']['tmp_name'] == "") {
- $error = "Required fields are mark with an astrick (*).<br/>";
- }
- else
- {
- $ext = strrev($_FILES['image']['name']);
- $ext = str_replace(strstr($ext,"."),"",$ext);
- $ext = strtolower(strrev($ext));
- $filename = time().".".$ext;
- if ($ext != "jpg" && $ext != "jpeg") { $error .= "All image uploads must be in JPG format"; }
- if (!(move_uploaded_file($_FILES['image']['tmp_name'],"src_images/".$filename))) { $error = "File would not upload, check src_images chmod settings (*).<br/>"; }
- }
- if ($error == "") {
- mysql_query("INSERT INTO `images` VALUES(null,'".addslashes($_POST['name'])."','".$filename."');") or die(mysql_error());
- echo 'Image successfully added. <a href="admin.php?page=editimage&id='.mysql_insert_id().'">Click here</a> to continue...<br/><br/>';
- echo '<script>top.location.href = "admin.php?page=editimage&id='.mysql_insert_id().'"</script>';
- $hideform = true;
- }
- else
- {
- echo '<font color="red">'.$error.'</font><br/>';
- }
- }
- if (!isset($hideform)) {
- ?>
- <b>Start by uploading an image...</b><br/><br/>
- <form method="POST" action="admin.php?page=addimage" enctype="multipart/form-data">
- <table>
- <tr><td>Name:</td><td><input type="text" name="name"></td></tr>
- <tr><td>Image JPG:</td><td><input type="file" name="image"></td></tr>
- </table>
- <input type="submit" value="Upload Image">
- </form>
- <?php
- }
- }
- if ($_GET['page'] == "editimage") {
- ?>
- <script>
- function updateXY(type,x,y) {
- if (type == "profilepic") {
- document.getElementById('addppx').value = x;
- document.getElementById('addppy').value = y;
- }
- if (type == "randfriend") {
- document.getElementById('addfriendppx').value = x;
- document.getElementById('addfriendppy').value = y;
- }
- if (type == "text") {
- document.getElementById('randtxtx').value = x;
- document.getElementById('randtxty').value = y;
- }
- }
- </script>
- <b>Edit Image Actions</b><br/><br/>
- <script>
- function strstr(haystack, needle, bool) {
- var pos = 0;
- haystack += "";
- pos = haystack.indexOf(needle); if (pos == -1) {
- return false;
- } else {
- if (bool) {
- return haystack.substr(0, pos);
- } else {
- return haystack.slice(pos);
- }
- }
- }
- function selectCoords(type) {
- if (type == "profilepic") {
- var url = "getcoords.php?id=<?php echo $_GET['id']; ?>&type=profilepic";
- } else if (type == "randfriend") {
- var url = "getcoords.php?id=<?php echo $_GET['id']; ?>&type=randfriend";
- } else if (type == "randtxt") {
- var w = document.getElementById('randtxtalign').selectedIndex;
- var selected_text = document.getElementById('randtxtalign').options[w].text;
- var w = document.getElementById('randtxtfont').selectedIndex;
- var font = document.getElementById('randtxtfont').options[w].text;
- var url = "getcoords.php?id=<?php echo $_GET['id']; ?>&type=text&align=" + selected_text + "&color=" + document.getElementById('randtxtcolor').value;
- url = url + "&font=" + font + "&fontsize=" + document.getElementById('randtxtsize').value;
- } else {
- var url = "getcoords.php?id=<?php echo $_GET['id']; ?>&type=text";
- }
- window.open(url, "", "resizable=1,HEIGHT=100,WIDTH=100");
- }
- </script>
- <center>
- <table style="border: 1px solid #000000; margin-top: 5px;" width="90%">
- <tr><td colspan=3 style="text-align: center; padding: 5px; border-bottom: 1px solid #000;"><b>Add Active User's Profile Picture</b></td></tr>
- <tr>
- <td rowspan=2 width=300 style="padding-left: 30px;">
- This function copies 50x50 thumbnail of users profile picture over the image at the following coordinates:<br/><br/>
- <div style="float: left;"><a href="javascript:addAction('userPP');"><b>[Add New Action]</b></a></div><div style="float: right;"><a href="javascript:selectCoords('profilepic');">Select Coordinates</a></div></td>
- <td style="padding-left: 5px;">X:</td>
- <td style="padding-right: 30px;"><input type="text" size=3 name="addppx" id="addppx" value="<?php if (isset($_POST['addppx'])) { echo $_POST['addppx']; } ?>">
- </td>
- </tr>
- <tr>
- <td style="padding-left: 5px;">Y:</td>
- <td style="padding-right: 30px;"><input type="text" size=3 name="addppy" id="addppy" value="<?php if (isset($_POST['addppy'])) { echo $_POST['addppy']; } ?>"></td>
- </tr>
- <tr><td colspan=3 style="border-top: 1px solid #000; padding: 10px;">
- <div id="userPPdiv" style="text-align: center; width: 100%;"><i>Action list not loaded yet</i></div>
- </td></tr>
- </table></center><br/>
- <script>
- function listUpdate(type) {
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser broke!");
- return false;
- }
- }
- }
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var responsee = ajaxRequest.responseText;
- document.getElementById(type + 'div').innerHTML = responsee;
- }
- }
- var queryString = "admin-ajax-" + type + ".php?id=<?php echo $_GET['id']; ?>";
- ajaxRequest.open("GET", queryString, true);
- ajaxRequest.send(null);
- }
- function delAction(id) {
- if (!confirm("Are you sure you want to delete this action?")) {
- return false;
- }
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser broke!");
- return false;
- }
- }
- }
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var responsee = ajaxRequest.responseText;
- }
- }
- var queryString = "admin-ajax-del-action.php?id=" + id;
- ajaxRequest.open("GET", queryString, true);
- ajaxRequest.send(null);
- refreshLists();
- }
- function showData(id) {
- if (document.getElementById('dataDiv' + id).innerHTML != "") {
- document.getElementById('dataDiv' + id).innerHTML = "";
- document.getElementById('dataLink' + id).innerHTML = "Show Data";
- return false;
- }
- else
- {
- document.getElementById('dataLink' + id).innerHTML = "Hide Data";
- }
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser broke!");
- return false;
- }
- }
- }
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var responsee = ajaxRequest.responseText;
- var jsObject = JSON.parse(responsee);
- document.getElementById('dataDiv' + id).innerHTML = decode64(jsObject.data);
- }
- }
- var queryString = "admin-ajax-getdata.php?id=" + id;
- ajaxRequest.open("GET", queryString, true);
- ajaxRequest.send(null);
- }
- function refreshLists() {
- listUpdate('userPP');
- listUpdate('friendPP');
- listUpdate('randtxt');
- }
- function addAction(type) {
- document.getElementById(type + 'div').innerHTML = '<img src="images/ajax.gif" align=ABSMIDDLE"> Processing your request...';
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser broke!");
- return false;
- }
- }
- }
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var responsee = ajaxRequest.responseText;
- refreshLists();
- }
- }
- var getString = "?id=<?php echo $_GET['id']; ?>";
- if (type == "userPP") {
- if (document.getElementById('addppx').value == "") {
- alert("Missing X value");
- refreshLists();
- return false;
- }
- if (document.getElementById('addppy').value == "") {
- alert("Missing Y value");
- refreshLists();
- return false;
- }
- getString = getString + "&x=" + document.getElementById('addppx').value;
- getString = getString + "&y=" + document.getElementById('addppy').value;
- document.getElementById('addppx').value = "";
- document.getElementById('addppy').value = "";
- }
- if (type == "friendPP") {
- if (document.getElementById('addfriendppx').value == "") {
- alert("Missing X value");
- refreshLists();
- return false;
- }
- if (document.getElementById('addfriendppy').value == "") {
- alert("Missing Y value");
- refreshLists();
- return false;
- }
- getString = getString + "&x=" + document.getElementById('addfriendppx').value;
- getString = getString + "&y=" + document.getElementById('addfriendppy').value;
- document.getElementById('addfriendppx').value = "";
- document.getElementById('addfriendppy').value = "";
- }
- if (type == "randtxt") {
- if (document.getElementById('randtxtx').value == "") {
- alert("Missing X value");
- refreshLists();
- return false;
- }
- if (document.getElementById('randtxty').value == "") {
- alert("Missing Y value");
- refreshLists();
- return false;
- }
- if (document.getElementById('randtxtarea').value == "") {
- alert("Missing lines of random text");
- refreshLists();
- return false;
- }
- if (document.getElementById('randtxtsize').value == "") {
- alert("Missing font size value");
- refreshLists();
- return false;
- }
- }
- if (type == "randtxt") {
- var postString = "id=<?php echo $_GET['id']; ?>&x=" + document.getElementById('randtxtx').value;
- postString = postString + "&y=" + document.getElementById('randtxty').value;
- postString = postString + "&size=" + document.getElementById('randtxtsize').value;
- postString = postString + "&align=" + document.getElementById('randtxtalign').value;
- postString = postString + "&font=" + document.getElementById('randtxtfont').value;
- postString = postString + "&color=" + document.getElementById('randtxtcolor').value;
- postString = postString + "&width=" + document.getElementById('randtxtwidth').value;
- postString = postString + "&data=" + document.getElementById('randtxtarea').value;
- var queryString = "admin-ajax-add-" + type + ".php";
- ajaxRequest.open("POST", queryString, true);
- ajaxRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
- ajaxRequest.send(postString);
- }
- else
- {
- var queryString = "admin-ajax-add-" + type + ".php" + getString;
- ajaxRequest.open("GET", queryString, true);
- ajaxRequest.send(null);
- }
- document.getElementById('addppx').value = "";
- document.getElementById('addppy').value = "";
- document.getElementById('addfriendppx').value = "";
- document.getElementById('addfriendppy').value = "";
- document.getElementById('randtxty').value = "";
- document.getElementById('randtxtx').value = "";
- document.getElementById('randtxtwidth').value = "";
- document.getElementById('randtxtarea').value = "";
- refreshLists();
- }
- function editAction(id) {
- if (!confirm("Are you sure you want to edit this action? This function deletes the current action and prefills the create form with the action's values")) {
- return false;
- }
- var ajaxRequest;
- try{
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- alert("Your browser broke!");
- return false;
- }
- }
- }
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var responsee = ajaxRequest.responseText;
- var jsObject = JSON.parse(responsee);
- document.getElementById('randtxtx').value = jsObject.x;
- document.getElementById('randtxty').value = jsObject.y;
- document.getElementById('randtxtcolor').value = jsObject.color;
- document.getElementById('randtxtcolor').style.backgroundColor = "#" + jsObject.color;
- document.getElementById('randtxtsize').value = jsObject.size;
- document.getElementById('randtxtwidth').value = jsObject.width;
- document.getElementById('randtxtarea').value = str_replace("<br/>","",decode64(jsObject.data),1);
- var opts = document.getElementById('randtxtfont').getElementsByTagName('option');
- for (var i=0;i<opts.length;i++){
- opts[i].selected = (opts[i].value == jsObject.font ? "selected" : "");
- }
- var opts = document.getElementById('randtxtalign').getElementsByTagName('option');
- for (var i=0;i<opts.length;i++){
- opts[i].selected = (opts[i].value == jsObject.align ? "selected" : "");
- } var opts = document.getElementById('randtxtfont').getElementsByTagName('option');
- delAction(id);
- refreshLists();
- }
- }
- var queryString = "admin-ajax-getdata.php?id=" + id;
- ajaxRequest.open("GET", queryString, true);
- ajaxRequest.send(null);
- }
- function decode64(data) {
- var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
- var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
- ac = 0,
- dec = "",
- tmp_arr = [];
- if (!data) {
- return data;
- }
- data += '';
- do { // unpack four hexets into three octets using index points in b64
- h1 = b64.indexOf(data.charAt(i++));
- h2 = b64.indexOf(data.charAt(i++));
- h3 = b64.indexOf(data.charAt(i++));
- h4 = b64.indexOf(data.charAt(i++));
- bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
- o1 = bits >> 16 & 0xff;
- o2 = bits >> 8 & 0xff;
- o3 = bits & 0xff;
- if (h3 == 64) {
- tmp_arr[ac++] = String.fromCharCode(o1);
- } else if (h4 == 64) {
- tmp_arr[ac++] = String.fromCharCode(o1, o2);
- } else {
- tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
- }
- } while (i < data.length);
- dec = tmp_arr.join('');
- dec = this.utf8_decode(dec);
- return dec;
- }
- function utf8_decode (str_data) {
- var tmp_arr = [],
- i = 0,
- ac = 0,
- c1 = 0,
- c2 = 0,
- c3 = 0;
- str_data += '';
- while (i < str_data.length) {
- c1 = str_data.charCodeAt(i);
- if (c1 < 128) {
- tmp_arr[ac++] = String.fromCharCode(c1);
- i++;
- } else if (c1 > 191 && c1 < 224) {
- c2 = str_data.charCodeAt(i + 1);
- tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
- i += 2;
- } else {
- c2 = str_data.charCodeAt(i + 1);
- c3 = str_data.charCodeAt(i + 2);
- tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
- i += 3;
- }
- }
- return tmp_arr.join('');
- }
- function str_replace (search, replace, subject, count) {
- var i = 0,
- j = 0,
- temp = '',
- repl = '',
- sl = 0,
- fl = 0,
- f = [].concat(search),
- r = [].concat(replace),
- s = subject,
- ra = Object.prototype.toString.call(r) === '[object Array]',
- sa = Object.prototype.toString.call(s) === '[object Array]';
- s = [].concat(s);
- if (count) {
- this.window[count] = 0;
- }
- for (i = 0, sl = s.length; i < sl; i++) {
- if (s[i] === '') {
- continue;
- }
- for (j = 0, fl = f.length; j < fl; j++) {
- temp = s[i] + '';
- repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
- s[i] = (temp).split(f[j]).join(repl);
- if (count && s[i] !== temp) {
- this.window[count] += (temp.length - s[i].length) / f[j].length;
- }
- }
- }
- return sa ? s : s[0];
- }
- refreshLists();
- </script>
- <script type="text/javascript" src="jscolor/jscolor.js"></script>
- <center>
- <table style="border: 1px solid #000000; margin-top: 5px;" width="90%">
- <tr><td colspan=3 style="text-align: center; padding: 5px; border-bottom: 1px solid #000;"><b>Add Random Friend's Profile Pic (and Name)</b></td></tr>
- <tr>
- <td rowspan=2 width=300 style="padding-left: 30px;">
- This function copies 50x50 thumbnail of a random friend's profile pic and stores the friend's name in a dynamic tag for use in Random Text function below:<br/><br/>
- <div style="float: left;"><a href="javascript:addAction('friendPP');"><b>[Add New Action]</b></a></div><div style="float: right;"><a href="javascript:selectCoords('randfriend');">Select Coordinates</a></div></td>
- <td style="padding-left: 5px;">X:</td>
- <td style="padding-right: 30px;"><input type="text" size=3 name="addfriendppx" id="addfriendppx"></td>
- </tr>
- <tr>
- <td style="padding-left: 5px;">Y:</td>
- <td style="padding-right: 30px;"><input type="text" size=3 name="addfriendppy" id="addfriendppy"></td>
- </tr>
- <tr><td colspan=3 style="border-top: 1px solid #000; padding: 10px;">
- <div id="friendPPdiv" style="text-align: center; width: 100%;"><i>Action list not loaded yet</i></div>
- </td></tr>
- </table></center><br/>
- <center>
- <table style="border: 1px solid #000000; margin-top: 5px;" width="90%">
- <tr><td colspan=7 style="text-align: center; padding: 5px; border-bottom: 1px solid #000;"><b>Add Text (randomly picked by line)</b></td></tr>
- <tr><td colspan=7 style="text-align: center;">This function selects a random line from inputted text and copies it onto image:</td></tr>
- <tr>
- <td style="padding-left: 5px;">X:</td><td style="padding-right: 15px;"><input type="text" size=3 name="randtxtx" id="randtxtx"></td>
- <td nowrap="nowrap">Text Align:</td><td><select name="randtxtalign" id="randtxtalign"><option value="left">Left</option><option value="center">Center</option><option value="right">Right</option></select></td>
- <td>Font:</td><td style="padding-right: 15px;"><select name="randtxtfont" id="randtxtfont"><?php
- if ($handle = opendir('fonts')) {
- while (false !== ($entry = readdir($handle))) {
- if ($entry != "." && $entry != ".." && strstr($entry,".ttf")) {
- $entry = str_replace(".ttf","",$entry);
- echo '<option value="'.$entry.'">'.$entry.'</option>';
- }
- }
- closedir($handle);
- }
- ?></select></td>
- <td rowspan=2>
- Color:<br/>
- <input type="text" class="color" name="randtxtcolor" id="randtxtcolor" size=4 value="000000">
- </td>
- </tr>
- <tr>
- <td style="padding-left: 5px;">Y:</td><td style="padding-right: 15px;"><input type="text" size=3 name="randtxty" id="randtxty"></td>
- <td>Wrap Width:</td><td style="padding-right: 15px;"><input type="text" size=3 name="randtxtwidth" id="randtxtwidth">px</td>
- <td nowrap="nowrap">Font Size:</td><td><input type="text" size=2 name="randtxtsize" id="randtxtsize" value="14">pt</td>
- </tr>
- <tr><td colspan=7 style="border-top: 1px solid #000; padding: 10px;">
- <center><textarea wrap="off" id="randtxtarea" style="width: 90%; height: 150px;" name="randtxtarea"></textarea><br/><br/>
- <a href="javascript:void(0);" onclick="javascript:selectCoords('randtxt');">Select Coordinates</a> -
- <a href="javascript:void(0);" onclick="javascript:window.open('dynamic_tags.php', 'myWindow', 'status = 1, height = 300, width = 300, resizable = 0');">Dynamic Tags & Functions</a> -
- <a href="javascript:void(0);" onclick="addAction('randtxt');"><b>[Add New Action]</b></a>
- </center>
- </td></tr>
- <td colspan=7 style="border-top: 1px solid #000; padding: 10px;">
- <div id="randtxtdiv" style="text-align: center; width: 100%;"><i>Action list not loaded yet</i></div>
- </td></tr>
- </table></center><br/>
- <?php
- }
- if ($_GET['page'] == "apps") {
- $query = mysql_query("SELECT COUNT(*) FROM `images`");
- $row = mysql_fetch_assoc($query);
- if ($row['COUNT(*)'] == 0) {
- echo 'You must <a href="?page=addimage">add image</a> first.';
- exit;
- }
- if (isset($_GET['del'])) {
- mysql_query("DELETE FROM `apps` WHERE `id` = '".addslashes($_GET['del'])."' LIMIT 1");
- mysql_query("DELETE FROM `template` WHERE `app_id` = '".addslashes($_GET['del'])."' LIMIT 1");
- }
- echo '<b>My Applications</b><br/>';
- $query = mysql_query("SELECT * FROM `apps`");
- if (mysql_affected_rows() > 0) {
- echo '<br/><table><tr><td><b>Facebook ID</b></td><td><b>Application Name</b></td><td> </td></tr>';
- while ($row = mysql_fetch_assoc($query)) {
- echo '<tr><td><a target="_blank" href="https://developers.facebook.com/apps/'.$row['app_id'].'">'.$row['app_id'].'</a></td>';
- echo '<td>'.stripslashes($row['app_name']).'</td>';
- echo '<td><a href="?page=editapp&id='.$row['id'].'"><img src="images/edit.png" border=0 alt="Edit"></a> <a href="?page=template&id='.$row['app_id'].'"><img src="images/template.jpg" border=0 alt="Template"></a> <a href="https://www.facebook.com/dialog/pagetab?app_id='.$row['app_id'].'&next='.urlencode($callbackurl."admin.php").'"><img src="images/addfb.png" border=0 alt="Add to Fan Page"></a> <a href="?page=apps&del='.$row['id'].'" onclick="return confirm(\'Are you sure you want to delete?\');"><img src="images/delete.png" border=0 alt="Delete"></a></td>';
- echo '</tr>';
- }
- echo '</table><br/><br/>';
- ?>
- <center>
- <b>Action Guide:</b><br/><br/>
- <div style="font-size: 10px;">
- <img src="images/edit.png" border=0 alt="Edit" align=ABSMIDDLE> Edit App Information
- <img src="images/template.jpg" border=0 alt="Template" align=ABSMIDDLE> Edit App Template<br/><br/>
- <img src="images/addfb.png" border=0 alt="Facebook" align=ABSMIDDLE> Add to Facebook Page
- <img src="images/delete.png" border=0 alt="Delete" align=ABSMIDDLE> Delete Application<br/>
- </div></center><br/>
- <?php
- }
- else
- {
- echo '<i>No applications found in database.</i><br/><br/>';
- }
- }
- if ($_GET['page'] == "addapp") {
- $query = mysql_query("SELECT COUNT(*) FROM `images`");
- $row = mysql_fetch_assoc($query);
- if ($row['COUNT(*)'] == 0) {
- echo 'You must <a href="?page=addimage">add an image template</a> first.';
- exit;
- }
- $query = mysql_query("SELECT COUNT(*) FROM `domains`");
- $row = mysql_fetch_assoc($query);
- if ($row['COUNT(*)'] == 0) {
- echo 'You must <a href="?page=domains">add a domain</a> first.';
- exit;
- }
- if (isset($_POST['appid'])) {
- $error = "";
- if ($_POST['appid'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($_POST['appsecret'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($_POST['appname'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($error == "") {
- $app_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=".$_POST['appid']."&client_secret=".$_POST['appsecret']."&grant_type=client_credentials");
- if (!strstr(" ".$app_token,"access_token=")) {
- $error = "It appears the application ID and secret key you entered are invalid (Could not grab app authroization token)<br/>";
- }
- else
- {
- $app_token = str_replace("access_token=","",$app_token);
- }
- }
- if ($error == "") {
- $facebook = new Facebook(array(
- 'appId' => $_POST['appid'],
- 'secret' => $_POST['appsecret']
- ));
- if (!empty($_POST['likeland'])) { $likeland = 1; } else { $likeland = 0; }
- if (!empty($_POST['userscrape'])) { $scrape = 1; } else { $scrape = 0; }
- if (!empty($_POST['tagusers'])) { $tag = 1; } else { $tag = 0; }
- if (!empty($_POST['redirectafter'])) { $redir = $_POST['redirecturl']; } else { $redir = 0; }
- $data = array("publishing"=>$_POST['publishing'],"caption"=>addslashes($_POST['pmsg']),"likeland"=>$likeland,"userscrape"=>$scrape,"tagusers"=>$tag,"redirect"=>$redir);
- mysql_query("INSERT INTO `apps` VALUES(null,'".addslashes($_POST['appid'])."','".addslashes($_POST['appsecret'])."','".addslashes($_POST['appnamespace'])."','".addslashes($_POST['appdomain'])."','".addslashes($_POST['appname'])."','".$_POST['image']."','".serialize($data)."');") or die(mysql_error());
- $created_id = mysql_insert_id();
- $domainq = mysql_query("SELECT * FROM `domains` WHERE `id` = '".addslashes($_POST['appdomain'])."' LIMIT 1");
- $domain = mysql_fetch_assoc($domainq);
- $properties['app_domains'] = array($domain['domain']);
- $properties['canvas_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'canvas.php?id='.$created_id;
- $properties['secure_canvas_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'canvas.php?id='.$created_id;
- $properties['page_tab_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'tab.php?id='.$created_id;
- $properties['secure_page_tab_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'tab.php?id='.$created_id;
- $properties['privacy_policy_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'privacy.html';
- $properties['canvas_fluid_height'] = false;
- $properties['access_token'] = $app_token;
- $properties['page_tab_default_name'] = $_POST['appname'];
- $facebook->api('/'.$_POST['appid'],'post',$properties);
- echo '<font color="green">Application successfully added.</font><br/><br/>';
- $hideform = true;
- }
- else
- {
- echo '<font color="red">'.$error.'</font><br/>';
- }
- }
- if (!isset($hideform)) {
- ?>
- <b>Create a Application</b> (<a href="https://developers.facebook.com/apps" target="_blank">Create ID & secret here</a>)<br/>
- <form method="POST" action="admin.php?page=addapp" enctype="multipart/form-data">
- <table>
- <tr><td>Application ID:</td><td><input type="text" name="appid" value="<?php if (isset($_POST['appid'])) { echo $_POST['appid']; } ?>"> *</td></tr>
- <tr><td>Application Secret:</td><td><input type="text" name="appsecret" value="<?php if (isset($_POST['appsecret'])) { echo $_POST['appsecret']; } ?>"> *</td></tr>
- <tr><td>Application Namespace:</td><td><input type="text" name="appnamespace" value="<?php if (isset($_POST['appnamespace'])) { echo $_POST['appnamespace']; } ?>"> *</td></tr>
- <tr><td>Domain:</td><td><select name="appdomain"><?php
- $query = mysql_query("SELECT * FROM `domains`");
- if (mysql_affected_rows() > 0) {
- while ($row = mysql_fetch_assoc($query)) { echo '<option value="'.$row['id'].'">'.$row['domain'].'</option>'; }
- }
- ?></select></td></tr>
- <tr><td>Application Name:</td><td><input type="text" name="appname" value="<?php if (isset($_POST['appname'])) { echo $_POST['appname']; } ?>"> *</td></tr>
- <tr><td>Image Template:</td><td><select name="image">
- <?php
- $query = mysql_query("SELECT * FROM `images`");
- while ($irow = mysql_fetch_assoc($query)) {
- echo '<option value="'.$irow['id'].'">'.stripslashes($irow['name']).' (ID: '.$irow['id'].')</option>';
- }
- ?>
- </select> *</td></tr>
- <tr><td>Photo Caption (<a href="javascript:void(0);" onclick="alert('Input a caption into the photo image submitted to wall. This method is not recommended as it\'s against the Facebook Terms of Service to auto-fill photo captions without users generating/typing them manually in your app first. This text is spinnable.');">?</a>):</td><td nowrap="nowrap"><input type="text" name="pmsg" value="<?php if (isset($_POST['pmsg'])) { echo $_POST['pmsg']; } ?>"> <i>(Not recommended)</i></td></tr>
- <tr><td>Publishing (<a href="javascript:void(0);" onclick="alert('Present the user with a link to publish image (Manual) or automatically publish image without presenting link (Auto). Manual is recommended as it\s more friendly to the Facebook Terms of Service.');">?</a>):</td><td nowrap="nowrap"><input type="radio" name="publishing" value="manual" checked="checked" id="pubmanual"><label for="pubmanual">Manual <i>(Recommended)</i></label> <input type="radio" name="publishing" value="auto" id="pubauto"><label for="pubauto">Auto</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="likeland" id="likeland"> <label for="likeland">Enable Like Gateway (<a href="javascript:void(0);" onclick="alert('User must like a page before viewing image results');">?</a>)</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="userscrape" id="userscrape"> <label for="userscrape">Email permissions + scrape name, email, and Facebook ID (<a href="javascript:void(0);" onclick="alert('All data is added to user_info table in MySQL database.');">?</a>)</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="tagusers" id="tagusers"> <label for="tagusers">Tag friends that get randomly selected (<a href="javascript:void(0);" onclick="alert('This is not recommended. It is against the Facebook Terms of Service.');">?</a>) <i>(Not Recommended)</i></label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="redirectafter" id="redirectafter"> <label for="redirectafter">After publish, redirect user to: <input type="text" name="redirecturl" value="http://"></label></td></tr>
- </table><br/>
- <input type="submit" value="Create Application">
- </form>
- <?php
- }
- }
- if ($_GET['page'] == "editapp") {
- if (isset($_POST['appid'])) {
- $error = "";
- if ($_POST['appid'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($_POST['appsecret'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($_POST['appname'] == "") { $error = "Required fields are mark with an astrick (*).<br/>"; }
- if ($error == "") {
- $app_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=".$_POST['appid']."&client_secret=".$_POST['appsecret']."&grant_type=client_credentials");
- if (!strstr(" ".$app_token,"access_token=")) {
- $error = "It appears the application ID and secret key you entered are invalid (Could not grab app authroization token)<br/>";
- }
- else
- {
- $app_token = str_replace("access_token=","",$app_token);
- }
- }
- if ($error == "") {
- $facebook = new Facebook(array(
- 'appId' => $_POST['appid'],
- 'secret' => $_POST['appsecret']
- ));
- $domainq = mysql_query("SELECT * FROM `domains` WHERE `id` = '".addslashes($_POST['appdomain'])."' LIMIT 1");
- $domain = mysql_fetch_assoc($domainq);
- if (!empty($_POST['likeland'])) { $likeland = 1; } else { $likeland = 0; }
- if (!empty($_POST['userscrape'])) { $scrape = 1; } else { $scrape = 0; }
- if (!empty($_POST['tagusers'])) { $tag = 1; } else { $tag = 0; }
- if (!empty($_POST['redirectafter'])) { $redir = $_POST['redirecturl']; } else { $redir = 0; }
- $data = array("publishing"=>$_POST['publishing'],"caption"=>addslashes($_POST['pmsg']),"likeland"=>$likeland,"userscrape"=>$scrape,"tagusers"=>$tag,"redirect"=>$redir);
- mysql_query("UPDATE `apps` SET `app_id` = '".addslashes($_POST['appid'])."', `secret` = '".addslashes($_POST['appsecret'])."', `namespace` = '".addslashes($_POST['appnamespace'])."', `domain` = '".addslashes($_POST['appdomain'])."', `app_name` = '".addslashes($_POST['appname'])."', `image` = '".$_POST['image']."', `data` = '".serialize($data)."' WHERE `id` = '".$_GET['id']."' LIMIT 1") or die(mysql_error());
- $created_id = $_GET['id'];
- $properties['app_domains'] = array($domain['domain']);
- $properties['canvas_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'canvas.php?id='.$created_id;
- $properties['secure_canvas_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'canvas.php?id='.$created_id;
- $properties['page_tab_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'tab.php?id='.$created_id;
- $properties['secure_page_tab_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'tab.php?id='.$created_id;
- $properties['privacy_policy_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'privacy.html';
- $properties['canvas_fluid_height'] = false;
- $properties['access_token'] = $app_token;
- $properties['page_tab_default_name'] = $_POST['appname'];
- $facebook->api('/'.$_POST['appid'],'post',$properties);
- echo 'Application successfully updated.';
- $hideform = true;
- }
- else
- {
- echo '<font color="red">'.$error.'</font><br/>';
- }
- }
- $query = mysql_query("SELECT * FROM `apps` WHERE `id` = '".$_GET['id']."' LIMIT 1");
- $row = mysql_fetch_assoc($query);
- $data = unserialize($row['data']);
- if (!isset($hideform)) {
- ?>
- <b>Edit App</b> (<a href="https://developers.facebook.com/apps" target="_blank">Create new ID & secret here</a>)<br/>
- <form method="POST" action="admin.php?page=editapp&id=<?php echo $_GET['id']; ?>" enctype="multipart/form-data">
- <table>
- <tr><td>Application ID:</td><td><input type="text" name="appid" value="<?php if (isset($_POST['appid'])) { echo $_POST['appid']; } else { echo $row['app_id']; } ?>"> *</td></tr>
- <tr><td>Application Secret:</td><td><input type="text" name="appsecret" value="<?php if (isset($_POST['appsecret'])) { echo $_POST['appsecret']; } else { echo $row['secret']; } ?>"> *</td></tr>
- <tr><td>Application Namespace:</td><td><input type="text" name="appnamespace" value="<?php if (isset($_POST['appnamespace'])) { echo $_POST['appnamespace']; } else { echo $row['namespace']; } ?>"> *</td></tr>
- <tr><td>Domain:</td><td><select name="appdomain"><?php
- $domainq = mysql_query("SELECT * FROM `domains`");
- if (mysql_affected_rows() > 0) {
- while ($drow = mysql_fetch_assoc($domainq)) {
- echo '<option value="'.$drow['id'].'"';
- if ($row['domain'] == $drow['id']) { echo ' selected="selected"'; }
- echo '>'.$drow['domain'].'</option>';
- }
- }
- ?></select></td></tr>
- <tr><td>Application Name:</td><td><input type="text" name="appname" value="<?php if (isset($_POST['appname'])) { echo $_POST['appname']; } else { echo $row['app_name']; } ?>"> *</td></tr>
- <tr><td>Image:</td><td><select name="image">
- <?php
- $query = mysql_query("SELECT * FROM `images`");
- while ($irow = mysql_fetch_assoc($query)) {
- echo '<option value="'.$irow['id'].'" ';
- if ($irow['id'] == $row['image']) { echo 'SELECTED'; }
- echo '>'.$irow['name'].' (ID: '.$irow['id'].')</option>';
- }
- ?>
- </select> *</td></tr>
- <tr><td>Photo Caption (<a href="javascript:void(0);" onclick="alert('Input a caption into the photo image submitted to wall. This method is not recommended as it\'s against the Facebook Terms of Service to auto-fill photo captions without users generating/typing them manually in your app first. This text is spinnable.');">?</a>):</td><td nowrap="nowrap"><input type="text" name="pmsg" value="<?php if (isset($_POST['pmsg'])) { echo $_POST['pmsg']; } else { echo stripslashes($data['caption']); } ?>"> <i>(Not recommended)</i></td></tr>
- <tr><td>Publishing (<a href="javascript:void(0);" onclick="alert('Present the user with a link to publish image (Manual) or automatically publish image without presenting link (Auto). Manual is recommended as it\s more friendly to the Facebook Terms of Service.');">?</a>):</td><td nowrap="nowrap"><input type="radio" name="publishing" value="manual" <?php if ($data['publishing'] == "manual") { echo 'checked="checked"'; } ?> id="pubmanual"><label for="pubmanual">Manual <i>(Recommended)</i></label> <input type="radio" name="publishing" <?php if ($data['publishing'] == "auto") { echo 'checked="checked"'; } ?> value="auto" id="pubauto"><label for="pubauto">Auto</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="likeland" id="likeland" <?php if ($data['likeland'] == 1) { echo 'checked="checked"'; } ?>> <label for="likeland">Enable Like Gateway (<a href="javascript:void(0);" onclick="alert('User must like a page before viewing image results');">?</a>)</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="userscrape" id="userscrape" <?php if ($data['userscrape'] == 1) { echo 'checked="checked"'; } ?>> <label for="userscrape">Email permissions + scrape name, email, and Facebook ID (<a href="javascript:void(0);" onclick="alert('All data is added to user_info table in MySQL database.');">?</a>)</label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="tagusers" id="tagusers" <?php if ($data['tagusers'] == 1) { echo 'checked="checked"'; } ?>> <label for="tagusers">Tag friends that get randomly selected (<a href="javascript:void(0);" onclick="alert('This is not recommended. It is against the Facebook Terms of Service.');">?</a>) <i>(Not Recommended)</i></label></td></tr>
- <tr><td colspan=2><input type="checkbox" name="redirectafter" id="redirectafter" <?php if (isset($data['redirect']) && strlen($data['redirect']) > strlen("http://")) { echo 'checked="checked"'; } ?>> <label for="redirectafter">After publish, redirect user to: <input type="text" name="redirecturl" value="<?php if (isset($data['redirect']) && strlen($data['redirect']) > strlen("http://")) { echo $data['redirect']; } else { echo "http://"; } ?>"></label></td></tr>
- <tr><td colspan=2 style="text-align: center;"><input type="submit" value="Edit Application"></td></tr>
- </table>
- </form>
- <?php
- //print_r($data);
- }
- }
- if ($_GET['page'] == "template") {
- if (isset($_POST['tmpltxt'])) {
- //echo "SELECT * FROM `template` WHERE `app_id` = '".$_GET['id']."' AND `type` = '".$_GET['type']."' LIMIT 1";
- mysql_query("SELECT * FROM `template` WHERE `app_id` = '".$_GET['id']."' AND `type` = '".$_GET['type']."' LIMIT 1") or die(mysql_error());
- if (mysql_affected_rows() > 0) {
- mysql_query("UPDATE `template` SET `value` = '".addslashes($_POST['tmpltxt'])."' WHERE `app_id` = '".$_GET['id']."' AND `type` = '".$_GET['type']."' LIMIT 1");
- }
- else
- {
- mysql_query("INSERT INTO `template` VALUES('".$_GET['id']."','".$_GET['type']."','".addslashes($_POST['tmpltxt'])."');");
- }
- }
- $types = array(array("name" => "Header HTML/CSS", "id" => "header"),array("name" => "Footer HTML/CSS", "id" => "footer"), array("name" => "Like Gateway (Fan Page)", "id" => "notliked"), array("name" => "Login Page (Fan Page)", "id" => "fan-login"));
- if (!isset($_GET['type'])) { $_GET['type'] = "header"; }
- $tmp = 0;
- echo '<b>Editing:</b> ';
- foreach ($types as $type) {
- if ($tmp > 0) { echo ' | '; }
- if ($_GET['type'] == $type['id']) {
- $query = mysql_query("SELECT * FROM `template` WHERE `app_id` = '".$_GET['id']."' AND `type` = '".$type['id']."' LIMIT 1");
- if (mysql_affected_rows() > 0) { $rrow = mysql_fetch_assoc($query); $rrow['value'] = stripslashes($rrow['value']); } else { $rrow['value'] = file_get_contents('default_tmpl/'.$type['id'].'.php'); $rrow['type'] = $type['id']; }
- $rrow['value'] = str_replace("&","&",$rrow['value']);
- echo '<b>'.$type['name'].'</b>';
- }
- else
- {
- echo '<a href="?page=template&id='.$_GET['id'].'&type='.$type['id'].'">'.$type['name'].'</a>';
- }
- $tmp++;
- }
- ?>
- <br/><br/>
- <form method="POST" action="admin.php?page=template&id=<?php echo $_GET['id']; ?>&type=<?php echo $rrow['type']; ?>">
- <input type="hidden" name="type" value="<?php echo $rrow['type']; ?>">
- <textarea name="tmpltxt" rows=10 cols=70>
- <?php echo stripslashes($rrow['value']); ?>
- </textarea><br/>
- <input type="submit" value="Update Template">
- </form>
- <?php
- }
- if ($_GET['page'] == "stats") {
- echo "<B>App Statistics</B><br/><br/>";
- $query = mysql_query("SELECT * FROM `stats`");
- if (mysql_affected_rows() > 0) {
- echo '<table><tr><td><b><b>App Name</b></td><td><b>Today</b></td><td><b>Yesterday</b></td><td><b>This Week</b></td><td><b>This Month</b></td><td><b>Last Month</b></td></tr>';
- while ($row = mysql_fetch_assoc($query)) {
- $appq = mysql_query("SELECT * FROM `apps` WHERE `id` = '".$row['app_id']."' LIMIT 1");
- $app = mysql_fetch_assoc($appq);
- echo '<tr><td>'.stripslashes($app['app_name']).'</td><td>'.$row['today'].'</td><td>'.$row['yesterday'].'</td><td>'.$row['last_week'].'</td><td>'.$row['this_month'].'</td><td>'.$row['last_month'].'</td></tr>';
- }
- echo '</table>';
- }
- else
- {
- echo "No statistical information logged.";
- }
- echo '<br/><br/><i>* This feature tracks image publishes, not views</i>';
- }
- if ($_GET['page'] == "domains") {
- if (isset($_POST['domain'])) { mysql_query("INSERT INTO `domains` VALUES(null,'".addslashes($_POST['domain'])."');"); }
- echo '<b>Domains</b><br/><br/>';
- $query = mysql_query("SELECT * FROM `domains`");
- if (mysql_affected_rows() > 0) {
- echo '<table>';
- while ($row = mysql_fetch_assoc($query)) {
- echo '<tr><td>'.$row['domain'].'</td><td style="padding-left: 10px;"><a href="?page=deldomain&id='.$row['id'].'">[Delete & Move Apps]</a></td></tr>';
- }
- echo '</table>';
- }
- else
- {
- echo '<i>No domains added yet</i>';
- }
- ?>
- <form method="POST" action="admin.php?page=domains">
- <br/><br/><b>Add a Domain</b><br/><br/>
- Domain: <input type="text" name="domain"> <input type="submit" value="Add Domain">
- </form><br/><br/>
- <i>* Base domain only! Do not include www. Subdomains allowed.</i>
- <?php
- }
- if ($_GET['page'] == "deldomain") {
- echo '<b>Delete Domain & Move Apps</b><br/><br/>';
- if (isset($_POST['moveto'])) {
- $appsq = mysql_query("SELECT * FROM `apps` WHERE `domain` = '".$_POST['moveto']."' LIMIT 1");
- if (mysql_affected_rows() > 0) {
- while ($app = mysql_fetch_assoc($appsq)) {
- $app_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=".$app['app_id']."&client_secret=".$app['secret']."&grant_type=client_credentials");
- if (!strstr(" ".$app_token,"access_token=")) {
- $error = "It appears the application ID and secret key you entered are invalid (Could not grab app authroization token)<br/>";
- }
- else
- {
- $app_token = str_replace("access_token=","",$app_token);
- }
- $facebook[$row['id']] = new Facebook(array(
- 'appId' => $_POST['appid'],
- 'secret' => $_POST['appsecret']
- ));
- $domainq = mysql_query("SELECT * FROM `domains` WHERE `id` = '".addslashes($_POST['moveto'])."' LIMIT 1");
- $domain = mysql_fetch_assoc($domainq);
- mysql_query("UPDATE `apps` SET `domain` = '".addslashes($_POST['moveto'])."' WHERE `id` = '".$app['id']."' LIMIT 1") or die(mysql_error());
- $created_id = $_GET['id'];
- $properties['app_domains'] = array($domain['domain']);
- $properties['canvas_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'canvas.php?id='.$created_id;
- $properties['secure_canvas_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'canvas.php?id='.$created_id;
- $properties['page_tab_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'tab.php?id='.$created_id;
- $properties['secure_page_tab_url'] = str_replace("http://","https://",str_replace($base_domain,$domain['domain'],$callbackurl)).'tab.php?id='.$created_id;
- $properties['privacy_policy_url'] = str_replace($base_domain,$domain['domain'],$callbackurl).'privacy.html';
- $properties['access_token'] = $app_token;
- $facebook->api('/'.$app['app_id'],'post',$properties);
- }
- }
- mysql_query("DELETE FROM `domains` WHERE `id` = '".$_GET['id']."' LIMIT 1");
- }
- else
- {
- $query = mysql_query("SELECT * FROM `domains` WHERE `id` != '".$_GET['id']."' LIMIT 1");
- if (mysql_affected_rows() < 1) {
- echo 'You must have at least one domain. Please add another before deleting this one.';
- exit;
- }
- $query = mysql_query("SELECT * FROM `domains` WHERE `id` = '".$_GET['id']."' LIMIT 1");
- $row = mysql_fetch_assoc($query);
- ?>
- <form method="POST" action="admin.php?page=deldomain&id=<?php echo $row['id']; ?>">
- <b>Deleting:</b> <?php echo $row['domain']; ?><br/><br/>
- <b>Move apps to:</b> <select name="moveto"><?php
- $domainq = mysql_query("SELECT * FROM `domains` WHERE `id` != '".$row['id']."'");
- if (mysql_affected_rows() > 0) {
- while ($drow = mysql_fetch_assoc($query)) {
- echo '<option value="'.$drow['id'].'">'.$drow['domain'].'</option>';
- }
- }
- ?></select><br/><br/>
- <input type="submit" value="Delete Domain">
- </form>
- <?php
- }
- }
- if ($_GET['page'] == "spin") {
- if (isset($_GET['del'])) {
- mysql_query("DELETE FROM `spinners` WHERE `id` = '".$_GET['del']."' LIMIT 1");
- }
- echo '<b>App Spinners</b><br/><br/>';
- $query = mysql_query("SELECT * FROM `spinners`");
- if (mysql_affected_rows() > 0) {
- echo '<table><tr><td><b>Spinner URL</b></td><td><b>App IDs to Spin</b></td><td> </td></tr>';
- while ($row = mysql_fetch_assoc($query)) {
- echo '<tr><td><a target="_blank" href="'.$callbackurl.$row['id'].'">'.$row['id'].'</a></td><td>';
- $appIDs = unserialize($row['data']);
- $idstr = "";
- foreach ($appIDs as $id => $val) {
- if ($idstr == "") { $idstr .= $id; } else { $idstr .= ", ".$id; }
- }
- echo $idstr.'</td><td><a href="?page=editspin&id='.$row['id'].'"><img src="images/edit.png" border=0></a> <a href="?page=spin&del='.$row['id'].'"><img src="images/delete.png" border=0></a></td></tr>';
- }
- echo '</table><br/><br/>';
- ?>
- <b>How it Works:</b><br/><br/>
- <b>1)</b> Spinner URLs are automatically attached to photo captions with corresponding IDs<br/>
- <b>2)</b> If more than one spinner is attached to the app, a spinner URL is selected randomly<br/>
- <b>3)</b> If you have more than one domain added, domain will also be spun in URL<br/>
- <?php
- }
- else
- {
- echo '<i>No spinners have been created yet</i>';
- }
- }
- if ($_GET['page'] == "addspin") {
- if (isset($_POST['submit'])) {
- $query = mysql_query("SELECT * FROM `apps`");
- while ($row = mysql_fetch_assoc($query)) {
- if (isset($_POST['app'.$row['id']]) && !empty($_POST['app'.$row['id']])) {
- $appIDs[$row['id']] = 1;
- }
- }
- if (isset($appIDs)) {
- $count = 1;
- while ($count > 0) {
- $randId = randString(6);
- $query = mysql_query("SELECT COUNT(*) FROM `spinners` WHERE `id` = '".$randId."' LIMIT 1");
- $count = mysql_fetch_assoc($query);
- $count = $count['COUNT(*)'];
- }
- mysql_query("INSERT INTO `spinners` VALUES('".$randId."','".serialize($appIDs)."');");
- $hideform = true;
- echo '<font color="green">Spinner generated successfully:</font><br/><br/><b>Your Spinner URL:</b> <a href="'.$callbackurl.$randId.'">'.$callbackurl.$randId.'</a>';
- }
- }
- if (!isset($hideform)) {
- echo '<form method="POST" action="admin.php?page=addspin"><b>Generate a Spinner URL</b><br/><br/>';
- $query = mysql_query("SELECT * FROM `apps`");
- if (mysql_affected_rows() > 0) {
- while ($row = mysql_fetch_assoc($query)) {
- echo '<input type="checkbox" name="app'.$row['id'].'" id="app'.$row['id'].'"> <label for="app'.$row['id'].'">'.stripslashes($row['app_name']).' (App ID: '.$row['id'].')</label><br/>';
- }
- }
- echo '<br/><input type="submit" name="submit" value="Generate"></form>';
- }
- }
- if ($_GET['page'] == "editspin") {
- if (isset($_POST['submit'])) {
- $query = mysql_query("SELECT * FROM `apps`");
- while ($row = mysql_fetch_assoc($query)) {
- if (isset($_POST['app'.$row['id']]) && !empty($_POST['app'.$row['id']])) {
- $appIDs[$row['id']] = 1;
- }
- }
- if (isset($appIDs)) {
- //print_r($appIDs);
- mysql_query("UPDATE `spinners` SET `data` = '".serialize($appIDs)."' WHERE `id` = '".$_GET['id']."'");
- }
- }
- $query = mysql_query("SELECT * FROM `spinners` WHERE `id` = '".$_GET['id']."' LIMIT 1");
- $spin = mysql_fetch_assoc($query);
- $spin = unserialize($spin['data']);
- if (!isset($hideform)) {
- echo '<form method="POST" action="admin.php?page=editspin&id='.$_GET['id'].'"><b>Edit a Spinner URL</b><br/><br/>';
- $query = mysql_query("SELECT * FROM `apps`");
- if (mysql_affected_rows() > 0) {
- while ($row = mysql_fetch_assoc($query)) {
- echo '<input type="checkbox" name="app'.$row['id'].'" id="app'.$row['id'].'" ';
- if (isset($spin[$row['id']])) { echo 'checked="checked"'; }
- echo '> <label for="app'.$row['id'].'">'.stripslashes($row['app_name']).' (App ID: '.$row['id'].')</label><br/>';
- }
- }
- echo '<br/><input type="submit" name="submit" value="Edit Spinner"></form>';
- }
- }
- function randString($length, $charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
- $str = '';
- $count = strlen($charset);
- while ($length--) {
- $str .= $charset[mt_rand(0, $count-1)];
- }
- return $str;
- }
- ?>
- </td></tr></table><br/><br/>Created by <a href="http://www.devswift.com/" target="_blank">DevSwift</a><br/><br/>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement