Jump to content

drisate

Members
  • Posts

    805
  • Joined

  • Last visited

Everything posted by drisate

  1. Hey guys i am using a global filter on my $_POST function filter($str){return htmlentities($str, ENT_QUOTES);} $_POST = array_map('filter', $_POST); It helps me encode the stuff into the database. It works great on all my fields exept my arrays ... Ex: fields like this <input type="text" name="name[]" size="20"> breaks Any sugestions on gething this global filter working?
  2. Hey guys i need to create a genealogy tree view in PHP and i have no idea on how to get started ... Is there existing class's for that out there? Any recomandations on the "how to"? Maby flash/xml is better? ... I am lost ...
  3. wow thx bro it's working great now :-) It opens a html page replaces the BBCode and seves it <?php $file = $dossier_cam_autres_fichiers.'/'.nomValide($_FILES['fichierhtml']['name']); // Ouvre un fichier pour lire un contenu existant $current = file_get_contents($file); // on replace le BBCODE function my_replace($m){ static $i = 0; $id=md5($i++); $m[1] = preg_replace('/\[titre\](.*?)\[\/titre\]/s', '<a href="#" onclick="showhide(\''.$id.'\'); return(false);">\1</a>', $m[1]); $m[1] = preg_replace('/\[texte\](.*?)\[\/texte\]/s', '<div style="display: none; border-width:1px;border-style:solid;border-color:#000000;width:100%;" id="'.$id.'"><div style="margin:10px"> \1 </div><div align="right" style="margin:10px"><a href="#'.$id.'" onclick="showhide(\''.$id.'\'); return(false);">Fermer</a></div></div>', $m[1]); return $m[1]; } //first select invisible tag(s) $out = preg_replace_callback('/\s*\[invisible\](.*?)\[\/invisible\]/s', 'my_replace',$current); if ( !strstr($out, "function showhide(id){") ) { $out = '<script> function showhide(id){ if (document.getElementById){ obj = document.getElementById(id); if (obj.style.display == "none"){ obj.style.display = ""; } else { obj.style.display = "none"; } } } </script> '."\n\n".$out; } // Écrit le résultat dans le fichier file_put_contents($file, $out); ?>
  4. Yeah thats how i would do it. That whay the only thing paypal needs to send your back is the ID of the member when the paiement is done.
  5. Well it all depens on what options your gona give them ... but something basic would probably be something like this: table = recipe id, user_id, title, recipe <form method="POST">Title: <input type="text" name="T1" size="20"><br> Recipe: <br> <textarea rows="20" name="S1" cols="48"></textarea><br> <input type="submit" value="Submit" name="B1"></form> INSERT INTO DATABASE <?php if ($_POST){ if ($_POST[title]==""){$err .= "You must provide a title for your recipe<br>";} if ($_POST[recipe]==""){$err .= "Your recipe is empty<br>";} if ($err){ echo $err; }else{ $insert = mysql_query("INSERT INTO recipe (id, user_id, title, recipe)VALUES ('', '$_SESSION[id]', '$_POST[title]', '$_POST[recipe]'") } } ?> SHOW LISTE FOR USER <?php echo '<table border="1" width="100%">'; $select = mysql_query("SELECT * FROM recipe WHERE user_id='$_SESSION[id]'") or die(mysql_error()); while ($recipe = mysql_fetch_array($select)) { echo "<tr><td>$recipe[title]</td></tr>"; } echo '</table>'; ?> Those are just basic exemples. You need to sanitize your stuff but i hope thats the kick you were asking for. Have fun and learn a lot :-)
  6. Put the county inside a session start all your pages with session_start(); Then innitialize the session when the visitor uses the search Ex: $_SESSION[county] = $_POST[county]; Then evry time you need the county var you use the $_SESSION[county] As long as you start your PHP page with session_start(); the var will be available
  7. thanks sasa thats almost what i need What i need to do in replace the [titre] part into a link like this: <a href="#" onclick="showhide('$id'); return(false);">Title sample 1</a> The $id could be a md5 version of the title + a random number between 1 and 99999 added in case theres more then one same title Then i need to replace the [texte] part into this: <div style="display: none;" id="$id"> Texte sample 1 </div> The $id needs to be the same for both the title and the texte. Then i take the new file content and replace the existing content with the new version using file_put_contents($file, $current); 1. Problem is there can be more then one replace to do in the $current string. 2. Once i did get the $var1 and $var2 extracted and changed how do i put it back in $content? I am pretty sure preg_match_all is not what i need but your the expert lol Here my code: <?php // $file = $dossier_cam_autres_fichiers.'/'.nomValide($_FILES['fichierhtml']['name']); // Open up the file and read the content // $current = file_get_contents($file); // SAMPLE CODE $current = '[invisible] [titre]Title sample 1[/titre] [texte]Texte sample 1[/texte] [/invisible] [invisible] [titre]Title sample 2[/titre] [texte]Texte sample 2[/texte] [/invisible] [invisible] [titre]Title sample 3[/titre] [texte]Texte sample 3[/texte] [/invisible]'; //first select invisible tag(s) preg_match_all('/\[invisible\](.*?)\[\/invisible\]/s',$current,$out); if(count($out[1]) > 0){ $out = implode('', $out[1]); // put all invisible tags together preg_match('/\[titre\](.*?)\[\/titre\]/s', $out, $out1); // extract var 1 $var1 = '<a href="#" onclick="showhide(\''.md5($out1[1]).'\'); return(false);">'.$out1[1].'</a>'; preg_match('/\[texte\](.*?)\[\/texte\]/s', $out, $out1); $var2 = '<div style="display: none;" id="'.md5($out1[1]).'">'.$out1[1].'</div>'; } // How the hell do i put back those vars into the $current >.< echo $current; // Put the result back into the file // file_put_contents($file, $current); ?>
  8. Hey guys i need help. I am a newbie in regex and i need to extract 2 vars from a string that contains the following.: [invisible] [titre]$var1[/titre] [texte]$var2[/texte] [/invisible] I need to point out that the string contains more [titre] and [texte] tags that are part of diffrent groups than [invisible]. And one more thing, the [invisible] tag can occure more that one time. thx in advance ;-)
  9. What if i do something like this at the end function delete_photo_tmp (){ $myDirectory = opendir("."); while($entryName = readdir($myDirectory)) { $dirArray[] = $entryName; } closedir($myDirectory); $indexCount = count($dirArray); sort($dirArray); for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files if ( strstr($dirArray[$index], "Ressource id #") ) { unlink("$dirArray[$index]"); } } } }
  10. No sure i will be able to use the same function 4 times if the tmp file is not there anymore right?
  11. Here's my code function photo($image, $largeur_maximum, $destination){ $autorises = 'gifjpegjpgpngGIFJPEGJPGPNG'; $extension = explode('.', $destination); $extension = strtolower($extension[sizeof($extension) - 1]); if (ereg($extension, $autorises)) { $dimensions = getimagesize($image); $largeur_actuelle = $dimensions[0]; $hauteur_actuelle = $dimensions[1]; if ($largeur_maximum == "original") { $nouvelle_largeur = $dimensions[0]; $nouvelle_hauteur = $dimensions[1]; } else { if ($largeur_actuelle > $largeur_maximum) { $nouvelle_largeur = $largeur_maximum; $nouvelle_hauteur = $hauteur_actuelle / ($largeur_actuelle / $largeur_maximum); } else { $nouvelle_largeur = $dimensions[0]; $nouvelle_hauteur = $dimensions[1]; } } if ($extension == 'jpg' || $extension == 'jpeg') { $image_p = imagecreatetruecolor($nouvelle_largeur, $nouvelle_hauteur); $image = imagecreatefromjpeg($image); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nouvelle_largeur, $nouvelle_hauteur, $largeur_actuelle, $hauteur_actuelle); imagejpeg($image_p, $image); } else if ($extension == 'gif') { $image_p = imagecreatetruecolor($nouvelle_largeur, $nouvelle_hauteur); $image = imagecreatefromgif($image); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nouvelle_largeur, $nouvelle_hauteur, $largeur_actuelle, $hauteur_actuelle); imagegif($image_p, $image); } else if ($extension == 'png') { $wm = imagecreatefrompng($image); //Position du WM sur l'image finale $positionx = 0; $positiony = 0; //Calcul de l'image du watermark $largeurW = imagesx($wm); $hauteurW = imagesy($wm); //Si l'image source est plus large que celle du WM, on effectue la mise en place du WM if ($largeurSrc > $largeurW) { # Création de l'image finale aux dimensions de l'image qui va accueillir le WM $final = imagecreatetruecolor($largeurSrc, $hauteurSrc); # configuration du canal alpha pour le WM imagealphablending($wm, false); imagesavealpha($wm, true); # Ajout du watermark imagecopyresampled($final, $wm, $positionx, $positiony, 0, 0, $largeurW, $hauteurW, $largeurW, $hauteurW); # Pour ajouter d'autre photo par dessus, procéder de la meme façon # affichage de l'image finale header("Content-type: image/png"); imagepng($image); } } copy($image, $destination); } } when i wana upload a file i simply do this: $rand = rand("1000", "90000") . "-"; $name = $rand . nomValide($_FILES['image']['name']); photo($_FILES['image']['tmp_name'],$media_small_whidth,'../'.$media_small.$name); photo($_FILES['image']['tmp_name'],$media_medium_whidth,'../'.$media_medium.$name); photo($_FILES['image']['tmp_name'],$media_medbig_whidth,'../'.$media_medbig.$name); photo($_FILES['image']['tmp_name'],$media_big_whidth,'../'.$media_big.$name); photo($_FILES['image']['tmp_name'],'original','../'.$media_original.$name); This creates 4 version of the same photo with diffrent width + the original format. All versions are used in the site depending of the page.
  12. Hey guys! Everytime i upload something to the server theres a files created called Resource id #10 (number increments after eachj upload) From what i can ubserve, those are the TMP file ... but for somereason it's staying there and piles up and takes out a lot of space. Is there a way to delete them when the upload is finished?
  13. Hey guys i am trying to replace all the links in a var in to something else ... Ex: http://google.com into http://mywebsite.ca?email=XX_EMAIL&nid=XX_ID&dat=http://google.com What i have so fare is function matche($matches){ $url = str_replace('http://', '', $matches[1]); $url = str_replace('www.', '', $url); return 'href="http://maplaza.ca?email=XX_EMAIL&nid=XX_ID&dat='.$url.'"'; } $messages = preg_replace_callback("/href=['\"]([^'\"]+)['\"]/","matche",html_entity_decode($messages)); But for some reason it's not matching any link ... Ex of texte in $messages after html_entity_decode : <table width="100%"> <tbody> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php" target="_blank"> <font face="verdana" color="white" size="2"> Politique de confidentialité</font></a></td> </tr> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php?pageid=147&mod=nousjoindre" target="_blank"> <font face="verdana" color="white" size="2"> Communiquer avec nous</font></a></td> </tr> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php?pageid=158" target="_blank"> <font face="verdana" color="white" size="2"> Annoncer sur mywebsite.ca</font></a></td> </tr> </tbody> </table> As you can see http://mywebsite.ca/index.php?pageid=158 should be transformed into http://mywebsite.ca?email=XX_EMAIL&nid=XX_ID&dat=mywebsite.ca/index.php?pageid=158 Any help would be apreciated...
  14. This is what i tryed so fare but it's not working imgFile.src = 'media/original/' + image_1; if (imgFile.width < 300) { html +='<img src="media/original/' + image_1 + '" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' }else{ html +='<img src="media/medbig/' + image_1 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' }
  15. Thx ... But i have no idea how to programme that. Any help would be welcome
  16. Hey guys i need to check the image size of an image and if it's smaller then 300px large then load the original image ... But i have no idea how to do that in javascript lol this is how i would do it in PHP list($width, $height, $type, $attr) = getimagesize('media/original/'.$list[image1]); if ($width<'300'){ [...] This is my Javascript code if (image_1!== '') { html +='<img src="media/medbig/' + image_1 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' } else if (image_2!== '') { html +='<img src="media/medbig/' + image_2 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' } else if (image_3!== '') { html +='<img src="media/medbig/' + image_3 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' } else if (image_4!== '') { html +='<img src="media/medbig/' + image_4 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' } else if (image_5!== '') { html +='<img src="media/medbig/' + image_5 + '" width="300" style="border: 1px solid black;" id="img_preview_' + id + '"><br><br>' } if media/original/' + image_5 + ' is smaller then 300px large use him in stead of media/medbig/' + image_5 + '
  17. The problem is not making it slide ... the problem is generating the tree. I am gona have exacly teh same problem using the script you just gave but istead of <div> it would be <ul>. Any help on generating this from the array above would be great id 1, parent 0 <div id=1> id 2, parent 1 <div id=2> id 3, parent 2 id 4, parent 2 </div> // id 2 id 5, parent 1<div id=5> id 6, parent 5 </div> // id 5 </div> // id 1
  18. if i bring back the code to the basic the shell whould look like <?php //recursive function that prints categories function generate_menu($parent){ global $menu_array; if ($menu_array){ foreach($menu_array as $key => $value){ if ($value['parent'] == $parent) { generate_menu($key); } } } } ?> Now how can i open and close a div at the good time. id 1, parent 0 <div id=1> id 2, parent 1 <div id=2> id 3, parent 2 id 4, parent 2 </div> // id 2 id 5, parent 1<div id=5> id 6, parent 5 </div> // id 5 </div> // id 1 The div must start before the childs and end after the last child of that level.
  19. Hey guys i am trying to create a page menu with a + and - icon to show or hide the childs This is a screeny of what it should look like: As you can see in this images each section must be expandable ... to do that i need to open a div when the child list starts and close it when it ends. Thats not to complicated to do. But the problem is there can be a unlimited number of categorys in categorys ... so ia m having a hard time closing the div's at the good place ... The hole tree is inside and array that looks like this: Array ( [42] => Array ( [titre1] => Gestions des pages [parent] => 11 [idd] => 42 ) [11] => Array ( [titre1] => Zone de gestion [parent] => 0 [idd] => 11 ) [14] => Array ( [titre1] => HÉBERGEMENT [parent] => 0 [idd] => 14 ) [34] => Array ( [titre1] => François Blaquière [parent] => 17 [idd] => 34 ) [35] => Array ( [titre1] => Joëlle Bergeron [parent] => 17 [idd] => 35 ) [36] => Array ( [titre1] => Patrick Simard [parent] => 17 [idd] => 36 ) [37] => Array ( [titre1] => Florian Siretas [parent] => 17 [idd] => 37 ) [38] => Array ( [titre1] => Valeria Valdes [parent] => 17 [idd] => 38 ) [39] => Array ( [titre1] => Marie-Ève Matte [parent] => 17 [idd] => 39 ) [15] => Array ( [titre1] => Sauvegarde [parent] => 0 [idd] => 15 ) [16] => Array ( [titre1] => Entreprise [parent] => 0 [idd] => 16 ) [17] => Array ( [titre1] => Équipe [parent] => 0 [idd] => 17 ) [18] => Array ( [titre1] => Services [parent] => 0 [idd] => 18 ) [19] => Array ( [titre1] => Centre de données [parent] => 0 [idd] => 19 ) [20] => Array ( [titre1] => Aide aux utilisateurs [parent] => 0 [idd] => 20 ) [21] => Array ( [titre1] => La configuration de votre courriel. [parent] => 20 [idd] => 21 ) [23] => Array ( [titre1] => Configuration de Outlook Express [parent] => 23 [idd] => 23 ) [24] => Array ( [titre1] => Configuration de Outlook 2003 [parent] => 21 [idd] => 24 ) [25] => Array ( [titre1] => Configuration de Outlook 2007 [parent] => 21 [idd] => 25 ) [40] => Array ( [titre1] => Site Internet [parent] => 26 [idd] => 40 ) [26] => Array ( [titre1] => Accueil [parent] => 0 [idd] => 26 ) [43] => Array ( [titre1] => Infolettre [parent] => 11 [idd] => 43 ) [45] => Array ( [titre1] => Site Internet [parent] => 26 [idd] => 45 ) [46] => Array ( [titre1] => Site Internet [parent] => 26 [idd] => 46 ) [47] => Array ( [titre1] => Site Internet [parent] => 26 [idd] => 47 ) [48] => Array ( [titre1] => Site Internet [parent] => 26 [idd] => 48 ) [50] => Array ( [titre1] => Téléchargement [parent] => 0 [idd] => 50 ) [51] => Array ( [titre1] => Skype [parent] => 50 [idd] => 51 ) [52] => Array ( [titre1] => TeamViewer [parent] => 50 [idd] => 52 ) I tryed doing this ... but it's not working. The div's are not closed so when you click on a + icone the hole page colapses <?php //recursive function that prints categories as a nested html unorderd list function generate_menu($parent, $count=0, $level=0, $parent_list){ if (!isset ($parent_list)){$parent_list = array();} if ($count==""){$count=0;} global $menu_array; echo '<div style="width:750px" align="center">'; if ($menu_array){ foreach($menu_array as $key => $value) { $parent_list[parent][] = $value['parent']; if ($value['parent'] == $parent) { $check = @current(@mysql_fetch_assoc(@mysql_query("SELECT count(id) FROM page_categ WHERE parent = '$value[idd]'"))); if ($parent=="0"){ $color = "#656D80"; }else{ $color = "#e8e8e8"; $level = check_level($value['idd'], '0'); unset($level_i); $i = 0; while ($i <= $level) { $level_i .= '<img border="0" src="images/icon4.png">'; $i++; } $level_i .= '<img border="0" src="images/icon1.png">'; } if ($check and $value['parent']!="0"){ $color="#CDCDCD"; } if (!$value['titre1']){$value['titre1']="Aucun titre";} //echo $totals[$value[idd]]; print ('<table style="BORDER-COLLAPSE: collapse" id="table2" border="0" cellspacing="3" bordercolor="#111111" cellpadding="3" width="100%"> <tr class="eg-bar"> <td style="font-family: verdana; font-weight: normal; font-size: 11px; border-top: 1px solid; border-bottom: medium none" bgcolor="'.$color.'" width="70%" colspan="2">'.$level_i.'<font color="#FFFFFF">'); if ($check and $value['parent']=="0"){ echo '<span id="'.alpharizer($value[idd]).'-title" class="iconspan"><img src="images/iconplusblanc.png" width="11" height="11" /></span>'; }else{ echo '<img border="0" src="images/icon4.png">'; } print ('</font> <input style="height:16px; font-size:10px;" type="text" name="ordre[]" value="1" size="1"><input type="hidden" name="id[]" value="102"><input type="hidden" name="is[]" value="categ"> <a href="page.php?mod=addmod&id=' . $value['idd'] . '&parent='.$value['parent'].'"> <font color="#FFFFFF">'.$value['titre1'].'</font></a></td> <td style="color: #000000; font-family: verdana; font-weight: normal; font-size: 11px; border-top: 1px solid; border-bottom: medium none" bgcolor="'.$color.'" width="30%" align="right">'); // Si c'est une catégorie principale if ($value['parent']=="0"){ $_add = 'add'; $_del = 'del'; // Si c'est une catégori secondaire }else{ $_add = 'adds'; $_del = 'dels'; } if ($_SESSION[status] <= $value[$_add]) { echo '<a style="height:30px;" href="page.php?mod=addmod&id=' . $value['idd'] . '&ajout=1&parent='.$value['parent'].'"><img alt="Ajouter" src="images/monplus.png" border="0" width="16" height="16"></a> '; } // -> Supression if ($_SESSION[status] <= $value[$_del]) { echo '<a title="Suprimer" href="javascript: confirm_link(\'Vous êtes sur le point de supprimer cette élément de la liste. Ce faisan, vous supprimerait également tout les pages associé à celle-ci! Voulez-vous vraiment continuer?\', \'page.php?mod=del&id=' . $value['idd'] . '\');"><img alt="Suprimer" src="images/delete_16.png" border="0" width="16" height="16"></a> '; } print ('</td> </tr> </table>'); $id_f = alpharizer($value[idd]); $id_p = alpharizer($value[parent]); if ($check and !$close){ $parent_list[parent][$id_f][]=1; echo '<div id="'.$id_f.'" class="icongroup'.$id_f.'">'; } //echo "<br>".getPar($parent_list, &$parArr, $id_p)." > $check<br>"; if (getPar($parent_list, &$parArr, $id_p) == $check){ echo '</div>'; //echo "<br>CLOSED!<br>"; unset($has_childs); } generate_menu($key, $count++, $level, $parent_list); /*echo '</div><pre>'; print_r($parent_list); echo "</pre>";*/ } } echo '</div>'; }else{ echo "<br><br>Aucune page ajouter a ce jour"; } } ?> The if (getPar($parent_list, &$parArr, $id_p) == $check) part is supose to check how much rows has been printed VS how much row total there should be and if the total is meeted then it prints out the </div>... But it's not working and now i am completly lost lol I guess the hole code above needs to be rethinked. In any case thats not gona work eather because this can also happen: id 1, parent 0 id 2, parent 1 id 3, parent 2 id 4, parent 1 How can i make it do this: id 1, parent 0 <div id=1> id 2, parent 1 <div id=2> id 3, parent 2 id 4, parent 2 id 5, parent 1<div id=5> id 6, parent 5 </div> // id 5 </div> // id 2 </div> // id 1 Any sugestions?
  20. your right lol thx haha
  21. Got it thx guys ;-) function getPar($array, &$parArr, $id) { foreach ( $array as $key => $value ) { if( $value['parent'] == $id) { if ( !isset($parArr[$value['parent']]) || !$parArr[$value['parent']] ) { $parArr[$value['parent']] = 1; } else { $parArr[$value['parent']]++ ; } } } return $parArr[$id]; } echo getPar($menu_array, $parArr, 0);
  22. thanks it's perfect. :-) One last thing. Is there a way to modify that function so it only returns the number i need? Ex: $nb_of_child = getPar($array, &$parArr, 0); // number of childs for id 0
  23. Nope lol i need to count a specefic portion of the array. Ex: id 1 has parent 0 id 2 has parent 1 id 3 has parent 1 id 4 has parent 0 id 5 has parent 4 id 6 has parent 4 id 7 has parent 6 id 8 has parent 6 How can i return 2 for ID 6 (theres 2 child in it) when everything is in 1 big array.
×
×
  • 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.