http://www.reecemcmillin.com/albums/
<?php
$uncut = file_get_contents('http://www.google.com/#sclient=psy-ab&hl=en&safe=active&source=hp&q=' . $_POST['band'] . '+' . $_POST['album'] . '+zip+inurl:mediafire');
$strip1 = strstr($uncut, 'www.mediafire.com/?');
$link = substr($strip1, 0, 30);
echo $link;
?>
It doesn't seem to be writing the website content to $uncut. Can somebody help me figure out what's wrong? Thanks.<3
Clients are not supposed to send URI-fragments (the portion of the URI following #) to servers when they retrieve a document. PHP is probably sending a request for the google homepage, effectively: file_get_contents('http://www.google.com/');. If you echo $uncut, that's probably what you'll see you're getting back.
Try a querystring-based URI instead.
<?php
$uncut = file_get_contents('http://www.google.com/search?sclient=psy-ab&hl=en&safe=active&source=hp&q=' . urlencode($_POST['band']) . '+' . urlencode($_POST['album']) . '+zip+inurl:mediafire');
Related
I took a part of PHP code from a different Stackoverflow question, and it works perfectly.
<?php header>
//Display IceCast Server Stats
$server = "***********"; //IP (x.x.x.x or domain name)
$iceport = "8070"; //Port
$iceurl = "live"; //Mountpoint
$online = "<font color=green><b>ONLINE</b> </font><br />";
$offline = "<font color=red><b>OFFLINE</b></font><br />";
if($fp = #fsockopen($server, $iceport, $errno, $errstr, '1')) {
fclose($fp);
$ice_status=$online;
echo "<p><b>DJ:</b> $ice_status";
$stats = file("http://" . $server . ":" . $iceport . "/status2.xsl");
$status = explode(",", $stats[5]);
$artist = explode("-", $status[5]);
echo " " . $artist[1];
echo " - ";
echo " " . $artist[2];
echo "<br />";
// echo "<b>Listeners:</b> <b> " . $status[3] . "</b>";
echo "</p>";
//echo "<br />";
//echo "<p><a href=http://" . $server . ":" . $iceport . "/" . $iceurl . " target=new><b>Listen!</b></a></p>";
} else {
$ice_status=$offline;
echo "<p><b>DJ:</b> $ice_status";
}
?>
<hr />
</center>
I'm trying to add the stream name, which is currently:
echo "DJ: $ice_status";
This displays DJ: ONLINE, but I want it to say DJ: (DJ Name/Stream Name)
I do believe its variables from status2.xsl, but I'm a complete noob at this, and can't seem to figure out how to use it. Could anyone tell me what streamname variable would be?
I was also wondering, is it possible to make it so the "nowplaying.php" refreshes, but my whole web page doesn't? I've tried an iframe, but it makes it look really bad, and has errors.
What my website looks like at the moment: https://i.stack.imgur.com/luc4O.jpg
I'd suggest having a look at TheFineManualâ„¢:
http://icecast.org/docs/icecast-2.4.1/server-stats.html#xslt
Especially the part about status-json.xsl. Make sure you are running an up to date version of Icecast. Icecast is available from all major Linux distributions in up to date packaging. Xiph provides independent packaging, which is useful if there are no up to date packages for a distribution, e.g. shortly after an Icecast release.
status2.xsl was an example file, and a bad one at that. It was removed from newer Icecast versions.
This is my sms url
"https://example.com/api/sendhttp.php?authkey=#############&mobiles=".$mobile."&message=".urlencode($rem)."&sender=abcdef&route=#"
Here is my Code
<?php
session_start();
$mobile=98994564564;
$rem="Hi";
$url=$_SESSION['smsurl'];
echo $url;
?>
What I am trying to do here is I am calling this url through session variable. But when I am displaying the url, it is not getting value of $mobile and $rem.
It should display
"https://example.com/api/sendhttp.php?authkey=#############&mobiles=8994564564"&message=".urlencode("Hi")."&sender=abcdef&route=#"
The problem is, $_SESSION['smsurl'] does not contain the actual variables like $mobile or $rem, instead it contains the value of those variables. So you can't simply do $mobile=ABC; $rem="XYZ"; $url=$_SESSION['smsurl']; to change the query part of the URL.
The solution is,
Parse the URL
Change the query part of the URL
Reconstruct the URL again
So your code should be like this,
<?php
session_start();
$mobile=98994564564;
$rem="Hi";
$urlArray = parse_url($_SESSION['smsurl']);
parse_str($urlArray['query'], $qStringArray);
$qStringArray['mobiles'] = $mobile;
$qStringArray['message'] = urlencode($rem);
$qString = http_build_query($qStringArray);
$apiUrl = $urlArray['scheme'] . '://' . $urlArray['host'] . $urlArray['path'] . '?' . $qString;
// Display the final URL
echo $apiUrl;
?>
I'm working on a simple script - file input which will change the site's background to the given image. It works, but my problem starts when I refresh site - the background image disappears.
I was wondering how to set and check if the background was set, so it will be there as long since next file input ?
I was trying to do that with a constant but does not work, here is my code:
if (isset($_POST['submit_bgImg'])) {
$myTarget = 'img/' . basename($_FILES['bg_img']['name']);
if (move_uploaded_file($_FILES['bg_img']['tmp_name'], $myTarget)) {
print('<style> body {background-image:url(img/' . $myFile . ');}</style>');
define('MY_BG', $_FILES['bg_img']['name']);
}
}
if (defined('MY_BG')) {
print('<style> body {background-image:url(img/' . MY_BG . ');}</style>');
}
any help ?
If you want to keep it only for the user you must store MY_BG variable in Session or Cookies like :$_SESSION['my_bg'] = $_FILES['bg_img']['name'];
if you want to keep it forever you must store it on a file or a Database like MySQL
$conn = new MySQLi('host','user','password','database name');
$conn->query("INSERT INTO table VALUES ('" . $bg_name . "')");
Try out with echo in php instead of print.I recommended to you can use ajax.
if (isset($_POST['submit_bgImg'])) {
$myTarget = 'img/' . basename($_FILES['bg_img']['name']);
if (move_uploaded_file($_FILES['bg_img']['tmp_name'], $myTarget)) {
echo "<style> body {background-image:url(img/' . $myFile . ');}</style>";
define('MY_BG', $_FILES['bg_img']['name']);
}
}
if (defined('MY_BG')) {
echo "<style> body {background-image:url(img/' . MY_BG . ');}</style>";
}
I have just a quick question. i was using a normal html link tag to redirect to a paypal checkout page and it was working fine even when i had php inside the url. but when i was using it in a php header
the url cuts off where i enter the php.
header('location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=<? echo $product . " " . $server ?>&amount=<? echo $xprice1; ?>%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest');
You are placing the PHP code inside of the location redirect as a string. The code is not being evaluated as PHP.
Try this instead:
<?php
$url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=" . $product . " " . $server ."&amount=" . $xprice1 . "%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest";
header('location: ' . $url);
Or, you could keep it in one line like so:
<?php
header('location: ' . "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=" . $product . " " . $server ."&amount=" . $xprice1 . "%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest");
header('location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=<? echo $product' . " " . '$server ?>&amount=<? echo $xprice1; ?>%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest');
This may solve your problem. Please dont forget to tick the answer right if it works.
having an annoying issue with getting xml data from a url
if i set "$file_show_title" to a single word (comes from the url passed from another page) then all works fine. if if "$file_show_title" is 2 words (tried encoding the url also) then it failed to find the address.
im not the best at explaining but i hope that this is enough for someone to help me please
thanks
$url = file_get_contents("http://www.thetvdb.com/api/GetSeries.php?seriesname=".$file_show_title);
$xml = simplexml_load_string($url);
$seriesid = $xml->Series[0]->seriesid;
$seriesbanner = $xml->Series[0]->banner;
$seriesname = $xml->Series[0]->SeriesName;
$serieslanguage = $xml->Series[0]->language;
$seriesfist_aired = $xml->Series[0]->FirstAired;
$seriesoverview = $xml->Series[0]->Overview;
echo '<img src="/images/'.$seriesbanner.'">'."<br />";
echo $seriesname."<br />";
echo $seriesid."<br />";
echo $serieslanguage."<br />";
echo $seriesfist_aired."<br />";
echo $seriesoverview."<br />";
What you needed was urlencode Please see http://php.net/manual/en/function.urlencode.php for more information
Example
$url = file_get_contents("http://www.thetvdb.com/api/GetSeries.php?seriesname=" . urlencode("Prison Break"));
Now Use
$url = file_get_contents("http://www.thetvdb.com/api/GetSeries.php?seriesname=" . urlencode($file_show_title));
I hope it helps