Exemplo n.º 1
0
 /**
  * Save an uploaded image to a new location
  * @param string $original_file Path to the temporary image
  * @param string $original_extension Original file extension of temporary image
  * @param string $save_as Filename to save the new image as
  * @return void Temporary image is resampled, resized, and saved in its final location
  */
 static function SaveAvatar($original_file, $original_extension, $save_as)
 {
     $avatar_size = 100;
     $save_as = UPLOAD_PATH . '/avatars/' . $save_as;
     list($width_src, $height_src) = getimagesize($original_file);
     // Determine new image dimensions
     $ratio = $width_src / $height_src;
     // Check for dimension overage
     if ($width_src > $height_src && $width_src > $avatar_size) {
         $width_dst = $avatar_size;
         // Resize width
         $height_dst = floor($width_dst / $ratio);
         // Resize height based on ratio
     } else {
         if ($width_src < $height_src && $height_src > $avatar_size) {
             $height_dst = $avatar_size;
             // Resize height
             $width_dst = floor($height_dst * $ratio);
             // Resize width based on ratio
         } else {
             if ($width_src == $height_src && $width_src > $avatar_size) {
                 $width_dst = $avatar_size;
                 // Resize width
                 $height_dst = $avatar_size;
                 // Resize height
             } else {
                 $width_dst = $width_src;
                 $height_dst = $height_src;
             }
         }
     }
     Plugin::Trigger('avatar.before_save');
     // Determin which type of image object to create (and how to process it) based on file extension
     if (in_array($original_extension, array('jpg', 'jpeg'))) {
         // Create image object from original image
         $image = imagecreatefromjpeg($original_file);
         // Resize image & Resample (To corrupt any possible injections)
         $image_dst = imagecreatetruecolor($width_dst, $height_dst);
         imagecopyresampled($image_dst, $image, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src);
         // Save image to HDD as JPG
         imagejpeg($image_dst, $save_as, 100);
     } else {
         // Create image object from original image
         if ($original_extension == 'gif') {
             // GIFs are converted to PNGs
             $image = imagecreatefromgif($original_file);
         } else {
             $image = imagecreatefrompng($original_file);
         }
         // Create empty resized image & turn off transparency
         $image_dst = imagecreatetruecolor($width_dst, $height_dst);
         imagealphablending($image_dst, false);
         imagesavealpha($image_dst, true);
         // Resize image & Resample (To corrupt any possible injections)
         imagecopyresampled($image_dst, $image, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src);
         // Save image to HDD as PNG
         imagepng($image_dst, $save_as);
     }
     Plugin::Trigger('avatar.save');
 }
Exemplo n.º 2
0
 /**
  * Output paginated links
  * @return mixed Returns the pagination block with links 
  */
 public function Paginate()
 {
     Plugin::Trigger('pagination.paginate');
     if ($this->total <= $this->records_per_page) {
         return '';
     }
     $links = $this->GetLinks();
     $previous = $this->GetPrevious();
     $first = $this->GetFirst();
     $last = $this->GetLast();
     $next = $this->GetNext();
     return '<ul id="pagination">' . $previous . $first . $links . $last . $next . '</ul>';
 }
Exemplo n.º 3
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
Plugin::Trigger('admin.plugin_settings.start');
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$enabled_plugins = Plugin::GetEnabledPlugins();
// Validate plugin
if (!empty($_GET['plugin']) && Plugin::ValidPlugin($_GET['plugin'], true)) {
    $plugin = trim($_GET['plugin']);
} else {
    App::Throw404();
}
// Verify plugin is enabled and has 'Settings'
if (array_search($plugin, $enabled_plugins) !== false && method_exists($plugin, 'Settings')) {
    $plugin_info = Plugin::GetPluginInfo($plugin);
    $page_title = $plugin_info->name . ' Settings';
} else {
    App::Throw404();
}
// Output Page
Plugin::Trigger("admin.{$plugin}.before_render");
include 'header.php';
call_user_func(array($plugin, 'Settings'));
Plugin::Trigger("admin.{$plugin}.settings");
include 'footer.php';
Exemplo n.º 4
0
    $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'])) {
        View::$vars->email = trim($_POST['email']);
    } else {
        View::$vars->Errors['email'] = Language::GetText('error_email');
    }
    // Validate feedback
    if (!empty($_POST['feedback']) && !ctype_space($_POST['feedback'])) {
        View::$vars->feedback = trim($_POST['feedback']);
    } else {
        View::$vars->Errors['feedback'] = Language::GetText('error_message');
    }
    // Send email if no errors
    if (empty(View::$vars->Errors)) {
        $subject = 'Message received From ' . $config->sitename;
        $Msg = "Name: " . View::$vars->name . "\n";
        $Msg .= "E-mail: " . View::$vars->email . "\n";
        $Msg .= "Message:\n" . View::$vars->feedback;
        App::Alert($subject, $Msg);
        Plugin::Trigger('contact.send');
        View::$vars->message_type = 'success';
        View::$vars->message = Language::GetText('success_contact_sent');
    } else {
        View::$vars->message_type = 'error';
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->Errors);
    }
}
// Output Page
Plugin::Trigger('contact.before_render');
View::Render('contact.tpl');
Exemplo n.º 5
0
        throw new Exception(Language::GetText('error_flag_own'));
    }
    // Verify Flag doesn't exist
    $data = array('type' => $_POST['type'], 'id' => $_POST['id'], 'user_id' => $user->user_id);
    if (Flag::Exist($data)) {
        throw new Exception(Language::GetText('error_flag_duplicate'));
    }
    Plugin::Trigger('flag.ajax.before_flag');
    // Send admin alert
    if (Settings::Get('alerts_flags') == '1') {
        $subject = 'Content Flagged As Inappropriate';
        $body = "One of your members flagged content as inappropriate. ";
        $body .= "Please review the content to verify it is valid. ";
        $body .= "You can login to the Admin Panel to dismiss the flag, or uphold it and ban the content.";
        $body .= "\n\n=======================================================\n";
        $body .= "Content Type: {$type}\n";
        $body .= "URL: {$url}\n";
        $body .= "{$name}\n";
        $body .= "=======================================================";
        Plugin::Trigger('flag.ajax.alert');
        App::Alert($subject, $body);
    }
    // Create flag and output message
    Flag::Create($data);
    Plugin::Trigger('flag.ajax.flag');
    echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_flag')));
    exit;
} catch (Exception $e) {
    echo json_encode(array('result' => 0, 'msg' => $e->getMessage()));
    exit;
}
Exemplo n.º 6
0
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
$query = "SELECT " . DB_PREFIX . "favorites.video_id FROM " . DB_PREFIX . "favorites INNER JOIN " . DB_PREFIX . "videos ON " . DB_PREFIX . "favorites.video_id = " . DB_PREFIX . "videos.video_id WHERE status = 'approved' AND private = '0' AND " . DB_PREFIX . "favorites.user_id = " . View::$vars->user->user_id;
$result_count = $db->Query($query);
$total = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, $total, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
View::$vars->result = $db->Query($query);
// Output page
Plugin::Trigger('myfavorites.before_render');
View::Render('myaccount/myfavorites.tpl');
Exemplo n.º 7
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');
Exemplo n.º 8
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_play');
Plugin::Trigger('mobile_play.start');
// Verify a video was selected
if (!isset($_GET['vid']) || !is_numeric($_GET['vid'])) {
    App::Throw404();
}
// Verify video exists
$data = array('video_id' => $_GET['vid'], 'status' => 'approved', 'private' => '0', 'gated' => '0');
$id = Video::Exist($data);
if (!$id) {
    App::Throw404();
}
// Retrieve video
View::$vars->video = $video = new Video($id);
View::$vars->meta->title = $video->title;
// Output Page
Plugin::Trigger('mobile_play.before_render');
View::Render('play.tpl');
Exemplo n.º 9
0
    $namespace .= ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
    $xml_root = '<urlset' . $namespace . '></urlset>';
    $xml_frame = $xml_header . $xml_root;
    $xml = new SimpleXMLElement($xml_frame);
    // Add video entries
    while ($row = $db->FetchObj($result)) {
        $video = new Video($row->video_id);
        $url = $xml->addChild('url');
        $url->addChild('loc', $video->url . '/');
        $block = $url->addChild('video:video', '', 'video');
        $block->addChild('content_loc', $config->flv_url . '/' . $video->filename . '.flv');
        $block->addChild('thumbnail_loc', $config->thumb_url . '/' . $video->filename . '.jpg');
        $block->addChild('title', $video->title);
        $block->addChild('description', $video->description);
        $block->addChild('rating', Rating::GetFiveScaleRating($row->video_id));
        $block->addChild('view_count', $video->views);
        $block->addChild('publication_date', Functions::DateFormat('Y-m-d', $video->date_created));
        foreach ($video->tags as $_value) {
            $block->addChild('tag', $_value);
        }
        $block->addChild('category', $row->cat_name);
        $block->addChild('family_friendly', 'yes');
        $block->addChild('duration', Functions::DurationInSeconds($video->duration));
    }
} else {
    App::Throw404();
}
// Output XML
Plugin::Trigger('video_sitemap.output');
header("Content-type: text/xml");
echo $xml->asXML();
Exemplo n.º 10
0
    $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE MATCH(title, tags, description) AGAINST ('{$search_terms}') AND status = 'approved' AND private = '0' AND video_id != " . View::$vars->video->video_id . " LIMIT 9";
    View::$vars->result_related = $db->Query($query);
} else {
    // Use LIKE query
    $tags = View::$vars->video->tags;
    foreach ($tags as $key => $tag) {
        $tag = $db->Escape($tag);
        $sub_queries[] = "video_id IN (SELECT video_id FROM " . DB_PREFIX . "videos WHERE title LIKE '%{$tag}%' OR description LIKE '%{$tag}%' OR tags LIKE '%{$tag}%')";
    }
    $sub_queries = implode(' OR ', $sub_queries);
    $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE ({$sub_queries}) AND status = 'approved' AND private = '0' AND video_id != " . View::$vars->video->video_id . " LIMIT 9";
    View::$vars->result_related = $db->Query($query);
}
Plugin::Trigger('play.load_suggestions');
### Retrieve comment count
$query = "SELECT COUNT(comment_id) FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " AND status = 'approved'";
Plugin::Trigger('play.comment_count');
$result_comment_count = $db->Query($query);
$comment_count = $db->FetchRow($result_comment_count);
View::$vars->comment_count = $comment_count[0];
### Retrieve comments
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " AND status = 'approved' ORDER BY comment_id DESC LIMIT 0, 5";
Plugin::Trigger('play.load_comments');
$result_comments = $db->Query($query);
View::$vars->comment_list = array();
while ($row = $db->FetchObj($result_comments)) {
    View::$vars->comment_list[] = $row->comment_id;
}
// Output Page
Plugin::Trigger('play.before_render');
View::Render('play.tpl');
Exemplo n.º 11
0
            View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
        } else {
            View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
        }
    } else {
        View::$vars->errors['email'] = Language::GetText('error_email');
    }
    ### Create user if no errors were found
    if (empty(View::$vars->errors)) {
        View::$vars->data['confirm_code'] = User::CreateToken();
        View::$vars->data['status'] = 'new';
        View::$vars->data['password'] = md5(View::$vars->data['password']);
        Plugin::Trigger('register.before_create');
        User::Create(View::$vars->data);
        View::$vars->message = Language::GetText('success_registered');
        View::$vars->message_type = 'success';
        $replacements = array('confirm_code' => View::$vars->data['confirm_code'], 'host' => HOST, 'sitename' => $config->sitename);
        $mail = new Mail();
        $mail->LoadTemplate('welcome', $replacements);
        $mail->Send(View::$vars->data['email']);
        Plugin::Trigger('register.create');
        unset(View::$vars->data);
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
// Output Page
Plugin::Trigger('register.before_render');
View::Render('register.tpl');
Exemplo n.º 12
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('upload_complete');
Plugin::Trigger('upload_complete.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
App::EnableUploadsCheck();
View::$vars->user = new User(View::$vars->logged_in);
### Verify user completed upload process
if (isset($_SESSION['upload'])) {
    unset($_SESSION['upload']);
} else {
    header('Location: ' . HOST . '/myaccount/upload/video/');
    exit;
}
// Output page
Plugin::Trigger('upload_complete.before_render');
View::Render('myaccount/upload_complete.tpl');
Exemplo n.º 13
0
            View::$vars->data['private_url'] = htmlspecialchars(trim($_POST['private_url']));
            View::$vars->private_url = View::$vars->data['private_url'];
        } catch (Exception $e) {
            View::$vars->errors['private_url'] = Language::GetText('error_private_url');
        }
    } else {
        View::$vars->data['private'] = '0';
        View::$vars->data['private_url'] = '';
        View::$vars->private_url = Video::GeneratePrivate();
    }
    // Update video if no errors were made
    if (empty(View::$vars->errors)) {
        View::$vars->video->Update(View::$vars->data);
        View::$vars->message = Language::GetText('success_video_updated');
        if (View::$vars->video->private == '1') {
            View::$vars->private_url = View::$vars->video->private_url;
        }
        View::$vars->message_type = 'success';
        Plugin::Trigger('edit_video.edit');
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
### Populate categories dropdown
$query = "SELECT cat_id, cat_name FROM " . DB_PREFIX . "categories";
View::$vars->result_cat = $db->Query($query);
// Output page
Plugin::Trigger('edit_video.before_render');
View::Render('myaccount/edit_video.tpl');
Exemplo n.º 14
0
    View::$vars->video_url = View::$vars->video->url;
    $url = HOST . '/videos/' . View::$vars->video->video_id . '/comments';
} else {
    if (!empty($_GET['private']) && ($video_id = Video::Exist(array('status' => 'approved', 'private_url' => $_GET['private'])))) {
        View::$vars->video = new Video($video_id);
        View::$vars->private = true;
        View::$vars->video_url = HOST . '/private/videos/' . View::$vars->video->private_url;
        $url = HOST . '/private/comments/' . View::$vars->video->private_url;
    } else {
        App::Throw404();
    }
}
// Retrieve Video
View::$vars->meta->title = Functions::Replace(View::$vars->meta->title, array('video' => View::$vars->video->title));
// Retrieve comments count
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " ORDER BY comment_id DESC";
$result_count = $db->Query($query);
View::$vars->total_comments = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, View::$vars->total_comments, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
$result = $db->Query($query);
View::$vars->comment_list = array();
while ($row = $db->FetchObj($result)) {
    View::$vars->comment_list[] = $row->comment_id;
}
// Output page
Plugin::Trigger('comments.before_render');
View::Render('comments.tpl');
Exemplo n.º 15
0
if (!$logged_in) {
    App::Throw404();
}
$user = new User($logged_in);
$data = array();
/***********************
Handle page if submitted
***********************/
if (isset($_POST['submitted'])) {
    // Save update if no errors were found
    if (!empty($_POST['post']) && !ctype_space($_POST['post'])) {
        $data['post'] = htmlspecialchars(trim($_POST['post']));
        $data['user_id'] = $user->user_id;
        Plugin::Trigger('post.ajax.before_post_update');
        $post_id = Post::Create($data);
        $post = new Post($post_id);
        // Retrieve new formatted status updated
        View::InitView();
        ob_start();
        View::RepeatingBlock('post.tpl', array($post->post_id));
        $status_update = ob_get_contents();
        ob_end_clean();
        Plugin::Trigger('post.ajax.post_update');
        echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_status_updated'), 'other' => $status_update));
        exit;
    } else {
        echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_status_update')));
        exit;
    }
}
// END verify if page was submitted
Exemplo n.º 16
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');
 }
Exemplo n.º 17
0
    App::Throw404();
}
// Check if video is valid
if (!Video::Exist(array('video_id' => $_POST['video_id'], 'status' => 'approved'))) {
    App::Throw404();
}
$video = new Video($_POST['video_id']);
// Verify rating was given
if (!isset($_POST['rating']) || !in_array($_POST['rating'], array('1', '0'))) {
    App::Throw404();
}
// Verify user is logged in
if (!$logged_in) {
    echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_rate_login')));
    exit;
}
// Check user doesn't rate his own video
if ($user->user_id == $video->user_id) {
    echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_rate_own')));
    exit;
}
// Submit rating if none exists
if (Rating::AddRating($_POST['rating'], $video->video_id, $logged_in)) {
    Plugin::Trigger('rate.ajax.rate_video');
    echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_rated'), 'other' => Rating::GetRating($video->video_id)));
    exit;
} else {
    Plugin::Trigger('rate.ajax.rate_video_duplicate');
    echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_rate_duplicate')));
    exit;
}
Exemplo n.º 18
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('system_404');
Plugin::Trigger('system_404.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
// Output page
header("HTTP/1.0 404 Not Found");
Plugin::Trigger('system_404.before_render');
View::Render('system_404.tpl');
Exemplo n.º 19
0
    }
    ### Validate image data
    $handle = fopen($_FILES['upload']['tmp_name'], 'r');
    $image_data = fread($handle, filesize($_FILES['upload']['tmp_name']));
    if (!@imagecreatefromstring($image_data)) {
        throw new Exception(Language::GetText('error_uploadify_extension'));
    }
    ### Change permissions on avatar & delete previous IF/APP
    try {
        Filesystem::Open();
        $avatar_path = UPLOAD_PATH . '/avatars';
        $save_as = Avatar::CreateFilename($extension);
        Avatar::SaveAvatar($_FILES['upload']['tmp_name'], $extension, $save_as);
        // Check for existing avatar
        if (!empty($user->avatar)) {
            Avatar::Delete($user->avatar);
        }
        Filesystem::SetPermissions("{$avatar_path}/{$save_as}", 0644);
        Filesystem::Close();
    } catch (Exception $e) {
        App::Alert('Error During Avatar Upload', $e->getMessage());
        throw new Exception(Language::GetText('error_uploadify_system', array('host' => HOST)));
    }
    ### Update User
    $user->Update(array('avatar' => $save_as));
    Plugin::Trigger('update_profile.update_avatar');
    // Output success message
    exit(json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_avatar_updated'), 'other' => $user->avatar_url)));
} catch (Exception $e) {
    exit(json_encode(array('result' => 0, 'msg' => $e->getMessage())));
}
Exemplo n.º 20
0
$result_total = $db->Query($query);
$total = $db->FetchObj($result_total);
// Retrieve total count
if ($total->total > 20 && strlen($keyword) > 3) {
    // Use FULLTEXT query
    $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND MATCH(title, tags, description) AGAINST('{$keyword}')";
    Plugin::Trigger('search.search_count');
    $result_count = $db->Query($query);
    $count = $db->Count($result_count);
} else {
    // Use LIKE query
    $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%' OR tags LIKE '%{$keyword}%')";
    $result_count = $db->Query($query);
    $count = $db->Count($result_count);
}
Plugin::Trigger('search.search_count');
// Initialize pagination
$url .= !empty($query_string) ? '?' . http_build_query($query_string) : '';
View::$vars->pagination = new Pagination($url, $count, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
Plugin::Trigger('search.search');
$result = $db->Query($query);
View::$vars->search_videos = array();
while ($video = $db->FetchObj($result)) {
    View::$vars->search_videos[] = $video->video_id;
}
// Output Page
Plugin::Trigger('search.before_render');
View::Render('search.tpl');
Exemplo n.º 21
0
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);
    if (empty(View::$vars->meta->title)) {
        View::$vars->meta->title = $page->title;
    }
} else {
    App::Throw404();
}
// Output Page
Plugin::Trigger('page.before_render');
View::Render('page.tpl');
Exemplo n.º 22
0
        $data = array('member' => $member->user_id, 'user_id' => $user->user_id);
        if (!Subscription::Exist($data)) {
            $subscribed = Subscription::Create($data);
            Plugin::Trigger('subscribe.ajax.subscribe');
            echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_subscribed', array('username' => $member->username)), 'other' => (string) Language::GetText('unsubscribe')));
            exit;
        } else {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_duplicate')));
            exit;
        }
        ### Handle unsubscribe user from a member
    ### Handle unsubscribe user from a member
    case 'unsubscribe':
        // Verify user is logged in
        if (!$logged_in) {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_login')));
            exit;
        }
        // Delete subscription if one exists
        $subscription_id = Subscription::Exist(array('user_id' => $user->user_id, 'member' => $member->user_id));
        if ($subscription_id) {
            Subscription::Delete($subscription_id);
            Plugin::Trigger('subscribe.ajax.unsubscribe');
            echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_unsubscribed', array('username' => $member->username)), 'other' => (string) Language::GetText('subscribe')));
            exit;
        } else {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_noexist')));
            exit;
        }
}
// END action switch
Exemplo n.º 23
0
    // 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;
    }
    // Validate New member Videos
    if (isset($_POST['new_video']) && in_array($_POST['new_video'], array('0', '1'))) {
        View::$vars->data['new_video'] = $_POST['new_video'];
    } else {
        View::$vars->errors['new_video'] = TRUE;
    }
    if (empty(View::$vars->errors)) {
        View::$vars->privacy->Update(View::$vars->data);
        View::$vars->message = Language::GetText('success_privacy_updated');
        View::$vars->message_type = 'success';
        Plugin::Trigger('privacy_settings.update_privacy');
    } else {
        View::$vars->message = Language::GetText('error_general');
        View::$vars->message_type = 'error';
    }
}
// Output page
Plugin::Trigger('privacy_settings.before_render');
View::Render('myaccount/privacy_settings.tpl');
Exemplo n.º 24
0
        $comment_id = Comment::Create($data);
        $comment = new Comment($comment_id);
        $comment->Approve('activate');
        // Retrieve formatted new comment
        if (Settings::Get('auto_approve_comments') == 1) {
            if ($block) {
                View::InitView();
                ob_start();
                View::RepeatingBlock($block, array($comment->comment_id));
                $output = ob_get_contents();
                ob_end_clean();
            } else {
                $output = $comment;
            }
            $message = (string) Language::GetText('success_comment_posted');
            $other = array('auto_approve' => 1, 'output' => $output);
        } else {
            $message = (string) Language::GetText('success_comment_approve');
            $other = array('auto_approve' => 0, 'output' => '');
        }
        echo json_encode(array('result' => 1, 'msg' => $message, 'other' => $other));
        Plugin::Trigger('comment.ajax.post_comment');
        exit;
    } else {
        $error_msg = Language::GetText('errors_below');
        $error_msg .= '<br /><br /> - ' . implode('<br /> - ', $Errors);
        echo json_encode(array('result' => 0, 'msg' => $error_msg));
        exit;
    }
}
// END verify if page was submitted
Exemplo n.º 25
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');
Exemplo n.º 26
0
    App::Throw404();
}
### Check if user is subscribed
if (View::$vars->logged_in) {
    $data = array('user_id' => View::$vars->user->user_id, 'member' => View::$vars->member->user_id);
    View::$vars->subscribe_text = Subscription::Exist($data) ? 'unsubscribe' : 'subscribe';
} else {
    View::$vars->subscribe_text = 'subscribe';
}
### Count subscription
$query = "SELECT COUNT(sub_id) FROM " . DB_PREFIX . "subscriptions WHERE member = " . View::$vars->member->user_id;
$result = $db->Query($query);
View::$vars->sub_count = $db->FetchRow($result);
### Retrieve video list
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE user_id = " . View::$vars->member->user_id . " AND status = 'approved' AND private = '0' LIMIT 3";
Plugin::Trigger('profile.load_recent_videos');
View::$vars->result_videos = $db->Query($query);
### Update Member view count
$data = array('views' => View::$vars->member->views + 1);
View::$vars->member->Update($data);
### Retrieve latest status updates
$query = "SELECT post_id FROM " . DB_PREFIX . "posts WHERE user_id = " . View::$vars->member->user_id . "  ORDER BY post_id DESC LIMIT 0, {$post_count}";
Plugin::Trigger('profile.load_posts');
$result_posts = $db->Query($query);
View::$vars->post_list = array();
while ($row = $db->FetchObj($result_posts)) {
    View::$vars->post_list[] = $row->post_id;
}
// Output Page
Plugin::Trigger('profile.before_render');
View::Render('profile.tpl');
Exemplo n.º 27
0
        Plugin::Trigger('messsage_inbox.purge_all_messages');
    }
    // Delete message (Request came from view message page)
} else {
    if (isset($_GET['delete']) && is_numeric($_GET['delete']) && $_GET['delete'] > 0) {
        $data = array('recipient' => View::$vars->user->user_id, 'message_id' => $_GET['delete']);
        $message_id = Message::Exist($data);
        if ($message_id) {
            Message::Delete($message_id);
            View::$vars->message = Language::GetText('success_messages_purged');
            View::$vars->message_type = 'success';
            Plugin::Trigger('message_inbox.delete_message');
        }
    }
}
/******************
Prepare page to run
******************/
// Retrieve total count
$query = "SELECT message_id FROM " . DB_PREFIX . "messages WHERE recipient = " . View::$vars->user->user_id;
$result_count = $db->Query($query);
$total = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, $total, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
View::$vars->result = $db->Query($query);
// Output page
Plugin::Trigger('message_inbox.before_render');
View::Render('myaccount/message_inbox.tpl');
Exemplo n.º 28
0
    // Validate private
    if (!empty($_POST['private']) && $_POST['private'] == '1') {
        View::$vars->data['private'] = '1';
        if (!empty($_POST['private_url']) && strlen($_POST['private_url']) == 7 && !Video::Exist(array('private_url' => $_POST['private_url']))) {
            View::$vars->data['private_url'] = htmlspecialchars(trim($_POST['private_url']));
            View::$vars->private_url = View::$vars->data['private_url'];
        } else {
            View::$vars->errors['private_url'] = Language::GetText('error_private_url');
        }
    } else {
        View::$vars->data['private'] = '0';
    }
    // Validate Video Upload last (only if other fields were valid)
    if (empty(View::$vars->errors)) {
        View::$vars->data['user_id'] = View::$vars->user->user_id;
        View::$vars->data['filename'] = Video::CreateFilename();
        View::$vars->data['status'] = 'new';
        Plugin::Trigger('upload.before_create_video');
        $_SESSION['upload'] = Video::Create(View::$vars->data);
        Plugin::Trigger('upload.create_video');
        header('Location: ' . HOST . '/myaccount/upload/video/');
        exit;
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
// Output page
Plugin::Trigger('upload.before_render');
View::Render('myaccount/upload.tpl');
Exemplo n.º 29
0
 /**
  * Delete a record
  * @param integer $id ID of record to be deleted
  * @return void Record is deleted from database
  */
 static function Delete($id)
 {
     $db = Database::GetInstance();
     Plugin::Trigger('rating.delete');
     $query = "DELETE FROM " . DB_PREFIX . self::$table . " WHERE " . self::$id_name . " = {$id}";
     $db->Query($query);
 }
Exemplo n.º 30
0
    $target = UPLOAD_PATH . '/temp/' . $video->filename . '.' . $extension;
    Plugin::Trigger('upload.ajax.before_move_video');
    if (!@move_uploaded_file($_FILES['upload']['tmp_name'], $target)) {
        App::Alert('Error During Video Upload', 'The raw video file transfer failed. Video File: ' . $target);
        throw new Exception(Language::GetText('error_uploadify_system', array('host' => HOST)));
    }
    ### Change permissions on raw video file
    Plugin::Trigger('upload.ajax.before_change_permissions');
    try {
        Filesystem::Open();
        Filesystem::SetPermissions($target, 0644);
        Filesystem::Close();
    } catch (Exception $e) {
        App::Alert('Error During Video Upload', $e->getMessage());
        throw new Exception(Language::GetText('error_uploadify_system', array('host' => HOST)));
    }
    ### Update video information
    $data = array('status' => 'pending conversion', 'original_extension' => $extension);
    Plugin::Trigger('upload.ajax.before_update_video');
    $video->Update($data);
    ### Initilize Encoder
    $cmd_output = $config->debug_conversion ? CONVERSION_LOG : '/dev/null';
    Plugin::Trigger('upload.ajax.before_encode');
    $converter_cmd = 'nohup ' . Settings::Get('php') . ' ' . DOC_ROOT . '/cc-core/system/encode.php --video="' . $video->video_id . '" >> ' . $cmd_output . ' 2>&1 &';
    exec($converter_cmd);
    Plugin::Trigger('upload.ajax.encode');
    // Output success message
    exit(json_encode(array('result' => 1, 'msg' => '')));
} catch (Exception $e) {
    exit(json_encode(array('result' => 0, 'msg' => $e->getMessage())));
}