Example #1
0
 public function testGetPathInfo()
 {
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['SERVER_SOFTWARE'] = '';
     $_SERVER['PATH_INFO'] = '';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['PATH_INFO'] = '/foo/bar';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['SERVER_SOFTWARE'] = 'lighttpd/1.4.26';
     $_SERVER['PATH_INFO'] = '';
     $_SERVER['REQUEST_URI'] = '/horde/path.php';
     $_SERVER['SCRIPT_NAME'] = '/horde/path.php';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/path.php?baz';
     $_SERVER['QUERY_STRING'] = 'baz';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/path.php/foo/bar';
     $_SERVER['SCRIPT_NAME'] = '/horde/path.php';
     $_SERVER['QUERY_STRING'] = '';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/path.php/foo/bar?baz';
     $_SERVER['QUERY_STRING'] = 'baz';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/foo/bar?baz';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/';
     $_SERVER['SCRIPT_NAME'] = '/horde/index.php';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/index.php';
     $_SERVER['SCRIPT_NAME'] = '/horde/index.php';
     $_SERVER['QUERY_STRING'] = '';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/index.php?baz';
     $_SERVER['QUERY_STRING'] = 'baz';
     $this->assertEquals('', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/index.php/foo/bar';
     $_SERVER['SCRIPT_NAME'] = '/horde/index.php';
     $_SERVER['QUERY_STRING'] = '';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/horde/index.php/foo/bar?baz';
     $_SERVER['QUERY_STRING'] = 'baz';
     $this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
     $_SERVER['REQUEST_URI'] = '/test/42?id=42';
     $_SERVER['SCRIPT_NAME'] = '/test/index.php';
     $_SERVER['QUERY_STRING'] = 'id=42&id=42';
     $this->assertEquals('/42', Horde_Util::getPathInfo());
 }
Example #2
0
 *   - OPTIONS: Additional URL options
 *     - jsonhtml: (boolean) On error, return in text/html format instead of
 *                 application/json
 *
 * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL-2). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   Michael Slusarz <*****@*****.**>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL-2
 * @package  Horde
 */
require_once __DIR__ . '/../lib/Application.php';
list($app, $action) = explode('/', trim(Horde_Util::getPathInfo(), '/'));
if (empty($action)) {
    // This is the only case where we really don't return anything, since
    // the frontend can be presumed not to make this request on purpose.
    // Other missing data cases we return a response of boolean false.
    exit;
}
try {
    Horde_Registry::appInit($app, array('authentication' => 'fallback'));
} catch (Exception $e) {
    // Uncaught exception.  Sending backtrace info back via AJAX is just a
    // waste of time.
    exit;
}
// Open an output buffer to ensure that we catch errors that might break JSON
// encoding.
Example #3
0
            break;
        case 'format':
            // Format is specially mangled
            $lastpart = 'channel_format';
            break;
        case 'author':
        case 'channel_format':
        case 'tag':
        case 'tag_id':
        case 'story':
        case 'story_id':
        case 'channel':
        case 'channel_id':
            $lastpart = $part;
            break;
        default:
            if (!empty($lastpart)) {
                $criteria[$lastpart] = $part;
                $lastpart = null;
            } else {
                // An unknown directive
                Horde::log("Malformed request URL: " . Horde_Util::getPathInfo(), 'WARN');
                exit;
            }
            break;
    }
}
if (empty($deliveryType)) {
    $deliveryType = 'html';
}
include __DIR__ . '/' . basename($deliveryType) . '.php';
Example #4
0
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Kronolith
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'session_control' => 'none'));
// Determine the username to show free/busy time for.
$cal = Horde_Util::getFormData('c');
$user = Horde_Util::getFormData('u');
if (!empty($cal)) {
    if (is_array($cal)) {
        $cal = implode('|', $cal);
    }
} elseif ($pathInfo = Horde_Util::getPathInfo()) {
    $user = basename($pathInfo);
}
$cache = $injector->getInstance('Horde_Cache');
$key = 'kronolith.fb.' . ($user ? 'u.' . $user : '******' . $cal);
$fb = $cache->get($key, 360);
if (!$fb) {
    if ($user) {
        $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $user));
        $registry->setTimeZone();
        $cal = @unserialize($prefs->getValue('fb_cals'));
        if (is_array($cal)) {
            $cal = implode('|', $cal);
        }
        // If the free/busy calendars preference is empty, default to
        // the user's default_share preference, and if that's empty,
Example #5
0
 /**
  * Returns a session-id-ified version of $SCRIPT_NAME resp. $PHP_SELF.
  *
  * @param boolean $script_params Include script parameters like
  *                               QUERY_STRING and PATH_INFO?
  *                               (Deprecated: use Horde::selfUrlParams()
  *                               instead.)
  * @param boolean $nocache       Include a cache-buster parameter in the
  *                               URL?
  * @param boolean $full          Return a full URL?
  * @param boolean $force_ssl     Ignore $conf['use_ssl'] and force creation
  *                               of a SSL URL?
  *
  * @return Horde_Url  The requested URL.
  */
 public static function selfUrl($script_params = false, $nocache = true, $full = false, $force_ssl = false)
 {
     if (!strncmp(PHP_SAPI, 'cgi', 3)) {
         // When using CGI PHP, SCRIPT_NAME may contain the path to
         // the PHP binary instead of the script being run; use
         // PHP_SELF instead.
         $url = $_SERVER['PHP_SELF'];
     } else {
         $url = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['PHP_SELF'];
     }
     if (isset($_SERVER['REQUEST_URI'])) {
         $url = Horde_String::common($_SERVER['REQUEST_URI'], $url);
     }
     if (substr($url, -9) == 'index.php') {
         $url = substr($url, 0, -9);
     }
     if ($script_params) {
         if ($pathInfo = Horde_Util::getPathInfo()) {
             if (substr($url, -1) == '/') {
                 $pathInfo = substr($pathInfo, 1);
             }
             $url .= $pathInfo;
         }
         if (!empty($_SERVER['QUERY_STRING'])) {
             $url .= '?' . $_SERVER['QUERY_STRING'];
         }
     }
     $url = self::url($url, $full, array('force_ssl' => $force_ssl));
     return $nocache && $GLOBALS['browser']->hasQuirk('cache_same_url') ? $url->unique() : $url;
 }
Example #6
0
} catch (Horde_Exception $e) {
    $auth = $injector->getInstance('Horde_Core_Factory_Auth')->create('imp');
    if (!$auth->authenticate($_SERVER['PHP_AUTH_USER'], array('password' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null))) {
        header('WWW-Authenticate: Basic realm="IMP RSS Interface"');
        header('HTTP/1.0 401 Unauthorized');
        echo '401 Unauthorized';
        exit;
    }
}
$items = array();
$mailbox = IMP_Mailbox::get('INBOX');
$new_mail = $request = $searchid = false;
$unseen_num = 0;
/* Determine the mailbox that was requested and if only new mail should be
 * displayed. Default to new mail in INBOX. */
$request = Horde_Util::getPathInfo();
if (!empty($request)) {
    $request_parts = explode('/-/', $request);
    if (!empty($request_parts[0])) {
        $ns_info = $mailbox->imp_imap->getNamespace(IMP_Imap::NS_DEFAULT);
        $mailbox = IMP_Mailbox::get(preg_replace('/\\//', $ns_info->delimiter, trim($request_parts[0], '/')))->namespace_append;
        /* Make sure mailbox exists or else exit immediately. */
        if (!$mailbox->exists) {
            exit;
        }
    }
    $new_mail = isset($request_parts[1]) && $request_parts[1] === 'new';
}
$imp_mailbox = $mailbox->list_ob;
/* Obtain some information describing the mailbox state. */
$total_num = count($imp_mailbox);