jason_15
-
Posts
3 -
Joined
-
Last visited
Posts posted by jason_15
-
-
I dont get expected output
<?php function is_localhost(){ if(in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))){ return true; } return false; } function home_url(){ $scheme = $_SERVER['REQUEST_SCHEME']; $server_name = $_SERVER['SERVER_NAME']; $dir = (is_localhost()) ? dirname($_SERVER['REQUEST_URI']) : NULL; return $scheme . '://' . $server_name . $dir; } print home_url(); # Dir where executed home_url() : administrator # Localhost output: http://localhost/project_name/sub_project_name/administrator # Live output: http://www.project_name.com # Expected output # Localhost: http://localhost/project_name/sub_project_name # Live: http://www.project_name.com/sub_project_name ?>
-
How to send out plain and htlm email[with email templates] based on user selected language?
/* === GET USER SELECTED LANGUAGE === */
if(!empty($_GET['language'])){ if(in_array($_GET['language'], array('EN-US','RO'))){ $date = date_create(NULL, timezone_open(date_default_timezone_get())); date_add($date, date_interval_create_from_date_string('90 days')); $expire = date_timestamp_get($date); $_SESSION['user_language'] = $_GET['language']; setcookie('user_language', $_GET['language'], $expire); }else{ $_SESSION['user_language'] = $config['default_language']; } } else if(!empty($_SESSION['user_language'])) $language = (string) $_SESSION['user_language']; else if(!empty($_COOKIE['user_language'])) $language = (string) $_COOKIE['user_language']; else $language = $config['default_language']; require 'languages/user/'.$language.'/index.php';
/* === languages/user/EN-US/index.php === */
<?php $lang = array(); $lang['global']['welcome'] = 'Welcome %a'; # %a - username # $lang['global']['login'] = 'Login'; $lang['global']['logout'] = 'Logout'; /* ................................................... */
localhost url with project and sub-project name
in PHP Coding Help
Posted