예제 #1
0
/** 
* Index file, handles all requests, includes all includes
* I'd like to move all pages into here eventually to turn it into a single-page app but *shrugs* 
*/
define('includeConst', TRUE);
// Allows this page to be accessed directly, not included in another page
include_once 'pdo.inc';
include_once 'userHandler.php';
include_once 'groupHandler.php';
include_once 'postHandler.php';
include_once 'head.inc';
// Action handlers
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'newPost':
            createNewPost($db, $group, $userId, $_POST['content'], canAnnounce($role));
            break;
        case "register":
            include 'registerHandler.inc';
            break;
        case "logout":
            if (session_status() === PHP_SESSION_NONE) {
                session_start();
            }
            unset($_SESSION['id']);
            break;
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'remove') {
    removeFromGroup($_GET['user'], $db, $group);
    echo "<meta http-equiv='REFRESH' content='0;url=/?page=group'>";
예제 #2
0
        $results = $yelp->search($kw, $location, $latitude, $longitude);
        //add in yelp table
        $d = array();
        $d['biz_type'] = 'Yelp';
        $d['biz_query'] = $yelp_query;
        $d['biz_results'] = json_encode($results);
        $d['module_id'] = $colname_rsModule;
        $modelGeneral->addDetails('auto_pre_biz', $d);
        //adding ends
        $businesses = array();
        if ($results['total'] > 0) {
            foreach ($results['businesses'] as $k => $v) {
                $categories = array();
                if (!empty($v['categories'])) {
                    foreach ($v['categories'] as $cats) {
                        $categories[] = $cats[1];
                    }
                }
                $biz = array('title' => $v['name'], 'description' => $v['name'], 'category' => $categories, 'photos' => array($v['image_url']), 'videos' => array(), 'urls' => array(), 'address' => $v['location']['display_address'][0] . ', ' . $v['location']['display_address'][1] . ', ' . $v['location']['country_code'], 'address2' => $v['location']['display_address'][0] . ', ' . $v['location']['display_address'][1] . ', ' . $v['location']['country_code'], 'showAddress' => 1, 'lat' => $v['location']['coordinate']['latitude'], 'lng' => $v['location']['coordinate']['longitude'], 'phone_number' => $v['display_phone'], 'place_id' => $v['id'], 'place_id_type' => 'Yelp', 'rc_approved' => 1);
                $checkRow = $modelGeneral->fetchRow("select * from " . $tablename . " WHERE place_id = ? AND place_id_type = ?", array($v['id'], 'Yelp'), 0);
                if (empty($checkRow)) {
                    $return = createNewPost($biz, $currentURL, $globalCity, $colname_rsModule, $resultModule, $resultModuleFields, $modelGeneral, $tablename, 'System0000', 1);
                }
            }
        }
        $modelGeneral->clearCache($query_limit_rsView, array());
        $yelpCheck = 1;
    }
    //check1
}
//lat, lng
예제 #3
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../includes/init.php';
require_once 'lib/businessLogic.php';
session_start();
$action = $_REQUEST['action'];
if ($action == "post") {
    $props = array();
    $props['p_text'] = isset($_POST['p_text']) ? $_POST['p_text'] : "";
    $props['u_id'] = $_SESSION['loggedInUser']['u_id'];
    $post = createNewPost($props);
    print json_encode($post);
    return;
}
if ($action == "Deactivate profile") {
    $result = deactivateProfile($_SESSION['loggedInUser']['u_id']);
    print json_encode($result);
    return;
}
if ($action == "Activate profile") {
    $result = activateProfile($_SESSION['loggedInUser']['u_id']);
    print json_encode($result);
    return;
}
if ($action == "Accept") {
    $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id']);
    $acceptedUser = acceptFriendship($props);
    $result = array('u_about_myself' => $acceptedUser['u_about_myself'], 'u_id' => $acceptedUser['u_id'], 'days' => calculateDaysTillTheDate($acceptedUser['u_birthdate']));
    print json_encode($result);
    return;
}
예제 #4
0
<?php 
session_start();
function createNewPost($newPostContent, $idEd)
{
    $pid = $idEd;
    $timeDiv = '<div class="postTime">' . date('l jS \\of F Y') . '</div>';
    $au = '<div class="postAuther">By ' . 'Jimish Fotariya' . '</div>';
    $stat = $timeDiv . $au;
    $sDiv = '<div class="postArea" id="' . $pid . '"><div class="postContent">';
    $eDiv = "</div>";
    //"</div>".$stat.'</div>';
    $newPostContent = $sDiv . $newPostContent . $eDiv;
    return $newPostContent;
}
$blogId = $_SESSION['blogId'];
$newPostContent = createNewPost($_POST["d"], urldecode($_POST['idEd']));
$filePath = '../@' . $blogId . '/index.php';
$prevData = file_get_contents($filePath);
$newPostContent = str_replace('=" ', '="', $newPostContent);
$newPostContent = str_replace("=' ", "='", $newPostContent);
$nextData = str_replace(urldecode($_POST['r']), $newPostContent, $prevData);
if (file_put_contents($filePath, $nextData)) {
    die("edited");
} else {
    die("error");
}
//die(htmlentities($newPostContent));
?>

예제 #5
0
             $longitude = $_POST['lng'];
         }
     }
     $queryEditTags = "SELECT * FROM auto_pre_tags WHERE id = ?";
     $rowResultEditTags = $modelGeneral->fetchAll($queryEditTags, array($id), 0);
     if (!empty($rowResultEditTags)) {
         $tmp = array();
         foreach ($rowResultEditTags as $tags) {
             $tmp[] = $tags['tag'];
         }
         $_POST['tags'] = implode(', ', $tmp);
     }
     $pageTitle = 'Edit Record "' . (!empty($rowResultEdit['title']) ? $rowResultEdit['title'] : '') . '"';
 }
 if (isset($_POST['MM_Insert']) && $_POST['MM_Insert'] == 'form1') {
     $return = createNewPost($_POST, $currentURL, $globalCity, $colname_rsModule, $resultModule, $resultModuleFields, $modelGeneral, $tablename, $_SESSION['user']['id'], 0);
     if ($return['error'] == 0) {
         header("Location: " . $return['url']);
         exit;
     } else {
         $error = $return['error'];
     }
     /*try {
           $latitude = $_POST['lat'];
           $longitude = $_POST['lng'];
           $data = $_POST;
           if (isset($data['MM_Insert'])) unset($data['MM_Insert']);
           if (isset($data['submit'])) unset($data['submit']);
           $data['id'] = guid();
           $data['uid'] = $_SESSION['user']['id'];
     
예제 #6
0
function testNewPost($db)
{
    include 'postHandler.php';
    echo createNewPost($db, 12, 1, 'Testing');
}
예제 #7
0
<?php 
session_start();
function createNewPost($newPostContent)
{
    $pid = 'post_' . time();
    $timeDiv = '<div class="postTime">' . date('l jS \\of F Y') . '</div>';
    $au = '<div class="postAuther">By ' . $_SESSION['fname'] . " " . $_SESSION['lname'] . '</div>';
    $stat = $timeDiv . $au;
    $sDiv = '<div class="postArea" id="' . $pid . '"><div class="postContent">';
    $eDiv = "</div>" . $timeDiv . $au . '</div>';
    $newPostContent = "<!--[[-Nextpost-]]-->\n" . $sDiv . $newPostContent . $eDiv;
    return $newPostContent;
}
$blogId = $_SESSION['blogId'];
$newPostContent = createNewPost($_POST["d"]);
$filePath = '../@' . $blogId . '/index.php';
$prevData = file_get_contents($filePath);
$newPostContent = str_replace('=" ', '="', $newPostContent);
$newPostContent = str_replace("=' ", "='", $newPostContent);
$nextData = str_replace("<!--[[-Nextpost-]]-->", $newPostContent, $prevData);
if (file_put_contents($filePath, $nextData)) {
    die("posted");
} else {
    die("error");
}
//die(htmlentities($newPostContent));
?>

예제 #8
0
파일: new.php 프로젝트: xkeitax48/mySamples
<?php

//// 日記の新規作成処理を実行するページです ////
// エラーがあれば表示します
error_reporting(E_ALL);
// セッションを開始します
session_start();
// 関数のファイルを読み込みます
require_once "function.php";
// ログインしていなければログインフォームに戻ります
if (!isLogin()) {
    message("ログインしてください");
    header("location: login_form.php");
    exit;
}
// 記事がPOSTされているか判定します
// POSTされていなければ新規作成フォームに戻ります
if (empty($_POST["post"])) {
    message("入力されていない項目があります");
    header("location: new_form.php");
    exit;
}
// 記事をDBに書き込みます
$today = date("Ymd");
createNewPost($_SESSION["person_id"], $today, $_POST["post"]);
// マイページに移動します
header("location: mypage.php");
exit;