Jump to content

drisate

Members
  • Posts

    805
  • Joined

  • Last visited

Everything posted by drisate

  1. I did not post my code because it's really off the track ... // INSERT $parrain = 0; $i = 1; $INSERT = mysql_query("INSERT INTO abibtech (id, parrain) VALUES ('', '0')"); while ($i <= 100) { if ($last!=""){$where = "WHERE $last";} $select = mysql_query("SELECT * FROM abibtech $last") or die("<strong>SELECT * FROM abibtech $last</strong><br>".mysql_error()); $i=1; while ($level = mysql_fetch_array($select)) { $INSERT = mysql_query("INSERT INTO abibtech (id, parrain) VALUES ('', '$level[id]')"); $INSERT = mysql_query("INSERT INTO abibtech (id, parrain) VALUES ('', '$level[id]')"); if ($last==""){$last .= " where id!='$level[id]' ";}else{$last .= " or id!='$level[id]' ";} if ($i=="10000"){echo "<h1>FIN</h1>";exit();} echo "$i | "; $i++; } } id parrent 1 0 2 1 3 1 4 2 5 2 6 3 7 3 8 1 9 1 10 2 11 2 12 3 13 3 14 4 15 4 16 5 17 5 18 6 19 6 20 7 21 7 22 1 23 1 [...] i dont get how to loop level by level 100 times (Would be equal to 10.000 members) 0 11 2222 33333333 4444444444444444 [...]
  2. Hey guys i need to generate a table for a multilevel marketing simulation of 10.000 members. It's a bi-level. All i need is a table with id, parrent I am lost with the double loop ...
  3. Hey guys i have a table of pages set up with the possability of inserting pages inside pages. I am trying to make a delete button that would delete every child pages creating an array of page id's. page 1 L page 1.1 L page 1.2 L page 1.3 L page 1.4 page 2 my code looks like this so fare class delete_page { function page($cat_id, $x = ''){ $sql = mysql_query("SELECT * FROM pages WHERE parent='$cat_id' order by id asc"); while ($select = mysql_fetch_assoc($sql)) { $this->x[] = $select['id']; $this->x = $this->page($select['id'], $this->x); } return $this->x; } function get_page($cat_id){ return $this->page($cat_tid); } } $page = new delete_page; $get_array_page = $page->get_page(1); For some reason the above code sends me an array of all the pages in the database instead of returning only the child pages of the ID i inserted in the $get_array_page = $page->get_page(1) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) It should normaly return only page 1 L page 1.1 L page 1.2 L page 1.3 L page 1.4 with out page 2 like this Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) What did i miss?
  4. This is what i got so fare $i = 1; $INSERT = mysql_query("INSERT INTO mtable (id, parrain) VALUES ('', '0')"); while ($i <= 10) { if ($last!=""){$where = "WHERE $last";} $select = mysql_query("SELECT * FROM mtable $last") or die("<strong>SELECT * FROM mtable $last</strong><br>".mysql_error()); $i=1; while ($level = mysql_fetch_array($select)) { $INSERT = mysql_query("INSERT INTO mtable (id, parrain) VALUES ('', '$level[id]')"); $INSERT = mysql_query("INSERT INTO mtable (id, parrain) VALUES ('', '$level[id]')"); if ($last==""){$last .= " where id!='$level[id]' ";}else{$last .= " or id!='$level[id]' ";} if ($i=="10000"){echo "<h1>FIN</h1>";exit();} echo "$i | "; $i++; } } As you can see the loop is not right. $mtable = array( array('id'=>'1','parrain'=>'0'), array('id'=>'2','parrain'=>'1'), array('id'=>'3','parrain'=>'1'), array('id'=>'4','parrain'=>'2'), array('id'=>'5','parrain'=>'2'), array('id'=>'6','parrain'=>'3'), array('id'=>'7','parrain'=>'3'), array('id'=>'8','parrain'=>'1'), array('id'=>'9','parrain'=>'1'), array('id'=>'10','parrain'=>'2'), array('id'=>'11','parrain'=>'2'), array('id'=>'12','parrain'=>'3'), array('id'=>'13','parrain'=>'3'), array('id'=>'14','parrain'=>'4'), array('id'=>'15','parrain'=>'4'), array('id'=>'16','parrain'=>'5'), array('id'=>'17','parrain'=>'5'), array('id'=>'18','parrain'=>'6'), array('id'=>'19','parrain'=>'6'), array('id'=>'20','parrain'=>'7'), array('id'=>'21','parrain'=>'7'), array('id'=>'22','parrain'=>'1'), array('id'=>'23','parrain'=>'1'), array('id'=>'24','parrain'=>'2'), array('id'=>'25','parrain'=>'2'), array('id'=>'26','parrain'=>'3'), array('id'=>'27','parrain'=>'3'), array('id'=>'28','parrain'=>'4'), array('id'=>'29','parrain'=>'4'), array('id'=>'30','parrain'=>'5'), array('id'=>'31','parrain'=>'5'), array('id'=>'32','parrain'=>'6'), array('id'=>'33','parrain'=>'6'), array('id'=>'34','parrain'=>'7'), array('id'=>'35','parrain'=>'7'), array('id'=>'36','parrain'=>'8'), array('id'=>'37','parrain'=>'8'), array('id'=>'38','parrain'=>'9'), array('id'=>'39','parrain'=>'9'), array('id'=>'40','parrain'=>'10'), array('id'=>'41','parrain'=>'10'), array('id'=>'42','parrain'=>'11'), array('id'=>'43','parrain'=>'11'), array('id'=>'44','parrain'=>'12'), array('id'=>'45','parrain'=>'12'), array('id'=>'46','parrain'=>'13'), array('id'=>'47','parrain'=>'13'), array('id'=>'48','parrain'=>'14'), array('id'=>'49','parrain'=>'14'), array('id'=>'50','parrain'=>'15'), array('id'=>'51','parrain'=>'15'), array('id'=>'52','parrain'=>'16'), array('id'=>'53','parrain'=>'16'), array('id'=>'54','parrain'=>'17'), array('id'=>'55','parrain'=>'17'), array('id'=>'56','parrain'=>'18'), array('id'=>'57','parrain'=>'18'), array('id'=>'58','parrain'=>'19'), array('id'=>'59','parrain'=>'19'), array('id'=>'60','parrain'=>'20'), array('id'=>'61','parrain'=>'20'), array('id'=>'62','parrain'=>'21'), array('id'=>'63','parrain'=>'21') );
  5. Hey guys ;-) I got a client that asked me today to create him an MLM type website. The first part of my work would be to test if there system works so I need to run a full demo of the multilevel structure. The MLM structure works as follow: 1 person finds 2 members and they then find 2 more each and so on until we reach 100 level deep. If i got this right, At level 5 there will be 25 members At level 10 there will be 100 members At level 20 there will be 400 members At level 40 there will be 1.600 members At level 100 there will be 10.000 members So at the end of the demo there should be 10k members inserted into the table The table looks like this: id, parent, level, under Parent is the ID of the guy that recruited him, level is the level that guy is at (level 1, 2 , 3, 4 or 5) and under is the number of people under him. I need to run a script that will insert all the data into that table so that we can run some test on the liability of the project so we can set the rates right. At first I thought it would be a piece of cake ... but when I started I found out very fast that populating the MLM network 5 level deep is gona be tricky ... my first attempt gave me a result that looks like this: |0| |1|2| |x|x|3|4| x|x|x|x|x|x|5|6| As you can see the script only grab the last id then adds 2 new members then uses the last one as the parent and starts over ... So my script is useless and I did not figer out how to do everything in 1 step ... Any help would be appreciated.
  6. Hey guys i need to find a way to return all the phrases a certain word is found in. Ex: $str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In facilisis faucibus vehicula. Praesent fermentum odio at dolor semper rutrum. Etiam pretium, diam ac mattis vehicula, dui ipsum congue ipsum, in sodales neque libero sit amet lorem. Morbi ac neque nec arcu feugiat convallis. Praesent quis diam a libero varius ipsum elementum."; $phrases = find_phrase($str, "ipsum"); $phrases would then output an array like this: $phrases[0] = Lorem ipsum dolor sit amet, consectetur adipiscing elit. $phrases[1] = Etiam pretium, diam ac mattis vehicula, dui ipsum congue ipsum, in sodales neque libero sit amet lorem. $phrases[2] = Praesent quis diam a libero varius ipsum elementum. How would the find_phrase function be build to achieve that?
  7. Yeah worked great thx playful :-)
  8. Hey guys i have a small code that replaces all the links in a string. It works great ... but i just noticed it also replaces the mailto witch causes problems My regex looks like this #href=['|\"](.+?)['|\"]# I need to modify it so mailto links are not replaced href="mailto:hello@domail.com" While every othe forms of link remains replaced. function matche($matches){ $url = str_replace('http://', '', $matches[1]); $url = str_replace('www.', '', $url); return 'href="$domain?email=XX_EMAIL&nid=XX_ID&redirect='.base64_encode($url).'"'; } $messages = preg_replace_callback("#href=['|\"](.+?)['|\"]#","matche",html_decode($messages));
  9. Thx i found the solution #href=['|\"](.+?)['|\"]#
  10. Hey guys i am trying to search all href in a string and add someting in front so i can catch some stats before i redirect the user. For exemple : href="http://twitter.com" Should be changed into: http://test.ca?dat='.urlencode("http://twitter.com").' But i can't get it to work ... so what i got so fare is <?php $str = "<a target='_blank' href='http://twitter.com'>TEST 1</a> <a target='_blank' href='http://twitter.com'>TEST 2</a>"; $str .= ' <a href="http://twitter.com">TEST 1</a> <a href="http://twitter.com">TEST 2</a>'; function matche($matches){ $url = str_replace('http://', '', $matches[1]); $url = str_replace('www.', '', $url); return 'href="http://test.ca?email=XX_EMAIL&nid=XX_ID&dat='.urlencode($url).'"'; } echo preg_replace_callback("/href=['\"]([.*]+)['\"]/","matche",$str); ?>
  11. command was good ... i had a patch problem thx anyway ;-)
  12. Hey guys i am trying to create a small script using exec() to convert PDF files into images ... The script worked well in the past and for some reasons it staped working. exec('"C:\\Program Files\\ImageMagick-6.7.1-Q16\\convert.exe" -verbose -density 150 D:\\Inetpub\\www.goulet.ca\\Pub\\Web\\new\\media\\other\\'.$value.' -quality 100 -sharpen 0x1.0 D:\\Inetpub\\www.goulet.ca\\Pub\\Web\\new\\media\\pdf_flipbook\\'.$value.'\\img.png', $out); the $out var returns an empty array
  13. Ths is what i have in my httpd.conf file <Directory "/"> Options +ExecCGI +FollowSymLinks -Includes +IncludesNOEXEC +Indexes -MultiViews +SymLinksIfOwnerMatch AllowOverride All </Directory>
  14. Hey guys i recently migrated 304 websites from my plesk server (Apache 2.2.3, PHP 5.1.6) to my Cpanel server (Apache 2.0.64, PHP 5.2.9) and i got a strange error with a few website that use to work fine ... What i understand is that those websites has flash plugins using XML files to load in the data. Now the problem is that the webmasters used an htaccess hack to rander the XML files as if it was a PHP file using this line of code: AddType application/x-httpd-php .php .xml The problem is that for some reason this line of code stoped working and the PHP is put up in clear texte inside the XML file causing the flash plugin to crash. At first i thought it was a missing apache module. So i installed Mime Magic but that did not change a thing. An other weird thing abbout this is that the line AddType code is not returning a server error 500 ... Any help would be appreciated. Tx :-)
  15. Yup get all the data inside an array then sort it using the php array sorting functions asort() ksort() sort() [...]
  16. It worked using the IP adresse instead of using the domain name ... weird ! ... Anybody has a clue?
  17. I am having a very weird problem ... i am trying to check if a remote images existe ou not. I am using this code function url_exists($url) { $header_response = get_headers($url, 1); if ( strpos( $header_response[0], "404" ) !== false ){ return false; }else{ return true; } } but it returns: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution I cant seem to be able to find anywhere a way to fix this issue ... I tryed all sorts of difrent functions on the web an none seems to work so there must be something wrong with the server ... Ex: the following image needs to be fetched http://mls.cameleonmedia.info/SIA/MT8603541.jpg
  18. Hey guys i was wandering if somebody could help me create a script that would transform an HTML string into a PNG with transparent background in order to protect the tutorial from being copied. String would look like this $html = '<b>Hello world</b><br><u>Tis is a test</u>';
  19. Hey guys i have a message thats has been encoded with a private key. On my side, i have a pubkey.pem file but i have no idea how to convert the unreadble string into something understandble. Also, i have no idea what the encryption is ... i attached the public key to this message. I woud like to know if somebody here would be able to point me in the right direction in order to be able to decrypt the encoded string. Also, this will be a one time thing so lets keep stuff as simple as possible lol Thx in advance :-) [attachment deleted by admin]
  20. drisate

    eval()

    Hey guys i am currently playing arround with a vbulletin installation. I wanted to add some PHP code into a template so i did this $testing = '<table class="tborder" width="100%" align="center" border="0" cellpadding="6" cellspacing="1"> <tr> <td class="tcat" width="50%">Informations challenge</td> <td class="tcat" width="50%">Informations participation</td> </tr> <tr valign="top"> <td class="panelsurround" align="center"> <div class="panel"> <div align="left">xxx</div> </div> </td> <td class="panelsurround" align="center"> <div class="panel"> <div align="left"> <div class="fieldset"> xxx</div> </div> </div> </td> </tr> </table>'; $tt = str_replace('[allo]', $testing, fetch_template($templatename)); eval('print_output("'.$tt.'");'); and now i get a Parse error: syntax error, unexpected T_STRING in public_html/forum/member.php(831) : eval()'d code on line 252 The original string looked like this eval('print_output("' . fetch_template($templatename) . '");'); I juste wanted to replace [allo] with some new code ... strange thing is if i remove the $testing var from the STR replace the page loads with out the error $tt = str_replace('[allo]', '', fetch_template($templatename)); eval('print_output("'.$tt.'");'); So for some reason it does not like complex HTML? I tryed this and it worked $tt = str_replace('[allo]', '<b>Hello</b>', fetch_template($templatename)); eval('print_output("'.$tt.'");'); So why the hell does my $testing var return that error lol
  21. Ths it's not working but thats the start i needed to get the rest done =) thank you very much!
  22. This si exacly what i need but i need it in PHP <script type="text/javascript"> function wsFTP_decoder(in_string) { my_password = in_string.substring(37, in_string.length); var x = ""; for (var i = 0; i < my_password.length / 2; i++) { document.forms[0].decoded_entry.value = ""; var my_character = my_password.substring(i * 2, i * 2 + 2); var my_parsed = in_string.substring(5 + i, 6 + i); var my_clear_txt = parseInt("0x" + my_character) - i - 1 - ((47 + parseInt("0x" + my_parsed)) % 57); x = x + String.fromCharCode(my_clear_txt); document.forms[0].decoded_entry.value = x; } } </script>
  23. Hey guys i need to create a php function that will decrypt a hex string that looks like this: V8384FFD0CCE1B5FABBDBD6A2B584EAAEA4999B9B7A777FAA should return leadplus This is what i have so fare function hex_str($hex){ $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2){ $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } But it's not returning the good string at all! 8OýÎ_«½½j+XNªêI™¹·§wú Help would be very appreciated
  24. I am pretty confident this one should work ... but it's not. I took it from an other script <?php $outImg = imagecreatetruecolor ($outWidth, $outHeight); // Load src image switch($srcType) { case "png": $srcImg = imagecreatefrompng($uri); $blending = false; break; case "gif": $srcImg = imagecreatefromgif($uri); $blending = true; break; case "jpeg": $srcImg = imagecreatefromjpeg($uri); break; default: diewith("unsupported file type '$uri'"); }; // preserve transparency for PNG and GIF images if ($srcType == 'png' || $srcType == 'gif'){ // allocate a color for thumbnail $background = imagecolorallocate($outImg, 0, 0, 0); // define a color as transparent imagecolortransparent($outImg, $background); // set the blending mode for thumbnail imagealphablending($outImg, $blending); // set the flag to save alpha channel imagesavealpha($outImg, true); } // Resize image imagecopyresampled($outImg, $srcImg, 0, 0, 0, 0, $outWidth, $outHeight, $srcWidth, $srcHeight); ?>
×
×
  • 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.