Example #1
0
 function squiggly($string)
 {
     $input = $string . " ";
     preg_match_all("~@(.*?)[\\ \\,\\-\\;\\?\\!\\.\\/\\(\\)\\:\\'\\\"]~", $input, $output);
     $arrayTags = $output[1];
     foreach ($arrayTags as $tagName) {
         $resultArray = explode(":|:|:|:", pageType($tagName));
         $pageType = $resultArray[0];
         $match = $resultArray[1];
         if ($pageType === "profile") {
             $string = str_replace("@" . $tagName, "@{" . $match . "}@", $string);
         } elseif ($pageType === "project") {
             $string = str_replace("@" . $tagName, "#{" . $match . "}#", $string);
         }
     }
     return $string;
 }
 function saveComment($commentid, $q, $commentText)
 {
     $commentText = addslashes($commentText);
     //---get user information---//
     $sessionid = $_SESSION["sessionid"];
     $random = $_SESSION["random"];
     $query = "SELECT * FROM sessions WHERE sessionid = '{$sessionid}' AND random = '{$random}' ";
     $recordSet = mysql_query($query) or die(mysql_error());
     $row = mysql_fetch_array($recordSet);
     if ($row["userid"] > 0) {
         $myid = $row["userid"];
         //---tagging---//
         $commentText = squiggly($commentText);
         $arrayTagUsers = array();
         $input = $commentText;
         preg_match_all("~@{(.*?)}@~", $input, $output);
         $arrayTags = $output[1];
         foreach ($arrayTags as $tagid) {
             array_push($arrayTagUsers, $tagid);
         }
         //---existing comment---//
         if ($commentid > 0) {
             $query = "UPDATE comments SET comment = '{$commentText}' WHERE commentid = '{$commentid}' AND commenterid = '{$myid}' ";
             mysql_query($query);
             return "success:|:|:|:existing";
         } elseif ($q !== "") {
             $resultArray = explode(":|:|:|:", pageType($q));
             $pageType = $resultArray[0];
             $match = $resultArray[1];
             $query = "INSERT INTO comments (commenterid, locationType, locationid, comment) VALUES('{$myid}','{$pageType}','{$match}','{$commentText}')";
             mysql_query($query) or die(mysql_error());
             include "notify.php";
             foreach ($arrayTagUsers as $userid) {
                 notify($userid, "@{" . $myid . "}@ tagged you on #{" . $match . "}#");
             }
             return "success:|:|:|:new";
         } else {
             return "failure:|:|:|:no_q";
         }
     } else {
         return "failure:|:|:|:signIn";
     }
 }
 function showComments($q)
 {
     //---get user information---//
     $sessionid = $_SESSION["sessionid"];
     $random = $_SESSION["random"];
     $query = "SELECT * FROM sessions WHERE sessionid = '{$sessionid}' AND random = '{$random}' ";
     $recordSet = mysql_query($query) or die(mysql_error());
     $row = mysql_fetch_array($recordSet);
     if ($row["userid"] > 0) {
         $myid = $row["userid"];
     } else {
         $myid = 0;
     }
     //---build megaArray---//
     $megaArray = array();
     array_push($megaArray, "comments");
     $resultArray = explode(":|:|:|:", pageType($q));
     $pageType = $resultArray[0];
     $match = $resultArray[1];
     $query = "SELECT * FROM comments WHERE locationType = '{$pageType}' AND locationid = '{$match}' ";
     $recordSet = mysql_query($query) or die(mysql_error());
     while ($row = mysql_fetch_array($recordSet)) {
         $arrayComment = array();
         if ($myid > 0 and $row["commenterid"] === $myid) {
             $arrayComment[0] = "editable";
         } elseif ($myid > 0 and $row["locationType"] === "profile" and $row["locationid"] === $myid) {
             $arrayComment[0] = "deletable";
         } else {
             $arrayComment[0] = "readable";
         }
         $arrayComment[1] = $row["commentid"];
         $arrayComment[2] = match("users", "userid", "username", $row["commenterid"]);
         $arrayComment[3] = $row["createDate"];
         $arrayComment[4] = unsquiggly($row["comment"]);
         array_push($megaArray, $arrayComment);
     }
     //---return megaArray---//
     for ($i = 1; $i < count($megaArray); $i++) {
         $stringifiedComment = implode(":|:|:|:", $megaArray[$i]);
         $megaArray[$i] = $stringifiedComment;
     }
     return implode(":|::|::|:", $megaArray);
 }
Example #4
0
<?php

include "../universal/config.php";
//---pageType---//
if (isset($_POST["showPage"])) {
    $resultArray = explode(":|:|:|:", pageType($_POST["q"]));
    $pageType = $resultArray[0];
    $match = $resultArray[1];
    //---showProfile---//
    if ($pageType === "profile") {
        include "showProfile.php";
        $result = showProfile($match);
        echo $pageType . ":|:|:|:" . $result;
    } elseif ($pageType === "project") {
        include "showProject.php";
        $result = showProject($match);
        echo $pageType . ":|:|:|:" . $result;
    } elseif ($pageType === "search") {
        include "showSearch.php";
        $result = showSearch($match);
        if ($result === "") {
            echo $pageType;
        } else {
            echo $pageType . ":|:|:|:" . $result;
        }
    } elseif ($pageType === "home") {
        echo "home";
    }
} elseif (isset($_POST["showList"])) {
    include "showList.php";
    if (isset($_POST["q"])) {