In localhost i have given baseurl in yii like this
<?php echo Yii::app()->baseUrl;?>
It is working in local but not working in live.
please give your opinion
You missed the request part in between -
<?php echo Yii::app()->request->baseUrl;?>
<?php echo yii::app()->getBaseUrl(true);?>
output:http://www.example.com
<?php echo yii::app()->getBaseUrl(false);?>
output:www.example.com
Related
I have just finished configuring my LAMP environment on new macbook but would like to go a little further.
My home dir is as follows:
var/www/
site1.com
site2.com
site3.com
I would like my localhost homepage to automatically display a link for each folder within my home directory. Could anyone point in my the right direction for a solution to this?
create links to each folder in your homepage
site1
site2
site3
I used PHP for this, making use of "glob"
<?php foreach (glob("*", GLOB_ONLYDIR) as $filename) {
if ($filename != "project_thumbs") {
echo '<a className="project" href="/'.$filename.'/"><img src="project_thumbs\/'.$filename.'.png"></img><h3>'.$filename.'</h3></a>';
}
} ?>
I have a problem with my download file due to some wrong coding in htaccess,here is my htaccess code for this url
URL:
https//www.example.com/download.php?fil=`<?php echo $nm ; ?>`&fpath=`<?php echo $fpath ; ?>`&ntid=`<?php echo $ntid ; ?>`
$nm= b5fgh68dsk3nlxz.pdf ,
$fpath= ..uploads/45 ,
$ntid= 146
now htaccess is
RewriteEngine ON
RewriteRule ^n9/([a-zA-Z0-9!##$-_]*)/([a-zA-Z0-9!##$-_]*)/([0-9]+)$ download.php?fil=$1&fpath=$2&ntid=$3
now problem is normally without htaccess files can download easily but with the htaccess download couldn't established
url looks after htaccess
https://www.example.com/n9/b5fgh68dsk3nlxz.pdf/..uploads/45/146
That ..uploads part also looks like a possible vulnerability allowing people to get the source of possibly any file on the server if you're not careful.
But if your download.php file takes precautions before giving them the file contents, I'd seek a workaround to preserve your slashes. From your PHP file which is generating the link, I'd do:
<?php
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
?>
download
Then from your download.php on the top I'd use:
<?php
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
if(isset($_GET['fil']))$_GET['fil']=base64url_decode($_GET['fil']);
if(isset($_GET['fpath']))$_GET['fpath']=base64url_decode($_GET['fpath']);
if(isset($_GET['ntid']))$_GET['ntid']=base64url_decode($_GET['ntid']);
?>
Finally, use can get by with the following clean .htaccess:
RewriteRule ^n9/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ download.php?fil=$1&fpath=$2&ntid=$3
I've setup my apache server on Centos 6.4 . But when i run my page, browse displayed Apache test page, What wrong i did?
In /var/www/vhosts/testing.page, my file "index.php" is:
<?php
echo 'Welcome, Trien';
?>
My virtual host:
![virtual host][1]
And my page displayed:
![Browse display][2]
Any help?
thank
Delete the index.htm or index.html if exist.
Also, check the permission for the file, make sure it has 'execute' permission.
Turns out my php.ini file wasn't configured properly. With fatcow (my host) you have to change the .ini file to specify the directory where you are saving session date and include
session.save_path=("directory"); prior to session_start();.
You guys were absolutely right. This has been a great learning experience.
I am having trouble with sessions.
On my first page I have declared session variables properly I know because I can print them with in the php file that I declared them in. On the page which the user is forwarded to with my header I try to do the following but nothing prints. Its as if the session_start(); does nothing. I tried Print_R(); and it just prints Array ( ). Here is my code from the page specified in the header- it is a .phtml file.
//HTML code up here
<?
session_start();
echo $_SESSION['dentist_first_name'];
Print_r ($_SESSION);
?>
//HTML code down here
Is there anything I have to do on the landing page to make sure that the session is continued? I used session_start(); on the original page.
Really confused that my variables aren't getting picked up.
session_start() must be called before you output any HTML
<?
session_start();
?>
//HTML code up here
<?php
echo $_SESSION['dentist_first_name'];
Print_r ($_SESSION);
?>
//HTML code down here
session_start(); has to be before you output HTML
if that's the case you mention the header forwards users. Is the header forwarding the user before it gets to the $_SESSION declaration in the page?
If you do any output before session_start(), this won't work.
Even a withespace before php open tag is an output:
<?
session_start();
?>
Do this:
<?
session_start();
?>
I am trying to create a whitelabel service for my site. I want to do it like dohop does. So I created a sub domain on my main site like : whitelabel.example.com and I want to know what I have to do in order for a user to be able to set a cname on his domain to use my service.
I tried this:
User's domain: userdomain.com
tests.userdomain.com - CNAME - whitelabel.example.com
www.tests.userdomain.com - CNAME - whitelabel.example.com
When I ping tests.userdomain.com I get:
Pinging to whitelabel.example.com
So I guess the CNAME does it's job but I can't figure out what I have to do on my server (example.com) in order to understand and reply to the request.
All I get when i type tests.userdomain.com in my browser is cpanel's default page that informs me of an error.
If you was using PHP for instance you could do:
<?php
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$host = str_replace('.example.com','',$host);
echo $host;
?>
Once your CNAME as has setup, you need to use your sub domain into iframe so that when any visitor make a search, they will land to your subdomain which is pointed to dohop affiliate server. Hope this help!
Thanks