Hallo,

I am trying to understand this code which doesn't make sense to me.

company.php

<?php
require('wds.php');
include(INC_DIR . 'header.inc.php');
?>

<div class="container">
    <div id="header">
        <h1 id="book-of-love"><img src="<?php echo SITEURL; ?>images/infracom.png" /> <!--Indonusa Group<span> Portal</span> --></h1>
    </div>

    <div class="infra-article">
        <?php
        if ( isset($_GET['pageSlug']) && !empty($_GET['pageSlug']) ) {
            $q = new wdsQuery("SELECT pages_ID, pages_title, pages_description, pages_content, pages_slug FROM " . $dbtable['pages'] . " WHERE pages_slug = '" . slugs($_GET['pageSlug']) . "'");
            if ( $q->numRows() == 1 ) {
                $r = $q->fetchArray();
            ?>
            <h1 class="heading"><?php echo $r['pages_title']; ?></h1>
            <?php echo $r['pages_content']; ?>
            <?php
            }
            else {
                generate404();
            }
            ?>
        <?php
        }
        else {
            generate404();
        }
        ?>
    </div>


    <?php include(INC_DIR . 'footer.inc.php'); ?>
</div>
</body>
</html>

header.inc.php

<?php
if( !defined('WDS_ROOT') )
    exit;

$meta = array();
$meta['title'] = 'Error 404 Object Not Found';
$meta['keywords'] = $config['sitekeywords'];
$meta['description'] = $config['sitename'] . ' :: The page you looking for is not found at this site.';
$meta['robots'] = 'noindex,nofollow';

switch(getCurrentFilename()) :
    case "index.php" :
        $meta['title'] = $config['sitename'] . ' :: ' . $config['sitedescription'];
        $meta['keywords'] = $config['sitename'] . ', ' . $config['sitekeywords'];
        $meta['description'] = $config['sitedescription'];
        $meta['robots'] = 'index,follow';
    break;
    case "company.php" :
        if ( isset($_GET['pageSlug']) && !empty($_GET['pageSlug']) ) {
            $metaCheck = new wdsQuery("SELECT pages_ID, pages_title, pages_description, pages_content, pages_slug FROM " . $dbtable['pages'] . " WHERE pages_slug = '" . slugs($_GET['pageSlug']) . "'");
            if ( $metaCheck->numRows() == '1' ) {
                $metaResult = $metaCheck->fetchArray();
                $meta['title'] = $metaResult['pages_title'];
                $meta['keywords'] = $metaResult['pages_title'] . ',' . $config['sitekeywords'];
                $meta['description'] = $config['sitename'] . ' :: ' . $metaResult['pages_title'] . ' | ' . $metaResult['pages_description'];
                $meta['robots'] = 'index,follow';
            }
        }
    break;
    case "contact.php" :
        $meta['title'] = "Contact";
        $meta['keywords'] = 'contact,' . $config['sitekeywords'];
        $meta['description'] = $config['sitename'] . ' :: Contact Us';
        $meta['robots'] = 'noindex,nofollow';
    break;
    default:
        $meta['title'] = 'Error 404 Object Not Found';
        $meta['keywords'] = $config['sitekeywords'];
        $meta['description'] = $config['sitename'] . ' :: The page you looking for is not found at this site.';
        $meta['robots'] = 'noindex,nofollow';
endswitch;
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title><?php echo netralMetaDesc($meta['title'] . " :: " . $config['sitename']); ?></title>
    <meta name="description" content="<?php echo netralMetaDesc($meta['description']); ?>" />
    <meta name="keywords" content="<?php echo strtolower(netralMetaDesc($meta['keywords'])); ?>" />
    <meta name="robots" content="<?php echo $meta['robots']; ?>" />
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL; ?>css/style.css" />
    <link rel="shortcut icon" href="<?php echo SITEURL; ?>favicon.png" />
    <link href='https://fonts.googleapis.com/css?family=PT+Sans+Narrow&v1' rel='stylesheet' type='text/css' />
    <link href='https://fonts.googleapis.com/css?family=Wire+One&v1' rel='stylesheet' type='text/css' />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
    <script type="text/javascript" src="<?php echo SITEURL; ?>js/jquery.easing-1.3.min.js"></script>
    <script type="text/javascript" src="<?php echo SITEURL; ?>js/reality.js"></script>
    <script type="text/javascript">
        $(function() {
            $('#love-story').theHappyCouple({
                jantan : {
                    'storyTitle' : {speed : 400, easing : 'easeOutBack', delay : 200, dir : -1},
                    'storyDescription' : {speed : 400, easing : 'easeOutBack', delay : 400, dir : -1},
                    'storyPicture'  : {speed : 400, easing : 'easeOutBack', delay : 0, dir : -1}
                },
                betina : {
                    'storyTitle' : {speed : 200, easing : 'easeInExpo', delay : 150, dir : 1},
                    'storyDescription' : {speed : 200, easing : 'easeInExpo', delay : 300, dir : 1},
                    'storyPicture'  : {speed : 200, easing : 'easeInExpo', delay : 0, dir : 1}
                }
            });
        });
    </script>
</head>
<body>
<div id="infra-header">
    <ul>
        <li><a href="<?php echo SITEURL; ?>">Front Page</a></li>
        <li><a href="<?php echo SITEURL . 'company/history.html'; ?>">Company History</a></li>
        <li><a href="<?php echo SITEURL . 'company/vision-mission.html'; ?>">Vision Mission</a></li>
        <li><a href="<?php echo SITEURL . 'contact.html'; ?>">Contact Us</a></li>
    </ul>
</div>

In the website in my localhost I can see history.html & vision-mission.html while on the other hand I cannot find company/history.html & company/vision-mission.html file in my folder. If the file does not exist, then why the file works well in my localhost as if that the file exist?

Recommended Answers

All 8 Replies

Check the .htaccess file, there is probably a rewrite to match the switch cases in header.inc.php. Also check the code of the getCurrentFilename() function, that should give some hints about the url manipulation.

I search getCurrentFilename() ini php.net - (php manual):

-----------------
PHP Function List

getcurrentfilename() doesn't exist. Closest matches:

----------------

I don't which other function might works the same, there are too many closest matches.

That is a user defined function, check within the included files.
For example check in wds.php, as you see the header.inc.php file is included after wds.php.

wds.php

<?php
if( !defined('WDS_ROOT') )
    define('WDS_ROOT', dirname(__FILE__) . "/");

if ( function_exists('date_default_timezone_set') )
    date_default_timezone_set('Asia/Jakarta');


define('ENV_PRODUCTION', TRUE);
/** -------------------------------------------------------------------- +
|*                 Copyright (C) 2012 Web Data Solusindo                *|
|*              Website : http://www.webdatasolusindo.co.id             *|
|*                     Email : <info@wds.co.id>                         *|
|*                                                                      */
define('PROJECT_AUTHORS', 'Christian Ditaputratama | Web Data Solusindo');
          define('AUTHOR_EMAIL', 'christian.dita@wds.co.id');
                        define('SINCE', '2012');
/** =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

[*] No part of this packages may be reproduced in any format, electronic,
print, or otherwise, without the expressed written permission of the
author.

[*] TODO : Add SNMP, POP3, whois, memchache, SSO and Disqus API.

[*] Report BUG or SECURITY problems to PROJECT_AUTHORS
--------------------------------------------------------------------------
    ++ +-++-++-++-+ +-++-++-+ +-++-++-++-+ +-++-++-++-++-++-++-++-++-++
   +                               ____    ____                        |
   |                 __        __ |  _"\  / __"| u                     +
   +                 \"\      /"//| | | |<\___ \/                      |
   |                 /\ \ /\ / /\U| |_| |\u___) |                      +
   +                U  \ V  V /  U|____/ u|____/>>                     |
   |                .-,_\ /\ /_,-. |||_    )(  (__)                    +
   +                 \_)-'  '-(_/ (__)_)  (__)                         |
   |                                                                   +
   +                                                                   +
   +- -+ +-++-++-++-+ +-++-++-+ +-++-++-++-+ +-++-++-++-++-++-++-++-++-+
   |(c)| |2||0||1||2| |W||e||b| |D||a||t||a| |S||o||l||u||s||i||n||d||o|
   +- -+ +-++-++-++-+ +-++-++-+ +-++-++-++-+ +-++-++-++-++-++-++-++-++-+
-------------------------------------------------------------------------*/
/**
 * CORE CONFIGURATIONS
 *
 * @version       1.30-dev
 * @author        Christian Ditaputratama <christian.dita@wds.co.id>
 * @package       WDS-FW
 *
 * What does it do?
 * 
 * It manages all site configurations. In short, it manages the whole
 * classes, upload path, admin location, how errors should be show
 * and stored, database and it's registered tables.
 */


ini_set('display_errors', ENV_PRODUCTION);

#define('SITEURL', 'http://www.infracom.co.id/');
define('SITEURL', '');

define('CORE_DIR', WDS_ROOT . 'WDS_engines/');
define('INC_DIR', WDS_ROOT . 'WDS_inc/');

define('ADMIN_URL', "InfRaAdmIn337/");
define('ADMIN_TPL', 'WDS Elite Admin Page Theme');

define('WDS_DB_HOST', 'localhost');
define('WDS_DB_NAME', 'project_infracom');
define('WDS_DB_USER', 'root');
define('WDS_DB_PASS', '');

#define('WDS_DB_HOST', 'localhost');
#define('WDS_DB_NAME', 'infracom_infracom');
#define('WDS_DB_USER', 'infracom_webUsr');
#define('WDS_DB_PASS', 'ASaadj23hDSH');

define('SITECOOKIES_ADMINTOKEN', "DeX_gTgVDFSIf76");
define('SITECOOKIES_ADMINUSER', "DeX_M78kKZHEA");

$dbtable = array(
    "pages" => "infracom_pages",
    "links" => "infracom_links",
    "admin" => "infracom_admin",
    "settings" => "infracom_settings"
);

require( CORE_DIR . 'class.wdsConnect.php');
$sql = new wdsConnect(WDS_DB_HOST, WDS_DB_USER, WDS_DB_PASS, WDS_DB_NAME);
$sql->open();
require( CORE_DIR . 'class.wdsCookie.php');
require( CORE_DIR . 'class.gravatar.php');
require( CORE_DIR . 'class.wdsValidator.php');
require( CORE_DIR . 'class.mailer.php');
require( CORE_DIR . 'func_go.php');
require( CORE_DIR . 'class.wdsAuth.php');
require('config.php');

/*
$confg = array(
    'siteurl' => 'http://tompel.wds.co.id/infracom/'
);

$indoProduct = array(
    'prod-ktp' => array(
        'name' => 'ktp.net.id',
        'url' => 'http://www.ktp.net.id/',
        'description' => 'Landing Right and Network Access Point',
        'color' => '#85C516'
    ),
    'prod-indonusa' => array(
        'name' => 'indonusa.net.id',
        'url' => 'http://www.indonusa.net.id/',
        'description' => 'Business Integrator System &amp; Structured Cabling System',
        'color' => '#01019D'
    ),
    'prod-idlink' => array(
        'name' => 'idlink.net.id',
        'url' => 'http://www.idlink.net.id/',
        'description' => 'High Technology IP-Based Network',
        'color' => '#CA1830'
    )
);
*/
?>

func_go.php

function getCurrentFilename() {
    $parts = explode("/", $_SERVER['SCRIPT_NAME']);
    return $parts[count($parts) - 1];
}

Here is the function in func_go.php

look to me that company/vision-mission.html get redirected to company.php?pageSlug=vision-mission

in company the vision-mision page is fechted for the data base:

wdsQuery("SELECT pages_ID, pages_title, pages_description, pages_content, pages_slug FROM " . $dbtable['pages'] . " WHERE pages_slug = '" . slugs($_GET['pageSlug']) . "'");

and echoed:

echo $r['pages_content'];

This is the result of the above code:
infracom

I wonder why company history & vision/mission does not look as good as the front page & contactus.

The thing is this code works offline without errors and the error only appears after I upload it online.

@pzuurveen

yes, in company the vision-mision page is fechted for the data base:

wdsQuery("SELECT pages_ID, pages_title, pages_description, pages_content, pages_slug FROM " . $dbtable['pages'] . " WHERE pages_slug = '" . slugs($_GET['pageSlug']) . "'");

and echoed:

echo $r['pages_content'];

What should I do to fix the error?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.