Error dirname($_SERVER[ 'PHP_SELF' ]) pada config.php

Error pada software CMS perlu perbaikan bug, tentu saja upaya ini tidak mudah. Bug ini tidak muncul saat kita mengakses alamat website, namun terekam jelas pada error.txt. Pada kasus ini misalnya ditemukan bug yang dapat kita lihat pada file config.php sebagai berikut.

2016-07-13 16:32:34 - App Warning:  AbanteCart core v.1.1.9 Warning: Accessing store with unconfigured or unknown domain ( tokoteknologi.co.id/index.php/static_pages/image/thumbnails/18/7d/storefront/view/image/thumbnails/18/7c/image/thumbnails/18/b5/image/thumbnails/18/78/image/thumbnails/18/84/image/thumbnails/18/7d/ ).
Check setting of your store domain URL in System Settings . Loading default store configuration for now. in /home/tokotek2/public_html/core/lib/config.php on line 169

Solusi:

Cari variabel yang menyimpan url tersebut, dalam kasus ini disimpan dalam $url.

//detect URL for the store
$url = str_replace('www.', '', $_SERVER[ 'HTTP_HOST' ]) .
rtrim(dirname($_SERVER[ 'PHP_SELF' ]), '/.\\') . '/';

Berdasarkan PHP Documentation:

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

'HTTP_HOST'
Contents of the Host: header from the current request, if there is one.
'PHP_SELF'
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/foo/bar.php would be /foo/bar.php. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

__FILE__ The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.

Edit Code (Code GitHub):

//detect URL for the store
$url = str_replace('www.', '', $_SERVER[ 'HTTP_HOST' ]) .
'/';


Our Divisions

 

Our Partners

TMN Studio

Who's Online

We have 12 guests and no members online