Ejemplo n.º 1
0
function get_comments($post_id)
{
    $comment = array();
    $sql = "SELECT * FROM pb_comments WHERE post_id='{$post_id}'";
    $conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while ($val = $result->fetch_assoc()) {
            $user_data = json_decode(pb_table_data('pb_users', 'user_data', "user_id='+{$val['author']}'"), true);
            $item = array('id' => $val['id'], 'date' => $val['date'], 'timestamp' => array('date' => $val['date'], 'laps' => time_ago(strtotime($val['date']))), 'user' => array('id' => $val['author'], 'name' => $user_data[0]['name'], 'username' => $user_data[0]['username'], 'avatar' => $user_data[0]['avatar']), 'status' => $val['status'], 'comment' => $val['comment']);
            array_push($comment, $item);
        }
    }
    $conn->close();
    return json_encode($comment);
}
Ejemplo n.º 2
0
<?php

//pb_product
if ($slq_table == 'pb_post') {
    $pData = json_decode($val['product_info']);
    $saveImag = array();
    $saveImag_size = array();
    foreach ($pData as $pd) {
        $images = explode(',', $pd->images);
        $timeAgo = time_ago(strtotime($pd->timestamp));
        $date = $pd->timestamp;
        foreach ($images as $img) {
            array_push($saveImag, pb_safe_image_structure(pb_table_data('pb_safe_image', 'string', "uid='{$img}'")));
            array_push($saveImag_size, pb_safe_image_structure(pb_table_data('pb_safe_image', 'size', "uid='{$img}'")));
        }
        $title = $pd->title;
        $desc = $pd->desc;
        $tags = $pd->tags;
        $price = $pd->price;
        $condition = $pd->condition;
    }
    $user_data = json_decode(pb_user_data($val['user_id'], 'user_data'), true);
    foreach ($user_data as $data) {
        $author = $data['name'];
        $user = $data['username'];
        $avatar = $data['avatar'];
    }
    $comment = json_decode(get_comments($val['product_id']));
    $imgSize = explode(':', $saveImag_size[0]);
    $entity = array('id' => $val['product_id'], 'type' => $val['type'], 'timestamp' => array('date' => $date, 'laps' => $timeAgo), 'user' => array('id' => $val['user_id'], 'name' => $author, 'username' => $user, 'avatar' => $avatar), 'images' => array('featured' => $saveImag[0], 'featured_width' => $imgSize[0], 'featured_height' => $imgSize[1], 'list' => $saveImag), 'product_info' => array('title' => $title, 'desc' => $desc, 'tags' => $tags, 'price' => $price, 'condition' => $condition), 'trans_info' => json_decode($val['trans_info']), 'comments' => array('count' => count($comment), 'comments' => $comment), 'status' => $val['status']);
    array_push($mainJson, $entity);
Ejemplo n.º 3
0
             array_push($mainJson, $entity);
         }
     }
 }
 $conn->close();
 //pb_services
 $conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME);
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 }
 $sql = "SELECT service_id, title, category, ratings, logo FROM pb_services WHERE (category LIKE '%{$query}%' OR title LIKE '%{$query}%' OR bio LIKE '%{$query}%') LIMIT 200";
 $result = $conn->query($sql);
 if (is_object($result)) {
     if ($result->num_rows > 0) {
         while ($val = $result->fetch_assoc()) {
             $img = pb_table_data('pb_safe_image', 'string', "uid='{$val['logo']}'");
             $entity = array('id' => $val['service_id'], 'type' => 'service', 'title' => strtolower($val['title']), 'info' => strtolower($val['category']), 'small' => strtolower($val['category'] . '<div class="pb-stars-search" data-stars="' . $val['ratings'] . '"></div>'), 'image' => $img);
             array_push($mainJson, $entity);
         }
     }
 }
 $conn->close();
 //pb_services
 $conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME);
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 }
 $sql = "SELECT id, question FROM pb_faq WHERE question LIKE '%{$query}%' LIMIT 200";
 $result = $conn->query($sql);
 if (is_object($result)) {
     if ($result->num_rows > 0) {
Ejemplo n.º 4
0
function pb_add_reveiw($user_id)
{
    pb_add_comment($user_id);
    $svr_id = $_POST['post_id'];
    $ratings = $_POST['ratings'];
    if ($ratings > '0') {
        if ($ratings > '0') {
            $r = '3';
        }
        if ($ratings > '25') {
            $r = '3.5';
        }
        if ($ratings > '50') {
            $r = '4';
        }
        if ($ratings > '75') {
            $r = '4.5';
        }
        if ($ratings > '90') {
            $r = '5';
        }
    } else {
        if ($ratings < '0') {
            $r = '3';
        }
        if ($ratings < '-25') {
            $r = '3.5';
        }
        if ($ratings < '-50') {
            $r = '2';
        }
        if ($ratings < '-75') {
            $r = '1.5';
        }
        if ($ratings < '-90') {
            $r = '1';
        }
    }
    $indb = pb_table_data('pb_services', 'ratings', "service_id='{$svr_id}'");
    $tot = (double) $r + (double) $indb;
    $adv = $tot / 2;
    return pb_db("UPDATE pb_services SET ratings='{$adv}' WHERE service_id='{$svr_id}'");
}
Ejemplo n.º 5
0
    $sql = "SELECT product_id, type, user_id, product_info FROM pb_post WHERE status='open' AND product_id BETWEEN {$limit} and {$offset} ORDER BY product_id DESC";
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $pData = json_decode($row['product_info']);
        $saveImag = array();
        $saveImag_size = array();
        foreach ($pData as $pd) {
            $images = explode(',', $pd->images);
            $timeAgo = time_ago(strtotime($pd->timestamp));
            $date = $pd->timestamp;
            foreach ($images as $img) {
                array_push($saveImag, pb_safe_image_structure(pb_table_data('pb_safe_image', 'string', "uid='{$img}'")));
                array_push($saveImag_size, pb_safe_image_structure(pb_table_data('pb_safe_image', 'size', "uid='{$img}'")));
            }
            $title = $pd->title;
            $desc = $pd->desc;
            $tags = $pd->tags;
            $price = $pd->price;
            $condition = $pd->condition;
        }
        $user_data = json_decode(pb_table_data('pb_users', 'user_data', "user_id='{$row['user_id']}'"), true);
        $comment = json_decode(get_comments($row['product_id']));
        $imgSize = explode(':', $saveImag_size[0]);
        $entity = array('id' => $row['product_id'], 'type' => $row['type'], 'timestamp' => array('date' => $date, 'laps' => $timeAgo), 'user' => array('id' => $row['user_id'], 'name' => $user_data[0]['name'], 'username' => $user_data[0]['username'], 'avatar' => $user_data[0]['avatar']), 'images' => array('featured' => $saveImag[0], 'featured_size' => array('width' => $imgSize[0], 'height' => $imgSize[1]), 'list' => $saveImag), 'product_info' => array('title' => $title, 'desc' => $desc, 'tags' => $tags, 'price' => $price, 'condition' => $condition), 'comments' => array('count' => count($comment), 'comments' => $comment));
        array_push($mainJson, $entity);
    }
}
$conn->close();
echo return_graph($mainJson, 'json');