Esempio n. 1
0
 public function render_exception()
 {
     global $USER, $SESSION;
     if (defined('GROUP') && $USER->is_logged_in()) {
         $roles = $USER->get('grouproles');
         if (!isset($roles[GROUP])) {
             $group = group_current_group();
             if ($group->jointype == 'open' || get_record('group_member_invite', 'group', GROUP, 'member', $USER->get('id'))) {
                 $message = get_string('notmembermayjoin', 'group', $group->name);
                 // Error code equals 1 if we have objection=1 in url
                 if ($this->getCode() == '1') {
                     $message .= ' ' . get_string('accessdeniedobjection', 'error');
                 }
                 $SESSION->add_error_msg($message);
                 $next = substr($_SERVER['REQUEST_URI'], strlen(get_mahara_install_subdirectory()) - 1);
                 $goto = group_homepage_url($group);
                 $goto .= (strpos($goto, '?') ? '&' : '?') . 'next=' . urlencode($next);
                 redirect($goto);
             }
             if ($group->request && !get_record('group_member_request', 'group', GROUP, 'member', $USER->get('id'))) {
                 $SESSION->add_error_msg(get_string('notamember', 'group'));
                 redirect(get_config('wwwroot') . 'group/requestjoin.php?id=' . GROUP . '&returnto=view');
             }
         }
     }
     header("HTTP/1.0 403 Forbidden", true);
     return parent::render_exception();
 }
Esempio n. 2
0
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
defined('INTERNAL') || die;
//
// Set session settings
//
session_name(get_config('cookieprefix') . 'mahara');
ini_set('session.save_path', '3;' . get_config('dataroot') . 'sessions');
ini_set('session.gc_divisor', 1000);
// Session timeout is stored in minutes in the database
ini_set('session.gc_maxlifetime', get_config('session_timeout') * 60);
ini_set('session.use_only_cookies', true);
ini_set('session.cookie_path', get_mahara_install_subdirectory());
ini_set('session.cookie_httponly', 1);
ini_set('session.hash_bits_per_character', 4);
// TEMPORARY: this will be REMOVED after the session path changing
// has been around for a bit.
// Attempt to create session directories
$sessionpath = get_config('dataroot') . 'sessions';
if (!is_dir("{$sessionpath}/0")) {
    // Create three levels of directories, named 0-9, a-f
    $characters = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
    foreach ($characters as $c1) {
        check_dir_exists("{$sessionpath}/{$c1}");
        foreach ($characters as $c2) {
            check_dir_exists("{$sessionpath}/{$c1}/{$c2}");
            foreach ($characters as $c3) {
                check_dir_exists("{$sessionpath}/{$c1}/{$c2}/{$c3}");
Esempio n. 3
0
 private function _fixref($hrefsrc)
 {
     static $basepath;
     if (!$basepath) {
         $basepath = get_mahara_install_subdirectory();
     }
     $artefacts = $this->get_artefactids_imported_by_entryid($hrefsrc);
     if (is_null($artefacts) || count($artefacts) != 1) {
         // This can happen if a Leap2A xml file is uploaded that refers to
         // files that (naturally) weren't uploaded with it.
         log_debug("Warning: fixref was expecting one artefact to have been imported by entry {$hrefsrc} but seems to have gotten " . count($artefacts));
         return $hrefsrc;
     }
     return $basepath . 'artefact/file/download.php?file=' . $artefacts[0];
 }
Esempio n. 4
0
/**
 * Like {@link get_script_path()} but returns a URI relative to WWWROOT
 * @see get_script_path()
 * @return string
 */
function get_relative_script_path()
{
    $maharadir = get_mahara_install_subdirectory();
    // $maharadir always has a trailing '/'
    return substr(get_script_path(), strlen($maharadir) - 1);
}
 public function render_exception()
 {
     global $USER, $SESSION;
     if (defined('GROUP') && $USER->is_logged_in()) {
         $roles = $USER->get('grouproles');
         if (!isset($roles[GROUP])) {
             $group = group_current_group();
             if ($group->jointype == 'open' || $group->jointype == 'invite' && get_record('group_member_invite', 'group', GROUP, 'member', $USER->get('id'))) {
                 $SESSION->add_error_msg(get_string('notmembermayjoin', 'group', $group->name));
                 $next = substr($_SERVER['REQUEST_URI'], strlen(get_mahara_install_subdirectory()) - 1);
                 redirect(get_config('wwwroot') . 'group/view.php?id=' . GROUP . '&next=' . urlencode($next));
             }
             if ($group->jointype == 'request' && !get_record('group_member_request', 'group', GROUP, 'member', $USER->get('id'))) {
                 $SESSION->add_error_msg(get_string('notamember', 'group'));
                 redirect(get_config('wwwroot') . 'group/requestjoin.php?id=' . GROUP . '&returnto=view');
             }
         }
     }
     header("HTTP/1.0 403 Forbidden", true);
     return parent::render_exception();
 }