Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
class_parents() perhaps?
-
Hotlink protection It is a way of preventing other people from linking directly to some of your files. Images for example. You can prevent other webpages from using images on your site and therefore using your bandwidth instead of their own. Optionally you can display another image instead of the one they requested (goatse (safe to click) for example if you're evil ). Raw access log With this function you can download an access log. It is a log containing informations about each request made to the HTTP server (apache). Password protected directories This is just a GUI way of enabling .htaccess password protection of a folder. See: http://httpd.apache.org/docs/2.2/howto/auth.html Allow anonymous access (FTP): This is a matter of whether anonymous FTP users can read from /home/public_ftp and if they can write to /home/public_ftp/incoming. It's fine to leave it as it is by default.
-
If you plan on releasing your script as a commercial script, then you could encrypt it, but it is really annoying for the user if (s)he wants to modify how your script works. If you don't encrypt it, then you can't enforce the inclusion of copyright.php, besides, they could just make it an empty file. They are not allowed to even if they can. It's still copyright infringement to use copyrighted content without proper permissions.
-
Well, I don't quite know what you mean with saving show.php as a JPEG. Do you want show.php to output a picture (a JPEG)? Try this: <?php // do some stuff here to determine the path of the image on the server - for this example we'll just set it like this: $img_path = "/home/somebody/images/test.jpg"; // note that this is outside the document root in this example header("Content-type: image/jpeg"); // here we tell the browser that it is a jpeg @readfile($img_path); // here we read the contents of the file and output it die(); ?>
-
Something like this? show.php: <?php $pm_result = mysql_query("SELECT * FROM `pms` WHERE `reciever_id`='$id' ORDER BY `date_added` DESC") or die(mysql_error()); if(mysql_num_rows($pm_result) > 0) { echo "<form action='mass_delete.php' method='post'>"; while($pm = mysql_fetch_assoc($pm_result)) { echo "{$pm['subject']} - <input type='checkbox' name='pm_delete[{$row['id']}]' value='1' /><br />"; } echo "<input type='submit' value='Delete selected PMs</input></form>"; } else { echo "no pms"; } ?> mass_delete.php: <?php if(is_array($_POST['pm_delete']) && count($_POST['delete'])>0) { $values = array_map('intval',$_POST['pm_delete']); if(@mysql_query("DELETE FROM pms WHERE id IN(".join(',',$values).")")) { echo "pms deleted"; } else { echo "pms could not be deleted: ".mysql_error(); } } else { die("please select some pms to delete"); } ?> Note: The code is not tested, even it it shouldn't work it should give you an idea of how to do it.
-
header("Content-type: image/jpeg");
-
Overloading works a bit different in PHP, you can do something like this: <?php class Test { private $bDoSomething; public function __call($name, $arguments=array()) { if($name=='something') { if(count($arguments) == 0) // something() { return $this->bDoSomething; } else if(count($arguments) == 1) // something($bToSet) { $this->bDoSomething = $arguments[0]; return $this->bDoSomething; } else { trigger_error("Invalid argument count", E_USER_ERROR); } } } } $test = new Test(); $test->something("test"); echo $test->something(); // output: test ?> You could also choose to do it in another way (like you attempted): <?php class Test { private $bDoSomething; public function something($bToSet=null) { if(!empty($bToSet)) { $this->bDoSomething = $bToSet; } return $this->bDoSomething; } } $test = new Test(); $test->something("test"); echo $test->something(); // output: test ?> Note that overloading is for PHP5 only.
-
[SOLVED] How to tell search engines to ignore part of HTML?
Daniel0 replied to Azu's topic in Miscellaneous
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title</title> </head> <body> <div>Everybody can see this.</div> <?php $bots = array('googlebot'); // i can't remember what the other ones are called if(!in_array($_SERVER['HTTP_USER_AGENT'], $bots)) { // Don't display this to bots echo <<<EOF <div>You are not a known bot so you are allowed to view this as well.</div> EOF; } else { // display this to known bots only echo <<<EOF <div style='display:none;'><a href='http://example.com/page1.php>text here</a> <a href='http://example.com/page2.php'>other text here</a></div> EOF; } ?> <div>Everybody can see this as well.</div> </body> </html> Be careful with that though. You'll risk getting banned because it can look suspicious to a bot if you have a hidden div with a lot of links. I believe this is what is called "Cloaking". -
In httpd.conf: Listen localhost:80 Much easier
-
Well, you could always just set it using ini_set. Edit: Before session_start.
-
Try this: page1.php: <script type="text/javascript"> function populate_subcat(category_id, subcat_obj_id) { var obj = document.getElementById(subcat_obj_id); var http_request; if(window.XMLHttpRequest) { http_request = new XMLHttpRequest(); } else if(window.ActiveXObject) { try { http_request = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { http_request = new ActiveXObject('Microft.XMLHTTP'); } catch(e) {} } } if(!http_request) { alert('Error: Could not create an XMLHttpRequest instance.'); return false; } http_request.onreadystatechange = function() { if(http_request.readyState == 4) { if(http_request.status == 200) { obj.innerHTML = obj.innerHTML+http_request.responseText; obj.style.display=''; } else { alert('Error: Failed getting subcategories from the database.'); } } }; http_request.open('GET', 'page2.php?cat_id='+category_id, true); http_request.send(); } function makeRequest(url) { var httpRequest; if (window.XMLHttpRequest) { // Mozilla, Safari, ... httpRequest = new XMLHttpRequest(); if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!httpRequest) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } httpRequest.onreadystatechange = function() { alertContents(httpRequest); }; httpRequest.open('GET', url, true); httpRequest.send(''); } </script> <table> <tr> <td align="center" valign="top"> <select name="cat" onChange="populate_subcat(this.value, 'subcat')"> <option selected value=''>Select Category</option> <?php $db_link = mysql_connect("localhost","root",""); mysql_select_db("database_name", $db_link); $query_result = mysql_query("SELECT DISTINCT cat, category FROM category"); while($cat = mysql_fetch_assoc($query_result)) { echo "\t\t\t\t<option value='{$row['cat']}'>{$row['category']}</option>\n"; } ?> </select> </td> <td align="center" valign="top"> <select name='subcat' id='subcat' style='display:none;'> <option selected value=''>Select Subategory</option> </select> </td> </tr> </table> page2.php: <?php $db_link = mysql_connect("localhost","root",""); mysql_select_db("database_name", $db_link); $query_result = mysql_query("SELECT * FROM subcategory WHERE cat='".mysql_real_escape_string($_GET['cat_id'])."'"); while($cat = mysql_fetch_assoc($query_result)) { echo "\t\t\t\t<option value='{$row['subc']}'>{$row['subcat']}</option>\n"; } ?> If you had prototype, then you could replace the Javascript with: function populate_subcat(category_id, subcat_obj_id) { var obj = $(subcat_obj_id); new Ajax.Request('page2.php?cat_id='+category_id, { method: 'get', onSuccess: function(request) { obj.style.display=''; obj.innerHTML = obj.innerHTML+request.responseText; } }); } Note: Code is not tested.
-
It's 1440: http://php.net/ref.session
-
I don't see much point in that page, it just lets you change how that page looks. Those pop-up windows you are talking about, they do not appear... $_GET
-
I searched Google. Another person had a similar problem. It seemed to work if he didn't send the Pragma: no-cache header. Try to comment that line out and see if it helps. A person at the PHP documentation says that IE (also IE7) is having problems with SSL downloads where the above-mentioned header is sent. Since you are using IE, have you tried another browser (Firefox, Opera, Safari, etc.)? http://php.net/header#74876 The bug in IE I mentioned before is explained here: http://support.microsoft.com/kb/812935
-
Argh, damn... Somebody edit the topic - I can't anymore...
-
[SOLVED] How to tell search engines to ignore part of HTML?
Daniel0 replied to Azu's topic in Miscellaneous
Consider this page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title</title> </head> <body> <div>Everybody can see this.</div> <?php $bots = array('googlebot'); // i can't remember what the other ones are called if(!in_array($_SERVER['HTTP_USER_AGENT'], $bots)) { echo <<<EOF <div>You are not a known bot so you are allowed to view this as well.</div> EOF; } ?> <div>Everybody can see this as well.</div> </body> </html> In that way you can control what the bots should and shouldn't see (i.e. "blocking" text). -
No, they have to download the code in order for the browser to be able to interpret it. Everything you place on your page (HTML, CSS, Javascript, images etc.) is downloaded by the user to their cache.
-
Why do you post separate topics for all parts of your site?
-
No it isn't. It's full of table tags. View-source Tables or not, it still can't be pure CSS. (X)HTML is needed as well... -- It looks ok, but you should have a more consistent layout throughout your entire site. Main site, forums and blogs all use different layouts. If you enter your store/services section, then I see no link back to the main page.
-
[SOLVED] How to tell search engines to ignore part of HTML?
Daniel0 replied to Azu's topic in Miscellaneous
You could use PHP to determine if the HTTP_USER_AGENT is a known bot (e.g. "googlebot"). If it is, then simply don't output it. -
Your search button looks a bit misplaced in Firefox.
-
This doesn't fix your proble, but instead of $line1="ID\tProduct\tColor\tSales\t"; $line2="1\tPrinter\tGrey\t13\t"; $line3="2\tCD\tBlue\t15\t"; $line4="3\tDVD\tRed\t7\t"; $line5="4\tMonitor\tGreen\t4\t"; $line6="5\tTelephone\tBlack\t2\t"; $data="$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n"; why not just do this: $data = <<<EOF ID Product Color Sales 1 Printer Grey 13 2 CD Blue 15 3 DVD Red 7 4 Monitor Green 4 5 Telephone Black 2 EOF;
-
Would you then explain to me how you would keep the user logged in even AFTER they've closed the browser? That can only be done using cookies. Besides, how can you say that all PHP developers prefer sessions?
-
Generally, you shouldn't rely on data which users can manipulate themselves (i.e. data which come from them).
-
/templates/--js/blah.js if your index.php is in /. If you require(_once) a file, then you don't instruct the browser to get the things there, you include the contents of that file into the current script before it is output.