Beispiel #1
0
function com_get_user_id()
{
    //Here you need to set the user_id from your session
    if (com_is_logged()) {
        $user_id = $_SESSION['user']['id'];
        return $user_id;
    } else {
        return false;
    }
}
Beispiel #2
0
 /**
  * Get user gravatar from database or custom avatar or gravatar
  *
  * @access  public
  * @return  string
  */
 public function user_avatar()
 {
     if (com_is_logged()) {
         $u = self::$config['db_users'];
         $rows = $u['id'] . ',' . $u['name'] . ',' . $u['email'] . (!empty($u['avatar']) ? ',' . $u['avatar'] : '');
         $user_id = com_get_user_id();
         $db = new Database();
         if ($db->select($u['table'], $rows, $u['id'] . " = {$user_id} ", null, 1)) {
             $user = $db->getResult();
             $user = $user[1];
             if (!empty($u['avatar'])) {
                 return $user['avatar'];
             } else {
                 if (function_exists('com_get_user_avatar')) {
                     return com_get_user_avatar($user_id);
                 } else {
                     return $this->gravatar($user['email']);
                 }
             }
         }
     }
 }
Beispiel #3
0
            if (isset($_GET['page'])) {
                $_GET['parent'] = 0;
                $_GET['email'] = false;
                $_GET['status'] = 1;
                $_GET['page'] = urldecode($_GET['page']);
                $data = Comments::get_comments($_GET);
                echo json_encode(array('success' => true, 'data' => $data));
            } else {
                echo 0;
            }
            break;
    }
}
// POST actions
if (isset($_POST['action'])) {
    if (Comments::config('logged_only') && !com_is_logged()) {
        die('0');
    }
    switch ($_POST['action']) {
        case 'add-comment':
            $_POST['page'] = urldecode($_POST['page']);
            $data = Comments::add_comment($_POST);
            if (!empty(Comments::errors)) {
                echo json_encode(array('success' => false, 'data' => Comments::errors));
            } else {
                echo json_encode(array('success' => true, 'data' => $data));
            }
            break;
        case 'comment-notification':
            if (!empty($_POST['comment_id']) and is_numeric($_POST['comment_id']) and isset($_SESSION['com_email_notif']) and $_SESSION['com_email_notif'] + 6 > time()) {
                $rows = 'id,page,author,author_email,author_url,date,comment,user_id,author_ip,status';