예제 #1
0
 /**
  * Extract values from database and set them to object properties
  * @param integer $id ID of record to be instantiated
  * @return void DB record's fields are loaded into object properties
  */
 private function Get($id)
 {
     $query = "SELECT " . DB_PREFIX . self::$table . ".*, username FROM " . DB_PREFIX . self::$table . " INNER JOIN " . DB_PREFIX . "users on " . DB_PREFIX . self::$table . ".user_id = " . DB_PREFIX . "users.user_id WHERE " . self::$id_name . "= {$id}";
     $result = $this->db->Query($query);
     $row = $this->db->FetchAssoc($result);
     foreach ($row as $key => $value) {
         $this->{$key} = $value;
     }
     // Video Specific values
     $this->tags = preg_split('/\\s?,\\s?/', $this->tags);
     $this->duration = substr($this->duration, 0, 3) == '00:' ? substr($this->duration, 3) : $this->duration;
     $this->slug = Functions::CreateSlug($this->title);
     $this->date_created = Functions::GmtToLocal($this->date_created);
     $this->url = HOST . '/videos/' . $this->video_id . (!empty($this->slug) ? '/' . $this->slug : '');
     Plugin::Trigger('video.get');
 }
예제 #2
0
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.';
        $message_type = 'success';
        unset($data);
    } catch (Exception $e) {
        $errors['cat_name'] = true;
        $message = $e->getMessage();
        $message_type = 'error';
    }
}
/*******************************
예제 #3
0
// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
App::LoadClass('Page');
// 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/');
// Validate Slug
if (!empty($_POST['action']) && in_array($_POST['action'], array('slug', 'title'))) {
    if ($_POST['action'] == 'slug') {
        $slug = Functions::CreateSlug(trim($_POST['slug']));
    } else {
        if ($_POST['action'] == 'title') {
            $slug = Functions::CreateSlug(trim($_POST['title']));
        } else {
            App::Throw404();
        }
    }
} else {
    App::Throw404();
}
// Validate Page ID
if (isset($_POST['page_id']) && $_POST['page_id'] == 0) {
    $page_id = 0;
} else {
    if (!empty($_POST['page_id']) && is_numeric($_POST['page_id']) && Page::Exist(array('page_id' => $_POST['page_id']))) {
        $page_id = $_POST['page_id'];
    } else {
        App::Throw404();
예제 #4
0
 }
 // Validate status
 if (!empty($_POST['status']) && in_array($_POST['status'], array('published', 'draft'))) {
     $data['status'] = $_POST['status'];
 } else {
     $errors['status'] = "You didn't provide a valid status";
 }
 // Validate title
 if (!empty($_POST['title']) && !ctype_space($_POST['title'])) {
     $data['title'] = htmlspecialchars(trim($_POST['title']));
 } else {
     $errors['title'] = "You didn't enter a valid title";
 }
 // Validate slug
 if (!empty($_POST['slug']) && !ctype_space($_POST['slug'])) {
     $slug = Functions::CreateSlug(trim($_POST['slug']));
     if ($slug == $page->slug || !Page::IsReserved($slug) && !Page::Exist(array('slug' => $slug))) {
         $data['slug'] = $slug;
     } else {
         $errors['slug'] = "URL is not available";
     }
 } else {
     $errors['slug'] = "You didn't enter a valid URL";
 }
 // Validate content
 if (!empty($_POST['content']) && !ctype_space($_POST['content'])) {
     $data['content'] = trim($_POST['content']);
 } else {
     $data['content'] = '';
 }
 // Update record if no errors were found