Esempio n. 1
0
 /**
  * Send an email notification to the site admin
  * @param string $subject The subject of the alert email
  * @param string $body The body of the message for the alert email
  * @return void sends an alert email to site admin
  */
 static function Alert($subject, $body)
 {
     App::LoadClass('Mail');
     $mail = new Mail();
     $mail->subject = $subject;
     $mail->body = $body;
     $mail->Send(Settings::Get('admin_email'));
 }
Esempio n. 2
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Message');
App::LoadClass('Privacy');
App::LoadClass('Mail');
// Establish page variables, objects, arrays, etc
View::InitView('message_send');
Plugin::Trigger('message_send.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
View::$vars->to = NULL;
View::$vars->subject = NULL;
View::$vars->msg = NULL;
View::$vars->errors = array();
View::$vars->message = null;
$message = array();
// Verify if request came from outside page
if (isset($_GET['username'])) {
    $username = trim($_GET['username']);
    $data = array('username' => $username);
    $id = User::Exist($data);
    if ($id) {
        $recipient = new User($id);
        View::$vars->to = $recipient->username;
    }
    // Verify if request came from reply
} elseif (isset($_GET['msg']) && is_numeric($_GET['msg'])) {
    $message_id = trim($_GET['msg']);
Esempio n. 3
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Privacy');
// Establish page variables, objects, arrays, etc
View::InitView('privacy_settings');
Plugin::Trigger('privacy_settings.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
View::$vars->privacy = Privacy::LoadByUser(View::$vars->user->user_id);
View::$vars->data = array();
View::$vars->errors = array();
View::$vars->message = null;
/**************************
 * Handle Form if submitted
 *************************/
if (isset($_POST['submitted'])) {
    // Validate Video Comments
    if (isset($_POST['video_comment']) && in_array($_POST['video_comment'], array('0', '1'))) {
        View::$vars->data['video_comment'] = $_POST['video_comment'];
    } else {
        View::$vars->errors['video_comment'] = TRUE;
    }
    // Validate Private Message
    if (isset($_POST['new_message']) && in_array($_POST['new_message'], array('0', '1'))) {
        View::$vars->data['new_message'] = $_POST['new_message'];
    } else {
        View::$vars->errors['new_message'] = TRUE;
    }
Esempio n. 4
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('Video');
// Establish page variables, objects, arrays, etc
View::InitView('mobile_videos');
Plugin::Trigger('mobile_videos.start');
// Retrieve video count
$query = "SELECT COUNT(video_id) FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND gated = '0'";
$result = $db->Query($query);
View::$vars->count = $db->FetchRow($result);
View::$vars->count = View::$vars->count[0];
// Retrieve video list
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND gated = '0' ORDER BY video_id DESC LIMIT 20";
View::$vars->videos = array();
$result = $db->Query($query);
while ($video = $db->FetchObj($result)) {
    View::$vars->videos[] = $video->video_id;
}
// Output Page
Plugin::Trigger('mobile_videos.before_render');
View::Render('videos.tpl');
Esempio n. 5
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Page');
// Establish page variables, objects, arrays, etc
View::InitView();
Plugin::Trigger('page.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
$page_id = null;
// Parse preview request
if (!empty($_GET['preview']) && is_numeric($_GET['preview'])) {
    $page_id = Page::Exist(array('page_id' => $_GET['preview']));
    // Parse the URI request
} else {
    $request = preg_replace('/^\\/?(.*?)\\/?$/', '$1', basename($_SERVER['REQUEST_URI']));
    $page_id = Page::Exist(array('slug' => $request, 'status' => 'published'));
}
### Validate requested page
if ($page_id) {
    // Retrieve custom page
    $page = new Page($page_id);
    $page_name = 'page_' . $page->slug;
    // Set view settings for custom page
    View::$vars->page = $page;
    View::$options->page = $page_name;
    View::$vars->meta = Language::GetMeta($page_name);
Esempio n. 6
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
App::LoadClass('Plugin');
// Retrieve video information
if (!isset($_POST['token'], $_POST['timestamp'])) {
    App::Throw404();
}
// Load main session and validate login
session_write_close();
session_id($_POST['token']);
session_start();
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
// Validate file upload key
$upload_key = md5(md5($_POST['timestamp']) . SECRET_KEY);
if (!isset($_SESSION['upload_key']) || $_SESSION['upload_key'] != $upload_key) {
    App::Throw404();
}
try {
    ### Verify upload was made
    if (empty($_FILES) || !isset($_FILES['upload']['name'])) {
        throw new Exception('nofile');
    }
    ### Check for upload errors
    if ($_FILES['upload']['error'] != 0) {
        App::Alert('Error During Plugin Upload', 'There was an HTTP FILE POST error (Error code #' . $_FILES['upload']['error'] . ').');
        throw new Exception('error');
Esempio n. 7
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Message');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
View::InitView('message_inbox');
Plugin::Trigger('message_inbox.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 20;
$url = HOST . '/myaccount/message/inbox';
View::$vars->message = null;
/***********************
Handle form if submitted
***********************/
// Delete message (Request came from this page)
if (isset($_POST['submitted'])) {
    // Verify messages were chosen
    if (!empty($_POST['delete']) && is_array($_POST['delete'])) {
        foreach ($_POST['delete'] as $value) {
            $data = array('recipient' => View::$vars->user->user_id, 'message_id' => $value);
            $message_id = Message::Exist($data);
            if ($message_id) {
                Message::Delete($message_id);
                Plugin::Trigger('message_inbox.purge_single_message');
            }
        }
        View::$vars->message = Language::GetText('success_messages_purged');
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
App::LoadClass('Category');
// Establish page variables, objects, arrays, etc
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$page_title = 'Video Categories';
$categories = array();
$data = array();
$errors = array();
$message = null;
/**************************
Handle create category form
**************************/
if (isset($_POST['submitted_add'])) {
    try {
        // Validate title
        if (empty($_POST['cat_name']) || ctype_space($_POST['cat_name'])) {
            throw new Exception('Invalid category name. Please try again.');
        }
        $data['slug'] = Functions::CreateSlug(trim($_POST['cat_name']));
        $data['cat_name'] = htmlspecialchars(trim($_POST['cat_name']));
        if (Category::Exist(array('slug' => $data['slug']))) {
            throw new Exception('Category name or slug already exists. Please note that in the slug special characters are replaced by hyphens.');
        }
        Category::Create($data);
        $message = $data['cat_name'] . ' was successfully created.';
Esempio n. 9
0
 /**
  * Make a user visible to the public and notify admin of registration
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void User is activated, and admin alerted. If approval is
  * required user is marked pending and placed in queue
  */
 public function Approve($action)
 {
     global $config;
     $send_alert = false;
     Plugin::Trigger('user.before_approve');
     // 1) Admin created user in Admin Panel
     // 2) User signed up & activated
     // 3) User is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // User is activating account, but approval is required
         if ($action == 'activate' && Settings::Get('auto_approve_users') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Member Awaiting Approval';
             $body = 'A new member has registered and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending'));
             Plugin::Trigger('user.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_users') == '1') {
                 $send_alert = true;
                 $subject = 'New Member Registered';
                 $body = 'A new member has registered.';
             }
             // Activate & Release
             $this->Update(array('status' => 'active', 'released' => 1));
             // Update user's anonymous comments IF/APP
             $query = "UPDATE " . DB_PREFIX . "comments SET user_id = {$this->user_id} WHERE email = '{$this->email}'";
             $this->db->Query($query);
             // Send Welcome email
             if ($action == 'approve') {
                 App::LoadClass('Mail');
                 $mail = new Mail();
                 $mail->LoadTemplate('account_approved', array('sitename' => $config->sitename));
                 $mail->Send($this->email);
             }
             Plugin::Trigger('user.release');
         }
         // User is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Activate User
             $this->Update(array('status' => 'active'));
             Plugin::Trigger('user.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Username: {$this->username}\n";
         $body .= "Profile URL: " . HOST . "/members/{$this->username}/\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('user.approve');
 }
Esempio n. 10
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Rating');
App::LoadClass('Subscription');
App::LoadClass('Flag');
App::LoadClass('Post');
// Establish page variables, objects, arrays, etc
View::InitView('profile');
Plugin::Trigger('profile.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
$success = NULL;
$errors = NULL;
$sub_id = NULL;
$post_count = 5;
// Verify Member was supplied
if (isset($_GET['username'])) {
    $data = array('username' => $_GET['username'], 'status' => 'Active');
    $user_id = User::Exist($data);
} else {
    App::Throw404();
}
// Verify Member exists
if ($user_id) {
    View::$vars->member = new User($user_id);
Esempio n. 11
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Subscription');
Plugin::Trigger('subscribe.ajax.start');
// Establish page variables, objects, arrays, etc
$logged_in = User::LoginCheck();
if ($logged_in) {
    $user = new User($logged_in);
}
Plugin::Trigger('subscribe.ajax.login_check');
// Verify passed values
if (empty($_POST['type']) || !in_array($_POST['type'], array('subscribe', 'unsubscribe'))) {
    App::Throw404();
}
if (empty($_POST['user']) || !is_numeric($_POST['user'])) {
    App::Throw404();
}
// Validate user
if (!User::Exist(array('user_id' => $_POST['user'], 'status' => 'active'))) {
    App::Throw404();
}
$member = new User($_POST['user']);
### Handle subscribe/unsubscribe
switch ($_POST['type']) {
    ### Handle subscribe user to a member
    case 'subscribe':
        // Verify user is logged in
        if (!$logged_in) {
Esempio n. 12
0
<?php

App::LoadClass('PHPMailer');
class Mail
{
    private $config;
    public $template;
    public $phpmailer;
    public $from_name;
    public $from_address;
    public $subject = '';
    public $body = '';
    /**
     * Instantiate object
     * @global object $config Site configuration settings
     * @return object Returns object of class type
     */
    public function __construct()
    {
        global $config;
        $this->config = $config;
        $this->phpmailer = new PHPMailer();
        // Retrieve "From" name and address
        $url = parse_url(HOST);
        $this->from_name = Settings::Get('from_name');
        $this->from_address = Settings::Get('from_address');
        $this->from_name = empty($this->from_name) ? $this->config->sitename : $this->from_name;
        $this->from_address = empty($this->from_address) ? 'cumulusclips@' . $url['host'] : $this->from_address;
        $this->phpmailer->FromName = $this->from_name;
        $this->phpmailer->From = $this->from_address;
        // Retrieve SMTP settings
Esempio n. 13
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Flag');
// Establish page variables, objects, arrays, etc
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$page_title = 'Edit Video';
$private_url = Video::GeneratePrivate();
$categories = array();
$data = array();
$errors = array();
$message = null;
// Retrieve Category names
$query = "SELECT cat_id, cat_name FROM " . DB_PREFIX . "categories";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
    $categories[$row->cat_id] = $row->cat_name;
}
// Build return to list link
if (!empty($_SESSION['list_page'])) {
    $list_page = $_SESSION['list_page'];
} else {
    $list_page = ADMIN . '/videos.php';
}
### Verify a video was provided
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] != 0) {
Esempio n. 14
0
 /**
  * Make a video visible to the public and notify subscribers of new video
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void Video is activated, subscribers are notified, and admin
  * alerted. If approval is required video is marked as pending and placed in queue
  */
 public function Approve($action)
 {
     App::LoadClass('User');
     App::LoadClass('Privacy');
     App::LoadClass('Mail');
     global $config;
     $send_alert = false;
     Plugin::Trigger('video.before_approve');
     // 1) Admin created video in Admin Panel
     // 2) User created video
     // 3) Video is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // User uploaded video but needs admin approval
         if ($action == 'activate' && Settings::Get('auto_approve_videos') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Video Awaiting Approval';
             $body = 'A new video has been uploaded and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending approval'));
             Plugin::Trigger('video.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_videos') == '1') {
                 $send_alert = true;
                 $subject = 'New Video Uploaded';
                 $body = 'A new video has been uploaded.';
             }
             // Activate & Release
             $this->Update(array('status' => 'approved', 'released' => 1));
             // Send subscribers notification if opted-in
             $query = "SELECT user_id FROM " . DB_PREFIX . "subscriptions WHERE member = {$this->user_id}";
             $result = $this->db->Query($query);
             while ($opt = $this->db->FetchObj($result)) {
                 $subscriber = new User($opt->user_id);
                 $privacy = Privacy::LoadByUser($opt->user_id);
                 if ($privacy->OptCheck('new_video')) {
                     $replacements = array('host' => HOST, 'sitename' => $config->sitename, 'email' => $subscriber->email, 'member' => $this->username, 'title' => $this->title, 'video_id' => $this->video_id, 'slug' => $this->slug);
                     $mail = new Mail();
                     $mail->LoadTemplate('new_video', $replacements);
                     $mail->Send($subscriber->email);
                     Plugin::Trigger('video.notify_subscribers');
                 }
             }
             Plugin::Trigger('video.release');
         }
         // Video is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Approve Video
             $this->Update(array('status' => 'approved'));
             Plugin::Trigger('video.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Title: {$this->title}\n";
         $body .= "URL: {$this->url}\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('video.approve');
 }
Esempio n. 15
0
// Load App class and perform pre-init checks
if (!class_exists('App')) {
    include LIB . '/App.php';
}
App::InstallCheck();
App::MaintCheck();
// Load DB & FTP credentials
include_once 'config.php';
// Load Main Classes
App::LoadClass('Database');
App::LoadClass('Settings');
App::LoadClass('Functions');
App::LoadClass('Language');
App::LoadClass('View');
App::LoadClass('Plugin');
App::LoadClass('Filesystem');
// Retrieve site settings from DB
$db = Database::GetInstance();
Settings::LoadSettings();
// General Site Settings from DB
define('HOST', Settings::Get('base_url'));
define('MOBILE_HOST', Settings::Get('base_url') . '/m');
define('SECRET_KEY', Settings::Get('secret_key'));
$config = new stdClass();
$config->sitename = Settings::Get('sitename');
$config->roles = unserialize(Settings::Get('roles'));
$config->enable_uploads = Settings::Get('enable_uploads');
$config->debug_conversion = Settings::Get('debug_conversion') == '1' ? true : false;
$config->video_size_limit = Settings::Get('video_size_limit');
$config->accepted_video_formats = array('flv', 'wmv', 'avi', 'ogg', 'mpg', 'mp4', 'mov', 'm4v');
$config->accepted_avatar_formats = array('png', 'jpeg', 'jpg', 'gif');
Esempio n. 16
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Pagination');
App::LoadClass('Rating');
App::LoadClass('Favorite');
// Establish page variables, objects, arrays, etc
View::InitView('myfavorites');
Plugin::Trigger('myfavorites.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/myfavorites';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['vid']) && is_numeric($_GET['vid']) && $_GET['vid'] != 0) {
    $data = array('user_id' => View::$vars->user->user_id, 'video_id' => $_GET['vid']);
    $id = Favorite::Exist($data);
    if ($id) {
        Favorite::Delete($id);
        View::$vars->message = Language::GetText('success_favorite_removed');
        View::$vars->message_type = 'success';
        Plugin::Trigger('myfavorites.remove_favorite');
    }
}
// Retrieve total count
Esempio n. 17
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Message');
// Establish page variables, objects, arrays, etc
View::InitView('message_read');
Plugin::Trigger('message_read.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
### Verify a message was chosen
if (empty($_GET['msg']) || !is_numeric($_GET['msg'])) {
    App::Throw404();
}
### Retrieve message information
$message_id = trim($_GET['msg']);
$data = array('recipient' => View::$vars->user->user_id, 'message_id' => $message_id);
$message_id = Message::Exist($data);
if ($message_id) {
    View::$vars->message = new Message($message_id);
    $data = array('status' => 'read');
    View::$vars->message->Update($data);
} else {
    App::Throw404();
}
// Outuput page
Plugin::Trigger('message_read.before_render');
View::Render('myaccount/message_read.tpl');
Esempio n. 18
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('Video');
App::LoadClass('Rating');
Plugin::Trigger('video_sitemap.start');
// Establish page variables, objects, arrays, etc
$xml_header = '<?xml version="1.0" encoding="UTF-8"?>';
$limit = 45000;
### Verify if page was provided
if (!isset($_GET['page'])) {
    App::Throw404();
}
### Count number of video xml files
$query = "SELECT COUNT(video_id) FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0'";
$result = $db->Query($query);
$row = $db->FetchRow($result);
if ($row[0] > $limit) {
    $file_count = ceil($row[0] / $limit);
} else {
    $file_count = 1;
}
### Display content based on requested xml type
if (empty($_GET['page'])) {
    // Open sitemap index
    Plugin::Trigger('video_sitemap.sitemapindex');
    $xml_root = '<sitemapindex></sitemapindex>';
    $xml_frame = $xml_header . $xml_root;
    $xml = new SimpleXMLElement($xml_frame);
    $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
Esempio n. 19
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Video');
App::LoadClass('Flag');
App::LoadClass('Comment');
Plugin::Trigger('flag.ajax.start');
// Establish page variables, objects, arrays, etc
$logged_in = User::LoginCheck();
if ($logged_in) {
    $user = new User($logged_in);
}
Plugin::Trigger('flag.ajax.login_check');
// Verify valid ID was provided
if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
    App::Throw404();
}
if (empty($_POST['type']) || !in_array($_POST['type'], array('video', 'member', 'comment'))) {
    App::Throw404();
}
try {
    // Check if user is logged in
    if (!$logged_in) {
        throw new Exception(Language::GetText('error_flag_login'));
    }
    switch ($_POST['type']) {
        case 'video':
            $id = Video::Exist(array('video_id' => $_POST['id'], 'status' => 'approved'));
            if (!$id) {
Esempio n. 20
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Avatar');
### Retrieve video information
if (!isset($_POST['token'], $_POST['timestamp'])) {
    App::Throw404();
}
session_write_close();
session_id($_POST['token']);
session_start();
// Validate upload key
$upload_key = md5(md5($_POST['timestamp']) . SECRET_KEY);
if (!isset($_SESSION['upload_key']) || $_SESSION['upload_key'] != $upload_key) {
    App::Throw404();
}
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$user = new User($logged_in);
try {
    ### Verify upload was made
    if (empty($_FILES) || !isset($_FILES['upload']['name'])) {
        throw new Exception(Language::GetText('error_uploadify_empty'));
    }
    ### Check for upload errors
    if ($_FILES['upload']['error'] != 0) {
        App::Alert('Error During Avatar Upload', 'There was an HTTP FILE POST error (Error code #' . $_FILES['upload']['error'] . ').');
        throw new Exception(Language::GetText('error_uploadify_system', array('host' => HOST)));
    }
    ### Validate filesize
Esempio n. 21
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('contact');
Plugin::Trigger('contact.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
View::$vars->Errors = array();
View::$vars->name = null;
View::$vars->email = null;
View::$vars->feedback = null;
View::$vars->message = null;
View::$vars->message_type = null;
/***********************
Handle form if submitted
***********************/
if (isset($_POST['submitted'])) {
    // Validate name
    if (!empty($_POST['name']) && !ctype_space($_POST['name'])) {
        View::$vars->name = trim($_POST['name']);
    } else {
        View::$vars->Errors['name'] = Language::GetText('error_name');
    }
    // Validate email
    $string = '/^[a-z0-9][a-z0-9_\\.\\-]+@[a-z0-9][a-z0-9\\.-]+\\.[a-z0-9]{2,4}$/i';
    if (!empty($_POST['email']) && !ctype_space($_POST['email']) && preg_match($string, $_POST['email'])) {
Esempio n. 22
0
 /**
  * Make a comment visible to the public and notify user of new comment
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void Comment is activated, user is notified, and admin alerted.
  * If approval is required comment is marked pending and placed in queue
  */
 public function Approve($action)
 {
     App::LoadClass('User');
     App::LoadClass('Video');
     App::LoadClass('Privacy');
     App::LoadClass('Mail');
     global $config;
     $send_alert = false;
     $video = new Video($this->video_id);
     Plugin::Trigger('comment.before_approve');
     // 1) Admin posted comment in Admin Panel
     // 2) Comment is posted by user
     // 3) Comment is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // Comment is being posted by user, but approval is required
         if ($action == 'activate' && Settings::Get('auto_approve_comments') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Comment Awaiting Approval';
             $body = 'A new comment has been posted and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending'));
             Plugin::Trigger('comment.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_comments') == '1') {
                 $send_alert = true;
                 $subject = 'New Comment Posted';
                 $body = 'A new comment has been posted.';
             }
             // Activate & Release
             $this->Update(array('status' => 'approved', 'released' => 1));
             // Send video owner new comment notifition, if opted-in
             $privacy = Privacy::LoadByUser($video->user_id);
             if ($privacy->OptCheck('video_comment')) {
                 $user = new User($video->user_id);
                 $replacements = array('host' => HOST, 'sitename' => $config->sitename, 'email' => $user->email, 'title' => $video->title);
                 $mail = new Mail();
                 $mail->LoadTemplate('video_comment', $replacements);
                 $mail->Send($user->email);
                 Plugin::Trigger('comment.notify_member');
             }
             Plugin::Trigger('comment.release');
         }
         // Comment is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Activate Comment
             $this->Update(array('status' => 'approved'));
             Plugin::Trigger('comment.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Author: {$this->name}\n";
         $body .= "Video URL: {$video->url}/\n";
         $body .= "Comments: {$this->comments}\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('comment.approve');
 }