Ejemplo n.º 1
0
function upload($uid, $uploadName = false, $FILE, $newWidth = 0, $newHeight = 0)
{
    global $OP;
    $dots = explode(".", $FILE['name']);
    $extension = strtolower($dots[count($dots) - 1]);
    $extensions = array("png", "jpg", "gif", "jpeg");
    if ($uploadName === false) {
        $uploadName = $OP->randStr(5) . "_" . $OP->randStr(5) . "_" . $OP->randStr(5);
    }
    /**
     * Check if User Id is numeric and $FILE array contain more than 0 items
     */
    if (is_numeric($uid) && is_array($FILE) && count($FILE) > 0) {
        /**
         * Check if File Extension is supported
         */
        if (array_search($extension, $extensions) !== false) {
            $path = $FILE['tmp_name'];
            $resize = new ResizeImage($path);
            $ratio = $resize->imgw() / $resize->imgh();
            $newWidth = ($newWidth == 0 ? $resize->imgw() : $newWidth) * $ratio;
            $newHeight = ($newHeight == 0 ? $resize->imgh() : $newHeight) * $ratio;
            /**
             * We resize to reduce the file size of image
             */
            $resize->resizeTo($newWidth, $newHeight, 'exact');
            $resize->saveImage($path, 50);
            /**
             * For Saving Database Space, we md5 the upload file name
             */
            $uploadMD5Name = md5($uploadName);
            $uploadContent = file_get_contents($path);
            /**
             * Only do data insertion if the data doesn't exist, else update the already existing value
             */
            $sql = $OP->dbh->prepare("SELECT 1 FROM `data` WHERE `uid`=? AND `name`=?");
            $sql->execute(array($uid, $uploadMD5Name));
            if ($sql->rowCount() == 0) {
                $sql = $OP->dbh->prepare("INSERT INTO `data` (`uid`, `name`, `txt`) VALUES (?, ?, ?)");
                $sql->execute(array($uid, $uploadMD5Name, $uploadContent));
            } else {
                $sql = $OP->dbh->prepare("UPDATE `data` SET `txt` = ? WHERE `uid`=? AND `name`=?");
                $sql->execute(array($uploadContent, $uid, $uploadMD5Name));
            }
            /* We, for fun add a .png extension to the file name */
            $uploadName .= ".png";
            /* and return the image URL */
            return Open::URL("/data/{$uid}/{$uploadName}");
        } else {
            return "extensionNotSupported";
        }
    } else {
        return false;
    }
}
Ejemplo n.º 2
0
<?php

require_once "{$docRoot}/inc/render.php";
\Fr\LS::init();
if (isset($_POST['load'])) {
    $sql = $OP->dbh->prepare("SELECT id FROM notify WHERE uid=? ORDER BY id DESC LIMIT 10");
    $sql->execute(array($who));
    if ($sql->rowCount() == 0) {
        echo '$(".notifications .loading").hide();$(".notifications .nfs").html("<br/><br/><center><h2>No Notifications</h2></center>");';
    } else {
        $nfs = "";
        while ($r = $sql->fetch()) {
            $nfs .= Render::notification($r['id']);
        }
        $nfs = $OP->rendFilt($nfs);
        $nfs .= "<br/><a href='" . Open::URL("/notifications") . "' style='text-align:center;display:block;'>See All Notifications</a><br/>";
        ?>
$(".notifications .loading").hide();
$(".notifications .nfs").html("<?php 
        echo $nfs;
        ?>
");
$(".notifications #nfn_button").text("0");
$(".notifications #nfn_button").removeClass("b-red");
<?php 
    }
}
Ejemplo n.º 3
0
Archivo: load.php Proyecto: xereon/open
require_once "{$docRoot}/config.php";
require_once "{$docRoot}/inc/class.open.php";
require_once "{$docRoot}/inc/class.logsys.php";
$db = unserialize(DATABASE);
\Fr\LS::config(array("db" => array("host" => $db['host'], "port" => $db['port'], "name" => $db['name'], "username" => $db['user'], "password" => $db['pass'], "table" => "users"), "keys" => array("cookie" => "cantMakePublic", "salt" => "cantMakePublic"), "pages" => array("no_login" => array("/", "/register", "/me/ResetPassword"), "login_page" => "/login", "home_page" => "/home"), "features" => array("email_login" => false), "cookies" => array("domain" => CLEAN_HOST)));
/* Basic Variables */
$loggedIn = \Fr\LS::$loggedIn;
/* Boolean on status of current user (logged in or not) */
$who = \Fr\LS::$user;
/* The current user */
/* Global Variables */
$_P = count($_POST) > 0 ? true : false;
/* Boolean Variable whether POST data is sent with the request */
define("loggedIn", $loggedIn);
define("curUser", $who);
$OP = new Open();
if (!function_exists("get")) {
    function get($key, $uid = "", $json = true)
    {
        global $OP;
        return $OP->get($key, $uid, $json);
    }
}
/* Do these if user is logged in */
if (loggedIn && !isset($uimg)) {
    $uimg = get("img");
    $uaimg = get("avatar");
    $uname = get("name", "", false);
    /* Update the last seen time */
    $OP->save("seen");
}
Ejemplo n.º 4
0
    }
}
/* We make an array of Database Details */
$databaseDetails = unserialize(DATABASE);
/**
 * The PHP OAuth Library requires some special items in array, so we add that
 */
$databaseDetails["password"] = $databaseDetails["pass"];
$databaseDetails["socket"] = "/var/run/mysqld/mysqld.sock";
$client = new mysqli_oauth_client_class();
$client->database = $databaseDetails;
$client->server = 'Facebook';
$client->offline = true;
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = Open::URL('/oauth/login_with_facebook');
$client->client_id = 'fbAppID';
$client->client_secret = 'fbAppSecret';
$client->scope = 'user_about_me,email,user_birthday,user_location,publish_actions';
if ($success = $client->Initialize()) {
    if ($success = $client->Process()) {
        if (strlen($client->authorization_error)) {
            $client->error = $client->authorization_error;
            $success = false;
        } elseif (strlen($client->access_token)) {
            $success = $client->CallAPI('https://graph.facebook.com/me', 'GET', array(), array('FailOnAccessError' => true), $user);
            if ($success) {
                $location = $_SESSION['continue'];
                $email = $user->email;
                $name = $user->name;
                $gender = $user->gender;
Ejemplo n.º 5
0
    require_once "inc/render.php";
    ?>
  <?php 
    echo Render::chat("gadget");
    ?>
 </div>
 <div class="usersgt">
  <div class="cusgt">
   <div class="close">x</div>
   <img src="<?php 
    echo get("avatar");
    ?>
"/>
   <div class="otd">
    <a href="<?php 
    echo Open::URL("profile");
    ?>
"><?php 
    echo get("name", $who, false);
    ?>
</a><br/>
    <span class="status on"></span><span>Online</span>
   </div>
  </div>
  <div class="users">
   <div style="margin-top: 55px;">
    <?php 
    $sql = $OP->dbh->prepare("SELECT fid FROM conn WHERE uid=:who AND fid IN (SELECT uid FROM conn WHERE fid=:who)");
    $sql->execute(array(":who" => $who));
    while ($r = $sql->fetch()) {
        $id = $r['fid'];
Ejemplo n.º 6
0
<!DOCTYPE html>
<html>
	<head>
		<meta name="type" value="search"></meta>
		<?php 
$OP->head("Search", "ac,post_form,home,time,gadget", "ac,home,post_form,gadget");
?>
	</head>
	<body>
		<?php 
include "{$docRoot}/inc/header.php";
?>
		<div class="content blocks">
			<div class="block left viewpoint">
				<form action="<?php 
echo Open::URL('search');
?>
" method="GET">
					<input type="text" class="block" value="<?php 
echo $searchQuery;
?>
" name="q" id="q" />
					<button class="block">Search</button>
				</form>
				<style>
				#q{
					width:375px;
					margin: 0px;
				}
				@media screen and (max-width:500px){
					#q{
Ejemplo n.º 7
0
        $_GET['part'] = $request->page;
        $_GET['id'] = $request->ID;
        makeSource("profile");
        $GLOBALS['itsMyPage'] = true;
    }
});
$router->respond("/chat?/[i:id]?", function ($request, $response) {
    idPage("chat", $request);
});
$router->respond("/view?/[i:id]?", function ($request, $response) {
    idPage("view", $request);
});
$router->respond("/search/?[**:query]?", function ($request, $response) {
    if ($_SERVER['REDIRECT_URL'] == "/search" && isset($_GET['q'])) {
        $encodedQuery = Open::encodeQuery($_GET['q']);
        $url = Open::URL("/search/{$encodedQuery}");
        $response->redirect($url);
    } else {
        $_GET['q'] = $request->query;
        makeSource("search");
    }
    $GLOBALS['itsMyPage'] = true;
});
$router->respond("/data/?[**:path]?", function ($request, $response) {
    $_GET['request'] = $request->path;
    makeSource("data/handle");
    $GLOBALS['itsMyPage'] = true;
});
/* END - Dynamic Pages */
$router->respond("/css/[**:files]", function ($request, $response) use($docRoot) {
    $_GET['f'] = $request->files;
Ejemplo n.º 8
0
                  </div>
                <?php 
}
?>
              </div>
              <div class="block" style="width: 49%;">
                <?php 
foreach ($RP->getTopComments() as $r) {
    ?>
                  <div class="blocks item">
                    <div class="block rep"><?php 
    echo $r['rep'];
    ?>
</div>
                    <a class="block" href="<?php 
    echo Open::URL("view/{$r['pid']}#{$r['id']}");
    ?>
">
                      <?php 
    $c = $r['cmt'];
    if (strlen($c) > 10) {
        echo substr($c, 0, 10);
    } else {
        echo $c;
    }
    /* The above code should be in one line */
    ?>
                    </a>
                  </div>
                <?php 
}
Ejemplo n.º 9
0
 public static function notification($id)
 {
     global $OP;
     $sql = $OP->dbh->prepare("SELECT * FROM `notify` WHERE id=?");
     $sql->execute(array($id));
     while ($r = $sql->fetch()) {
         $fid = $r['fid'];
         $img = get("avatar", $fid);
         $name = get("fname", $fid, false);
         if (preg_match("/\\-/", $r['post'])) {
             list($aid, $pid) = explode("-", $r['post']);
         }
         if ($r['ty'] == "cmt") {
             $amsg = "commented on your post";
             $alnk = Open::URL("view/{$pid}#{$aid}");
         } elseif ($r['ty'] == "fol") {
             $amsg = "is now following you";
             $alnk = get("plink", $r['fid']);
         } elseif ($r['ty'] == "msg") {
             $amsg = "sent you a message";
             $alnk = Open::URL("/chat/{$r['fid']}");
         } elseif ($r['ty'] == "men") {
             $amsg = "mentioned you in a post";
             $alnk = Open::URL("/view/{$pid}");
         } elseif ($r['ty'] == "menc") {
             $amsg = "mentioned you in a comment";
             $alnk = Open::URL("/view/{$pid}");
         } else {
             $amsg = "";
             $alnk = "";
         }
         $iuR = $r['red'] == 0 ? "nred" : "";
         $iuT = $r['red'] == 0 ? "Unread Notification" : "";
         $nfs = "<a href='{$alnk}'>";
         $nfs .= "<div class='nfsi {$iuR}' id='{$id}' title='{$iuT}'>";
         $nfs .= "<div class='left'>";
         $nfs .= "<img height='32' width='32' src='{$img}'/>";
         $nfs .= "</div>";
         $nfs .= "<div class='right'>";
         $nfs .= "<span class='name'>{$name}</span><br/>";
         $nfs .= "<span class='time'>{$r['posted']}</span>";
         $nfs .= "<div class='cont'>";
         $nfs .= $amsg;
         $nfs .= "</div>";
         $nfs .= "</div>";
         $nfs .= "</div>";
         $nfs .= "</a>";
     }
     $sql = $OP->dbh->prepare("UPDATE `notify` SET red='1' WHERE `id` = ?");
     $sql->execute(array($id));
     return $nfs;
 }
Ejemplo n.º 10
0
 public function format($string, $advanced = false)
 {
     $string = htmlspecialchars($string);
     if ($advanced === true) {
         $string = preg_replace("/\\*\\*(.*?)\\*\\*/", '<b>$1</b>', $string);
         $string = preg_replace("/\\*\\/(.*?)\\/\\*/", '<i>$1</i>', $string);
         $string = preg_replace_callback('@((www|http://|https://)(.*?)(\\s|\\z|\\n)+)@', array($this, 'goodURL'), $string);
         $string = preg_replace('@(\\#[^ |\\@|\\&|\\*]+)@', '<a href="http://open.subinsb.com/search/\\1">\\1</a>', $string);
         $string = str_replace("http://open.subinsb.com/search/#", Open::URL("search/%23"), $string);
         $that = $this;
         // Because in callback functions, $this cannot defined directly and cannot be used
         $string = preg_replace_callback("/\\@(.*?)(\\s|\\z|[^0-9])/", function ($text) use($string, $that) {
             return $that->smention($string, $text);
         }, $string);
     }
     return $string;
 }
Ejemplo n.º 11
0
} else {
    /* Or the URL that was sent */
    $_SESSION['continue'] = $_GET['c'];
}
/* We make an array of Database Details */
$databaseDetails = unserialize(DATABASE);
/* The PHP OAuth Library requires some special items in array, so we add that */
$databaseDetails["password"] = $databaseDetails["pass"];
$databaseDetails["socket"] = "/var/lib/mysql/mysql.sock";
$client = new oauth_client_class();
$client->database = $databaseDetails;
$client->server = 'Google';
$client->offline = false;
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = Open::URL('/oauth/login_with_google');
$client->client_id = 'googleClientID';
$client->client_secret = 'googleClientSecret';
$client->scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me';
if ($success = $client->Initialize()) {
    if ($success = $client->Process()) {
        if (strlen($client->authorization_error)) {
            $client->error = $client->authorization_error;
            $success = false;
        } elseif (strlen($client->access_token)) {
            $success = $client->CallAPI('https://www.googleapis.com/oauth2/v2/userinfo', 'GET', array(), array('FailOnAccessError' => true), $user);
        }
    }
    $success = $client->Finalize($success);
}
if ($client->exit) {
Ejemplo n.º 12
0
<div style="padding: 0px 15px;margin: 0px -10px 0px -15px;">
	<font size="5" style="color:#74ACE9;background: url(<?php 
echo HOST;
?>
/cdn/img/up.png);background-position: left;background-size: 22px;background-repeat: no-repeat;padding-left: 28px;">Trending</font>
	<div style="padding-left:10px;margin-top:10px;color:black;">
		<?php 
$sql = $OP->dbh->query("SELECT * FROM `trend` ORDER BY `hits` DESC LIMIT 9");
foreach ($sql as $trend) {
    $title = $OP->format($trend['title']);
    $url = Open::URL("search/" . Open::encodeQuery($trend['title']));
    $extra = strlen($title) >= 25 ? "..." : "";
    $sTitle = str_split($title, 25);
    $sTitle = $sTitle[0] . $extra;
    echo '<div style="padding:1px;margin-bottom: 5px;">';
    echo '<a href="' . $url . '" title="' . $title . '">' . $sTitle . '</a>';
    echo "</div>";
}
$OP->dbh->query("DELETE FROM `trend` WHERE `hits` = (SELECT MIN(`hits`) FROM (SELECT * FROM `trend` HAVING COUNT(`hits`) > 150) x);");
?>
	</div>
</div>
<div style="background:#FAB359;border-radius: 10px;text-align:center;padding:5px;margin:5px 0px 0px 0px;">
	<a href="invite">Invite your Friends</a>
</div>
Ejemplo n.º 13
0
require "{$docRoot}/inc/oauth/database_oauth_client.php";
require "{$docRoot}/inc/oauth/mysqli_oauth_client.php";
/* We make an array of Database Details */
$databaseDetails = unserialize(DATABASE);
/* The PHP OAuth Library requires some special items in array, so we add that */
$databaseDetails["password"] = $databaseDetails["pass"];
$databaseDetails["socket"] = "/var/lib/mysql/mysql.sock";
$client = new mysqli_oauth_client_class();
$client->database = $databaseDetails;
$client->server = 'Twitter';
$client->offline = true;
$client->debug = true;
$client->debug_http = true;
$client->client_id = 'twitterClientID';
$client->client_secret = 'twitterClientSecret';
$client->redirect_uri = Open::URL('/oauth/login_with_twitter');
if ($success = $client->Initialize()) {
    if ($success = $client->Process()) {
        if (strlen($client->authorization_error)) {
            $client->error = $client->authorization_error;
            $success = false;
        } elseif (strlen($client->access_token)) {
            $success = $client->CallAPI('https://api.twitter.com/1.1/account/verify_credentials.json', 'GET', array(), array('FailOnAccessError' => true), $user);
            if ($success) {
                $success = $client->SetUser($who);
            }
        }
    }
    $success = $client->Finalize($success);
}
if ($client->exit) {
Ejemplo n.º 14
0
 public function sendMail($email, $subject, $body)
 {
     Open::sendEMail($email, $subject, $body);
     /* Change this to something else if you don't like PHP's mail() */
 }