Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. $headers .= "From: '$name' <$from>\n";
  2. The carat is a symbol to denote a control character on older systems. Could this just be your editor that your using? if you echo out the field in php code, does it display as a carat?
  3. laffin

    Logs

    You can use wrapper functions as litebearer suggests, very easy, basic and works well. or using 1 & 2 with MySQL trigger functions More Here
  4. $addcomment= (isset($_GET['addComment']) && ($_GET['addComment']=='TRUE')?TRUE:FALSE; or if (isset($_GET['addComment']) && ($_GET['addComment']=='TRUE') $addcomment=TRUE; else $addcomment=FALSE;
  5. some sample code for you <?php $MaxCols=5; $MaxRows=20; $PerTable=($MaxRows*$MaxCols); $items=range(1,$PerTable+rand(1,$PerTable)); $count=count($items); $tables=intval($count/$PerTable)+1; $table=0; while($table<$tables) { echo "<table>".PHP_EOL; for($i=0;$i<$MaxRows;$i++) { echo " <tr>".PHP_EOL; for($j=0;$j<$MaxCols;$j++) { $idx=($PerTable*$table)+($j*$MaxRows)+$i; $contents=(isset($items[$idx]))?$items[$idx]:' '; echo " <td>$contents</td>".PHP_EOL; } echo " </tr>".PHP_EOL; } echo "</table>".PHP_EOL; $table++; } ?>
  6. Yes, it's a good idea to use isset on variables where you are uncertain if it will be available. it's also good for setting default values if(isset($_GET['page']) $page=$_GET['page']; else $page=1; as a simple example
  7. Whether that mail server is on your computer or on a different host.
  8. Set up a variable/constant which tells subscripts they are being called from another script <?php define('IN_PAGE','index'); include('sub.php'); <?php if(!defined('IN_PAGE')) die('can not execute this script directly');
  9. You wont find a simple solution. Since you want html tags, this may break the page on any dangling tags such as: <div name="content">blah blah blah</div> If you require the html tags, You may find a solution using strip tags & strpos to find the character limit, than using simplexml and strpos to find the last block within the character limit
  10. doesnt hide anything, as soon as someone can get a phpinfo(); into the script, the gig is up. and you will be fortunate if they are good guys and advise you of this gaping hole in security. Mpst likely tho, they will be a lookee loo, to see what they can see with your db passwords, and maybe enlist help to alter the database.
  11. Javascript only prevents a refresh from happening, it will not proect against invalid data being sent to the server. there are many tools out there which disable and alter javascript. So it's not a good replacement system to a php script. It works well in conjunction.
  12. why so many variables for toppings? wouldnt it be easier to add in attributes to the toppings? I see this as a lot of extra coding, but it's your code. I think you may need a new perspective on what your trying to accomplish. You never assign topping, when u have 1 array_pop($_SESSION['topping']) to ($topping=array_pop($_SESSION['topping']))
  13. I like them pop up javascript calendars myself. regex for date matching isnt very hard preg_match('@^\d{2}[/-]\d{2}[/-]\d{4}$@',$date);
  14. All those fall within the 3 steps for security Storage Areas, I have seen many ppl who validate a login with a cookie, however since cookies are stored on client side, this makes them very vulnerable to editing. Use a Session base system to authenticate the user. Don't store any sensetive information in a cookie. (Sessions can use built in or one of the custom session handlers out on the net). Its just a matter of not leaving much for the user to alter.
  15. <?php $selected=array('caramel','marshmellows','cherry'); $final=array_pop($selected); $toppings=(count($selected)?(implode(', ',$selected) . ' & '):'') . $final; echo $toppings; ?>
  16. 1. Sanitize external data, so it is inserted into db properly 2. Validate data, so data isnt out of bounds/meets a specification 3. Storage Areas, Beware of Cookies
  17. Here let me help you with some sample code. <?php // Following Section builds a simple database, with sqlite if(!$db=sqlite_open(':memory:')) die('DB Open failure'); sqlite_exec('CREATE TABLE category(id INTEGER PRIMARY KEY, Name TEXT, Parent Integer)',$db); $data =array( 'Family/Events/Birthdays', 'Family/Events/Holidays/Halloween', 'Family/Events/Holidays/Thanksgiving', 'Family/Events/Holidays/Christmas', 'Family/Relatives', 'Friends/Family', 'Friends/Events' ); foreach($data as $tree) { $cats=explode('/',$tree); $Parent=0; foreach($cats as $cat) { $res=sqlite_query($db,'SELECT id FROM category WHERE Name=\''. sqlite_escape_string($cat) .'\' AND Parent='. $Parent); if(sqlite_num_rows($res)) { $Parent=sqlite_fetch_single($res); } else { sqlite_exec($db,$sql='INSERT INTO category (Name,Parent) VALUES (\''. sqlite_escape_string($cat) .'\','. $Parent .')',$err) or die("<br />$err<br />$sql"); $Parent=sqlite_last_insert_rowid($db); } } } // Following section retrieves all categegories into an array to build our breadcrumb info $res=sqlite_query($db,'SELECT * FROM category'); $cats=array(); while($row=sqlite_fetch_array($res,SQLITE_NUM)) { echo print_r($row,true).'<br />'.PHP_EOL; $cats[$row[0]] = array($row[1],$row[2]); } // Following Section builds the the links from node to node info (This is main part you want to understand) $breadcrumbs=array(); foreach($cats as $idx=>$cat) { $bc=array(); $pcat=$cat; $ok=true; do { $bc[]=$pcat; if($pcat[1]) $pcat=$cats[$pcat[1]]; else $ok=FALSE; } while($ok); $breadcrumbs[$idx]=array_reverse($bc); } // Just display results foreach($breadcrumbs as $bc) { $bcc = count($bc); for($i=0;$i<$bcc;$i++) { echo $bc[$i][0]; if(($i+1)<$bcc) echo ' -> '; } echo '<br />'.PHP_EOL; } ?> After the tree is built use a simple serialize/unserialize to create/fetch the file cache. saving your queries and having the breadcrumb info on hand. I would put this routine on your update/add/delete functions. Well good luck on yer project
  18. And here I thought you were trying to do something a lot more complicated as actual inserting elements into an array. Well good luck
  19. I would get rid of the javascript, and stick with a pure php solution. when you have your php solution working than add your javascript. I wrote this routine a number of years ago <?php $teams=array('Alpha','Beta','Gamma','Delta','Epsilon','Zeta','Eta'); define('MY_EOL','<br .>'.PHP_EOL); $round=0; $participants=$teams; while(count($participants)>1) { $round++; // Increment our round Echo 'Round '. $round. MY_EOL; $tables=array(); // Clear our tables $index=0; while(count($tables) < floor(count($participants)/2)) // want an even amount of tables $tables[]=array($participants[$index++],$participants[$index++]); if($index<count($participants))// extra team, add to tables, but no opposing team $tables[]=array($participants[$index++],NULL); $participants=array(); // clear out next round participants foreach($tables as $idx=>$table) { $tbl=$idx+1; echo " Table #{$tbl}: "; if($table[1]===NULL) // extra team advances to next level automatically { echo "{$table[0]} Holdover"; $winner=0; } else { echo "{$table[0]} vs. {$table[1]}"; $winner=rand(0,1); // Generate a winner } echo " - Winner {$table[$winner]}". MY_EOL; $participants[]=$table[$winner]; // Add WInnerto next round } } ?>
  20. Ur missing your WHERE keyword
  21. Breadcrumbs are easy to do, but the systems implemented can be a pain, if you store breadcrumbs in the db, this makes easy retrieval but a pain to update. I had a similar situation, what I opted for was to build dynamically as you did earlier, but used a cache file as well. This proved to be great on a system where I rarely changed the categories, and I could refresh the cache file anytime. So using breadcrumbs in the DB isn't the only solution. And it's far easier to deal with than a complicated update if you decide to move one category to another.
  22. First u need to build a hierarchy. Whether this is stored within the db or u build it dynamically. than u can use this list of ids to pull the articles
  23. Took a quick look... It's nothing really complicated, looks like the ajax is just a validator before the form is processed. When I selected something, click search, disabled javascript and cookies. hit refresh all the content was there, so no underlying sessions or anything. The uri holds yer parameters p=207:1:4398391836116838::NO:RP:: Each parameter is seperated by a ':' u figure those out, than u don't need to post the information, just get the page
  24. Yes, but u said yerself Ajax actually makes the post not the form. So u wud follow the ajax example for posting to which page
×
×
  • 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.