Ejemplo n.º 1
0
 function addApproval()
 {
     global $USERINFO;
     global $ID;
     global $INFO;
     if (!$INFO['exists']) {
         msg($this->getLang('cannot approve a non-existing revision'), -1);
         return;
     }
     $approvalRevision = $this->helper->getRevision();
     $approvals = $this->helper->getApprovals();
     if (!isset($approvals[$approvalRevision])) {
         $approvals[$approvalRevision] = array();
     }
     $approvals[$approvalRevision][$INFO['client']] = array($INFO['client'], $_SERVER['REMOTE_USER'], $USERINFO['mail'], time());
     $success = p_set_metadata($ID, array('approval' => $approvals), true, true);
     if ($success) {
         msg($this->getLang('version approved'), 1);
         $data = array();
         $data['rev'] = $approvalRevision;
         $data['id'] = $ID;
         $data['approver'] = $_SERVER['REMOTE_USER'];
         $data['approver_info'] = $USERINFO;
         if ($this->getConf('send_mail_on_approve') && $this->helper->isRevisionApproved($approvalRevision)) {
             /** @var action_plugin_publish_mail $mail */
             $mail = plugin_load('action', 'publish_mail');
             $mail->send_approve_mail();
         }
         trigger_event('PLUGIN_PUBLISH_APPROVE', $data);
     } else {
         msg($this->getLang('cannot approve error'), -1);
     }
     send_redirect(wl($ID, array('rev' => $this->helper->getRevision()), true, '&'));
 }
Ejemplo n.º 2
0
 /**
  * Handles input from the newform and redirects to the edit mode
  *
  * @author Andreas Gohr <*****@*****.**>
  * @author Gina Haeussge <*****@*****.**>
  */
 function handle_act_preprocess(&$event, $param)
 {
     global $TEXT;
     global $ID;
     if ($event->data != 'btngnew') {
         return true;
     }
     $tools =& plugin_load('helper', 'blogtng_tools');
     if (!$tools->getParam('new/title')) {
         msg($this->getLang('err_notitle'), -1);
         $event->data = 'show';
         return true;
     }
     $event->preventDefault();
     $new = $tools->mkpostid($tools->getParam('new/format'), $tools->getParam('new/title'));
     if ($ID != $new) {
         send_redirect(wl($new, array('do' => 'btngnew', 'btng[post][blog]' => $tools->getParam('post/blog'), 'btng[new][format]' => $tools->getParam('new/format'), 'btng[new][title]' => $tools->getParam('new/title')), true, '&'));
         return false;
         //never reached
     } else {
         $TEXT = $this->_prepare_template($new, $tools->getParam('new/title'));
         $event->data = 'preview';
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  * handle event
  */
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     if ($ACT != 'show') {
         return;
     }
     $redirects = confToHash($this->getsavedir() . '/shorturl.conf');
     if ($redirects[$ID]) {
         if (preg_match('/^https?:\\/\\//', $redirects[$ID])) {
             send_redirect($redirects[$ID]);
         } else {
             if ($this->getConf('showmsg')) {
                 msg(sprintf($this->getLang('redirected'), hsc($ID)));
             }
             send_redirect(wl($redirects[$ID], '', true));
         }
         exit;
     } else {
         if ($_GET['generateShortURL'] != "" && auth_quickaclcheck($ID) >= AUTH_READ) {
             $shorturl =& plugin_load('helper', 'shorturl');
             if ($shorturl) {
                 $shortID = $shorturl->autoGenerateShortUrl($ID);
             }
         }
     }
 }
Ejemplo n.º 4
0
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     global $INFO;
     if ($ACT != 'show') {
         return;
     }
     if (!$INFO['exists']) {
         return;
     }
     # don't try to read an article that doesn't exist
     $all = rtrim(rawWiki($ID));
     $inner = substr($all, 2, -2);
     if ($all == '[[' . $inner . ']]' and strpos($inner, '[[') === false and strpos($inner, ']]') === false) {
         if (!strpos($inner, '://') === false) {
             $url = $inner;
             # link is URL already
         } else {
             msg(sprintf('From: <a href="' . wl($ID, 'do=edit') . '">' . hsc($ID) . '</a>'));
             $url = html_wikilink($inner, $name = null, $search = '');
             $url = substr($url, strpos($url, '"') + 1);
             $url = substr($url, 0, strpos($url, '"'));
         }
         idx_addPage($ID);
         # ensure fulltext search indexing of referrer article - to put it on the backlink page of target article
         send_redirect($url);
     }
 }
Ejemplo n.º 5
0
/**
 * Fetch the an ID from request
 *
 * Uses either standard $_REQUEST variable or extracts it from
 * the full request URI when userewrite is set to 2
 *
 * For $param='id' $conf['start'] is returned if no id was found.
 * If the second parameter is true (default) the ID is cleaned.
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function getID($param = 'id', $clean = true)
{
    global $INPUT;
    global $conf;
    $id = $INPUT->str($param);
    //construct page id from request URI
    if (empty($id) && $conf['userewrite'] == 2) {
        $request = $_SERVER['REQUEST_URI'];
        $script = '';
        //get the script URL
        if ($conf['basedir']) {
            $relpath = '';
            if ($param != 'id') {
                $relpath = 'lib/exe/';
            }
            $script = $conf['basedir'] . $relpath . utf8_basename($_SERVER['SCRIPT_FILENAME']);
        } elseif ($_SERVER['PATH_INFO']) {
            $request = $_SERVER['PATH_INFO'];
        } elseif ($_SERVER['SCRIPT_NAME']) {
            $script = $_SERVER['SCRIPT_NAME'];
        } elseif ($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']) {
            $script = preg_replace('/^' . preg_quote($_SERVER['DOCUMENT_ROOT'], '/') . '/', '', $_SERVER['SCRIPT_FILENAME']);
            $script = '/' . $script;
        }
        //clean script and request (fixes a windows problem)
        $script = preg_replace('/\\/\\/+/', '/', $script);
        $request = preg_replace('/\\/\\/+/', '/', $request);
        //remove script URL and Querystring to gain the id
        if (preg_match('/^' . preg_quote($script, '/') . '(.*)/', $request, $match)) {
            $id = preg_replace('/\\?.*/', '', $match[1]);
        }
        $id = urldecode($id);
        //strip leading slashes
        $id = preg_replace('!^/+!', '', $id);
    }
    // Namespace autolinking from URL
    if (substr($id, -1) == ':' || $conf['useslash'] && substr($id, -1) == '/') {
        if (page_exists($id . $conf['start'])) {
            // start page inside namespace
            $id = $id . $conf['start'];
        } elseif (page_exists($id . noNS(cleanID($id)))) {
            // page named like the NS inside the NS
            $id = $id . noNS(cleanID($id));
        } elseif (page_exists($id)) {
            // page like namespace exists
            $id = substr($id, 0, -1);
        } else {
            // fall back to default
            $id = $id . $conf['start'];
        }
        send_redirect(wl($id, '', true));
    }
    if ($clean) {
        $id = cleanID($id);
    }
    if (empty($id) && $param == 'id') {
        $id = $conf['start'];
    }
    return $id;
}
Ejemplo n.º 6
0
 public function handle()
 {
     global $ID;
     if (isset($_GET['delete'])) {
         $log = $this->loadHelper('log404');
         $log->deleteRecord($_GET['delete']);
         msg("Records for " . $_GET['delete'] . " have been removed from the 404 log.");
         send_redirect(wl($ID, array('do' => 'admin', 'page' => $this->getPluginName()), true, '&'));
     }
 }
 public function login()
 {
     $login_hint = '';
     if (!empty($_SESSION[DOKU_COOKIE]['auth']['info']['mail'])) {
         $usermail = $_SESSION[DOKU_COOKIE]['auth']['info']['mail'];
         $login_hint = "&login_hint={$usermail}";
     }
     $url = $this->oAuth->getAuthorizationUri() . $login_hint;
     send_redirect($url);
 }
Ejemplo n.º 8
0
 /**
  * Should carry out any processing required by the plugin.
  */
 public function handle()
 {
     global $INPUT;
     global $ID;
     global $config_cascade;
     $config_file_path = end($config_cascade['main']['local']);
     // form submit
     $table = Schema::cleanTableName($INPUT->str('table'));
     if ($table && $INPUT->bool('save') && checkSecurityToken()) {
         $builder = new SchemaBuilder($table, $INPUT->arr('schema'));
         if (!$builder->build()) {
             msg('something went wrong while saving', -1);
         }
         touch($config_file_path);
     }
     // export
     if ($table && $INPUT->bool('export')) {
         $builder = new Schema($table);
         header('Content-Type: application/json');
         header("Content-Disposition: attachment; filename={$table}.struct.json");
         echo $builder->toJSON();
         exit;
     }
     // import
     if ($table && $INPUT->bool('import')) {
         if (isset($_FILES['schemafile']['tmp_name'])) {
             $json = io_readFile($_FILES['schemafile']['tmp_name'], false);
             if (!$json) {
                 msg('Something went wrong with the upload', -1);
             } else {
                 $builder = new SchemaImporter($table, $json, $INPUT->bool('lookup'));
                 if (!$builder->build()) {
                     msg('something went wrong while saving', -1);
                 }
                 touch($config_file_path);
             }
         }
     }
     // delete
     if ($table && $INPUT->bool('delete')) {
         if ($table != $INPUT->str('confirm')) {
             msg($this->getLang('del_fail'), -1);
         } else {
             try {
                 $schema = new Schema($table);
                 $schema->delete();
                 msg($this->getLang('del_ok'), 1);
                 touch($config_file_path);
                 send_redirect(wl($ID, array('do' => 'admin', 'page' => 'struct_schemas'), true, '&'));
             } catch (StructException $e) {
                 msg(hsc($e->getMessage()), -1);
             }
         }
     }
 }
 /**
  * Redirects to the service for requesting access
  *
  * This is the first step of oAuth authentication
  *
  * This implementation tries to abstract away differences between oAuth1 and oAuth2,
  * but might need to be overwritten for specific services
  */
 public function login()
 {
     if (is_a($this->oAuth, 'OAuth\\OAuth2\\Service\\AbstractService')) {
         /* oAuth2 handling */
         $url = $this->oAuth->getAuthorizationUri();
     } else {
         /* oAuth1 handling */
         // extra request needed for oauth1 to request a request token :-)
         $token = $this->oAuth->requestRequestToken();
         $url = $this->oAuth->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
     }
     send_redirect($url);
 }
Ejemplo n.º 10
0
 public function getAccessForm()
 {
     session_init();
     $objSecurity = new Security();
     $objSecurity->setCompany(request_var("company"));
     $objSecurity->setOffice(request_var("office"));
     $objSecurity->setUserId(request_var("uid"));
     $objSecurity->setForm(request_var("forma"));
     $page = $objSecurity->getAccessForm();
     //set_session_var(VAR_MAINPAGE, "../view/{$page}.php");
     set_session_var(VAR_MAINPAGE, "../controller/laboratory/controlOrder.php");
     send_redirect("../view/main/master.php");
 }
Ejemplo n.º 11
0
 /**
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_obs_action(Doku_Event &$event, $param)
 {
     if ($event->data !== 'show') {
         return;
     }
     global $INFO;
     $parts = explode(':', $INFO['id']);
     if (count($parts) == 2 && $parts[1] == 'obs') {
         if (!empty($INFO['filepath']) && !is_file($INFO['filepath'])) {
             // if you are here, obs has not yet been configured in this namespace, so redirect to the setup page
             send_redirect(DOKU_URL . 'obs-setup');
         }
     }
 }
Ejemplo n.º 12
0
 public function configureUser()
 {
     $_response = User::login(request_var('cmbCompany'), request_var('userId'));
     if (is_array($_response) && count($_response)) {
         session_init();
         $objUser = new User();
         $objUser->setId($_response["ParticipanteId"]);
         $objUser->setIdentification($_response["Identificacion"]);
         $objUser->setFirstName($_response["Nombre"]);
         $objUser->setLastName($_response["Apellido"]);
         $objUser->setFullName($_response["Nombre"] . " " . $_response["Apellido"]);
         $objUser->setUsername($_response["UsuarioId"]);
         $objUser->setCompany(request_var('cmbCompany'));
         $objUser->setOffice(request_var("cmbOffice"));
         set_session_var(VAR_USER, $objUser);
         send_redirect("../view/main/master.php");
     }
 }
Ejemplo n.º 13
0
 /**
  * handle user request
  */
 function handle()
 {
     global $ID, $INPUT;
     if (!$this->_restore_session()) {
         return $this->_close_session();
     }
     if ($INPUT->int('save') != 1) {
         return $this->_close_session();
     }
     if (!checkSecurityToken()) {
         return $this->_close_session();
     }
     if (is_null($this->_config)) {
         $this->_config = new configuration($this->_file);
     }
     // don't go any further if the configuration is locked
     if ($this->_config->_locked) {
         return $this->_close_session();
     }
     $this->_input = $INPUT->arr('config');
     while (list($key) = each($this->_config->setting)) {
         $input = isset($this->_input[$key]) ? $this->_input[$key] : null;
         if ($this->_config->setting[$key]->update($input)) {
             $this->_changed = true;
         }
         if ($this->_config->setting[$key]->error()) {
             $this->_error = true;
         }
     }
     if ($this->_changed && !$this->_error) {
         $this->_config->save_settings($this->getPluginName());
         // save state & force a page reload to get the new settings to take effect
         $_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
         $this->_close_session();
         send_redirect(wl($ID, array('do' => 'admin', 'page' => 'config'), true, '&'));
         exit;
     } elseif (!$this->_error) {
         $this->_config->touch_settings();
         // just touch to refresh cache
     }
     $this->_close_session();
 }
Ejemplo n.º 14
0
 /**
  * handle event
  */
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     if ($ACT != 'show') {
         return;
     }
     $redirects = confToHash(dirname(__FILE__) . '/redirect.conf');
     if ($redirects[$ID]) {
         if (preg_match('/^https?:\\/\\//', $redirects[$ID])) {
             send_redirect($redirects[$ID]);
         } else {
             if ($this->getConf('showmsg')) {
                 msg(sprintf($this->getLang('redirected'), hsc($ID)));
             }
             $link = explode('#', $redirects[$ID], 2);
             send_redirect(wl($link[0], '', true) . '#' . rawurlencode($link[1]));
         }
         exit;
     }
 }
Ejemplo n.º 15
0
 function forcessllogin(&$event, $param)
 {
     global $ACT;
     $acts = explode(',', $this->getConf('actions'));
     if (!is_array($acts)) {
         $acts = array();
     }
     if (!in_array($ACT, $acts)) {
         return;
     }
     if (is_ssl()) {
         return;
     }
     if ($event->name == 'ACTION_ACT_PREPROCESS' && !$this->getConf('splashpage')) {
         send_redirect('https://' . $this->host() . DOKU_BASE . DOKU_SCRIPT . '?' . $_SERVER['QUERY_STRING']);
         exit;
     }
     if ($event->name == 'TPL_ACT_RENDER') {
         echo $this->locale_xhtml('splashpage');
         $this->_render($ACT);
         $event->preventDefault();
     }
 }
 /**
  * Should carry out any processing required by the plugin.
  */
 public function handle()
 {
     global $INPUT;
     global $ID;
     $assignments = new Assignments();
     if ($INPUT->str('action') && $INPUT->arr('assignment') && checkSecurityToken()) {
         $assignment = $INPUT->arr('assignment');
         if (!blank($assignment['assign']) && !blank($assignment['tbl'])) {
             if ($INPUT->str('action') === 'delete') {
                 $ok = $assignments->removePattern($assignment['assign'], $assignment['tbl']);
                 if (!$ok) {
                     msg('failed to remove pattern', -1);
                 }
             } else {
                 if ($INPUT->str('action') === 'add') {
                     if ($assignment['assign'][0] == '/') {
                         if (@preg_match($assignment['assign'], null) === false) {
                             msg('Invalid regular expression. Pattern not saved', -1);
                         } else {
                             $ok = $assignments->addPattern($assignment['assign'], $assignment['tbl']);
                             if (!$ok) {
                                 msg('failed to add pattern', -1);
                             }
                         }
                     } else {
                         $ok = $assignments->addPattern($assignment['assign'], $assignment['tbl']);
                         if (!$ok) {
                             msg('failed to add pattern', -1);
                         }
                     }
                 }
             }
         }
         send_redirect(wl($ID, array('do' => 'admin', 'page' => 'struct_assignments'), true, '&'));
     }
 }
Ejemplo n.º 17
0
list($EXT, $MIME, $DL) = mimetype($MEDIA, false);
if ($EXT === false) {
    $EXT = 'unknown';
    $MIME = 'application/octet-stream';
    $DL = true;
}
// check for permissions, preconditions and cache external files
list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE);
// prepare data for plugin events
$data = array('media' => $MEDIA, 'file' => $FILE, 'orig' => $FILE, 'mime' => $MIME, 'download' => $DL, 'cache' => $CACHE, 'ext' => $EXT, 'width' => $WIDTH, 'height' => $HEIGHT, 'status' => $STATUS, 'statusmessage' => $STATUSMESSAGE);
// handle the file status
$evt = new Doku_Event('FETCH_MEDIA_STATUS', $data);
if ($evt->advise_before()) {
    // redirects
    if ($data['status'] > 300 && $data['status'] <= 304) {
        send_redirect($data['statusmessage']);
    }
    // send any non 200 status
    if ($data['status'] != 200) {
        header('HTTP/1.0 ' . $data['status'] . ' ' . $data['statusmessage']);
    }
    // die on errors
    if ($data['status'] > 203) {
        print $data['statusmessage'];
        exit;
    }
}
$evt->advise_after();
unset($evt);
//handle image resizing/cropping
if (substr($MIME, 0, 5) == 'image' && $WIDTH) {
Ejemplo n.º 18
0
 /**
  *  Refresh plugin list
  */
 function refresh()
 {
     global $config_cascade;
     // expire dokuwiki caches
     // touching local.php expires wiki page, JS and CSS caches
     @touch(reset($config_cascade['main']['local']));
     // update latest plugin date - FIXME
     global $ID;
     send_redirect(wl($ID, array('do' => 'admin', 'page' => 'plugin'), true, '&'));
 }
Ejemplo n.º 19
0
function act_redirect_execute($opts)
{
    $go = wl($opts['id'], '', true);
    if (isset($opts['fragment'])) {
        $go .= '#' . $opts['fragment'];
    }
    //show it
    send_redirect($go);
}
Ejemplo n.º 20
0
 public function handle_dologin(Doku_Event &$event, $param)
 {
     global $lang;
     global $ID;
     $singleService = $this->getConf('singleService');
     if ($singleService == '') {
         return true;
     }
     $lang['btn_login'] = $this->getLang('loginButton') . $singleService;
     if ($event->data != 'login') {
         return true;
     }
     /** @var helper_plugin_oauth $hlp */
     $hlp = plugin_load('helper', 'oauth');
     $enabledServices = $hlp->listServices();
     if (in_array($singleService, $enabledServices, true) === false) {
         msg($this->getLang('wrongConfig'), -1);
         return false;
     }
     $url = wl($ID, array('oauthlogin' => $singleService), true, '&');
     send_redirect($url);
 }
Ejemplo n.º 21
0
    check_session();
    send_messages(false);
} elseif ($_REQUEST['action'] === 'jsview') {
    check_session();
    send_messages(true);
} elseif ($_REQUEST['action'] === 'jsrefresh') {
    check_session();
    ob_start();
    print_messages();
    $msgs = ob_get_clean();
    ob_start();
    print_chatters();
    $chatters = ob_get_clean();
    echo json_encode(array($_REQUEST['id'], $msgs, $chatters, get_setting('topic')));
} elseif ($_REQUEST['action'] === 'redirect' && !empty($_GET['url'])) {
    send_redirect();
} elseif ($_REQUEST['action'] === 'wait') {
    send_waiting_room();
} elseif ($_REQUEST['action'] === 'post') {
    check_session();
    if (isset($_REQUEST['kick']) && isset($_REQUEST['sendto']) && valid_nick($_REQUEST['sendto'])) {
        if ($U['status'] >= 5 || $U['status'] >= 3 && $countmods === 0 && get_setting('memkick')) {
            if (isset($_REQUEST['what']) && $_REQUEST['what'] === 'purge') {
                kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], true);
            } else {
                kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], false);
            }
        }
    } elseif (isset($_REQUEST['message']) && isset($_REQUEST['sendto'])) {
        validate_input();
    }
Ejemplo n.º 22
0
 /**
  * Acquire a lock for the tile generator
  */
 function tile_lock($d)
 {
     global $conf;
     $lockDir = $conf['lockdir'] . '/' . md5($d['id']) . '.panoview';
     @ignore_user_abort(1);
     $timeStart = time();
     do {
         //waited longer than 25 seconds? -> stale lock?
         if (time() - $timeStart > 25) {
             if (time() - @filemtime($lockDir) > 30) {
                 $this->tile_unlock($d);
             }
             send_redirect(DOKU_URL . 'lib/plugins/panoview/tiles.php?tile=' . $d['zoom'] . '-' . $d['col'] . '-' . $d['row'] . '&image=' . rawurlencode($d['id']));
             exit;
         }
         $locked = @mkdir($lockDir, $conf['dmode']);
         if ($locked) {
             if (!empty($conf['dperm'])) {
                 chmod($lockDir, $conf['dperm']);
             }
             break;
         }
         usleep(rand(500, 3000));
     } while ($locked === false);
 }
Ejemplo n.º 23
0
    }
}
// handle meta saving
if ($IMG && $_REQUEST['do']['save']) {
    $JUMPTO = media_metasave($IMG, $AUTH, $_REQUEST['meta']);
}
// handle deletion
if ($DEL) {
    $res = 0;
    if (checkSecurityToken()) {
        $res = media_delete($DEL, $AUTH);
    }
    if ($res & DOKU_MEDIA_DELETED) {
        $msg = sprintf($lang['deletesucc'], noNS($DEL));
        if ($res & DOKU_MEDIA_EMPTY_NS) {
            // current namespace was removed. redirecting to root ns passing msg along
            send_redirect(DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode($msg) . '&edid=' . $_REQUEST['edid']);
        }
        msg($msg, 1);
    } elseif ($res & DOKU_MEDIA_INUSE) {
        if (!$conf['refshow']) {
            msg(sprintf($lang['mediainuse'], noNS($DEL)), 0);
        }
    } else {
        msg(sprintf($lang['deletefail'], noNS($DEL)), -1);
    }
}
// finished - start output
header('Content-Type: text/html; charset=utf-8');
include template('mediamanager.php');
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Ejemplo n.º 24
0
 /**
  * Execute the requested action(s) and initialize the plugin repository
  */
 public function handle()
 {
     global $INPUT;
     // initialize the remote repository
     /* @var helper_plugin_extension_repository $repository */
     $repository = $this->loadHelper('extension_repository');
     if (!$repository->hasAccess()) {
         $url = $this->gui->tabURL('', array('purge' => 1));
         msg($this->getLang('repo_error') . ' [<a href="' . $url . '">' . $this->getLang('repo_retry') . '</a>]', -1);
     }
     if (!in_array('ssl', stream_get_transports())) {
         msg($this->getLang('nossl'), -1);
     }
     /* @var helper_plugin_extension_extension $extension */
     $extension = $this->loadHelper('extension_extension');
     try {
         if ($INPUT->post->has('fn') && checkSecurityToken()) {
             $actions = $INPUT->post->arr('fn');
             foreach ($actions as $action => $extensions) {
                 foreach ($extensions as $extname => $label) {
                     switch ($action) {
                         case 'install':
                         case 'reinstall':
                         case 'update':
                             $extension->setExtension($extname);
                             $installed = $extension->installOrUpdate();
                             foreach ($installed as $ext => $info) {
                                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
                             }
                             break;
                         case 'uninstall':
                             $extension->setExtension($extname);
                             $status = $extension->uninstall();
                             if ($status) {
                                 msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getDisplayName())), 1);
                             } else {
                                 msg(sprintf($this->getLang('msg_delete_failed'), hsc($extension->getDisplayName())), -1);
                             }
                             break;
                         case 'enable':
                             $extension->setExtension($extname);
                             $status = $extension->enable();
                             if ($status !== true) {
                                 msg($status, -1);
                             } else {
                                 msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1);
                             }
                             break;
                         case 'disable':
                             $extension->setExtension($extname);
                             $status = $extension->disable();
                             if ($status !== true) {
                                 msg($status, -1);
                             } else {
                                 msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1);
                             }
                             break;
                     }
                 }
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         } elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
             $installed = $extension->installFromURL($INPUT->post->str('installurl'));
             foreach ($installed as $ext => $info) {
                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         } elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
             $installed = $extension->installFromUpload('installfile');
             foreach ($installed as $ext => $info) {
                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         }
     } catch (Exception $e) {
         msg($e->getMessage(), -1);
         send_redirect($this->gui->tabURL('', array(), '&', true));
     }
 }
Ejemplo n.º 25
0
/**
 * Handles media file deletions
 *
 * If configured, checks for media references before deletion
 *
 * @author Andreas Gohr <*****@*****.**>
 * @return mixed false on error, true on delete or array with refs
 */
function media_delete($id, $auth)
{
    if ($auth < AUTH_DELETE) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    global $conf;
    global $lang;
    $file = mediaFN($id);
    // trigger an event - MEDIA_DELETE_FILE
    $data['id'] = $id;
    $data['name'] = basename($file);
    $data['path'] = $file;
    $data['size'] = @file_exists($file) ? filesize($file) : 0;
    $data['unl'] = false;
    $data['del'] = false;
    $evt = new Doku_Event('MEDIA_DELETE_FILE', $data);
    if ($evt->advise_before()) {
        $data['unl'] = @unlink($file);
        if ($data['unl']) {
            addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
            $data['del'] = io_sweepNS($id, 'mediadir');
        }
    }
    $evt->advise_after();
    unset($evt);
    if ($data['unl'] && $data['del']) {
        // current namespace was removed. redirecting to root ns passing msg along
        send_redirect(DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode(sprintf(noNS($id), $lang['deletesucc'])));
    }
    return $data['unl'];
}
Ejemplo n.º 26
0
    $REV = $INPUT->int('rev');
}
if ($INPUT->str('mediado') == 'restore' && $conf['mediarevisions']) {
    $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH);
}
// handle deletion
if ($DEL) {
    $res = 0;
    if (checkSecurityToken()) {
        $res = media_delete($DEL, $AUTH);
    }
    if ($res & DOKU_MEDIA_DELETED) {
        $msg = sprintf($lang['deletesucc'], noNS($DEL));
        if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) {
            // current namespace was removed. redirecting to root ns passing msg along
            send_redirect(DOKU_URL . 'lib/exe/mediamanager.php?msg1=' . rawurlencode($msg) . '&edid=' . $INPUT->str('edid'));
        }
        msg($msg, 1);
    } elseif ($res & DOKU_MEDIA_INUSE) {
        if (!$conf['refshow']) {
            msg(sprintf($lang['mediainuse'], noNS($DEL)), 0);
        }
    } else {
        msg(sprintf($lang['deletefail'], noNS($DEL)), -1);
    }
}
// finished - start output
if (!$fullscreen) {
    header('Content-Type: text/html; charset=utf-8');
    include template('mediamanager.php');
}
Ejemplo n.º 27
0
<?php

session_start();
require "../config/system.php";
require "../libs/utils.php";
if (session_var("usrId") == "") {
    send_redirect("../index.php");
}
?>
<!DOCTYPE html>
<html lang="es">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title><?php 
echo CLIENT_NAME;
?>
</title>
        <link href="../css/main.css" type="text/css" rel="stylesheet" />
        <link href="../css/bootstrap.min.css" type="text/css" rel="stylesheet" />
	<link href="../css/font-awesome-4.4.0/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="../js/bootstrap.min.js"></script> 
		
        
        <link rel="stylesheet" href="../css/jquery_ui/<?php 
echo UI_THEME;
?>
/jquery-ui.css" />
	<link rel="stylesheet" href="../css/jquery.dataTables.min.css" />
        <script src="../js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
        <script src="../js/jquery.dataTables.min.js"></script>
Ejemplo n.º 28
0
 /**
  * Checks the session to see if the user is already logged in
  *
  * If not logged in, redirects to SAML provider
  */
 public function trustExternal($user, $pass, $sticky = false)
 {
     global $USERINFO;
     global $ID;
     global $ACT;
     global $conf;
     // trust session info, no need to recheck
     if (isset($_SESSION[DOKU_COOKIE]['auth']) && $_SESSION[DOKU_COOKIE]['auth']['buid'] == auth_browseruid() && isset($_SESSION[DOKU_COOKIE]['auth']['user'])) {
         $_SERVER['REMOTE_USER'] = $_SESSION[DOKU_COOKIE]['auth']['user'];
         $USERINFO = $_SESSION[DOKU_COOKIE]['auth']['info'];
         return true;
     }
     if (!isset($_POST['SAMLResponse']) && ($ACT == 'login' || get_doku_pref('adfs_autologin', 0))) {
         // Initiate SAML auth request
         $authrequest = new SamlAuthRequest($this->settings);
         $url = $authrequest->create();
         $_SESSION['adfs_redirect'] = wl($ID, '', true, '&');
         // remember current page
         send_redirect($url);
     } elseif (isset($_POST['SAMLResponse'])) {
         // consume SAML response
         $samlresponse = new SamlResponse($this->settings, $_POST['SAMLResponse']);
         try {
             if ($samlresponse->is_valid()) {
                 $_SERVER['REMOTE_USER'] = $samlresponse->get_attribute('login');
                 $USERINFO['user'] = $_SERVER['REMOTE_USER'];
                 $USERINFO['name'] = $samlresponse->get_attribute('fullname');
                 $USERINFO['mail'] = $samlresponse->get_attribute('email');
                 $USERINFO['grps'] = (array) $samlresponse->get_attribute('groups');
                 $USERINFO['grps'][] = $conf['defaultgroup'];
                 $USERINFO['grps'] = array_map(array($this, 'cleanGroup'), $USERINFO['grps']);
                 $_SESSION[DOKU_COOKIE]['auth']['user'] = $_SERVER['REMOTE_USER'];
                 $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
                 $_SESSION[DOKU_COOKIE]['auth']['buid'] = auth_browseruid();
                 # cache login
                 // cache user data
                 $changes = array('name' => $USERINFO['name'], 'mail' => $USERINFO['mail'], 'grps' => $USERINFO['grps']);
                 if ($this->triggerUserMod('modify', array($user, $changes)) === false) {
                     $this->triggerUserMod('create', array($user, "nil", $USERINFO['name'], $USERINFO['mail'], $USERINFO['grps']));
                 }
                 // successful login
                 if (isset($_SESSION['adfs_redirect'])) {
                     $go = $_SESSION['adfs_redirect'];
                     unset($_SESSION['adfs_redirect']);
                 } else {
                     $go = wl($ID, '', true, '&');
                 }
                 set_doku_pref('adfs_autologin', 1);
                 send_redirect($go);
                 // decouple the history from POST
                 return true;
             } else {
                 $this->logOff();
                 msg('The SAML response signature was invalid.', -1);
                 return false;
             }
         } catch (Exception $e) {
             $this->logOff();
             msg('Invalid SAML response: ' . hsc($e->getMessage()), -1);
             return false;
         }
     }
     // no login happened
     return false;
 }
Ejemplo n.º 29
0
 /**
  * Redirects browser to given comment anchor
  */
 function _redirect($cid)
 {
     global $ID;
     global $ACT;
     if ($ACT !== 'show') {
         return;
     }
     if ($this->getConf('moderate') && !auth_ismanager()) {
         msg($this->getLang('moderation'), 1);
         @session_start();
         global $MSG;
         $_SESSION[DOKU_COOKIE]['msg'] = $MSG;
         session_write_close();
         $url = wl($ID);
     } else {
         $url = wl($ID) . '#comment_' . $cid;
     }
     if (function_exists('send_redirect')) {
         send_redirect($url);
     } else {
         header('Location: ' . $url);
     }
     exit;
 }
Ejemplo n.º 30
0
 /**
  * @param                              $sticky
  * @param OAuth\Plugin\AbstractAdapter $service
  * @param string                       $servicename
  * @param string                       $page
  *
  * @return bool
  */
 protected function processLogin($sticky, $service, $servicename, $page)
 {
     $uinfo = $service->getUser();
     $ok = $this->processUser($uinfo, $servicename);
     if (!$ok) {
         return false;
     }
     $this->setUserSession($uinfo, $servicename);
     $this->setUserCookie($uinfo['user'], $sticky, $servicename);
     if (isset($page)) {
         send_redirect(wl($page));
     }
     return true;
 }