incorrect campsite path in Apache 2.2
  • I have installed Campsite 3.4.3 on a web server running PHP 5.3.3 and Apache 2.2.
    Apache 2.2 uses PCRE regular expressions, unlike Apache 1.3 that uses POSIX for its regular expressions. I suspect this might be the reason the rewrite rules don't work for me.
    My .htaccess file looks like this:
    # There might be no access to apache config, set options here
    DirectoryIndex index.php index.html
    Options -Indexes FollowSymLinks -MultiViews
    
    # Options might not allowed here, use Rewrite rules instead
    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        RewriteCond %{REQUEST_URI} /+get_img$
        RewriteRule . get_img.php [L]
    
        RewriteCond %{REQUEST_URI} /+attachment/+
        RewriteRule . attachment.php [L]
    
        RewriteCond %{REQUEST_URI} !\.php$
        RewriteCond %{REQUEST_URI} !\.html$
        RewriteCond %{REQUEST_URI} !\.css$
        RewriteCond %{REQUEST_URI} !\.js$
        RewriteCond %{REQUEST_URI} !/+admin
        RewriteCond %{REQUEST_URI} !/+install
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+javascript
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+css
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+images
        RewriteCond %{REQUEST_URI} !/+templates
        RewriteRule . index.php [L]
    
        RewriteCond %{REQUEST_URI} .tpl$
        RewriteRule . index.php [L]
    
        RewriteCond %{REQUEST_URI} /+admin$|/+admin/+.*|/+admin-files
        RewriteRule . admin.php [L]
    </IfModule>
    
    # Uncomment it for gui backup/restore process
    # NOTE: It can be incompatible on some shared hosting
    #php_value output_buffering Off
    

    When visiting http://chinaworker.info/admin/login.php I can't access the page and these lines appear in the error log:

    [Tue Dec 07 08:33:17 2010] [error] [client 194.9.94.253] File does not exist: chinaworker.info/public_html/www
    [Tue Dec 07 08:34:10 2010] [error] [client 194.9.94.253] File does not exist: chinaworker.info/public_html/www
    [Tue Dec 07 08:34:10 2010] [error] [client 194.9.94.253] File does not exist: chinaworker.info/public_html/www

    What should I do?
  • 19 Comments sorted by
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    hi Sebastian,

    apache 2.2 works well with default .htaccess. Demo site is running on 2.2: http://campsite-demo.sourcefabric.org/

    But in your case this is a rewrite issue of the shared hosting. I see the wrong way for index files: /www/webvol7/pu/lunvlk5jq4g7wj4/chinaworker.info/public_html /index.php instead of /index.php (the same for admin.php)
    The direct script calls are working well:
    http://chinaworker.info/get_img.php?NrImage=5&NrArticle= 1261
    http://chinaworker.info/index.php

    Check hoster's FAQ/Knowledge base for rewrite rules. In some cases hoster has own specific rewrite rules.
  • Andrey Podshivalov wrote on Tue, 07 December 2010 17:30
    The direct script calls are working well:
    http://chinaworker.info/get_img.php?NrImage=5&NrArticle= 1261
    http://chinaworker.info/index.php

    Yes, but notice the difference between http://chinaworker.info/index.php and http://chinaworker.info.
    When you specifically request index.php, the links at the top, to http://chinaworker.info/en/content/page/6/ http://chinaworker.info/en/content/?tpid=2&tpl=9 and several others, disappear. This is probably because "index.php" becomes the language code for those links, like "en" or "zh", and there is no such language code in Campsite.
    Andrey Podshivalov wrote on Tue, 07 December 2010 17:30
    Check hoster's FAQ/Knowledge base for rewrite rules. In some cases hoster has own specific rewrite rules.

    I added the line RewriteBase / so now my .htaccess is like this:
    # There might be no access to apache config, set options here
    DirectoryIndex index.php index.html
    Options -Indexes FollowSymLinks -MultiViews
    
    # Options might not allowed here, use Rewrite rules instead
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_URI} /+get_img$
        RewriteRule . get_img.php [L]
    
        RewriteCond %{REQUEST_URI} /+attachment/+
        RewriteRule . attachment.php [L]
    
        RewriteCond %{REQUEST_URI} !\.php$
        RewriteCond %{REQUEST_URI} !\.html$
        RewriteCond %{REQUEST_URI} !\.css$
        RewriteCond %{REQUEST_URI} !\.js$
        RewriteCond %{REQUEST_URI} !/+admin
        RewriteCond %{REQUEST_URI} !/+install
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+javascript
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+css
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+images
        RewriteCond %{REQUEST_URI} !/+templates
        RewriteRule . index.php [L]
    
        RewriteCond %{REQUEST_URI} .tpl$
        RewriteRule . index.php [L]
    
        RewriteCond %{REQUEST_URI} /+admin$|/+admin/+.*|/+admin-files
        RewriteRule . admin.php [L]
    </IfModule>
    
    # Uncomment it for gui backup/restore process
    # NOTE: It can be incompatible on some shared hosting
    #php_value output_buffering Off
    
    which solves part of the problem. The article pages are now working! This is a great improvement, but now if I try to access http://chinaworker.info/admin/login.php I get redirected to http://login.php/ which obviously doesn't work.
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    RewriteBase is wrong way. Any subfolder script won't be working.
    Try to add the slashes before index and admin scripts in .htaccess:
    RewriteRule . /index.php [L]
    and
    RewriteRule . /admin.php [L]

  • It makes no difference. I still get http://login.php when I try to go to the admin pages.
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    you forgot to remove RewriteBase

    On Tue, Dec 7, 2010 at 8:38 PM, Sebastian Olsson <
    campsite-support@lists.sourcefabric.org> wrote:

    > It makes no difference. I still get http://login.php when I try to go
    > to the admin pages.
    >

  • No, I removed RewriteBase. This is my .htaccess file:
    # There might be no access to apache config, set options here
    DirectoryIndex index.php index.html
    Options -Indexes FollowSymLinks -MultiViews
    
    # Options might not allowed here, use Rewrite rules instead
    <IfModule mod_rewrite.c>
        RewriteEngine On
        
        RewriteCond %{REQUEST_URI} /+get_img$
        RewriteRule . get_img.php [L]
    
        RewriteCond %{REQUEST_URI} /+attachment/+
        RewriteRule . attachment.php [L]
    
        RewriteCond %{REQUEST_URI} !\.php$
        RewriteCond %{REQUEST_URI} !\.html$
        RewriteCond %{REQUEST_URI} !\.css$
        RewriteCond %{REQUEST_URI} !\.js$
        RewriteCond %{REQUEST_URI} !/+admin
        RewriteCond %{REQUEST_URI} !/+install
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+javascript
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+css
        RewriteCond %{REQUEST_URI} !(/+plugins/[^/]*)?/+images
        RewriteCond %{REQUEST_URI} !/+templates
        RewriteRule . /index.php [L]
    
        RewriteCond %{REQUEST_URI} .tpl$
        RewriteRule . /index.php [L]
    
        RewriteCond %{REQUEST_URI} /+admin$|/+admin/+.*|/+admin-files
        RewriteRule . /admin.php [L]
    </IfModule>
    
    # Uncomment it for gui backup/restore process
    # NOTE: It can be incompatible on some shared hosting
    #php_value output_buffering Off
    
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    ok, then try /chinaworker.info/admin.php and /chinaworker.info/index.php
  • Andrey Podshivalov wrote on Tue, 07 December 2010 20:21
    ok, then try /chinaworker.info/admin.php and /chinaworker.info/index.php

    That breaks everything. Now the article pages are gone again. Everything points to the wrong address.

    The requested URL /chinaworker.info/admin.php was not found on this server.

    The requested URL /chinaworker.info/index.php was not found on this server.


    BTW, why are we changing the index.php line? We had fixed that. It was working. The only thing I still have problems with is the path to admin.php.
    I'm changing it back.
  • Maybe there is something wrong with admin.php. This is the code:
    <?php
    /**
     * This file gets called before any file in the "admin-files" directory is executed.
     * Think of it as a wrapper for all admin interface scripts.
     * Here you can set up anything that should be applied globally to all scripts.
     */
    
    $GLOBALS['g_campsiteDir'] = dirname(__FILE__);
    
    require_once($GLOBALS['g_campsiteDir'].DIRECTORY_SEPARATOR.'include'
    .DIRECTORY_SEPARATOR.'campsite_constants.php');
    require_once(CS_PATH_CONFIG.DIR_SEP.'install_conf.php');
    
    // goes to install process if configuration files does not exist yet
    if (!file_exists(CS_PATH_CONFIG.DIR_SEP.'configuration.php')
    || !file_exists(CS_PATH_CONFIG.DIR_SEP.'database_conf.php')) {
        header('Location: '.$Campsite['SUBDIR'].'/install/');
        exit(0);
    }
    
    require_once(CS_PATH_SITE.DIR_SEP.'include'.DIR_SEP.'campsite_init.php');
    require_once(CS_PATH_CONFIG.DIR_SEP.'liveuser_configuration.php');
    
    if (file_exists(CS_PATH_SITE.DIR_SEP.'upgrade.php')) {
        camp_display_message("Site is down for upgrade. Please initiate upgrade process.");
        echo '<META HTTP-EQUIV="Refresh" content="10">';
        exit(0);
    }
    
    // detect extended login/logout files
    $prefix = file_exists(CS_PATH_SITE.DIR_SEP.'admin-files'.DIR_SEP.'ext_login.php') ? '/ext_' : '/';
    
    global $ADMIN_DIR;
    global $ADMIN;
    global $g_user;
    require_once(CS_PATH_SITE.DIR_SEP.$ADMIN_DIR.DIR_SEP.'camp_html.php');
    require_once(CS_PATH_CLASSES.DIR_SEP.'SecurityToken.php');
    
    set_include_path(get_include_path() . PATH_SEPARATOR . CS_PATH_PEAR_LOCAL);
    
    camp_set_error_handler("camp_report_bug");
    
    camp_load_translation_strings("api");
    $plugins = CampPlugin::GetEnabled(true);
    foreach ($plugins as $plugin) {
        camp_load_translation_strings("plugin_".$plugin->getName());
    }
    
    $no_menu_scripts = array(
        $prefix . 'login.php',
        $prefix . 'do_login.php',
        $prefix . 'logout.php',
        '/issues/preview.php',
        '/issues/empty.php',
        '/ad_popup.php',
        '/articles/preview.php',
        '/articles/autopublish.php',
        '/articles/autopublish_do_add.php',
        '/articles/images/popup.php',
        '/articles/images/view.php',
        '/articles/topics/popup.php',
        '/articles/files/popup.php',
        '/articles/audioclips/campcaster_login.php',
        '/articles/audioclips/popup.php',
        '/articles/audioclips/edit.php',
        '/articles/empty.php',
        '/articles/yui-assets/post.php',
        '/comments/ban.php',
        '/comments/do_ban.php',
        '/imagearchive/do_add.php',
        '/smartlist/assets/php/dynamicfilter/data.php',
        '/smartlist/assets/load_filterby_menu.php',
        '/smartlist/assets/dt_actions.php'
        );
    
    CampPlugin::ExtendNoMenuScripts($no_menu_scripts);
    
    $request_uri = $_SERVER['REQUEST_URI'];
    $call_script = substr($request_uri, strlen("/$ADMIN"));
    
    // Remove any GET parameters
    if (($question_mark = strpos($call_script, '?')) !== false) {
        $call_script = substr($call_script, 0, $question_mark);
    }
    
    // Remove all attempts to get at other parts of the file system
    $call_script = str_replace('/../', '/', $call_script);
    if ($call_script == '/logout.php') $call_script = $prefix . 'logout.php';
    
    $extension = '';
    if (($extension_start = strrpos($call_script, '.')) !== false) {
        $extension = strtolower(substr($call_script, $extension_start));
    }
    
    if (($extension == '.php') || ($extension == '')) {
        header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Content-Type: text/html; charset=UTF-8");
    
        // If they arent trying to login in...
        if (($call_script != $prefix . 'login.php') && ($call_script != $prefix . 'do_login.php')) {
            // Check if the user is logged in already
            list($access, $g_user) = camp_check_admin_access(CampRequest::GetInput());
            if (!$access) {
                if ($call_script == '/articles/audioclips/popup.php') {
                    print("<script>\n");
                    print("window.opener.document.forms.article_edit.submit();");
                    print("window.close();");
                    print("</script>");
                }
                // If not logged in, show the login screen.
                header('Location: /' . $ADMIN . $prefix . 'login.php');
                exit(0);
            }
        }
    
        // Load common translation strings
        camp_load_translation_strings('globals');
    
        // If its not a PHP file, assume its a directory.
        if ($extension != '.php') {
            // If its a directory
            if (($call_script != '') && ($call_script[strlen($call_script)-1] != '/') ) {
                $call_script .= '/';
            }
            $call_script .= 'index.php';
        }
        $needs_menu = ! (in_array($call_script, $no_menu_scripts) || Input::Get('p_no_menu', 'boolean', false, true));
    
        // Verify the file exists
        $path_name = $Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script";
    
        if (!file_exists($path_name)) {
    
            foreach (CampPlugin::GetEnabled() as $CampPlugin) {
               $plugin_path_name = $Campsite['HTML_DIR'].'/'.$CampPlugin->getBasePath()."/$ADMIN_DIR/$call_script";
               if (file_exists($plugin_path_name)) {
                   $path_name = $plugin_path_name;
                   break;
               }
            }
            if (!file_exists($path_name)) {
                header("HTTP/1.1 404 Not found");
                exit;
            }
        }
    
        // Clean up the global namespace before we call the script
        unset($access);
        unset($extension);
        unset($extension_start);
        unset($question_mark);
        unset($no_menu_scripts);
        unset($request_uri);
    
        if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
            CampCache::singleton()->clear('user');
            unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
        }
        require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/init_content.php");
    
        // Get the main content
        ob_start();
        require_once($path_name);
        $content = ob_get_clean();
    
        // We create the top menu AFTER the main content because
        // of the localizer screen.  It will update the strings, which
        // need to be reflected immediately in the menu.
        $_top_menu = '';
        if ($needs_menu) {
            ob_start();
            echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    //        echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"rtl\" lang=\"ar\" xml:lang=\"ar\">\n";
            echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en\" xml:lang=\"en\">\n";
            require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/menu.php");
            $_top_menu = ob_get_clean();
        }
    
        $content =  $_top_menu . $content;
    
        //if ($needs_menu) {
            //$content .= "</td></tr>\n</table>\n";
        //}
        //$content .= "</html>\n";
        echo $content;
    
        camp_html_clear_msgs(true);
    } elseif (file_exists($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script")) {
        readfile($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script");
    } else {
        header("HTTP/1.1 404 Not found");
        exit;
    }
    
    // run internal cron scheduler
    if (SystemPref::Get('ExternalCronManagement') == 'N') {
        flush();
        camp_cron();
    }
    
    /**
     * Sets a user-defined error function.
     *
     *  The function set_error_handler() works differently in PHP 4 & 5.
     *  This function is a wrapper interface, to both versions of
     *  set_error_handler.
     *
     * @param $p_function The function to execute on error
     * @return void
     */
    function camp_set_error_handler($p_function)
    {
        // --- In PHP 5, the error handler-default is set at E_STRICT,
        //     which captures all legacy based errors.  Unfortunately, this is
        //     completely incompatible with PHP 4. ---
        if ( version_compare( phpversion(), "5.0.0", ">=" ) ) {
            set_error_handler($p_function, E_ALL);
    
        } else {
            // -- Meanwhile, the error-handler flag argument is not
            //    available in PHP 4, which always assumes it's value to be
            //    E_ALL --
            set_error_handler($p_function);
        }
    } // fn camp_set_error_handler
    
    
    /**
     * Called for all Campsite errors.
     */
    function camp_report_bug($p_number, $p_string, $p_file, $p_line)
    {
        global $ADMIN_DIR, $Campsite;
        require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/bugreporter/bug_handler_main.php");
        camp_bug_handler_main($p_number, $p_string, $p_file, $p_line);
    } // fn camp_report_bug
    
    ?>
    As you can see, it redirects to
    header('Location: /' . $ADMIN . $prefix . 'login.php');
    but why doesn't it work? It should go to http://chinaworker.info/admin-files/login.php and not http://login.php

    Does anybody understand this? Please help me.
    This is what the server returns when I go to http://chinaworker.info/admin/
    HTTP/1.1 302 Found
    Date: Thu, 09 Dec 2010 11:13:40 GMT
    Server: Apache/2.2.17 (FreeBSD) PHP/5.3.3 with Suhosin-Patch mod_ssl/2.2.17 OpenSSL/0.9.8n
    X-Powered-By: PHP/5.3.3
    Set-Cookie: PHPSESSID=f7c691bb23b5815e7af2a1b84beac2c4; path=/
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Last-Modified: Thu, 09 Dec 2010 11:13:41 GMT
    Cache-Control: no-store, no-cache, must-revalidate
    Location: //login.php
    Content-Length: 0
    Connection: close
    Content-Type: text/html; charset=UTF-8
    It looks like $ADMIN and $prefix are unset. What can I do about it? We need to publish all the new articles.
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    It works well with standard apache settings.
    It seems that apache returns wrong environment variables.
    Place the test.php file with <?php phpinfo(); ?> content.


    On Thu, Dec 9, 2010 at 12:56 PM, Sebastian Olsson <
    campsite-support@lists.sourcefabric.org> wrote:

    > Maybe there is something wrong with admin.php. This is the code:
    >
    > <?php
    > /**
    > * This file gets called before any file in the "admin-files" directory is executed.
    > * Think of it as a wrapper for all admin interface scripts.
    > * Here you can set up anything that should be applied globally to all scripts.
    > */
    >
    > $GLOBALS['g_campsiteDir'] = dirname(__FILE__);
    >
    > require_once($GLOBALS['g_campsiteDir'].DIRECTORY_SEPARATOR.' include'
    > .DIRECTORY_SEPARATOR.'campsite_constants.php');
    > require_once(CS_PATH_CONFIG.DIR_SEP.'install_conf.php');
    >
    > // goes to install process if configuration files does not exist yet
    > if (!file_exists(CS_PATH_CONFIG.DIR_SEP.'configuration.php')
    > || !file_exists(CS_PATH_CONFIG.DIR_SEP.'database_conf.php')) {
    > header('Location: '.$Campsite['SUBDIR'].'/install/');
    > exit(0);
    > }
    >
    > require_once(CS_PATH_SITE.DIR_SEP.'include'.DIR_SEP.'campsit e_init.php');
    > require_once(CS_PATH_CONFIG.DIR_SEP.'liveuser_configuration. php');
    >
    > if (file_exists(CS_PATH_SITE.DIR_SEP.'upgrade.php')) {
    > camp_display_message("Site is down for upgrade. Please initiate upgrade process.");
    > echo '<META HTTP-EQUIV="Refresh" content="10">';
    > exit(0);
    > }
    >
    > // detect extended login/logout files
    > $prefix = file_exists(CS_PATH_SITE.DIR_SEP.'admin-files'.DIR_SEP.'ext_ login.php') ? '/ext_' : '/';
    >
    > global $ADMIN_DIR;
    > global $ADMIN;
    > global $g_user;
    > require_once(CS_PATH_SITE.DIR_SEP.$ADMIN_DIR.DIR_SEP.'camp_h tml.php');
    > require_once(CS_PATH_CLASSES.DIR_SEP.'SecurityToken.php');
    >
    > set_include_path(get_include_path() . PATH_SEPARATOR . CS_PATH_PEAR_LOCAL);
    >
    > camp_set_error_handler("camp_report_bug");
    >
    > camp_load_translation_strings("api");
    > $plugins = CampPlugin::GetEnabled(true);
    > foreach ($plugins as $plugin) {
    > camp_load_translation_strings("plugin_".$plugin->getName());
    > }
    >
    > $no_menu_scripts = array(
    > $prefix . 'login.php',
    > $prefix . 'do_login.php',
    > $prefix . 'logout.php',
    > '/issues/preview.php',
    > '/issues/empty.php',
    > '/ad_popup.php',
    > '/articles/preview.php',
    > '/articles/autopublish.php',
    > '/articles/autopublish_do_add.php',
    > '/articles/images/popup.php',
    > '/articles/images/view.php',
    > '/articles/topics/popup.php',
    > '/articles/files/popup.php',
    > '/articles/audioclips/campcaster_login.php',
    > '/articles/audioclips/popup.php',
    > '/articles/audioclips/edit.php',
    > '/articles/empty.php',
    > '/articles/yui-assets/post.php',
    > '/comments/ban.php',
    > '/comments/do_ban.php',
    > '/imagearchive/do_add.php',
    > '/smartlist/assets/php/dynamicfilter/data.php',
    > '/smartlist/assets/load_filterby_menu.php',
    > '/smartlist/assets/dt_actions.php'
    > );
    >
    > CampPlugin::ExtendNoMenuScripts($no_menu_scripts);
    >
    > $request_uri = $_SERVER['REQUEST_URI'];
    > $call_script = substr($request_uri, strlen("/$ADMIN"));
    >
    > // Remove any GET parameters
    > if (($question_mark = strpos($call_script, '?')) !== false) {
    > $call_script = substr($call_script, 0, $question_mark);
    > }
    >
    > // Remove all attempts to get at other parts of the file system
    > $call_script = str_replace('/../', '/', $call_script);
    > if ($call_script == '/logout.php') $call_script = $prefix . 'logout.php';
    >
    > $extension = '';
    > if (($extension_start = strrpos($call_script, '.')) !== false) {
    > $extension = strtolower(substr($call_script, $extension_start));
    > }
    >
    > if (($extension == '.php') || ($extension == '')) {
    > header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
    > header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    > header("Cache-Control: no-store, no-cache, must-revalidate");
    > header("Content-Type: text/html; charset=UTF-8");
    >
    > // If they arent trying to login in...
    > if (($call_script != $prefix . 'login.php') && ($call_script != $prefix . 'do_login.php')) {
    > // Check if the user is logged in already
    > list($access, $g_user) = camp_check_admin_access(CampRequest::GetInput());
    > if (!$access) {
    > if ($call_script == '/articles/audioclips/popup.php') {
    > print("<script>\n");
    > print("window.opener.document.forms.article_edit.submit();");
    > print("window.close();");
    > print("</script>");
    > }
    > // If not logged in, show the login screen.
    > header('Location: /' . $ADMIN . $prefix . 'login.php');
    > exit(0);
    > }
    > }
    >
    > // Load common translation strings
    > camp_load_translation_strings('globals');
    >
    > // If its not a PHP file, assume its a directory.
    > if ($extension != '.php') {
    > // If its a directory
    > if (($call_script != '') && ($call_script[strlen($call_script)-1] != '/') ) {
    > $call_script .= '/';
    > }
    > $call_script .= 'index.php';
    > }
    > $needs_menu = ! (in_array($call_script, $no_menu_scripts) || Input::Get('p_no_menu', 'boolean', false, true));
    >
    > // Verify the file exists
    > $path_name = $Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script";
    >
    > if (!file_exists($path_name)) {
    >
    > foreach (CampPlugin::GetEnabled() as $CampPlugin) {
    > $plugin_path_name = $Campsite['HTML_DIR'].'/'.$CampPlugin->getBasePath()."/$ADMIN_DIR/$call_script ";
    > if (file_exists($plugin_path_name)) {
    > $path_name = $plugin_path_name;
    > break;
    > }
    > }
    > if (!file_exists($path_name)) {
    > header("HTTP/1.1 404 Not found");
    > exit;
    > }
    > }
    >
    > // Clean up the global namespace before we call the script
    > unset($access);
    > unset($extension);
    > unset($extension_start);
    > unset($question_mark);
    > unset($no_menu_scripts);
    > unset($request_uri);
    >
    > if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) {
    > CampCache::singleton()->clear('user');
    > unlink($GLOBALS['g_campsiteDir'] . '/reset_cache');
    > }
    > require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/init_content.php");
    >
    > // Get the main content
    > ob_start();
    > require_once($path_name);
    > $content = ob_get_clean();
    >
    > // We create the top menu AFTER the main content because
    > // of the localizer screen. It will update the strings, which
    > // need to be reflected immediately in the menu.
    > $_top_menu = '';
    > if ($needs_menu) {
    > ob_start();
    > echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\ <http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%5C>">\n";
    > // echo "<html xmlns=\"http://www.w3.org/1999/xhtml\ <http://www.w3.org/1999/xhtml%5C>" dir=\"rtl\" lang=\"ar\" xml:lang=\"ar\">\n";
    > echo "<html xmlns=\"http://www.w3.org/1999/xhtml\ <http://www.w3.org/1999/xhtml%5C>" dir=\"ltr\" lang=\"en\" xml:lang=\"en\">\n";
    > require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/menu.php");
    > $_top_menu = ob_get_clean();
    > }
    >
    > $content = $_top_menu . $content;
    >
    > //if ($needs_menu) {
    > //$content .= "</td></tr>\n</table>\n";
    > //}
    > //$content .= "</html>\n";
    > echo $content;
    >
    > camp_html_clear_msgs(true);
    > } elseif (file_exists($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script")) {
    > readfile($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script");
    > } else {
    > header("HTTP/1.1 404 Not found");
    > exit;
    > }
    >
    > // run internal cron scheduler
    > if (SystemPref::Get('ExternalCronManagement') == 'N') {
    > flush();
    > camp_cron();
    > }
    >
    > /**
    > * Sets a user-defined error function.
    > *
    > * The function set_error_handler() works differently in PHP 4 & 5.
    > * This function is a wrapper interface, to both versions of
    > * set_error_handler.
    > *
    > * @param $p_function The function to execute on error
    > * @return void
    > */
    > function camp_set_error_handler($p_function)
    > {
    > // --- In PHP 5, the error handler-default is set at E_STRICT,
    > // which captures all legacy based errors. Unfortunately, this is
    > // completely incompatible with PHP 4. ---
    > if ( version_compare( phpversion(), "5.0.0", ">=" ) ) {
    > set_error_handler($p_function, E_ALL);
    >
    > } else {
    > // -- Meanwhile, the error-handler flag argument is not
    > // available in PHP 4, which always assumes it's value to be
    > // E_ALL --
    > set_error_handler($p_function);
    > }
    > } // fn camp_set_error_handler
    >
    >
    > /**
    > * Called for all Campsite errors.
    > */
    > function camp_report_bug($p_number, $p_string, $p_file, $p_line)
    > {
    > global $ADMIN_DIR, $Campsite;
    > require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/bugreporter/bug_handler_main.php");
    > camp_bug_handler_main($p_number, $p_string, $p_file, $p_line);
    > } // fn camp_report_bug
    >
    > ?>
    >
    > As you can see, it redirects to
    > header('Location: /' . $ADMIN . $prefix . 'login.php');
    > but why doesn't it work? It should go to
    > http://chinaworker.info/admin-files/login.php and not http://login.php
    >
    > Does anybody understand this? Please help me.
    >

  • OK, I have a http://chinaworker.info/test.php file. Can you see what variable is causing this?
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    it's ok, but server returns wrong Location //login.php instead of
    /admin/login.php
    Add string
    echo $ADMIN; exit;
    before
    header('Location: /' . $ADMIN . $prefix . 'login.php'); in admin.php script.

    It should print: admin


    On Thu, Dec 9, 2010 at 1:30 PM, Sebastian Olsson <
    campsite-support@lists.sourcefabric.org> wrote:

    > OK, I have a http://chinaworker.info/test.php file. Can you see what
    > variable is causing this?
    >

  • It prints nothing.
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    ok, then remove it and add the same string in conf/campsite_install.php
    after string #39 ($ADMIN = ....)

    On Thu, Dec 9, 2010 at 2:53 PM, Sebastian Olsson <
    campsite-support@lists.sourcefabric.org> wrote:

    > It prints nothing.
    >

  • There is no such file. The directory conf/ has these files:


    • configuration.php
    • database_conf.php
    • install_conf.php
    • liveuser_configuration.php


  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    sorry, install_conf.php

    On Thu, Dec 9, 2010 at 3:19 PM, Sebastian Olsson <
    campsite-support@lists.sourcefabric.org> wrote:

    > There is no such file. The directory conf/ has these files:
    >
    >
    >
    > - configuration.php
    > - database_conf.php
    > - install_conf.php
    > - liveuser_configuration.php
    >
    >
    >
    >
    >

  • I can't find that line.
    <?php
    /**
     * @package Campsite
     *
     * @author Holman Romero <holman.romero@gmail.com>
     * @author Mugur Rus <mugur.rus@gmail.com>
     * @copyright 2008 MDLF, Inc.
     * @license http://www.gnu.org/licenses/gpl.txt
     * @version $Revision$
     * @link http://www.campware.org
     */
    
    $Campsite['APACHE_USER'] = 'www-data';
    $Campsite['APACHE_GROUP'] = 'www-data';
    $Campsite['CAMPSITE_DIR'] = (strlen($_SERVER['DOCUMENT_ROOT']) > 0)
         ? $_SERVER['DOCUMENT_ROOT'] : dirname(dirname(__FILE__));
    $Campsite['ETC_DIR'] = $Campsite['CAMPSITE_DIR'].'/conf';
    $Campsite['BIN_DIR'] = $Campsite['CAMPSITE_DIR'].'/bin';
    $Campsite['WWW_DIR'] = $Campsite['CAMPSITE_DIR'];
    
    $Campsite['HTML_DIR'] = $Campsite['CAMPSITE_DIR'];
    
    if (!isset($_SERVER['SERVER_PORT']))
    {
            $_SERVER['SERVER_PORT'] = 80;
    }
    $scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
    $Campsite['HOSTNAME'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : "";
    if (($_SERVER['SERVER_PORT'] != 80) && ($_SERVER['SERVER_PORT'] != 443)) {
        $Campsite['HOSTNAME'] .= ':'.$_SERVER['SERVER_PORT'];
    }
    $Campsite['WEBSITE_URL'] = $scheme.$Campsite['HOSTNAME'];
    unset($scheme);
    
    
    $Campsite['TEMPLATE_DIRECTORY'] = $Campsite['HTML_DIR']."/templates";
    $Campsite['TEMPLATE_BASE_URL'] = $Campsite['WEBSITE_URL']."/templates/";
    $Campsite['IMAGE_DIRECTORY'] = $Campsite['HTML_DIR'].'/images/';
    $Campsite['IMAGE_BASE_URL'] = $Campsite['WEBSITE_URL'].'/images/';
    $Campsite['ADMIN_IMAGE_BASE_URL'] = $Campsite['WEBSITE_URL'].'/css';
    $Campsite['IMAGE_PREFIX'] = 'cms-image-';
    $Campsite['IMAGEMAGICK_INSTALLED'] = true;
    $Campsite['THUMBNAIL_MAX_SIZE'] = 64;
    $Campsite['THUMBNAIL_COMMAND'] = 'convert -sample '
                    .$Campsite['THUMBNAIL_MAX_SIZE'].'x'.$Campsite['THUMBNAIL_MAX_SIZE'];
    $Campsite['THUMBNAIL_DIRECTORY'] = $Campsite['IMAGE_DIRECTORY'].'/thumbnails/';
    $Campsite['THUMBNAIL_BASE_URL'] = $Campsite['WEBSITE_URL'].'/images/thumbnails/';
    $Campsite['THUMBNAIL_PREFIX'] = 'cms-thumb-';
    $Campsite['FILE_BASE_URL'] = $Campsite['WEBSITE_URL'].'/files/';
    $Campsite['FILE_DIRECTORY'] = $Campsite['HTML_DIR'].'/files';
    $Campsite['FILE_NUM_DIRS_LEVEL_1'] = "1000";
    $Campsite['FILE_NUM_DIRS_LEVEL_2'] = "1000";
    $Campsite['TMP_DIRECTORY'] = '/tmp/';
    $Campsite['HELP_URL'] = 'http://code.campware.org/manuals/campsite/3.2/';
    $Campsite['ABOUT_URL'] = 'http://www.campware.org/en/camp/campsite_news/';
    $Campsite['SUPPORT_EMAIL'] = 'campsite-support@lists.campware.org';
    $Campsite['DEBUG'] = true;
    
    require_once($Campsite['CAMPSITE_DIR'].'/template_engine/classes/CampVersion.php');
    $version = new CampVersion();
    $Campsite['VERSION'] = $version->getVersion();
    ?>
  • Vote Up0Vote Down Andrey PodshivalovAndrey Podshivalov
    Posts: 1,526Member, Administrator, Sourcefabric Team
    That file is from old version (3.2). Please update it. You should use the
    latest 3.4.3

  • Yes, it works now. Thank you.
    I must have replaced the configuration files with the previous version by mistake when I was restoring the backup copy.