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; }
$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');
/** * 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'); }
} ### 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()))); }
/** * Terminate execution of web site in case of Database error. * @return void Website execution is terminated. Errors are logged and sent * via Email. User is redirected to error page if possible. */ private function KillDB() { // Log Database Error $date = date('m/d/Y G:iA'); $message_log = "### MySQL Error - {$date}\n\n"; $message_log .= "Error:\n" . $this->Error() . "\n\n"; $message_log .= "Query: " . $this->last_query . "\n\n"; App::Log(DB_ERR_LOG, $message_log); // Send Notification $subject = 'Site Error Encountered ' . $date; $message_alert = "An error was encountered on the website\n\n"; $message_alert .= "Date: " . $date . "\n\n"; $message_alert .= "Error:\n" . $this->Error() . "\n\n"; $message_alert .= "Query:\n" . $this->last_query; App::Alert($subject, $message_alert); if (!headers_sent()) { header("Location: " . HOST . "/system-error/"); } else { echo '<script>top.location = "' . HOST . '/system-error/";</script>'; } exit; }
} ### Move video to site temp directory $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) {
/** * 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'); }
/** * Delete an avatar * @param integer $filename Name of file to be deleted * @return void Avatar is deleted from filesystem */ static function Delete($filename) { try { Filesystem::Open(); Filesystem::Delete(UPLOAD_PATH . '/avatars/' . $filename); Filesystem::Close(); } catch (Exception $e) { App::Alert('Error During Avatar Removal', "Unable to delete avatar: {$filename}. Error: " . $e->getMessage()); } }
throw new Exception('error'); } ### Validate filesize if ($_FILES['upload']['size'] > $config->video_size_limit || filesize($_FILES['upload']['tmp_name']) > $config->video_size_limit) { throw new Exception('filesize'); } ### Validate video extension $extension = Functions::GetExtension($_FILES['upload']['name']); if (!in_array($extension, $config->accepted_video_formats)) { throw new Exception('extension'); } ### Move video to site temp directory $target = UPLOAD_PATH . '/temp/' . Video::CreateFilename() . '.' . $extension; if (!@move_uploaded_file($_FILES['upload']['tmp_name'], $target)) { App::Alert('Error During Processing', 'The raw video file transfer failed.'); throw new Exception('error'); } ### Change permissions on raw video file try { Filesystem::Open(); Filesystem::SetPermissions($target, 0644); } catch (Exception $e) { App::Alert('Error During Processing', 'Could not change the permissions on the raw video file.'); throw new Exception($e->getMessage()); } } catch (Exception $e) { exit(json_encode(array('status' => $e->getMessage(), 'message' => ''))); } ### Notify Upload AJAX of success $_SESSION['video'] = serialize(array('key' => $video_upload_key, 'name' => $_FILES['upload']['name'], 'temp' => $target)); exit(json_encode(array('status' => 'success', 'message' => $_FILES['upload']['name'])));
$video->Update($data); Plugin::Trigger('encode.update'); // Activate video $video->Approve('activate'); ///////////////////////////////////////////////////////////// // STEP 8 // // Clean up // ///////////////////////////////////////////////////////////// try { // Debug Log $config->debug_conversion ? App::Log(CONVERSION_LOG, 'Deleting raw video...') : null; ### Delete raw videos & pre-faststart files Filesystem::Open(); Filesystem::Delete($raw_video); Filesystem::Delete($mobile_temp); ### Delete encoding log files if ($config->debug_conversion) { App::Log(CONVERSION_LOG, "Video ID: {$video->video_id}, has completed processing!\n"); } else { Filesystem::Delete($debug_log); } } catch (Exception $e) { App::Alert('Error During Video Encoding', $e->getMessage()); App::Log(CONVERSION_LOG, $e->getMessage()); } Plugin::Trigger('encode.complete'); } catch (Exception $e) { App::Alert('Error During Video Encoding', $e->getMessage()); App::Log(CONVERSION_LOG, $e->getMessage()); exit; }
if (empty(View::$vars->Errors)) { View::$vars->message = Language::GetText('success_profile_updated'); View::$vars->message_type = 'success'; View::$vars->user->Update(View::$vars->data); Plugin::Trigger('update_profile.update_profile'); } else { View::$vars->message = Language::GetText('errors_below'); View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->Errors); View::$vars->message_type = 'error'; } } // END Handle Profile form /************************** Handle Reset Avatar Action **************************/ if (!empty($_GET['action']) && $_GET['action'] == 'reset' && !empty(View::$vars->user->avatar)) { try { Filesystem::Open(); Filesystem::Delete(UPLOAD_PATH . '/avatars/' . View::$vars->user->avatar); Filesystem::Close(); } catch (Exception $e) { App::Alert('Error during Avatar Reset', $e->getMessage()); } View::$vars->user->Update(array('avatar' => '')); View::$vars->message = Language::GetText('success_avatar_reset'); View::$vars->message_type = 'success'; Plugin::Trigger('update_profile.avatar_reset'); } // Output page Plugin::Trigger('update_profile.before_render'); View::Render('myaccount/update_profile.tpl');
### 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'); } ### Validate filesize if ($_FILES['upload']['size'] > 1024 * 1024 * 100 || filesize($_FILES['upload']['tmp_name']) > 1024 * 1024 * 100) { throw new Exception('filesize'); } ### Validate video extension $extension = Functions::GetExtension($_FILES['upload']['name']); if ($extension != 'zip') { throw new Exception('extension'); } ### Move video to site temp directory // Create temp dir $temp = DOC_ROOT . '/cc-content/.add-plugin'; Filesystem::Open(); Filesystem::CreateDir($temp); Filesystem::SetPermissions($temp, 0777); // Move zip to temp dir if (!@move_uploaded_file($_FILES['upload']['tmp_name'], $temp . '/plugin.zip')) { App::Alert('Uploaded file could not be moved from OS temp directory'); throw new Exception('error'); } } catch (Exception $e) { exit(json_encode(array('status' => $e->getMessage(), 'message' => ''))); } ### Notify Uploadify of success $_SESSION['upload'] = serialize(array('key' => $upload_key, 'name' => $_FILES['upload']['name'], 'temp' => $temp . '/plugin.zip')); exit(json_encode(array('status' => 'success', 'message' => $_FILES['upload']['name'])));
/** * 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'); }