Example #1
1
<?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
// +----------------------------------------------------------------------
_setView(__FILE__);
$itemID = get_id(2);
$itemsClass = new items();
$item = $itemsClass->get($itemID);
if (!is_array($item) || check_login_bool() && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') {
    header("HTTP/1.0 404 Not Found");
    header("Location: http://" . DOMAIN . "/" . $languageURL . "error");
}
abr('item', $item);
Example #2
0
function print_highlighted($lang)
{
    //The GeSHI syntax highlighter is included.
    include_once 'geshi/geshi.php';
    //The string returned is stored in a variable.
    $filename = get_id($_SERVER['REQUEST_URI']);
    //If file does not exist then it redirects the user to the home page.
    $file = fopen("data/{$filename}", "r") or header("Location: /");
    $source = '';
    while (!feof($file)) {
        $source = $source . fgets($file);
    }
    //The object created is passed two arguments for syntax highlighting.
    $geshi = new GeSHi($source, $lang);
    $geshi->set_overall_style('background-color: #f2f2f2; margin: 0px 35px; border: 1px dotted;', true);
    //$geshi->set_header_type(GESHI_HEADER_PRE_VALID);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    //The flag below shows the line numbers. See GeSHI docs for more options.
    $flag = GESHI_FANCY_LINE_NUMBERS;
    $geshi->enable_line_numbers($flag);
    $geshi->set_line_style(' padding: 0px 15px;');
    //The <pre> tags are included for maintaining the indentation.
    // echo "<pre>";
    echo $geshi->parse_code();
    // echo "</pre></div>";
    return 0;
}
 /**
  * Show and process config category form
  *
  * @param void
  * @return null
  */
 function update_category()
 {
     $category = ConfigCategories::findById(get_id());
     if (!$category instanceof ConfigCategory) {
         flash_error(lang('config category dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($category->isEmpty()) {
         flash_error(lang('config category is empty'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     $options = $category->getOptions(false);
     $categories = ConfigCategories::getAll(false);
     tpl_assign('category', $category);
     tpl_assign('options', $options);
     tpl_assign('config_categories', $categories);
     $submitted_values = array_var($_POST, 'options');
     if (is_array($submitted_values)) {
         foreach ($options as $option) {
             $new_value = array_var($submitted_values, $option->getName());
             if (is_null($new_value) || $new_value == $option->getValue()) {
                 continue;
             }
             $option->setValue($new_value);
             $option->save();
         }
         // foreach
         flash_success(lang('success update config category', $category->getDisplayName()));
         $this->redirectTo('administration', 'configuration');
     }
     // if
     $this->setSidebar(get_template_path('update_category_sidebar', 'config'));
 }
Example #4
0
function auth_id()
{
    global $torque_id, $torque_id_hash;
    // Prepare authentification of Torque Instance that uploads data to this server
    // If $torque_id is defined, this will overwrite $torque_id_hash from creds.php
    $session_id = get_id();
    // Parse IDs from "creds.php", if IDs are defined these will overrule HASHES
    $auth_by_hash_possible = false;
    if (isset($torque_id) && !empty($torque_id)) {
        if (!is_array($torque_id)) {
            $torque_id = array($torque_id);
        }
        $torque_id_hash = array_map(md5, $torque_id);
        $auth_by_hash_possible = true;
    } elseif (isset($torque_id_hash) && !empty($torque_id_hash)) {
        if (!is_array($torque_id_hash)) {
            $torque_id_hash = array($torque_id_hash);
        }
        $auth_by_hash_possible = true;
    }
    // Authenticate torque instance: Check if we know its HASH
    if ($auth_by_hash_possible) {
        if (in_array($session_id, $torque_id_hash)) {
            return true;
        }
    } else {
        return true;
    }
    return false;
}
function login($username, $password)
{
    $id = get_id($username);
    $username = validate($username);
    $password = md5($password);
    $sql = mysql_query("SELECT COUNT(`UserID`) FROM `user` WHERE `Username` = '{$username}' AND `Password` = '{$password}'");
    return mysql_result($sql, 0) == 1 ? $id : false;
}
Example #6
0
function sel_file($val)
{
    $return = get_id('goods', 'goo_img', $val);
    if (!$return) {
        $return = get_id('goods', 'goo_x_img', $val);
    }
    if (!$return) {
        $return = get_id('picture', 'pic_path', $val);
    }
    return $return;
}
Example #7
0
function recive_formular()
{
    //um einwenig weniger tipp arbeit zu haben und zukünftige erweiterungen schneller einfließen zu lassen
    //werden einfach nur alle tabellen felder durch gegangen und ggf berichtigt
    //konfiguration über config.php: $anmeldung_fields
    /*liest die bei der Anmeldung abgeschickten Daten aus, prüft sie und packt sie in einen Hash*/
    $daten = array();
    foreach ($GLOBALS["anmeldung_fields"] as $key) {
        switch ($key) {
            case 'idx':
                $daten[$key] = get_id();
                break;
            case 'ew_count':
                if (!is_numeric($_POST[$key]) or $_POST[$key] > 99) {
                    array_push($GLOBALS["error_msgs"], MSG_NUMBER_UNREAL);
                    $GLOBALS["error"] += 1;
                }
                $daten[$key] = abs($_POST[$key]);
                break;
            case 'ki_count':
                if (!is_numeric($_POST[$key]) or $_POST[$key] > 99) {
                    array_push($GLOBALS["error_msgs"], MSG_NUMBER_UNREAL);
                    $GLOBALS["error"] += 1;
                }
                $daten[$key] = abs($_POST[$key]);
                break;
            case 'ba_count':
                if (!is_numeric($_POST[$key]) or $_POST[$key] > 99) {
                    array_push($GLOBALS["error_msgs"], MSG_NUMBER_UNREAL);
                    $GLOBALS["error"] += 1;
                }
                $daten[$key] = abs($_POST[$key]);
                break;
            case 'newsletter':
                if (isset($_POST[$key])) {
                    $daten[$key] = "1";
                } else {
                    $daten[$key] = "0";
                }
                break;
            case 'timestamp':
                $daten[$key] = date("d.m.Y \\u\\m H:i:s");
                break;
            default:
                if (isset($_POST[$key])) {
                    $daten[$key] = $_POST[$key];
                } else {
                    $daten[$key] = "";
                }
        }
    }
    //gibt die Formular daten zurück
    return $daten;
}
 /**
  * Delete specific user
  *
  * @access public
  * @param void
  * @return null
  */
 function delete()
 {
     $this->setTemplate('del_user');
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         $this->redirectTo('administration');
     }
     // if
     if (!$user->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $delete_data = array_var($_POST, 'deleteUser');
     tpl_assign('user', $user);
     tpl_assign('delete_data', $delete_data);
     if (!is_array($delete_data)) {
         $delete_data = array('really' => 0, 'password' => '');
         // array
         tpl_assign('delete_data', $delete_data);
     } else {
         if ($delete_data['really'] == 1) {
             $password = $delete_data['password'];
             if (trim($password) == '') {
                 tpl_assign('error', new Error(lang('password value missing')));
                 return $this->render();
             }
             if (!logged_user()->isValidPassword($password)) {
                 tpl_assign('error', new Error(lang('invalid login data')));
                 return $this->render();
             }
             try {
                 DB::beginWork();
                 $user->delete();
                 ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 flash_success(lang('success delete user', $user->getDisplayName()));
             } catch (Exception $e) {
                 DB::rollback();
                 flash_error(lang('error delete user'));
             }
             // try
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         } else {
             flash_error(lang('error delete user'));
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         }
     }
 }
Example #9
0
function module_comment()
{
    global $global, $smarty;
    if ($global['id']) {
        $obj = new comment();
        $obj->set_where('com_channel_id = ' . get_id('channel', 'cha_code', $global['channel']));
        $obj->set_where('com_page_id = ' . $global['id']);
        $obj->set_page_size(5);
        $obj->set_page_num($global['page']);
        $sheet = $obj->get_sheet();
        set_link($obj->get_page_sum());
        $smarty->assign('comment', $sheet);
    }
}
	function uninstall($id = null) {
		ajx_current("empty");
		if (!$id) {
			$id=get_id();
		}
		if ( $plg  = Plugins::instance()->findById($id)) {
			if (!$plg->isInstalled()) return ;
			$plg->setIsInstalled(0);
			$plg->save();
			$name= $plg->getSystemName();
			$path = ROOT . "/plugins/$name/uninstall.php";
			if (file_exists($path)){
				include_once $path;
			}
		}
	}
Example #11
0
function set_more_global()
{
    global $global;
    $global['channel'] = get_global('channel', 'index');
    $global['cat'] = get_global('cat', 0);
    $global['page'] = get_global('page', 1);
    $global['id'] = get_global('id', 0);
    $global['original'] = $global['channel'];
    $global['channel_id'] = get_id('channel', 'cha_code', $global['channel']);
    if ($global['channel_id']) {
        $original_id = get_data('channel', $global['channel_id'], 'cha_original');
        if ($original_id) {
            $global['original'] = get_data('channel', $original_id, 'cha_code');
        }
    }
}
Example #12
0
function set_more_global()
{
    global $global;
    $global['admin_id'] = check_admin_login();
    $global['channel'] = get_global('channel', 'basic');
    $global['original'] = get_global('original', 'basic');
    $global['mod'] = get_global('mod', 'basic_info');
    $global['cat'] = get_global('cat', 0);
    $global['page'] = get_global('page', 1);
    $global['id'] = get_global('id', 0);
    $global['original'] = $global['channel'];
    $global['channel_id'] = get_id('channel', 'cha_code', $global['channel']);
    if ($global['channel_id']) {
        $original_id = get_data('channel', $global['channel_id'], 'cha_original');
        if ($original_id) {
            $global['original'] = get_data('channel', $original_id, 'cha_code');
        }
    }
}
Example #13
0
/**
 * This function call when a post request send .If that request is a valid addTicket request, new ticket will added,
 * Else redirect user to not found page or echo error message;
 * @param WP_USER $user
 * @return string
 */
function post_request($user)
{
    if (!isset($_POST["requestType"]) || $_POST["requestType"] != "addTicket" && $_POST["requestType"] != "addTicketAnswer") {
        header("Location: " . NOT_FOUND_URL);
        exit;
    }
    $const_array = array("applicant_id" => $user->ID, "status" => 0, "attachments" => $_POST["upfile"], "title" => $_POST["title"], "content" => $_POST["message"], "department" => $_POST["department"], "other" => "priority:" . $_POST["priority"] . "|", "related_order" => get_id($_POST["order"]));
    if (isset($_POST['relatedTicket'])) {
        $related_ticket = $_POST['relatedTicket'];
        $const_array = array_merge($const_array, array("related_ticket" => get_id($related_ticket)));
    }
    if ($_POST["requestType"] == "addTicket") {
        foreach ($const_array as $key => $value) {
            if (empty($value) && $value !== 0 && $key !== "attachments" && $key !== "order" && $key !== "related_ticket") {
                return "لطفا متنی تایپ کنید!" . "<br>";
            }
        }
    } else {
        if (empty($_POST["message"])) {
            return "متن پاسخ نیم تواند خالی باشد";
        }
    }
    $ticket = new Ticket($const_array);
    if ($ticket->create()) {
        if ($_POST["requestType"] == "addTicket") {
            echo "1|ticket.php?iti=" . $ticket->get_fake_id();
            exit;
        } else {
            if (get_user_level($user->ID) == 10) {
                Ticket::change_ticket_status($ticket->get_related_ticket_id(), 1);
            } else {
                Ticket::change_ticket_status($ticket->get_related_ticket_id(), 0);
            }
            echo "پاسخ شما افزوده شد";
        }
    } else {
        return "مشکلی در ایجاد تیکت وجود دارد.لطفا مجددا تلاش کنید";
    }
}
Example #14
0
function add_comment()
{
    safe('comment');
    global $global, $smarty, $lang;
    $channel = post('channel');
    $com_page_id = post('page_id');
    $com_username = post('username');
    $com_email = post('email');
    $com_rank = post('rank');
    $com_text = post('text');
    if ($channel == '' || $com_page_id == '' || $com_username == '' || $com_email == '' || $com_rank == '' || $com_text == '') {
        $info_text = $lang['submit_error_info'];
    } else {
        $com_channel_id = get_id('channel', 'cha_code', $channel);
        $com_add_time = time();
        $obj = new comment();
        $obj->set_value('com_channel_id', $com_channel_id);
        $obj->set_value('com_page_id', $com_page_id);
        $obj->set_value('com_username', $com_username);
        $obj->set_value('com_email', $com_email);
        $obj->set_value('com_rank', $com_rank);
        $obj->set_value('com_text', $com_text);
        $obj->set_value('com_add_time', $com_add_time);
        $obj->set_value('com_show', 0);
        $obj->set_value('com_lang', S_LANG);
        $obj->add();
        if (intval(get_varia('sentmail'))) {
            $email_title = '您的网站有了新的评论';
            $str = get_data($channel, $com_page_id, substr($channel, 0, 3) . '_title');
            $email_text = '评论:《' . $str . '》<br />' . $com_text;
            call_send_email($email_title, $email_text, $com_username, $com_email);
        }
        $info_text = $lang['submit_comment'];
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', $lang['go_back']);
    $smarty->assign('link_href', url(array('channel' => $channel, 'id' => $com_page_id)));
}
 function delete()
 {
     ajx_current("empty");
     $billingCategory = BillingCategories::findById(get_id());
     if (!$billingCategory instanceof BillingCategory) {
         flash_error(lang('billing category dnx'));
         return;
     }
     // if
     if (!$billingCategory->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     // if
     try {
         DB::beginWork();
         $billingCategory->delete();
         DB::commit();
         flash_success(lang('success delete billing category', $billingCategory->getName()));
         ajx_current("reload");
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
 function view()
 {
     $comment = Comments::findById(get_id());
     if (!$comment instanceof Comment) {
         flash_error(lang('comment dnx'));
         ajx_current("empty");
         return;
     }
     if (!$comment->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $object = $comment->getRelObject();
     if (!$object instanceof ContentDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     redirect_to($object->getViewUrl());
 }
	/**
	 * Delete company logo
	 *
	 * @param void
	 * @return null
	 */
	function delete_logo() {
		if(!logged_user()->isAdministrator()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		} // if

		$company = Contacts::findById(get_id());
		if(!($company instanceof Contact)) {
			flash_error(lang('company dnx'));
			ajx_current("empty");
			return;
		} // if

		try {
			DB::beginWork();
			$company->deleteLogo();
			$company->save();
			ApplicationLogs::createLog($company, ApplicationLogs::ACTION_EDIT);
			DB::commit();

			flash_success(lang('success delete company logo'));
			ajx_current("back");
		} catch(Exception $e) {
			DB::rollback();
			flash_error(lang('error delete company logo'));
			ajx_current("empty");
		} // try
	} // delete_logo
 function unarchive()
 {
     if (!can_manage_dimension_members(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $member = Members::findById(get_id());
     if (!$member instanceof Member) {
         flash_error(lang('member dnx'));
         ajx_current("empty");
         return;
     }
     if (get_id('user')) {
         $user = Contacts::findById($get_id('user'));
     } else {
         $user = logged_user();
     }
     if (!$user instanceof Contact) {
         ajx_current("empty");
         return;
     }
     try {
         DB::beginWork();
         set_time_limit(0);
         $count = $member->unarchive($user);
         evt_add("reload dimension tree", $member->getDimensionId());
         ajx_current("back");
         flash_success(lang('success unarchive member', $member->getName(), $count));
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
         ajx_current("empty");
     }
 }
Example #19
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
// +----------------------------------------------------------------------
_setView(__FILE__);
$itemID = get_id(1);
$itemsClass = new items();
//获取预览图
$previewFile = $itemsClass->get_theme_preview($itemID);
$previewFiles = array();
for ($i = 0; $i < count($previewFile); $i++) {
    $previewFiles[] = $previewFile[$i]["dir"];
}
abr('previewFiles', $previewFiles);
//作品详情
$item = $itemsClass->get($itemID);
if (!is_array($item) || $item['status'] == 'deleted') {
    header("HTTP/1.0 404 Not Found");
    header("Location: http://" . DOMAIN . "/" . $languageURL . "error");
} elseif (!is_array($item) || check_login_bool() && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') {
}
_setTitle($item['name']);
abr('meta_description', substr(strip_tags($item['description']), 0, 255));
require_once ROOT_PATH . '/apps/users/models/users.class.php';
Example #20
0
    header("Location: " . NOT_FOUND_URL);
    exit;
}
if (get_user_level($user->ID) == 10) {
    if (!isset($_GET["ticketType"])) {
        $tickets = get_all_tickets();
    } elseif (isset($_GET["user_id"])) {
        switch ($_GET["ticketType"]) {
            case "pending":
                $tickets = get_user_pending_tickets(get_id($_GET["user_id"]));
                break;
            case "answered":
                $tickets = get_user_answered_tickets(get_id($_GET["user_id"]));
                break;
            case "closed":
                $tickets = get_user_closed_tickets(get_id($_GET["user_id"]));
                break;
            default:
                header("Location:" . NOT_FOUND_URL);
                exit;
        }
    }
} else {
    if (!isset($_GET["ticketType"])) {
        $tickets = get_user_tickets($user->ID);
    } else {
        switch ($_GET["ticketType"]) {
            case "pending":
                $tickets = get_user_pending_tickets($user->ID);
                break;
            case "answered":
Example #21
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
// +----------------------------------------------------------------------
_setView(__FILE__);
$collectionID = get_id(2);
$collectionsClass = new collections();
$collection = $collectionsClass->get($collectionID);
if (!is_array($collection) || $collection['public'] == 'false' && check_login_bool() && $collection['user_id'] != $_SESSION['user']['user_id']) {
    refresh('/' . $languageURL . 'collections/', $langArray['wrong_collection'], 'error');
}
if (isset($_POST['rating'])) {
    $_GET['rating'] = $_POST['rating'];
}
if (!isset($_GET['rating']) || !is_numeric($_GET['rating']) || $_GET['rating'] > 5) {
    $_GET['rating'] = 5;
} elseif ($_GET['rating'] < 1) {
    $_GET['rating'] = 1;
}
$collection = $collectionsClass->rate($collectionID, $_GET['rating']);
$stars = '';
for ($i = 1; $i < 6; $i++) {
    if ($collection['rating'] >= $i) {
        $stars .= '<img src="{$template_data}img/star-on.png" alt="" class="left" />';
 /**
  * Delete specific project form
  *
  * @param void
  * @return null
  */
 function delete()
 {
     $project_form = ProjectForms::findById(get_id());
     if (!$project_form instanceof ProjectForm) {
         flash_error(lang('project form dnx'));
         if (ProjectForm::canAdd(logged_user(), active_project())) {
             $this->redirectTo('form');
         } else {
             $this->redirectToUrl(active_project()->getOverviewUrl());
         }
         // if
     }
     // if
     if (!$project_form->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         if (ProjectForm::canAdd(logged_user(), active_project())) {
             $this->redirectTo('form');
         } else {
             $this->redirectToUrl(active_project()->getOverviewUrl());
         }
         // if
     }
     // if
     if ($project_form->delete()) {
         ApplicationLogs::createLog($project_form, active_project(), ApplicationLogs::ACTION_DELETE, true);
         flash_success(lang('success delete project form', $project_form->getName()));
     } else {
         flash_error(lang('error delete project form'));
     }
     // if
     $this->redirectTo('form');
 }
 /**
  * Show calendar view milestone page
  *
  * @access public
  * @param void
  * @return null
  */
 function calendar()
 {
     $this->addHelper('textile');
     $project = active_project();
     $id = get_id();
     if (strlen($id) == 0) {
         $id = gmdate('Ym');
     }
     if (preg_match('/^(\\d{4})(\\d{2})$/', $id, $matches)) {
         list(, $year, $month) = $matches;
         tpl_assign('year', $year);
         tpl_assign('month', $month);
     } else {
         flash_error(lang('id missing'));
         $this->redirectToReferer(get_url('milestone'));
     }
     tpl_assign('milestones', $project->getMilestonesByMonth($year, $month));
 }
 /**
  * Delete company logo
  *
  * @param void
  * @return null
  */
 function delete_logo()
 {
     if (!logged_user()->isAdministrator(owner_company())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard');
     }
     // if
     $company = Companies::findById(get_id());
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         $this->redirectToReferer(get_url('administration', 'clients'));
     }
     // if
     try {
         DB::beginWork();
         $company->deleteLogo();
         $company->save();
         ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_EDIT);
         DB::commit();
         flash_success(lang('success delete company logo'));
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete company logo'));
     }
     // try
     $this->redirectToUrl($company->getEditLogoUrl());
 }
 /**
  * Detach file from related object
  *
  * @param void
  * @return null
  */
 function detach_from_object()
 {
     $manager_class = array_var($_GET, 'manager');
     $object_id = get_id('object_id');
     $file_id = get_id('file_id');
     $object = get_object_by_manager_and_id($object_id, $manager_class);
     if (!$object instanceof ProjectDataObject) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $file = ProjectFiles::findById($file_id);
     if (!$file instanceof ProjectFile) {
         flash_error(lang('file dnx'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $attached_file = AttachedFiles::findById(array('rel_object_manager' => $manager_class, 'rel_object_id' => $object_id, 'file_id' => $file_id));
     // findById
     if (!$attached_file instanceof AttachedFile) {
         flash_error(lang('file not attached to object'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     try {
         DB::beginWork();
         $attached_file->delete();
         DB::commit();
         flash_success(lang('success detach file'));
     } catch (Exception $e) {
         flash_error(lang('error detach file'));
         DB::rollback();
     }
     // try
     $this->redirectToReferer($object->getObjectUrl());
 }
Example #26
0
/**
 * @param sphinx_id $cl
 * @param testo della query $q
 * @param indie da usare $i
 * @param verbositi level $v 1  3 4 5 6=debug
 * @param offset $o
 * @param quante $l
 */
function printquery($cl, $q, $i, $v, $o, $l)
{
    $max = $o + $l;
    $cl->SetLimits($o, $l, $max, 0);
    $res = $cl->Query($q, $i);
    if ($res === false) {
        print "Query failed: " . $cl->GetLastError() . ".\n";
    } else {
        if ($cl->GetLastWarning() && $v > 6) {
            print "WARNING: " . $cl->GetLastWarning() . "\n\n";
        }
        if ($v > 3) {
            print "<h2>Query <br>{$q}<br> retrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec</h2>.\n";
            echo "<pre>";
            print "Query stats:\n";
            if (is_array($res["words"])) {
                foreach ($res["words"] as $word => $info) {
                    print "    '{$word}' found {$info['hits']} times in {$info['docs']} documents\n";
                }
            }
            print "\n";
            echo "</pre>";
        }
        if (is_array($res["matches"])) {
            $n = 1;
            if ($v > 4) {
                print "Matches:\n";
            }
            foreach ($res["matches"] as $docinfo) {
                if ($v > 5) {
                    print "{$n}. doc_id={$docinfo['id']}, weight={$docinfo['weight']}";
                }
                //echo "</pre>";
                foreach ($res["attrs"] as $attrname => $attrtype) {
                    $value = $docinfo["attrs"][$attrname];
                    if ($attrtype & SPH_ATTR_MULTI) {
                        $value = "(" . join(",", $value) . ")";
                    } else {
                        if ($attrtype == SPH_ATTR_TIMESTAMP) {
                            $value = date("Y-m-d H:i:s", $value);
                        }
                    }
                    print ", {$attrname}={$value}";
                }
                if ($v >= 1) {
                    print "\n";
                    echo "<p style=\" font-family:inconsolata; font-size:20px; padding: 8px 0 0px 6px; margin: 0;\">il testo era: </p>\n";
                    echo "<p style=\" width:95%; font-family:inconsolata; font-size:18px; padding: 6px 18px 22px 25px; margin: 0\">";
                    $link = "p?w=\\1";
                    $action = "";
                    //$id="id=\"\\1\"";
                    $id = "";
                    $pattern = "/(\\p{L}{3,})/u";
                    $replace = "<a {$id} href=\"{$link}\" {$action}>\\1</a>";
                    $text = get_id($docinfo[id]);
                    $text = preg_replace($pattern, $replace, $text);
                    echo "{$text}";
                    echo "</p>";
                    echo "<hr>";
                }
                if ($v < 1) {
                    $link = "p?w=\\1";
                    $action = "";
                    //$id="id=\"\\1\"";
                    $id = "";
                    $pattern = "/(\\p{L}{3,})/u";
                    $replace = "<a {$id} href=\"{$link}\" {$action}>\\1</a>";
                    $text = get_id($docinfo[id]);
                    $vers = get_vers($docinfo[id]);
                    $text = preg_replace($pattern, $replace, $text);
                    echo "{$vers['0']} {$text}";
                }
                $n++;
            }
        }
    }
}
 /**
  * Unsubscribe from message
  *
  * @param void
  * @return null
  */
 function unsubscribe()
 {
     $ticket = ProjectTickets::findById(get_id());
     if (!$ticket instanceof ProjectTicket) {
         flash_error(lang('ticket dnx'));
         $this->redirectTo('tickets');
     }
     // if
     if (!$ticket->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('tickets');
     }
     // if
     if ($ticket->unsubscribeUser(logged_user())) {
         flash_success(lang('success unsubscribe to ticket'));
     } else {
         flash_error(lang('error unsubscribe to ticket'));
     }
     // if
     $this->redirectToUrl($ticket->getViewUrl());
 }
 /**
  * Delete locale logo
  *
  * @param void
  * @return null
  */
 function delete_logo()
 {
     $locale = I18nLocales::findById(get_id());
     if (!$locale instanceof I18nLocale) {
         flash_error(lang('locale dnx'));
         $this->redirectToReferer(get_url('i18n', 'index'));
     }
     // if
     if (!$locale->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('i18n', 'index');
     }
     // if
     try {
         DB::beginWork();
         $locale->deleteLogo();
         $locale->save();
         ApplicationLogs::createLog($locale, 0, ApplicationLogs::ACTION_EDIT);
         DB::commit();
         flash_success(lang('success delete logo'));
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete logo', $e));
     }
     // try
     $this->redirectToUrl($locale->getEditLogoUrl());
 }
 /**
  * Delete comment
  *
  * @access public
  * @param void
  * @return null
  */
 function delete_comment()
 {
     $comment = MessageComments::findById(get_id());
     if (!$comment instanceof MessageComment) {
         flash_error(lang('comment dnx'));
         $this->redirectTo('message');
     }
     // if
     $message = $comment->getMessage();
     if (!$message instanceof ProjectMessage) {
         flash_error(lang('message dnx'));
         $this->redirectTo('message');
     }
     // if
     if (!$comment->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToUrl($message->getViewUrl());
     }
     // if
     try {
         DB::beginWork();
         $comment->delete();
         ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_DELETE);
         DB::commit();
         flash_success(lang('success delete comment'));
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete comment'));
     }
     // try
     $this->redirectToUrl($message->getViewUrl());
 }
Example #30
-1
function get_photos($post_id, $num = 0, $sizes = null, $ret = null, $landscape = null)
{
    // save the image with the highest priority
    // to use when returing only one image
    $top_priority['priority'] = 9999;
    // check if there are attachments
    if ($images = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image'))) {
        // loop through each image
        foreach ($images as $image) {
            $image->attachment_metadata = wp_get_attachment_metadata($image->ID);
            if (isset($photo['photos'])) {
                $i = count($photo['photos']);
            } else {
                $i = 0;
            }
            // store image information
            $photo['photos'][$i]['id'] = get_id($image);
            $photo['photos'][$i]['caption'] = get_caption($image);
            $photo['photos'][$i]['credit'] = get_credit($image);
            $photo['photos'][$i]['priority'] = get_priority($image);
            $photo['photos'][$i]['width'] = get_width($image);
            $photo['photos'][$i]['height'] = get_height($image);
            // return requested sizes
            if ($sizes) {
                foreach ($sizes as $size) {
                    $photo['photos'][$i]['src'][$size] = get_src($image, $size);
                }
            } else {
                // return all sizes when none are specified
                $photo['photos'][$i]['src']['full'] = get_src($image, 'full');
                $photo['photos'][$i]['src']['large'] = get_src($image, 'large');
                $photo['photos'][$i]['src']['thumbnail'] = get_src($image, 'thumbnail');
                $photo['photos'][$i]['src']['medium'] = get_src($image, 'medium');
                $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
                $photo['photos'][$i]['src']['alt-thumbnail'] = get_src($image, 'alt-thumbnail');
                $photo['photos'][$i]['src']['custom-495'] = get_src($image, 'custom-495');
                $photo['photos'][$i]['src']['custom-165'] = get_src($image, 'custom-165');
                $photo['photos'][$i]['src']['custom-260'] = get_src($image, 'custom-260');
                $photo['photos'][$i]['src']['custom-75x75-crop'] = get_src($image, 'custom-75x75-crop');
            }
            // store the photo with the highest priority in wordpress.
            // photos with high priorities are given low numbers.
            // photos with priority of -1 are ignored.
            if ($num === 1 && $photo['photos'][$i]['priority'] < $top_priority['priority'] && $photo['photos'][$i]['priority'] >= 0) {
                // if user wants a landscape photo, check
                // to make sure it is landscape
                if ($landscape && !is_landscape($image)) {
                    continue;
                }
                $top_priority = $photo['photos'][$i];
            }
            // determine image position based on priority
            if (!isset($photo['display']['feature']) && get_priority($image) === 1) {
                // feature photo - below headline
                $photo['display']['feature'] = $i;
                $photo['photos'][$i]['src']['single-feature'] = get_src($image, 'single-feature');
            } elseif (!isset($photo['display']['inline']) && get_priority($image) === 2) {
                // inline photo - thumbnail w/in post
                $photo['display']['inline'] = $i;
                $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
            } else {
                if (!isset($photo['display']['inline'])) {
                    // inline photo has not been set
                    $photo['display']['inline'] = $i;
                    $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
                } else {
                    // gallery photo - appears in post photo gallery
                    if (isset($photo['display']['gallery'])) {
                        $photo['display']['gallery'][count($photo['display']['gallery'])] = $i;
                    } else {
                        $photo['display']['gallery'][0] = $i;
                    }
                }
            }
            // return first photo when one is requested and there is only one
            if ($num === 1 && count($images) == 1) {
                return $photo['photos'][$i];
            }
        }
        // returns top photo when one is requested.
        // if user only wants one landscape photo,
        // but the top_priority is not landscape, don't
        // return anything.
        if ($num === 1) {
            if ($landscape && !is_landscape($image)) {
                return false;
            }
            return $top_priority;
        }
        // return all of the requested photos
        return $photo;
    } else {
        // check if the image is from the archives. images on our old
        // websites (custom CMS for some time then College Publisher)
        // were not saved as attachments, but were stored as custom
        // fields.
        $meta = get_post_custom($post_id);
        if ($meta && isset($meta['_image1'])) {
            $meta['_image1'] = get_image($meta['_image1']);
            // needed to make legacy photo output look like current photos
            $photo['photos'][0] = $meta['_image1'];
            $photo['photos'][0]['priority'] = 0;
            $photo['display']['inline'] = 0;
            if ($num === 1) {
                return $photo['photos'][0];
            }
            return $photo;
        }
    }
    // no images were found
    return false;
}