Esempio n. 1
0
abr('attributes', $attributes);
$attributeCategories = $attributesClass->getAllCategories(0, 0, $itemsClass->attributeCategoriesWhere);
abr('attributeCategories', $attributeCategories);
#加载分类
require_once ROOT_PATH . '/apps/categories/models/categories.class.php';
$categoriesClass = new categories();
$categories = $categoriesClass->getAll();
abr('categories', $categories);
#面包屑
abr('breadcrumb', '<a href="/' . $languageURL . '" title="">' . $langArray['home'] . '</a> \\ <a href="/' . $languageURL . 'items/' . $item['id'] . '" title="">' . $item['name'] . '</a> \\ <a href="/' . $languageURL . 'items/faq/' . $item['id'] . '" title="">' . $langArray['faqs'] . '</a>');
#FAQ
$faqs = $faqClass->CountAll($itemID);
abr('faqs', $faqs);
$user = $item['user'];
require_once ROOT_PATH . '/apps/system/models/badges.class.php';
$badges = new badges();
$badges_data = $badges->getAllFront();
$other_badges = array_map('trim', explode(',', $user['badges']));
$user_badges = array();
if ($user['exclusive_author'] == 'true' && isset($badges_data['system']['is_exclusive_author'])) {
    if ($badges_data['system']['is_exclusive_author']['photo'] && file_exists(DATA_SERVER_PATH . "/uploads/badges/" . $badges_data['system']['is_exclusive_author']['photo'])) {
        $user_badges[] = array('name' => $badges_data['system']['is_exclusive_author']['name'], 'photo' => '/uploads/badges/' . $badges_data['system']['is_exclusive_author']['photo']);
    }
}
if ($user['featured_author'] == 'true' && isset($badges_data['system']['has_been_featured'])) {
    if ($badges_data['system']['has_been_featured']['photo'] && file_exists(DATA_SERVER_PATH . "/uploads/badges/" . $badges_data['system']['has_been_featured']['photo'])) {
        $user_badges[] = array('name' => $badges_data['system']['has_been_featured']['name'], 'photo' => '/uploads/badges/' . $badges_data['system']['has_been_featured']['photo']);
    }
}
if (isset($user['statuses']['freefile']) && $user['statuses']['freefile'] && isset($badges_data['system']['has_free_file_month'])) {
    if ($badges_data['system']['has_free_file_month']['photo'] && file_exists(DATA_SERVER_PATH . "/uploads/badges/" . $badges_data['system']['has_free_file_month']['photo'])) {
Esempio n. 2
0
<?php

// +----------------------------------------------------------------------
// | Demila [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://demila.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
if (!isset($_GET['type']) || !in_array($_GET['type'], array('other', 'buyers', 'authors', 'referrals', 'system'))) {
    refresh('?m=' . $_GET['m'] . '&c=badges&type=system', '', 'error');
}
_setView(__FILE__);
_setTitle($langArray['badges'] . ' › ' . ucfirst($_GET['type']));
$types = array('system', 'other', 'buyers', 'authors', 'referrals');
$tmp = array();
foreach ($types as $type) {
    $tmp[] = array('name' => ucfirst($type), 'href' => '?m=' . $_GET['m'] . '&c=badges&type=' . $type);
}
abr('types', $tmp);
require_once ROOT_PATH . '/apps/system/models/badges.class.php';
$badges = new badges();
$data = $badges->getAll(START, LIMIT, "`type`='" . $_GET['type'] . "'");
abr('data', $data);
$p = paging("?m=" . $_GET['m'] . "&c=badges&type=" . $_GET['type'] . "&p=", "", PAGE, LIMIT, $badges->foundRows);
abr('paging', $p);
require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
Esempio n. 3
0
        $usersClass->editExclusiveAuthor('false', $_GET['id']);
    } elseif (isset($_POST['exclusive_true'])) {
        $usersClass = new users();
        $usersClass->editExclusiveAuthor('true', $_GET['id']);
    }
    $_POST = $cms->get($_GET['id']);
    $badges = explode(',', $_POST['badges']);
    $_POST['badges'] = array();
    foreach ($badges as $badge) {
        $_POST['badges'][] = $badge;
    }
}
$users = $cms->get($_GET['id']);
$users['stats'] = $cms->getStatistic($_GET['id']);
abr('user', $users);
require_once ROOT_PATH . '/apps/' . $_GET['m'] . '/models/groups.class.php';
$g = new groups();
$groups = $g->getAll();
abr('groups', $groups);
require_once ROOT_PATH . '/apps/system/models/badges.class.php';
$badges = new badges();
$badges_data = $badges->getAll(0, 0, "`type` = 'other'");
abr('badges', $badges_data);
if (isset($_POST['badges'])) {
    if (!is_array($_POST['badges'])) {
        $_POST['badges'] = explode(',', $_POST['badges']);
    }
} else {
    $_POST['badges'] = array();
}
require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
Esempio n. 4
0
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
if (!isset($_GET['type']) || !in_array($_GET['type'], array('other', 'buyers', 'authors', 'referrals', 'system'))) {
    refresh('?m=' . $_GET['m'] . '&c=badges&type=system', 'INVALID TYPE', 'error');
}
_setView(__FILE__);
_setTitle($langArray['add'] . ' ' . $langArray['badges'] . ' › ' . ucfirst($_GET['type']));
$is_from_to = false;
if (in_array($_GET['type'], array('buyers', 'authors', 'referrals'))) {
    $is_from_to = true;
}
abr('is_from_to', $is_from_to);
require_once ROOT_PATH . '/apps/system/models/badges.class.php';
$badges = new badges();
if (isset($_POST['add'])) {
    $status = $badges->add();
    if ($status !== true) {
        abr('error', $status);
    } else {
        refresh("?m=" . $_GET['m'] . "&c=badges&type=" . $_GET['type'], $langArray['add_complete']);
    }
} else {
    $_POST['visible'] = 'true';
}
$types_system = array();
if ($_GET['type'] == 'system') {
    $types_system = array('location_global_community' => $langArray['location_global_community'], 'has_free_file_month' => $langArray['has_free_file_month'], 'has_been_featured' => $langArray['has_been_featured'], 'power_elite_author' => $langArray['power_elite_author'], 'elite_author' => $langArray['elite_author'], 'has_had_item_featured' => $langArray['has_had_item_featured'], 'is_exclusive_author' => $langArray['is_exclusive_author']);
}
abr('types_system', $types_system);
Esempio n. 5
0
 function index()
 {
     $this->template->content = new View('admin/manage/badges/main');
     $this->template->content->title = Kohana::lang('ui_main.badges');
     // setup and initialize form field names
     $form = array('id' => '', 'name' => '', 'description' => '');
     //	copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //	 Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('name', 'standard_text', 'length[1,250]');
         $post->add_rules('description', 'standard_text');
         // Add some additional rules for adding a new badge
         if (isset($_POST['action']) and $_POST['action'] == 'a') {
             // Users can select a badge or upload one. See what they are doing.
             if ($_FILES['image']['error'] == 0) {
                 // Uploading an image, if uploaded, it overrules a selection
                 $uploading_custom_badge = true;
                 $post->add_rules('image', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[100K]');
             } else {
                 // Selecting one
                 $uploading_custom_badge = false;
                 $post->add_rules('selected_badge', 'required');
             }
         }
         if ($post->validate()) {
             // ADD
             if ($post->action == 'a') {
                 // Step 1. Save badge name and description
                 $badge = new Badge_Model();
                 $badge->name = $post->name;
                 $badge->description = $post->description;
                 $badge->save();
                 // Step 2. Save badge image
                 if ($uploading_custom_badge) {
                     $filename = upload::save('image');
                 } else {
                     // We already have this on the filesystem! Use that one.
                     $bp_path = MEDIAPATH . 'img/badge_packs/';
                     $selected_badge = base64_decode(str_ireplace('badge_', '', $post->selected_badge));
                     $filename = $bp_path . $selected_badge;
                 }
                 if ($filename) {
                     $new_filename = "badge_" . $badge->id . "_" . time();
                     $file_type = strrev(substr(strrev($filename), 0, 4));
                     // Large size
                     $l_name = $new_filename . $file_type;
                     Image::factory($filename)->save(Kohana::config('upload.directory', TRUE) . $l_name);
                     // Medium size
                     $m_name = $new_filename . '_m' . $file_type;
                     Image::factory($filename)->resize(80, 80, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $m_name);
                     // Thumbnail
                     $t_name = $new_filename . '_t' . $file_type;
                     Image::factory($filename)->resize(60, 60, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $t_name);
                     // Name the files for the DB
                     $media_link = $l_name;
                     $media_medium = $m_name;
                     $media_thumb = $t_name;
                     // Okay, now we have these three different files on the server, now check to see
                     //   if we should be dropping them on the CDN
                     if (Kohana::config("cdn.cdn_store_dynamic_content")) {
                         $cdn = new cdn();
                         $media_link = $cdn->upload($media_link);
                         $media_medium = $cdn->upload($media_medium);
                         $media_thumb = $cdn->upload($media_thumb);
                         // We no longer need the files we created on the server. Remove them.
                         $local_directory = rtrim(Kohana::config('upload.directory', TRUE), '/') . '/';
                         unlink($local_directory . $new_filename . $file_type);
                         unlink($local_directory . $new_filename . '_m' . $file_type);
                         unlink($local_directory . $new_filename . '_t' . $file_type);
                     }
                     // Only perform this operation if it's not coming from a badge pack,
                     //   otherwise we would lose badges every time we selected them!
                     if ($uploading_custom_badge) {
                         // Remove the temporary file
                         unlink($filename);
                     }
                     // Delete old badge image
                     ORM::factory('media')->where(array('badge_id' => $badge->id))->delete_all();
                     // Save new badge image
                     $media = new Media_Model();
                     $media->badge_id = $badge->id;
                     $media->media_type = 1;
                     // Image
                     $media->media_link = $media_link;
                     $media->media_medium = $media_medium;
                     $media->media_thumb = $media_thumb;
                     $media->media_date = date("Y-m-d H:i:s", time());
                     $media->save();
                 }
             }
             // ASSIGN USER
             if ($post->action == 'b') {
                 $badge_user = new Badge_User_Model();
                 $badge_user->badge_id = $post->badge_id;
                 $badge_user->user_id = $post->assign_user;
                 $badge_user->save();
             }
             // REVOKE USER
             if ($post->action == 'r') {
                 ORM::factory('badge_user')->where(array('badge_id' => (int) $post->badge_id, 'user_id' => (int) $post->revoke_user))->delete_all();
             } elseif ($post->action == 'd') {
                 // Remove from badge table
                 ORM::factory('badge')->delete((int) $post->badge_id);
                 // Remove from media
                 ORM::factory('media')->where(array('badge_id' => (int) $post->badge_id))->delete_all();
                 // Remove from assignment
                 ORM::factory('badge_user')->where(array('badge_id' => (int) $post->badge_id))->delete_all();
             }
         } else {
             $errors = arr::overwrite($errors, $post->errors('badges'));
             $form_error = TRUE;
         }
     }
     // Badge Pack stuff
     $this->template->content->badge_packs = badges::get_packs();
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     // Get badges
     $this->template->content->badges = Badge_Model::badges();
     $this->template->content->total_items = count($this->template->content->badges);
     // Get all users for dropdowns
     $users_result = ORM::factory('user')->orderby('name', 'asc')->find_all();
     $users = array();
     foreach ($users_result as $user) {
         $users[$user->id] = $user->username;
     }
     $this->template->content->users = $users;
     // Javascript Header
     $this->themes->js = new View('admin/manage/badges/badges_js');
 }
Esempio n. 6
0
// | Email author@demila.org
// +----------------------------------------------------------------------
if (!isset($_GET['fid']) || !is_numeric($_GET['fid'])) {
    refresh('?m=' . $_GET['m'] . '&c=badges&type=other', 'INVALID ID', 'error');
}
if (!isset($_GET['type']) || !in_array($_GET['type'], array('other', 'buyers', 'authors', 'referrals', 'system'))) {
    refresh('?m=' . $_GET['m'] . '&c=badges&type=system', 'INVALID TYPE', 'error');
}
_setView(__FILE__);
_setTitle($langArray['edit'] . ' ' . $langArray['badges'] . ' › ' . ucfirst($_GET['type']));
$is_from_to = false;
if (in_array($_GET['type'], array('buyers', 'authors', 'referrals'))) {
    $is_from_to = true;
}
abr('is_from_to', $is_from_to);
$cms = new badges();
$get_info = $cms->get($_GET['fid']);
if (isset($_POST['edit'])) {
    $status = $cms->edit($_GET['fid']);
    if ($status !== true) {
        abr('error', $status);
    } else {
        refresh("?m=" . $_GET['m'] . "&c=badges&type=" . $_GET['type'], $langArray['edit_complete']);
    }
} else {
    $_POST = $get_info;
}
$types_system = array();
if ($_GET['type'] == 'system') {
    $types_system = array('location_global_community' => $langArray['location_global_community'], 'has_free_file_month' => $langArray['has_free_file_month'], 'has_been_featured' => $langArray['has_been_featured'], 'power_elite_author' => $langArray['power_elite_author'], 'elite_author' => $langArray['elite_author'], 'has_had_item_featured' => $langArray['has_had_item_featured'], 'is_exclusive_author' => $langArray['is_exclusive_author']);
}
Esempio n. 7
0
<?php

// +----------------------------------------------------------------------
// | Demila [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://demila.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
define('USING_LANGUAGE', false);
require_once '../../../config.php';
require_once $config['root_path'] . '/core/functions.php';
include_once $config['system_core'] . "/initEngine.php";
admin_login();
if (isset($_POST['deleteKey']) && isset($_POST['id']) && isset($_SESSION['user']['access']['system'])) {
    require_once ROOT_PATH . "/apps/system/models/system.class.php";
    $cms = new system();
    $cms->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
} elseif (isset($_POST['deleteRow']) && isset($_POST['id']) && isset($_SESSION['user']['access']['system'])) {
    require_once ROOT_PATH . '/apps/system/models/badges.class.php';
    $badges = new badges();
    $badges->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
}
echo json_encode(array_merge($_POST, array('status' => 'unknown error')));
die;