Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Hi all,

Just been implementing Couch on a work site. It's now throwing this error when I try to access couch via localhost/"site-name"/couch. I just get this:

check_access( K_ACCESS_LEVEL_ADMIN ); // at this point we have a logged in user with appropriate priveleges if( ($_GET['o'] == 'users') ){ include_once( K_COUCH_DIR.'edit-users.php' ); } elseif( ($_GET['o'] == 'comments') ){ include_once( K_COUCH_DIR.'edit-comments.php' ); } elseif( ($_GET['o'] == 'folders') ){ include_once( K_COUCH_DIR.'edit-folders.php' ); } elseif( ($_GET['o'] == 'drafts') ){ include_once( K_COUCH_DIR.'edit-drafts.php' ); } else{ include_once( K_COUCH_DIR.'edit-pages.php' ); } //////////////////////////////////////////////////////////////////////////// function k_get_time(){ list ($msec, $sec) = explode(' ', microtime()); $microtime = (float)$msec + (float)$sec; return $microtime; } function k_timer_start(){ global $k_time_start; $k_time_start = k_get_time(); return true; } function k_timer_stop( $echo = 0 ){ global $k_time_start, $k_time_end; $k_time_end = k_get_time(); $diff = number_format( $k_time_end - $k_time_start, 3 ) . ' sec'; if ( $echo ){ echo $diff; } return $diff; }

Any ideas, much appreciated.

Thanks.
Hi,

From the look of it, it seems your web server is not configured to execute PHP (i.e. files with .php extensions) and is simply returning the script as plain text.

You'll have to configure your local stack to work with PHP files to make things work (Google would be your friend to help with the particular LAMP/WAMP stack you might be using).

Hope the reply helps.
Hi, thanks for this. What's odd is that I've not changed any of the XAMPP config, and I can load the php web pages for the site no problem, it's just the Couch pages that do this. I've created new sql databases, and reinstalled a clean version of Couch in the site's directory, but I'm still getting the same issue. I've cleared my cache and cookies, and I'm running PHP 5.6.15 and it all seems fine.

Thanks again.
Hi Frost. The output you get comes from the beginning of the couch/index.php file, but it's not from the very beginning. It's as if there were some sort of error in the file that kicks everything out of PHP at that point.

Please check your couch/index.php file. It should look like this. Maybe you'll see an error. In any event, try replacing that file with a new copy.

Code: Select all
<?php
    /*
    The contents of this file are subject to the Common Public Attribution License
    Version 1.0 (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at
    http://www.couchcms.com/cpal.html. The License is based on the Mozilla
    Public License Version 1.1 but Sections 14 and 15 have been added to cover use
    of software over a computer network and provide for limited attribution for the
    Original Developer. In addition, Exhibit A has been modified to be consistent with
    Exhibit B.

    Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
    WARRANTY OF ANY KIND, either express or implied. See the License for the
    specific language governing rights and limitations under the License.

    The Original Code is the CouchCMS project.

    The Original Developer is the Initial Developer.

    The Initial Developer of the Original Code is Kamran Kashif (kksidd@couchcms.com).
    All portions of the code written by Initial Developer are Copyright (c) 2009, 2010
    the Initial Developer. All Rights Reserved.

    Contributor(s):

    Alternatively, the contents of this file may be used under the terms of the
    CouchCMS Commercial License (the CCCL), in which case the provisions of
    the CCCL are applicable instead of those above.

    If you wish to allow use of your version of this file only under the terms of the
    CCCL and not to allow others to use your version of this file under the CPAL, indicate
    your decision by deleting the provisions above and replace them with the notice
    and other provisions required by the CCCL. If you do not delete the provisions
    above, a recipient may use your version of this file under either the CPAL or the
    CCCL.
    */

    ob_start();
    k_timer_start();
    define( 'K_ADMIN', 1 );

    if ( !defined('K_COUCH_DIR') ) define( 'K_COUCH_DIR', str_replace( '\\', '/', dirname(realpath(__FILE__) ).'/') );
    require_once( K_COUCH_DIR.'header.php' );
    header( 'Content-Type: text/html; charset='.K_CHARSET );

    $AUTH->check_access( K_ACCESS_LEVEL_ADMIN );

    // at this point we have a logged in user with appropriate priveleges

    if( ($_GET['o'] == 'users') ){
        include_once( K_COUCH_DIR.'edit-users.php' );
    }
    elseif( ($_GET['o'] == 'comments') ){
        include_once( K_COUCH_DIR.'edit-comments.php' );
    }
    elseif( ($_GET['o'] == 'folders') ){
        include_once( K_COUCH_DIR.'edit-folders.php' );
    }
    elseif( ($_GET['o'] == 'drafts') ){
        include_once( K_COUCH_DIR.'edit-drafts.php' );
    }
    else{
        include_once( K_COUCH_DIR.'edit-pages.php' );
    }

    ////////////////////////////////////////////////////////////////////////////
    function k_get_time(){
        list ($msec, $sec) = explode(' ', microtime());
        $microtime = (float)$msec + (float)$sec;
        return $microtime;
    }

    function k_timer_start(){
        global $k_time_start;
        $k_time_start = k_get_time();
        return true;
    }

    function k_timer_stop( $echo = 0 ){
        global $k_time_start, $k_time_end;
        $k_time_end = k_get_time();
        $diff = number_format( $k_time_end - $k_time_start, 3 ) . ' sec';
        if ( $echo ){ echo $diff; }
        return $diff;
    }
I second what @tim suggested. I'd suspect something being wrong with 'couch/config.php' file, though, as that normally would be the only core PHP file that needs modification before using Couch.

Please examine the config file to see if there is any syntax error that is causing PHP to go belly up. You can post or PM us the file if you'd like us to take a look at it for you.
Thanks all, I really appreciate it. What's really odd is that the issue persists even after a fresh reinstall of couch (as if I was starting from scratch).

Here's a copy of the config.php file:

Code: Select all
<?php

    if ( !defined('K_COUCH_DIR') ) die(); // cannot be loaded directly

    // 0.
    // Set the following to 1 to put your site in maintenance mode.
    // In this mode only admins will be able to access the site while the visitors will be
    // shown the 'Site undergoing maintenance' message.
    define( 'K_SITE_OFFLINE', 0 );

    // 1.
    // If necessary, define the full URL of your site including the subdomain, if any.
    // V.IMP: Don't forget the trailing slash!
    //define( 'K_SITE_URL', 'http://www.test.com/subfolder1/subfolder2/mysite/' );

    // 1b.
    // For security purpose, the 'index.php' file of Couch can be renamed to anything else.
    // If you do so, uncomment the following line and enter the new name.
    define( 'K_ADMIN_PAGE', 'admin.php' );

    // 2.
    // Your Time Zone
    // Example values (note how :15, :30, :45 will be entered as .25, .5 and .75 respectively):
    // +12.75 New Zealand (UTC+12:45)
    // +8.75  Australia (UTC+08:45)
    // +5.5   India (UTC+05:30)
    // +1     Germany (UTC+01:00)
    // 0      United Kingdom (UTC±0)
    // -2     Brazil (UTC-02:00)
    // -4.5   Venezuela (UTC-04:30)
    // -6     United States (Central Time) (UTC-06:00)
    // -8     United States (Pacific Time) (UTC-08:00)
    define( 'K_GMT_OFFSET', 0 );

    // 3.
    // Define the charset used by your site. If in any doubt, leave the default utf-8.
    define( 'K_CHARSET', 'utf-8' );

    // MySQL settings. You need to get this info from your web host.
    // 4.
    // Name of the database
    define( 'K_DB_NAME', 'couch_sql' );
    // 5.
    // Database username
    define( 'K_DB_USER', 'root' );
    // 6.
    // Database password
    define( 'K_DB_PASSWORD', '' );
    // 7.
    // MySQL hostname (it will usually be 'localhost')
    define( 'K_DB_HOST', 'localhost' );
    // 7b.
    // Needed only if multiple instances of this CMS are to be installed in the same database
    // (please use only alphanumeric characters or underscore (NO hyphen))
    define( 'K_DB_TABLES_PREFIX', '' );

    // 8.
    // Set the following to '1' if you wish to enable Pretty URLS.
    // After enabling it, use gen_htaccess.php to generate an .htaccess file and place it in the root folder of your site.
    define( 'K_PRETTY_URLS', 0 );

    // 9.
    // If set, CMS will cache generated pages and serve them if possible.
    define( 'K_USE_CACHE', 0 );

    // 10.
    // When the cache is invalidated (by adding, deleting or modifying pages in admin),
    // existing files in cache become useless but are not deleted immediately.
    // A purge routine gets executed at interval set here (in hours)
    // during which this deletion of stale files occurs.
    define( 'K_CACHE_PURGE_INTERVAL', 24 );

    // 11.
    // Even if the cache does not become invalidated, as noted above, files in cache
    // are removed after this interval (set in hours).
    define( 'K_MAX_CACHE_AGE', 7 * 24 ); // Default is 7 days

    // 12.
    // Upload folder if not using the default upload folder within 'couch'.
    // Should be relative to your site (don't forget to set write permissions on it).
    // No leading or trailing slashes please.
    //define( 'K_UPLOAD_DIR', 'myuploads' );

    // 12b.
    // Folder containing the embedded snippets if not using the default 'snippets' folder within 'couch'.
    // Should be relative to your site. No leading or trailing slashes please.
    //define( 'K_SNIPPETS_DIR', 'mysnippets' );

    // 13.
    // Your Email address. Will be used in contact forms.
    define( 'K_EMAIL_TO', 'youremail@gmail.com' );

    // 14.
    // Will be used as the sender of messages delivered by contact forms to the address above.
    define( 'K_EMAIL_FROM', 'contact@yourdomain.com' );

    // 15.
    // By default the inbuilt php function 'mail()' is used to deliver messages.
    // On certain hosts this function might fail due to configuration problems.
    // In such cases, set the following to '1' to use an alternative method to send emails
    define( 'K_USE_ALTERNATIVE_MTA', 0 );

    // 16.
    // Google Maps API Key.
    // You'll have to get one for your site from 'http://code.google.com/apis/maps/'
    // if your site makes use of Google maps.
    define( 'K_GOOGLE_KEY', 'ABQIAAAAD7z_FToS5NSqosnG9No1ABQYPrehWcZJH1ec0SZqipYFbK_nfRT1ryCGKzl5KGpFG3y5jyPe_uClVg' );

    // Set the following if you use PayPal buttons to sell products.
    // 17.
    // Set this to zero once you are ready to go live
    define( 'K_PAYPAL_USE_SANDBOX', 1 );
    // 18.
    // Email address of your PayPal 'business' account selling the item
    define( 'K_PAYPAL_EMAIL', 'seller_1272492192_biz@gmail.com' );
    // 19.
    // A three letter code for the currency you do your business in.
    // Some valid values are: AUD (Australian Dollar), CAD (Canadian Dollar), EUR (Euro),
    // GBP (Pound Sterling), JPY (Japanese Yen) and USD (U.S. Dollar).
    // Please check PayPal to find yours.
    define( 'K_PAYPAL_CURRENCY', 'USD' );

    // 20.
    // A setting of '1' will necessitate the admin to approve comments before they get published.
    // '0' will publish comments immediately.
    // A setting of '1' is strongly recommended in order to avoid spam.
    define( 'K_COMMENTS_REQUIRE_APPROVAL', 1 );

    // 21.
    // Minimum time interval required between two comments posted by the same user (in seconds).
    // Prevents comment flooding. A setting of 5 minutes (300 seconds) is recommended.
    define( 'K_COMMENTS_INTERVAL', 5 * 60 );

    // 22.
    // Language used for localization of admin panel. Needs to have a corresponding language file in couch folder.
    // Change to 'DE' for German or 'FR' for French.
    define( 'K_ADMIN_LANG', 'EN' );

    // 23.
    // Uncomment the following line if you wish to format self-closing HTML tags the old way e.g. as <br> instead of <br/>
    //define( 'K_HTML4_SELFCLOSING_TAGS', 1 );

    // 24.
    // Set the following to '1' if you wish to extract EXIF data from images uploaded to Gallery
    define( 'K_EXTRACT_EXIF_DATA', 0 );

    // 25.
    // Set the following to '1' if you wish to use KCFinder as the default file-browser (will require PHP5 and modern browsers)
    define( 'K_USE_KC_FINDER', 1 );

    // 99.
    // VERY IMPORTANT!
    // Set the following to '1' ONLY IF YOU HAVE BOUGHT A COMMERCIAL LICENSE for the site you are using this file on.
    // Doing so otherwise is NOT PERMITTED and will constitute a violation of the CPAL license this software is provided under.
    define( 'K_PAID_LICENSE', 0 );

        // Rebranding. Uncomment the following defines and add your info.
        // 99a. Company Logo on light background  (Max. 171 x 64 pixels. Needs to be placed within 'couch/theme/images/' folder)
        //define( 'K_LOGO_LIGHT', 'couch.gif' );

        // 99b. Company Logo on dark background  (Max. 171 x 64 pixels. Needs to be placed within 'couch/theme/images/' folder)
        //define( 'K_LOGO_DARK', 'couch_dark.gif' );

        // 99c. Footer content (Company name and link)
        //define( 'K_ADMIN_FOOTER', '<a href="http://www.yourcompany.com">COMPANY NAME</a>' );



Is there anything odd there that needs fixing do you think?

Thanks again.
Weirdly, just heading to random couch directory pages at the moment: going to _index.php throws this-

Code: Select all
delete_cookie(); } // authenticate if you can :) $AUTH = new KAuth( K_ACCESS_LEVEL_ADMIN ); 


I've tried deleting cookies, but it doesn't change. Looking at the source file shows that it should be capable of managing it's own cookies.

EDIT: Clarity
@Frost, I checked and there seems to be nothing wrong with the config file.

Well, this is definitely some odd server configuration issue. However, since your installation is local there is nothing much we'd be able to do to help, I'm afraid.

Local stacks are known to be quirky. If possible, I'd suggest you try a different stack or, better still, move your test site online. It's a given that you won't encounter this issue on a hosted server. For any other problem, we'd at least be able to access the installation to see first-hand the issue and try and do something more meaningful about it.

Thanks.
Thanks KK, it's great to have your support. I had the feeling it might be something like that the more I dug into it. I'll chuck the files up on our webhost and see how that goes. Really appreciate your help with all of this. I'll report back and let you know if that fixed it.

All the best.
Yeah, sticking it up online seems to have done it, it was a wonky local stack that did it in the end.

Thanks for all the help folks.
11 posts Page 1 of 2