PHP Code MainUrl / Want to use HTTPS instead of HTTP - php

I have a php documents in which is used a MainUrl to get the url. The thing is that the main url is HTTP. Is there a way to change it to HTTPS? Thank you
Im using codes like this
<img src="<?php echo MAIN_URL; ?>/img/adv-img.png">

Related

Generating url in laravel

I have a problem with url in Laravel
<td> Website: {{$data[0]->internet}}</td>
where internet is some website name, for example www.foo.com
The problem is that output URL is http://localhost/www.foo.com instead of http://www.foo.com
change the target attribute target="blank" to target="_blank"
Change your html to
{{$data[0]->internet}}
As stated in the Laravel documentation: https://laravel.com/docs/5.7/urls
The url helper may be used to generate arbitrary URLs for your
application. The generated URL will automatically use the scheme (HTTP
or HTTPS) and host from the current request
$post = App\Post::find(1);
echo url("/posts/{$post->id}");
// http://example.com/posts/1
In your case you won't need the url helper function.
Also make use of the http or https protocol in this format:
http://www.foo.com or https://www.foo.com to make an absolute url instead of a relative one.
Try this way:
{{$data[0]->internet}}
If your variable internet is some website name, for example
www.foo.com and you need to link this URl in anchor tag you dont need
to call this variable inside url() function you can simply use that
variable to link the url in anchor tag.
If you want to get the base URL of your site then you can use url()
fucntion which return base url of your website.
Just replace below line with your code
<td>
Website:
{{$data[0]->internet}}
</td>

PHP url rewriting

i am trying to make the URL in my PHP application cleaner using htaccess. Earlier the links of my application were in this format
http://localhost/25_2_april/video.php?cat_id=2&category=Programming-Language, but with the help of htaccess i was able to convert it into
http://localhost/25_2_april/video-library/2/Programming-Language. Now ,the question is that every time i run my application it loads the messy URL instead of the clean URL , although when i edit the url ,and make it clean url, then that works too. Now is there any way, that it directly loads the clean url instead of the messy url.
Below is the anchor tag through which i am calling this particular page.
<a href="<?php echo 'video.php?cat_id='.$cat_id.'&category='.$cat_name; ?>">
As you are adding static URL in html so must have to pass your clean URL as :
<a href="<?php echo 'http://localhost/25_2_april/video-library/'.$cat_id.'/'.$cat_name; ">

How to view an image outside of web root?

I have a .png that I want to embed on a particular page. This .png is outside of the web root, but we have a module in our system that allows users to view that image on a separate page. I found that I can use an iframe to view the .png on some browsers, but sometimes there is an authorization issue or when trying to print the page the image doesn't load through the iframe. I tried PHPs readfile(), but then I just have another authorization issue. I find the authorization issue odd since one has to be logged in to use our site at all. What would be the best way to imbed this image?
<?php foreach($activity->getMedias() as $media_count => $media):
<iframe id="content" src="http://www.mysite.com/media/view/id/<?php echo $media->getId(); ?>" frameborder="0" style="width: 100%; height:825px;" seamless="seamless">
<p>Your browser does not support iframes. Please upgrade to a modern browser.</p>
</iframe>
SOLVED
This is the code I used to get it to work. I am using Symfony 1.4.
<?php foreach($activity->getMedias() as $media_count => $media):
$dataString=sfConfig::get('sf_root_dir').'/media/'.$media->getLocation(); ?>
<img SRC="data:image/png;base64,<?php echo base64_encode(file_get_contents("../../../../../..".$dataString));?>">
Sounds like you're trying to pass a url to readfile, e.g.
readfile('http://example.com/foo/bar');
This causes PHP to start up a full-blown HTTP request back to itself. You need to use a local file-system path, e.g.
readfile('/path/outside/doc/root/to/the/image.png');
That's a purely local filesystem operation, and does not involve the HTTP layer at all, bypassing the entire document root/http authentication business.

php open dynamic link in new window with iframe

Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.
You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>
The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>
Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed

Load page within the page

I'm a beginner in PHP and Javascript..
I found a link from http://cmichaelis.whsites.net/whblog/jquery-extjs-1/example2
Inside it there is a code saying :
function addPanel(location)
{
tabpanel.add({
autoLoad: {url: location},
title: 'More Information...',
closable:true,
autoScroll:true
}).show();
}
how to use :
<a href="javascript:void(0);"
onclick="addPanel('loadpage.php?a=http://www.google.com')">
head over to Google
</a>
What I want to ask is.. what is the code for loadpage.php?
The PHP page does not echo out the contents of google.com as suggested in the other answer. It outputs an iframe that points to Google:
<iframe src="http://www.google.com" width="100%" height="100%" frameborder="no"></iframe>
It looks like loadpage.php could be in use to echo out the contents of www.google.com, using file_get_contents.
loadpage.php:
<?php
// Simplified output - should sanitise $_REQUEST params etc first..
echo file_get_contents($_REQUEST['a']);
?>
loadpage is effectively acting as a proxy, allowing your javascript to call pages which are not on your own domain.
As #annakata points out in the comments, the code above is obscenely dangerous as-is. The code is an illustration of the basic idea behind a proxy file - in production, this file would need to make sure that the $_REQUEST parameters were sanitised, e.g. only accept values from a whitelist.
The same origin policy is a security element of javascript that stops you from pulling content from outside your domain on to your page using javascript.
Some sites get around this by calling a proxy page on their own server (loadpage in this instance) which effectively just prints out the content of a target url. As this proxy page is on your server, this by-passes the same origin security issue, and still makes available the content of a page from another domain - here www.google.com
Oops, I somewhat foolishly didn't RTFA, but just the code in the question and hypothesised at what it could be doing. #andynormancx is right in his answer as to what the page linked in the q is actually doing.

Categories