Skip to content

Commit

Permalink
Laragon
Browse files Browse the repository at this point in the history
- Dynamic base url and cookie path
- Remove splat operator for compatibility to php 5.6
- Fix timezone warning
  • Loading branch information
R-N committed May 11, 2022
1 parent 1f19678 commit 3cd0194
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
18 changes: 15 additions & 3 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://localhost/akreditasi';

$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === 0 ? 'https://' : 'http://';
$domain = $_SERVER['HTTP_HOST'];
$root = $protocol.$domain;
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$req_uri = $_SERVER['REQUEST_URI'];
$path = substr($req_uri,0,strrpos($req_uri,'/'));

$config['base_url'] = $root;

//$config['base_url'] = 'http://localhost/akreditasi';

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -401,8 +411,10 @@
|
*/
$config['cookie_prefix'] = '';
$config['cookie_domain'] = 'localhost';
$config['cookie_path'] = '/akreditasi';
$config['cookie_domain'] = $domain;
$config['cookie_path'] = '/'.$path;
//$config['cookie_domain'] = 'localhost';
//$config['cookie_path'] = '/akreditasi';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;

Expand Down
16 changes: 15 additions & 1 deletion application/helpers/util_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,21 @@ function split_page_id($page_id=null){
function get_link($page_id=null){
if(!is_string($page_id)) return _get_link($page_id);
$arr = split_page_id($page_id);
$link = _get_link(...$arr);
switch(count($arr)){
case 0:
$link = _get_link();
break;
case 1:
$link = _get_link($arr[0]);
break;
case 2:
$link = _get_link($arr[0], $arr[1]);
break;
default:
$link = _get_link($arr[0], $arr[1], $arr[2]);
break;
}
//$link = _get_link(...$arr);
$link["id"] = $page_id;
return $link;
}
Expand Down
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
if( ! ini_get('date.timezone') )
{
date_default_timezone_set('GMT');
}
/**
* CodeIgniter
*
Expand Down

0 comments on commit 3cd0194

Please sign in to comment.