示例#1
0
 /**
  * Create the redirection of an alias
  *
  * @return boolean true on success, false on failure
  * @access public
  * @static
  */
 function redirect()
 {
     //get aliases for current folder
     $dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME'])));
     $aliases = CMS_module_cms_aliases::getByName($dirname);
     if (!$aliases) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']));
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //check each aliases returned to get the one which respond to current alias
     $matchAlias = false;
     $domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
     $websites = array();
     if ($domain) {
         $websites = CMS_websitesCatalog::getWebsitesFromDomain($domain);
     }
     foreach ($aliases as $alias) {
         if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) {
             if ($websites) {
                 foreach ($websites as $website) {
                     //alias match path, check for website
                     if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) {
                         //alias match website, use it
                         $matchAlias = $alias;
                     }
                 }
             } else {
                 //alias match path, check for website
                 if (!$alias->getWebsites()) {
                     //alias match website, use it
                     $matchAlias = $alias;
                 }
             }
         }
     }
     if (!$matchAlias) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain);
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //if alias is used as a page url, return page
     if ($matchAlias->urlReplaced()) {
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             $page = CMS_tree::getPageById($matchAlias->getPageID());
         } else {
             //no valid page set, go to 404
             $matchAlias->raiseError('No page set for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         if (!$page || $page->hasError()) {
             //no valid page found, go to 404
             $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         //return page path
         $pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
         if ($pPath) {
             if (file_exists($pPath)) {
                 return $pPath;
             } elseif ($page->regenerate(true)) {
                 clearstatcache();
                 if (file_exists($pPath)) {
                     return $pPath;
                 }
             }
         }
         //no valid url page found, go to 404
         $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     } else {
         //this is a redirection
         $params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
         if (isset($_SERVER['HTTP_REFERER'])) {
             header("Referer: " . $_SERVER['HTTP_REFERER']);
         }
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             //it's a redirection to an Automne Page
             $page = CMS_tree::getPageById($matchAlias->getPageID());
             if ($page && !$page->hasError()) {
                 $pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url');
                 if ($pageURL) {
                     CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302);
                 } else {
                     //no valid url page found, go to 404
                     $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                     CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
                 }
             } else {
                 //no valid page found, go to 404
                 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                 CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
             }
         } elseif ($matchAlias->getURL()) {
             //it's a redirection to an URL
             CMS_view::redirect($matchAlias->getURL(), true, $matchAlias->isPermanent() ? 301 : 302);
         } else {
             //no valid redirection found, go to 404
             $matchAlias->raiseError('Invalid redirection for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
     }
 }
示例#2
0
		}
		/*close login window*/
		Ext.WindowMgr.get(\'loginWindow\').close();';
            //eval content into parent
            $jscontent = '
		try {delete parent.Ext.Element.cache[\'loginField\'];} catch (e) {}
		parent.eval(\'' . sensitiveIO::sanitizeJSString($jscontent, true) . '\');';
            $view->addJavascript($jscontent);
            $view->show(CMS_view::SHOW_HTML);
        } else {
            //Disconnect user
            CMS_session::authenticate(array('disconnect' => true, 'type' => 'admin'));
            //Reset session (start fresh)
            Zend_Session::destroy();
            //Redirect
            CMS_view::redirect($_SERVER['SCRIPT_NAME'] . '?cms_action=wrongcredentials', true, 301);
        }
        break;
    case 'wrongcredentials':
        //display error login window on top of login form
        $loginError = "\n\t\tparent.Automne.message.popup({\n\t\t\tmsg: '{$cms_language->getJsMessage(MESSAGE_ERROR_LOGIN_INCORRECT)}',\n\t\t\tbuttons: Ext.MessageBox.OK,\n\t\t\ticon: Ext.MessageBox.ERROR,\n\t\t\tfn:function() {\n\t\t\t\tExt.fly('loginField').dom.select();\n\t\t\t}\n\t\t});";
        break;
}
//Send Login form frame window (in which login form is displayed)
//set main and ext CSS
$view->addCSSFile('ext');
$view->addCSSFile('main');
$view->addCSSFile('codemirror');
if (SYSTEM_DEBUG) {
    $view->addCSSFile('debug');
}
示例#3
0
        if (file_exists($pageURL)) {
            $redirectTo = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false);
        } else {
            //try to regenerate page
            if ($page->regenerate(true)) {
                clearstatcache();
                if (file_exists($pageURL)) {
                    $redirectTo = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false);
                }
            }
        }
    }
}
//do redirection to page if found
if ($redirectTo) {
    CMS_view::redirect($redirectTo . (isset($_SERVER['REDIRECT_QUERY_STRING']) ? '?' . $_SERVER['REDIRECT_QUERY_STRING'] : ''), true, 301);
}
//then if no page found, display 404 error page
header('HTTP/1.x 404 Not Found', true, 404);
//Check if requested file is an image
$imagesExtensions = array('jpg', 'jpeg', 'gif', 'png', 'ico');
if (isset($pathinfo['extension']) && in_array(strtolower($pathinfo['extension']), $imagesExtensions)) {
    if (file_exists(PATH_REALROOT_FS . '/img/404.png')) {
        CMS_file::downloadFile(PATH_REALROOT_FS . '/img/404.png');
    }
}
//send an email if needed
if (ERROR404_EMAIL_ALERT && sensitiveIO::isValidEmail(APPLICATION_MAINTAINER_EMAIL)) {
    $body = "A 404 Error occured on your website.\n";
    $body .= "\n\n";
    $body .= 'The requested file : ' . CMS_websitesCatalog::getMainURL() . $_SERVER['REQUEST_URI'] . ' was not found.' . "\n\n";
示例#4
0
}
$rootPage = $website->getRoot();
if ($rootPage->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
    //redirect to subpage if any
    $redirectlink = $rootPage->getRedirectLink(true);
    while ($redirectlink && $redirectlink->hasValidHREF() && sensitiveIO::IsPositiveInteger($redirectlink->getInternalLink())) {
        $rootPage = new CMS_page($redirectlink->getInternalLink());
        if ($rootPage->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
            $redirectlink = $rootPage->getRedirectLink(true);
        } else {
            $redirectlink = '';
        }
    }
}
$pPath = $rootPage->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
if ($pPath) {
    if (file_exists($pPath)) {
        $cms_page_included = true;
        require $pPath;
        exit;
    } elseif ($rootPage->regenerate(true)) {
        clearstatcache();
        if (file_exists($pPath)) {
            $cms_page_included = true;
            require $pPath;
            exit;
        }
    }
}
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);