Web Analytics Made Easy -
StatCounter PHP - Configuration file? - CodingForum

Announcement

Collapse
No announcement yet.

PHP - Configuration file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP - Configuration file?

    So, I have this code (not mine) that I'm trying to use on my site:

    PHP Code:
    <?php
    /*
    iStrip web comic publishing system - index (Main page view script)
    Copyright © 2002, 2003 Gordon McVey

    This file is part of iStrip.

    iStrip is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    */
    define ("VER_ISTRIP_INDEX",'1.6.3');

    include (
    'include/istrip_ver.php');

    if (
    VER_ISTRIP != VER_ISTRIP_INDEX)
        die (
    'index.php: Version incompatibility');

    include (
    'include/istrip_constants.php');
    include (
    'include/istrip_lang.php');
    include (
    'include/istrip_lib.php');
    include (
    'include/lib_utils.php');
    include (
    'include/smarty/Smarty.class.php');

    if (!@include (
    CFG_DIR_FILES.CFG_FILE_CONFIG))
        die (
    L_ISTRIP_ERR_CFG.L_BR);

    function 
    generatepage ()
    {
        if (!
    defined ('CFG_DISABLE'))
        {
            
    define ("COLCOPY",true);
            
    // Set up template directory/fiel vars
            
    $templatedir    CFG_DIR_TPL.CFG_THEME.'/';
            
    $templatefile    'index';
            
    $showcopyright    true;
            
    $hidefuture        true;
            
    // Set the content agreement cookie
            
    if (isset ($_POST ['content_agree']))
                if (isset (
    $_POST ['content_remember']))
                    
    setcookie ('istrip_content_agree',$_POST ['content_agree'],0x7FFFFFFF,getscriptdir ());
                else
                    
    setcookie ('istrip_content_agree',$_POST ['content_agree'],0,getscriptdir ());
            
    // Handle the entry page
            
    if ((!defined ('CFG_CONTENTWARN')) || (isset ($_COOKIE ['istrip_content_agree'])) || (isset ($_POST ['content_agree'])))
            {
                
    // If a valid template has been specified in HTTP_GET_VARS other than index than use it, otherwise use index
                
    if ((isset ($_GET ['view'])) && (($_GET ['view']) != 'index') && (($_GET ['view']) != 'enter') && (!stristr ($_GET ['view'],'/')))
                {
                    
    // Handle the viewfile template special case
                    
    switch ($_GET ['view'])
                    {
                        case (
    'rss')        :
                            
    header ('Content-type: application/rss+xml');
                            
    header ('Content-Disposition: inline; filename="rss.xml"');
                            
    $showcopyright    false;
                        break;
                        case (
    'vf_strip')    :
                        case (
    'vf_news')    :
                            if (isset (
    $_COOKIE ['istrip_user']))
                            {
                                
    // Set options for strip and news previewing
                                
    $templatedir    'admin/'.CFG_DIR_TPL_ADMIN;
                                
    $showcopyright    false;
                                
    $hidefuture        false;
                            }
                        break;
                        default:
                        break;
                    }
                    
    // Check that a valid tpl file has been specified, if not then use index.tpl for fallback
                    
    if ((file_exists ($templatedir.$_GET ['view'].CFG_EXT_TPL)) && (is_file ($templatedir.$_GET ['view'].CFG_EXT_TPL)) && (is_readable ($templatedir.$_GET ['view'].CFG_EXT_TPL)))
                        
    $templatefile $_GET ['view'];
                    else
                    {
                        
    $templatedir    CFG_DIR_TPL.CFG_THEME.'/';
                        
    $templatefile    'index';
                    }
                }
            }
            else
                
    $templatefile 'enter';
            
    // Load index file
            
    $stripindex loadindexfile (CFG_DIR_FILES.CFG_FILE_INDEX,$hidefuture);
            
    // Validate the strip ID
            
    $stripid     validatestripid ($_GET['strip_id'],sizeof ($stripindex));
            
    // Set up Smarty
            
    $page setupsmarty ($templatedir,CFG_DIR_FILES.CFG_DIR_COMPILE,$showcopyright);
            
    // Generate template vars
            
    $page -> assign ('archive',archiveinfo ($stripindex));
            
    $page -> assign ('nav',navlogic ($stripindex,$stripid));
            
    $page -> assign ('server',getserverinfo ());
            
    $page -> assign ('banner',setbannerfile (CFG_DIR_BANNER));
            
    $page -> assign ('view',$templatefile);
            
    $page -> assign ('status',getupdatestatus ());
            if (
    $stripindex)
                
    $page -> assign (generatecomicvars ($stripindex,$stripid,'','',CFG_NEWS_SEARCH));
            
    // Display page
            
    $page -> display ($templatefile.CFG_EXT_TPL);
        }
        else
            echo (
    CFG_DISABLE_MSG.L_BR);
    }

    if (
    defined ('DEBUG_TIMER'))
    {
        
    $stopwatch ['gen_time'] = number_format (stopwatch ('generatepage ();'),CFG_RND_TIMER);
        echo (
    varsubstring (L_DEBUG_TIMER,$stopwatch));
    }
    else
        
    generatepage ();
    ?>
    The problem I'm having is, the way the file locations are set up don't work. When I FTP something into the site's hosting and then try to copy the url for the file location, I get something along the lines of "ftp://[email protected]/public_html/index.php" which won't work if I put it into the address bar. The url that does work is just "site.com/index.php" So what's happening is the code is searching for the file "index.php" in the wrong place. So, I redid the code to this (iStrip being the folder where the files are):

    PHP Code:
    <?php
    /*
    iStrip web comic publishing system - index (Main page view script)
    Copyright © 2002, 2003 Gordon McVey

    This file is part of iStrip.

    iStrip is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    */
    define ("VER_ISTRIP_INDEX",'1.6.3');

    include (
    'iStrip/include/istrip_ver.php');

    if (
    VER_ISTRIP != VER_ISTRIP_INDEX)
        die (
    'iStrip/index.php: Version incompatibility');

    include (
    'iStrip/include/istrip_constants.php');
    include (
    'iStrip/include/istrip_lang.php');
    include (
    'iStrip/include/istrip_lib.php');
    include (
    'iStrip/include/lib_utils.php');
    include (
    'iStrip/include/smarty/Smarty.class.php');

    if (!@include (
    CFG_DIR_FILES.CFG_FILE_CONFIG))
        die (
    L_ISTRIP_ERR_CFG.L_BR);

    function 
    generatepage ()
    {
        if (!
    defined ('CFG_DISABLE'))
        {
            
    define ("COLCOPY",true);
            
    // Set up template directory/fiel vars
            
    $templatedir    CFG_DIR_TPL.CFG_THEME.'/';
            
    $templatefile    'iStrip/index';
            
    $showcopyright    true;
            
    $hidefuture        true;
            
    // Set the content agreement cookie
            
    if (isset ($_POST ['iStrip/content_agree']))
                if (isset (
    $_POST ['iStrip/content_remember']))
                    
    setcookie ('iStrip/istrip_content_agree',$_POST ['iStrip/content_agree'],0x7FFFFFFF,getscriptdir ());
                else
                    
    setcookie ('iStrip/istrip_content_agree',$_POST ['iStrip/content_agree'],0,getscriptdir ());
            
    // Handle the entry page
            
    if ((!defined ('CFG_CONTENTWARN')) || (isset ($_COOKIE ['iStrip/istrip_content_agree'])) || (isset ($_POST ['iStrip/content_agree'])))
            {
                
    // If a valid template has been specified in HTTP_GET_VARS other than index than use it, otherwise use index
                
    if ((isset ($_GET ['iStrip/view'])) && (($_GET ['iStrip/view']) != 'iStrip/index') && (($_GET ['iStrip/view']) != 'iStrip/enter') && (!stristr ($_GET ['iStrip/view'],'/')))
                {
                    
    // Handle the viewfile template special case
                    
    switch ($_GET ['iStrip/view'])
                    {
                        case (
    'iStrip/rss')        :
                            
    header ('Content-type: application/rss+xml');
                            
    header ('Content-Disposition: inline; filename="iStrip/rss.xml"');
                            
    $showcopyright    false;
                        break;
                        case (
    'iStrip/vf_strip')    :
                        case (
    'iStrip/vf_news')    :
                            if (isset (
    $_COOKIE ['iStrip/istrip_user']))
                            {
                                
    // Set options for strip and news previewing
                                
    $templatedir    'iStrip/admin/'.CFG_DIR_TPL_ADMIN;
                                
    $showcopyright    false;
                                
    $hidefuture        false;
                            }
                        break;
                        default:
                        break;
                    }
                    
    // Check that a valid tpl file has been specified, if not then use index.tpl for fallback
                    
    if ((file_exists ($templatedir.$_GET ['iStrip/view'].CFG_EXT_TPL)) && (is_file ($templatedir.$_GET ['iStrip/view'].CFG_EXT_TPL)) && (is_readable ($templatedir.$_GET ['iStrip/view'].CFG_EXT_TPL)))
                        
    $templatefile $_GET ['iStrip/view'];
                    else
                    {
                        
    $templatedir    CFG_DIR_TPL.CFG_THEME.'/';
                        
    $templatefile    'iStrip/index';
                    }
                }
            }
            else
                
    $templatefile 'iStrip/enter';
            
    // Load index file
            
    $stripindex loadindexfile (CFG_DIR_FILES.CFG_FILE_INDEX,$hidefuture);
            
    // Validate the strip ID
            
    $stripid     validatestripid ($_GET['iStrip/strip_id'],sizeof ($stripindex));
            
    // Set up Smarty
            
    $page setupsmarty ($templatedir,CFG_DIR_FILES.CFG_DIR_COMPILE,$showcopyright);
            
    // Generate template vars
            
    $page -> assign ('iStrip/archive',archiveinfo ($stripindex));
            
    $page -> assign ('iStrip/nav',navlogic ($stripindex,$stripid));
            
    $page -> assign ('iStrip/server',getserverinfo ());
            
    $page -> assign ('iStrip/banner',setbannerfile (CFG_DIR_BANNER));
            
    $page -> assign ('iStrip/view',$templatefile);
            
    $page -> assign ('status',getupdatestatus ());
            if (
    $stripindex)
                
    $page -> assign (generatecomicvars ($stripindex,$stripid,'','',CFG_NEWS_SEARCH));
            
    // Display page
            
    $page -> display ($templatefile.CFG_EXT_TPL);
        }
        else
            echo (
    CFG_DISABLE_MSG.L_BR);
    }

    if (
    defined ('DEBUG_TIMER'))
    {
        
    $stopwatch ['iStrip/gen_time'] = number_format (stopwatch ('iStrip/generatepage ();'),CFG_RND_TIMER);
        echo (
    varsubstring (L_DEBUG_TIMER,$stopwatch));
    }
    else
        
    generatepage ();
    ?>
    Which fixes most of the problems. However, this gets me an error of "no configuration file found" I guess my question is then: What do I need to change so it can find the configuration file?

  • #2
    um, ftp://[email protected]/public_html/index.php = http://site.com/index.php. So I'm not sure I really see an issue with the original code. You shouldn't be playing with filepaths of prebuilt software unless you know exactly what to modify and why.

    Looks to me that if you have an issue with this from site.com/index.php, than the problem is likely one of these two constants: CFG_DIR_FILES or CFG_FILE_CONFIG.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      I thought so too, but when I tried it without changing anything, it came up with an error on every line referencing a file. :/ When I changed it, I only got a "configuration file not found error" (it does exist, I made sure of it)

      So what exactly should I do about the constants, then?

      Comment


      • #4
        Are you running this directly, or are you using it as a plugin to smarty? I don't and never will use smarty, so I can't help you if its supposed to be plugged in. The problem is simple, but the solution is not as simple.
        I'd assume that no modification should be required, and that it would integrate with the smarty api appropriately. Its quite possible that the issue you have is simply an installation issue of the above software potentially in the wrong location. I wouldn't expect any type of plugin to be placed directly under the document root.
        You may get better support by contacting the developers of the plugin directly.
        PHP Code:
        header('HTTP/1.1 420 Enhance Your Calm'); 
        Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎