Jump to content

drisate

Members
  • Posts

    805
  • Joined

  • Last visited

Everything posted by drisate

  1. Well it save the date like that because thats how it has been inserted ... if you wish to break down the date your can do it like this: $date = explode ('-', $date); $year = $date[0]; $month = $date[1]; $day = $date[2]; (assuming the month was parameter 2 ...
  2. I created a comment code 2 years ago ... it's a very easy to use code. Heres what i did. comment.php <?php /** * @author Drisate * @copyright 2009 */ // Delete comment if ($_GET[action]=="del"){ $add = mysql_query("DELETE FROM comment WHERE id='$_GET[cid]'") or die(mysql_error()); print ('<table id="delete" class="tborder" id="post1501" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <tr valign="top"> <td class="alt2" align="middle" width="100%" bgcolor="#1D1D1D"> <p><b><font color="#FFFFFF">Your comment has been delete!</font></b></p> </td> </tr> </table><br>'); } // Add comment if ($_POST[comment]){ $_POST[title] = htmlentities($_POST[title], ENT_QUOTES); $_POST[message] = htmlentities($_POST[message], ENT_QUOTES); $date = date("d-m-Y H:i:s"); if (!$_POST[title]){$cmessage .= "Please provide a title.<br>";} if (!$_POST[message]){$cmessage .= "Please provide a message.<br>";} /* echo "<pre>"; print_r($_POST); echo "</pre>"; */ if (!$cmessage){ if ($_POST[comment]=="Add"){ $add = mysql_query("INSERT INTO comment (id, placeid, catid, userid, date, title, message) VALUES ('', '$placeid', '$catid', '$bbuserinfo[userid]', '$date', '$_POST[title]', '$_POST[message]')") or die(mysql_error()); $al = "Your comment was added!"; unset($_POST); unset($_GET[action]); } if ($_POST[comment]=="Modify"){ $add = mysql_query("UPDATE comment SET title='$_POST[title]', message='$_POST[message]' WHERE id='$_GET[cid]'") or die(mysql_error()); $al = "Your comment was modifyed!"; unset($_POST); unset($_GET[action]); } print ('<table class="tborder" id="post1501" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <tr valign="top"> <td class="alt2" align="middle" width="100%" bgcolor="#1D1D1D"> <p><b><font color="#FFFFFF">'.$al.'</font></b></p> </td> </tr> </table><br>'); } } // See comments $count = @current(@mysql_fetch_assoc(@mysql_query("SELECT count(id) FROM comment where placeid='$placeid' and catid='$catid'"))); if ($count){ print ('<table class="tborder" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <thead> <tr> <td class="tcat" align="left" width="100%">Posted comments</td> </tr>'); $select = mysql_query("SELECT * FROM comment where placeid='$placeid' and catid='$catid'") or die(mysql_error()); while ($thread = mysql_fetch_array($select)) { unset($tuser); $tuser = @mysql_fetch_assoc(@mysql_query("SELECT * FROM vb_user where userid='$thread[userid]'")); unset($groupe); $groupe = @mysql_fetch_assoc(@mysql_query("SELECT * FROM vb_usergroup where usergroupid='$thread[usergroupid]'")); unset($avatar); $avatar = @mysql_fetch_assoc(@mysql_query("SELECT * FROM vb_customavatar where userid='$thread[userid]'")); print ('<tr> <td id="comment_'.$thread[id].'" class="thead" align="left" width="100%"> <table cellspacing="10" cellpadding="10" width="100%" border="0"> <tr> <td style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif" width="134" align="left" valign="top" rowspan="2"> <div id="edit1500" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 6px; PADDING-TOP: 0px"> <table class="tborder" id="post1500" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <tr valign="top"> <td class="alt2" align="middle" width="175"> <div id="postmenu_1500" state="false" unselectable="true"> <a class="bigusername" href="http://dramis.info/board/member.php?u='.$thread[userid].'">'.$groupe[opentag].$tuser[username].$groupe[closetag].'</a> </div> <div class="smallfont">'.$groupe[opentag].$tuser[usertitle].$groupe[closetag].'</b></div>'); if ($avatar[filename]){ print (' <div class="smallfont"> <br> <a style="color: #c2bfae" href="http://dramis.info/board/member.php?u='.$thread[userid].'"> <img title="'.$tuser[username].'\'s Avatar" height="78" alt="'.$tuser[username].'\'s Avatar" src="http://dramis.info/board/image.php?u='.$thread[userid].'&dateline='.$avatar[dateline].'" width="80" border="0" style="border-width: 0px"></a> </div>'); } print ('</td> </tr> </table> </div> </td> <td style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif" align="left" valign="top"> <font color="#C2BFAE" size="2"><b><u>'.html_entity_decode($thread[title]).'</u><br> <br> </b></font><font color="#FFFFFF" size="2">'.nl2br(html_entity_decode($thread[message])).'</font></td> </tr>'); if ($thread[userid]==$bbuserinfo['userid']){ print (' <tr> <td style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif" align="right" valign="bottom" height="10"> <b><font color="#C2BFAE"><a href="'.$pagepath.'&action=mod&cid='.$thread[id].'#edit">[Edit]</a> <a href="'.$pagepath.'&action=del&cid='.$thread[id].'#delete">[Delete]</a></font></b></td> </tr>'); } print ('</table> </td> </tr> <tr> <td align="left" width="100%" height="1" bgcolor="#3B3B3B"></td> </tr>'); } print ('</thead> </table><br>'); } // Post comment if ($bbuserinfo['userid']!=0){ if ($cmessage){ print ('<table class="tborder" id="post1501" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <tr valign="top"> <td class="alt2" align="middle" width="100%" bgcolor="#1D1D1D"> <p align="left"><font color="#FF0000">OUPS!<br> '.$cmessage.'</font></p> </td> </tr> </table><br>'); } if ($_GET[action]=="mod"){ $_POST = @mysql_fetch_assoc(@mysql_query("SELECT * FROM comment where id='$_GET[cid]' ")); }else{ if (!$_POST[title]){ $_POST[title] = $dtitle; } } print ('<table class="tborder" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <thead> <tr> <td id="edit" class="tcat" align="left" width="100%">'); if ($_GET[action]=="add" or $_GET[action]==""){echo "Post your comment!";}else{echo "Modify your comment!";} print('</td> </tr> <tr> <td class="thead" align="left" width="100%"> <table cellspacing="10" cellpadding="10" width="100%" border="0"> <tr> <form method="POST" action="'.$pagepath.'&cid='.$_GET[cid].'#comment_'.$_GET[cid].'"> <td style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif"> <b><font color="#FFFFFF">Subject:<br> <input type="text" name="title" style="width:50%" value="'.html_entity_decode($_POST[title]).'"></font></b></td> </tr> </table> <table cellspacing="10" cellpadding="10" width="100%" border="0"> <tr> <td style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif"> <textarea rows="5" name="message" style="width:100%;" cols="20">'.html_entity_decode($_POST[message]).'</textarea><br> <br> <input type="submit" value="'); if ($_GET[action]=="mod"){echo "Modify";}else{echo "Add";} print('" name="comment"> <input type="reset" value="Reset" name="B4"> </td> </form> </tr> </table> </td> </tr> </thead> </table>'); }else{ print ('<table class="tborder" id="post1501" cellspacing="0" cellpadding="6" width="100%" align="center" border="0"> <tr valign="top"> <td class="alt2" align="middle" width="100%" bgcolor="#1D1D1D"> <p align="left"><font color="#FF0000">You must loggin to post/reply a comment! If you do not have an account you can create one even if your not part of the Dramis Consortium. Fallow this <a href="board/register.php">link</a>.</font></p> </td> </tr> </table>'); } ?> SQL CREATE TABLE IF NOT EXISTS `comment` ( `id` int(11) NOT NULL auto_increment, `placeid` varchar(255) NOT NULL, `catid` int(11) NOT NULL, `userid` int(11) NOT NULL, `date` varchar(255) NOT NULL, `title` varchar(255) NOT NULL, `message` longtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; and you call the comment systeme where ever you need it like this: $placeid = "23"; $catid = "news"; $pagepath = "index.php"; $dtitle = "RE: Hello world"; include ("comment.php"); $placeid is the ID or the name of the category Ex: News, Download, Article [...] Reason for this is if you use the code in a lot of difrent places you might end up with the same ID for a download and a news so this is just a way to make sure ID 23 for the download is not merged with ID 23 for the news $catid is the ID that tranks where the comment is posted ... Ex: the id of the article or the ID of the download or what ever $pagepath is the current page URL. Make sure you insert all the URL variables if there is any. Ex: $pagepath = "index.php?mod=tuto&id=$_GET[id]"; $dtitle is the title the comment systeme is gona log with. You can use the title of the news, download or what ever this comment is abbout. Ex: $dtitle = "RE: ".$cpage[titre]; This code is made to meet my requirements so i guess you will need to modify it a little. Have fun ;-)
  3. works perfect! function url_adder($string){ $select = mysql_query("SELECT * FROM rep_membre") or die(mysql_error()); while ($page = mysql_fetch_array($select)) { $ba = @current(@mysql_fetch_assoc(@mysql_query("SELECT batiment FROM numc where numc='$page[numc]'"))); $string = preg_replace('~('.html_entity_decode($page['entreprise']).')(?!(??!</?a[^>]*>).)*</a[^>]*>)(?![^<>]*>)~','<A class="link2" href="index.php?mod=rep&bcode='.$page[numc].'&icode='.$page[id].'&sorter=carte&anchor='.$page[id].'">'.html_entity_decode($page[entreprise]).'</a>',$string); } return $string; } Thx bro! Your da man!
  4. So in anycase, the code needs to check if the keyword is not inside the folowing href=' and ' href=" and " "> and </a> if not proceed with the replace
  5. Yeah no problem let say the keyword is "google" This would be the before: I really love google. you can access <a href="http://google.com">google.com here</a> I need the code to convert the all the google keywords but not the one part of the href and the one inside the a tag In this case only one needs to be converted. The after would look like this: I really love <A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">google</a>. you can access <a href="http://google.com">google.com here</a> My current str_replace code would convert it like this with out filtring out if the given keyword is part of a link url or tag: I really love <A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">google</a>. you can access <a href="http://<A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">google</a>.com"><A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">google</a>.com here</a> The code is used in a lot of places so thats the reson i had it inside a function url_adder($string){ The keywords are provided by a database so i need to loop them all and add the link when a match is found that is not already part of a link.
  6. Well i expect it to convert the key word into a link when the key word is not already part of a link. The str_replace method does not allow the check if the key word is part of a <a href or inside the link tag. so i guess the only way would be in regex
  7. Hey guys i need to be able to find and replace some key words by links in a texte. I made a function that works great but i am having issues when the keyword found is already part of a link ... <?php function url_adder($string){ $select = mysql_query("SELECT * FROM rep_membre") or die(mysql_error()); while ($page = mysql_fetch_array($select)) { $ba = @current(@mysql_fetch_assoc(@mysql_query("SELECT batiment FROM numc where numc='$page[numc]'"))); $string = str_ireplace(html_entity_decode("$page[entreprise]"), '<A class="link2" href="index.php?mod=rep&bcode='.$page[numc].'&icode='.$page[id].'&sorter=carte&anchor='.$page[id].'">'.html_entity_decode($page[entreprise]).'</a>', html_entity_decode("$string")); } return $string; } ?> So let say that the key word is google and that the code code looks like this: I really love <a href="http://www.google.com">Google.com</a>! So once passeg inside the function it would look like this I really love <a href="http://www.<A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">google</a>.com"><A class="link2" href="index.php?mod=rep&bcode=4&icode=5&sorter=carte&anchor=6">Google</a>.com</a>! It's obvious that this causes coding problems hehe
  8. Hey guys i have a converter code i made that is suposed to convert a copy past of data and create a board freindly version. Imput data looks like this: Resources at Colony [1:130:6] (Player 'XISORZ') on 02-28 13:54:19 Metal: 33.361 Crystal: 152.878 Deuterium: 1.361 Energy: 16.728 Activity Activity Activity means that the scanned player has been active on that planet or another player had fleet contact with the planet you scanned. Your espionage report shows abnormalities in the atmosphere of the planet which suggests activity within the last 15 minutes. fleets Large Cargo 108 Solar Satellite 492 Defense Rocket Launcher 8.874 Light Laser 1.559 Heavy Laser 305 Gauss Cannon 46 Ion Cannon 62 Plasma Turret 116 Large Shield Dome 1 Anti-Ballistic Missiles 1 Interplanetary Missiles 7 Chance of counter-espionage: 7 % The output is: INFOS ESP Date: 13:54:19 Player: XISORZ Planet: Colony [1:130:6] RESOURCES Metal: 33.361 Crystal: 152.878 Deuterium: 1.361 Energy: 16.728 FLEET Large Cargo: 108 Solar Satellite: 492 DEFENSES Heavy Laser: 305 Gauss Cannon: 46 Ion Cannon: 62 Plasma Turret: 116 Interplanetary Missiles: 7 ------- Created by DC ESP TOOL V1.2 --------- But as you can see, it's missing data in the DEFENSES section Rocket Launcher 8.874 Light Laser 1.559 Large Shield Dome 1 Anti-Ballistic Missiles 1 I don't get it why they are not picked up ... My code is the folowing: // first we check if the form has been posted if ($_POST[str] or $_GET[url=http://) { if (!$_GET[url]){ if ($_POST[board]=="1"){$theb = "Vbullettin";} if ($_POST[board]=="2"){$theb = "Burning Board";} // We explode each lines $str = explode("\r\n", $_POST["str"]); $linecount = count($str); // Number of lines // We loop the lines $i = 0; while ($i <= $linecount) { // We filter out empty lines $line = str_replace(' ', '', $str[$i]); if ($line != "") { $str[$i] = trim($str[$i]); $str[$i] = str_replace (' ', ' ', $str[$i]); $str[$i] = str_replace (' ', ' ', $str[$i]); if ($line == "fleets") { $html .= '<br><br><font color="DarkOrange" size="3"><b>FLEET</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]FLEET[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]FLEET[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Defense") { $html .= '<br><br><font color="DarkOrange" size="3"><b>DEFENSES</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]DEFENSES[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]DEFENSES[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Building") { $html .= '<br><br><font color="DarkOrange" size="3"><b>BUILDINGS</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]BUILDINGS[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]BUILDINGS[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Research") { $html .= '<br><br><font color="DarkOrange" size="3"><b>RESEARCH</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESEARCH[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESEARCH[/b][/size][/color]' . "\n"; $inc++; } // preg_match_all('/([^0-9\.]+)([0-9\.]+)/is',$str[$i],$output); if (preg_match('/^([a-z]+(?: [a-z]+){0,2}) ([0-9]+)(?: ([a-z]+(?: [a-z]+){0,2}) ([0-9]+))?$/i', $str[$i], $regs1)) { $Weapon1 = $regs1[1]; $Power1 = $regs1[2]; $Weapon2 = $regs1[3]; $Power2 = $regs1[4]; if ($Weapon1) { $html .= '<b>' . $Weapon1 . '</b>: <font color="#FF0000" size="2">' . $Power1 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon1 . '[/b]: [color=red]' . $Power1 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon1 . '[/b]: [color=red]' . $Power1 . '[/color]' . "\n"; } if ($Weapon2) { $html .= '<b>' . $Weapon2 . '</b>: <font color="#FF0000" size="2">' . $Power2 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon2 . '[/b]: [color=red]' . $Power2 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon2 . '[/b]: [color=red]' . $Power2 . '[/color]' . "\n"; } $inc++; } if (preg_match('/(Metal|Deuterium): ([0-9.]+) (Crystal|Energy): ([0-9.]+)/i', $str[$i], $regs2)) { $Weapon3 = $regs2[1]; $Power3 = $regs2[2]; $Weapon4 = $regs2[3]; $Power4 = $regs2[4]; if ($Weapon3) { $html .= '<b>' . $Weapon3 . '</b>: <font color="#FF0000" size="2">' . $Power3 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon3 . '[/b]: [color=red]' . $Power3 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon3 . '[/b]: [color=red]' . $Power3 . '[/color]' . "\n"; } if ($Weapon4) { $html .= '<b>' . $Weapon4 . '</b>: <font color="#FF0000" size="2">' . $Power4 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon4 . '[/b]: [color=red]' . $Power4 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon4 . '[/b]: [color=red]' . $Power4 . '[/color]' . "\n"; } $inc++; } if (preg_match('#Resources at (.+) \[([^\]]+)\] \(Player \'([^\']+)\'\) on [0-9]{2}-[0-9]{2} ((?:[0-9]{2}{2}[0-9]{2})#i', $str[$i], $regs3)) { //if (preg_match('/Resources at (.*) \[([0-9]+:[0-9]+:[0-9]+)\] \(Player \'(.*)\'\) on ([0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})/i', $str[$i], $regs3)) { $nb = "0"; $nb = $_POST[show_planet] + $_POST[show_player] + $_POST[show_coord] + $_POST[show_date]; if ($nb!="0"){ $html .= '<font color="DarkOrange" size="3"><b>INFOS</b></font><br>'; $bbcode[1] .= '[color="DarkOrange"][size="3"][b]INFOS[/b][/size][/color]' . "\n"; $bbcode[2] .= '[color="DarkOrange"][size="3"][b]INFOS[/b][/size][/color]' . "\n"; } $planet = $regs3[1]; $coords = $regs3[2]; $player = $regs3[3]; $date = $regs3[4]; if ($_POST[show_date]){ if ($date) { $html .= '<b>ESP Date</b>: ' . $date . '<br>'; $bbcode[1] .= '[b]ESP Date[/b]: ' . $date . "\n"; $bbcode[2] .= '[b]ESP Date[/b]: ' . $date . "\n"; } } if ($_POST[show_player]){ if ($player) { $html .= '<b>Player</b>: ' . $player . '<br>'; $bbcode[1] .= '[b]Player[/b]: ' . $player . "\n"; $bbcode[2] .= '[b]Player[/b]: ' . $player . "\n"; } } if ($coords) { $tcoords = '[' . $coords . ']'; } if ($_POST[show_planet] or $_POST[show_coords]){ if ($planet) { if ($_POST[show_planet]){$html .= '<b>Planet</b>: ' . $planet . ' ';} if ($_POST[show_coords]){$html .= $tcoords;} $html .= '<br>'; if ($_POST[show_planet]){$bbcode[1] .= '[b]Planet[/b]: ' . $planet . ' ';} if ($_POST[show_coords]){$bbcode[1] .= $tcoords;} $bbcode[1] .= "\n"; if ($_POST[show_planet]){$bbcode[2] .= '[b]Planet[/b]: ' . $planet . ' ';} if ($_POST[show_coords]){$bbcode[2] .= $tcoords;} $bbcode[2] .= "\n"; } } $html .= '<br><br><font color="DarkOrange" size="3"><b>RESOURCES</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESOURCES[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESOURCES[/b][/size][/color]' . "\n"; $inc++; } if (preg_match('/^Chance of counter.*?:\s+(\d+)\s+%\s+$/im', $str[$i], $regs2)) { $counter = $regs2[1]; $html .= '<br><br><center><i>Chance of counter-espionage: <b>' . $counter . '%</b></i></center>'; $bbcode[1] .= "\n\n" . ' [center][i]Chance of counter-espionage: [b]' . $counter . '%[/b][/i][/center] '; $bbcode[2] .= "\n\n" . ' [center][i]Chance of counter-espionage: [b]' . $counter . '%[/b][/i][/center] '; $inc++; } // Line is not empty //echo "Line: $i) ".$str[$i]."<br>"; // debug } $i++; } if ($inc){ $html .= '<br><center>------- <font color="DarkOrange" size="4"><b>Created by <a href="http://dramis.info?mod=esp">DC ESP TOOL V'.$verssion.'</a></font></b> ---------</center>'; $bbcode[1] .= '' . "\n" . ' [center]------- [b][size="4"][color="DarkOrange"]Created by [url="http://http://dramis.info?mod=esp"]DC ESP TOOL V'.$verssion.']) { if (!$_GET[url]){ if ($_POST[board]=="1"){$theb = "Vbullettin";} if ($_POST[board]=="2"){$theb = "Burning Board";} // We explode each lines $str = explode("\r\n", $_POST["str"]); $linecount = count($str); // Number of lines // We loop the lines $i = 0; while ($i <= $linecount) { // We filter out empty lines $line = str_replace(' ', '', $str[$i]); if ($line != "") { $str[$i] = trim($str[$i]); $str[$i] = str_replace (' ', ' ', $str[$i]); $str[$i] = str_replace (' ', ' ', $str[$i]); if ($line == "fleets") { $html .= '<br><br><font color="DarkOrange" size="3"><b>FLEET</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]FLEET[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]FLEET[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Defense") { $html .= '<br><br><font color="DarkOrange" size="3"><b>DEFENSES</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]DEFENSES[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]DEFENSES[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Building") { $html .= '<br><br><font color="DarkOrange" size="3"><b>BUILDINGS</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]BUILDINGS[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]BUILDINGS[/b][/size][/color]' . "\n"; $inc++; } if ($line == "Research") { $html .= '<br><br><font color="DarkOrange" size="3"><b>RESEARCH</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESEARCH[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESEARCH[/b][/size][/color]' . "\n"; $inc++; } // preg_match_all('/([^0-9\.]+)([0-9\.]+)/is',$str[$i],$output); if (preg_match('/^([a-z]+(?: [a-z]+){0,2}) ([0-9]+)(?: ([a-z]+(?: [a-z]+){0,2}) ([0-9]+))?$/i', $str[$i], $regs1)) { $Weapon1 = $regs1[1]; $Power1 = $regs1[2]; $Weapon2 = $regs1[3]; $Power2 = $regs1[4]; if ($Weapon1) { $html .= '<b>' . $Weapon1 . '</b>: <font color="#FF0000" size="2">' . $Power1 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon1 . '[/b]: [color=red]' . $Power1 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon1 . '[/b]: [color=red]' . $Power1 . '[/color]' . "\n"; } if ($Weapon2) { $html .= '<b>' . $Weapon2 . '</b>: <font color="#FF0000" size="2">' . $Power2 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon2 . '[/b]: [color=red]' . $Power2 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon2 . '[/b]: [color=red]' . $Power2 . '[/color]' . "\n"; } $inc++; } if (preg_match('/(Metal|Deuterium): ([0-9.]+) (Crystal|Energy): ([0-9.]+)/i', $str[$i], $regs2)) { $Weapon3 = $regs2[1]; $Power3 = $regs2[2]; $Weapon4 = $regs2[3]; $Power4 = $regs2[4]; if ($Weapon3) { $html .= '<b>' . $Weapon3 . '</b>: <font color="#FF0000" size="2">' . $Power3 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon3 . '[/b]: [color=red]' . $Power3 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon3 . '[/b]: [color=red]' . $Power3 . '[/color]' . "\n"; } if ($Weapon4) { $html .= '<b>' . $Weapon4 . '</b>: <font color="#FF0000" size="2">' . $Power4 . '</font><br>'; $bbcode[1] .= '[b]' . $Weapon4 . '[/b]: [color=red]' . $Power4 . '[/color]' . "\n"; $bbcode[2] .= '[b]' . $Weapon4 . '[/b]: [color=red]' . $Power4 . '[/color]' . "\n"; } $inc++; } if (preg_match('#Resources at (.+) \[([^\]]+)\] \(Player \'([^\']+)\'\) on [0-9]{2}-[0-9]{2} ((?:[0-9]{2}{2}[0-9]{2})#i', $str[$i], $regs3)) { //if (preg_match('/Resources at (.*) \[([0-9]+:[0-9]+:[0-9]+)\] \(Player \'(.*)\'\) on ([0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})/i', $str[$i], $regs3)) { $nb = "0"; $nb = $_POST[show_planet] + $_POST[show_player] + $_POST[show_coord] + $_POST[show_date]; if ($nb!="0"){ $html .= '<font color="DarkOrange" size="3"><b>INFOS</b></font><br>'; $bbcode[1] .= '[color="DarkOrange"][size="3"][b]INFOS[/b][/size][/color]' . "\n"; $bbcode[2] .= '[color="DarkOrange"][size="3"][b]INFOS[/b][/size][/color]' . "\n"; } $planet = $regs3[1]; $coords = $regs3[2]; $player = $regs3[3]; $date = $regs3[4]; if ($_POST[show_date]){ if ($date) { $html .= '<b>ESP Date</b>: ' . $date . '<br>'; $bbcode[1] .= '[b]ESP Date[/b]: ' . $date . "\n"; $bbcode[2] .= '[b]ESP Date[/b]: ' . $date . "\n"; } } if ($_POST[show_player]){ if ($player) { $html .= '<b>Player</b>: ' . $player . '<br>'; $bbcode[1] .= '[b]Player[/b]: ' . $player . "\n"; $bbcode[2] .= '[b]Player[/b]: ' . $player . "\n"; } } if ($coords) { $tcoords = '[' . $coords . ']'; } if ($_POST[show_planet] or $_POST[show_coords]){ if ($planet) { if ($_POST[show_planet]){$html .= '<b>Planet</b>: ' . $planet . ' ';} if ($_POST[show_coords]){$html .= $tcoords;} $html .= '<br>'; if ($_POST[show_planet]){$bbcode[1] .= '[b]Planet[/b]: ' . $planet . ' ';} if ($_POST[show_coords]){$bbcode[1] .= $tcoords;} $bbcode[1] .= "\n"; if ($_POST[show_planet]){$bbcode[2] .= '[b]Planet[/b]: ' . $planet . ' ';} if ($_POST[show_coords]){$bbcode[2] .= $tcoords;} $bbcode[2] .= "\n"; } } $html .= '<br><br><font color="DarkOrange" size="3"><b>RESOURCES</b></font><br>'; $bbcode[1] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESOURCES[/b][/size][/color]' . "\n"; $bbcode[2] .= "\n\n" . '[color="DarkOrange"][size="3"][b]RESOURCES[/b][/size][/color]' . "\n"; $inc++; } if (preg_match('/^Chance of counter.*?:\s+(\d+)\s+%\s+$/im', $str[$i], $regs2)) { $counter = $regs2[1]; $html .= '<br><br><center><i>Chance of counter-espionage: <b>' . $counter . '%</b></i></center>'; $bbcode[1] .= "\n\n" . '[center][i]Chance of counter-espionage: [b]' . $counter . '%[/b][/i][/center] '; $bbcode[2] .= "\n\n" . ' [center][i]Chance of counter-espionage: [b]' . $counter . '%[/b][/i][/center] '; $inc++; } // Line is not empty //echo "Line: $i) ".$str[$i]."<br>"; // debug } $i++; } if ($inc){ $html .= '<br><center>------- <font color="DarkOrange" size="4"><b>Created by <a href="http://dramis.info?mod=esp">DC ESP TOOL V'.$verssion.'</a></font></b> ---------</center>'; $bbcode[1] .= '' . "\n" . ' [center]------- [b][size="4"][color="DarkOrange"]Created by [url=http://"http://http://dramis.info?mod=esp"]DC ESP TOOL V'.$verssion.'[/url][/color][/size][/b] ---------[/center] '; $bbcode[2] .= '' . "\n" . ' [center]------- [b][size="4"][color="DarkOrange"]Created by [url=http://"http://http://dramis.info?mod=esp"]DC ESP TOOL V'.$verssion.'[/url][/color][/size][/b] ---------[/center] '; } }
  9. you can cycle through it by doing this foreach($array as $value){ }
  10. When your SQL is good and all you need is the number of rows theres no pointe doing it in 5 lines when you can just go for it like that. But it always depens on what your building. I was just pointing out that he could also do it like that since his gething troble with mysqli_num_rows($commresult) It may look durty, it may smell bad, but at least it works great hehe But you can do it like you want ;-)
  11. You can also do this to get the number of rows $numrows_comm = current(mysqli_fetch_assoc(mysqli_query("SELECT count(name) FROM comments WEHRE blog_id = " .$row['id']."ORDER BY dateposted;")));
  12. $ref_amt = $member_amt / 100 * 20;
  13. Just add that on top of the index.php page just under the <?php line
  14. The % are special characters that are not alowed inside an URL Ex: spaces = %20 You can use urlencode() and urldecode() They are used when you don't whant some characters in there to breake the var string
  15. You can create a random number like this <?php $rand = rand(10000000, 99999999); $INSERT = mysql_query("INSERT INTO $table (rand) VALUES ($rand) WHERE id='$_SESSION[id]'") or die(mysql_error()); ?>
  16. Theres probably a PHPError. Use this code to show it ini_set('display_errors', "1"); error_reporting(E_ALL & ~ E_NOTICE);
  17. <? function Check_Password($password) { //Makes it easy to implement grammar rules. $password_flaws = array(); $strlen = strlen($password); if($strlen <= 5) $password_flaws[sizeof($password_flaws)] = "too short"; $count_chars = count_chars($password, 3); if(strlen($count_chars) < $strlen / 2) $password_flaws[sizeof($password_flaws)] = "too simple"; //The function returns an empty string if the password is "good". $return_string = ""; $sizeof = sizeof($password_flaws); for($index = 0; $index < $sizeof; $index++) { if($index == 0) $return_string .= "the password is "; if($index == $sizeof - 1 && $sizeof != 1) $return_string .= " and "; //this is in case i have more than 3 sources of error. if($index != 0 && $index != $sizeof - 1) $return_string .= ", "; $return_string .= $password_flaws[$index]; } return($return_string); } ?> You can validate your password this way. Add in there any extra rules you may need. (don't over do it thought)
  18. To redirect to Paypal you can do an URL redirect like this header("location:https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=$paypal&item_name=$name&amount=$amount&currency_code=CAD&notify_url=".urlencode($notify_url)."&lc=EN&custom=$LAST&return=".urlencode($return));
  19. You can do that using cookies or session. You store in there $_SERVER[php_SELF] and $_SERVER[QUERRY_STRING] Then you can use header("location:$_SESSION[path]") or even the meta refresh code.
  20. If it does not show it may be because of a PHP Error. Try adding this: ini_set('display_errors', "1"); error_reporting(E_ALL & ~ E_NOTICE);
  21. The $where var is empty ... theres no limit in the SQL and the vars seems ok ... Unless you post the hole code theres nothing i can do to help at this point ... But if your looking to post X number of images by X number of line you can try this code i made <?php $mypage = "media_image.php?"; // Keep the ? at the end or finish it with & if you already have vars $nb_per_page = 9; $image_folder = "images"; $col = 3; if ($_GET == "") { $num_page = 1; } else { $num_page = $_GET['page']; } $offset = ($num_page - 1) * $nb_per_page; $nb_images = @current(@mysql_fetch_assoc(@mysql_query("SELECT count(id) FROM $DB_IMAGE"))); $re_page = $num_page * $nb_per_page; $ree_page = $re_page - $nb_per_page; $row = 0; // Start of the table print ('<table border="0" cellpadding="3" cellspacing="3" width="100%" id="table1"><tr>'); // Start the loop $select = mysql_query("SELECT * FROM $DB_IMAGE where collectionID=$cat $where ORDER BY $order_by limit $offset, $nb_per_page") or die(mysql_error()); while ($categ_list = mysql_fetch_array($select)) { // Lets show the images print ('<td align="center" valign="top"><img width="200" border="0" src="'.$image_folder.'/' . $categ_list[photo] .'"></td>'); if ($row == $col) { echo '</tr><tr>'; $row = 0; } $row++; } // Close the table echo "</table>"; $maxPage = ceil($nb_images / $nb_per_page); $self = "$mypage"; $nav = ''; for ($page = 1; $page <= $maxPage; $page++) { if ($page == $num_page) { $nav .= " $page "; } else { $nav .= " <a href=\"$self&page=$page\">$page</a> "; } } if ($num_page > 1) { $page = $num_page - 1; $prev = " <a href=\"$self&page=$page\">[Précédant]</a> "; $first = " <a href=\"$self&page=1\">[First page]</a> "; } else { $prev = ' '; $first = ' '; } if ($num_page < $maxPage) { $page = $num_page + 1; $next = " <a href=\"$self&page=$page\">[Next]</a> "; $last = " <a href=\"$self&page=$maxPage\">[Last page]</a> "; } else { $next = ' '; $last = ' '; } if ($re_page >= "$nb_images") { $re_page = "$nb_images"; } // Navigation print ("<center><br>($ree_page to $re_page from $nb_images) Page:<b>$first $prev $nav $next $last</center>"); ?> @Maq, It was only 1 line of code ... i use the [ code ] and [ php ] only when theres more then one line
  22. Whats the $where var? At the end of the page add this line echo "SELECT * FROM $DB_IMAGE where collectionID=$cat $where ORDER BY $order_by"; And post the result here
  23. Yeah it's a lot of code so i attached it to this post (change the upload.php to a .js file. We can't post .js here for some reason. You will also need to add it to the top of PostProb.php to test the form <script type="text/javascript" src="upload.js"></script> [attachment deleted by admin]
  24. Hey guys i am currently building a very complex form for one of my clients. The for has ALOT of imputs and can also generate new one automaticly using javascript. My problem is that come of them returns empty arrays while other works. Is there a maximum or some kind that a form can submit at the time? i made a print_r on the $_POST var and this is what i got (I tooke out all the other arrays but theres a lot more then what i am posting) [...] print ('<tr> <td> <input type="text" size="9" name="styleenc[]" value=""> </td> <td> <input type="text" size="9" name="couleurenc[]" value=""> </td> <td> <input type="text" size="2" name="c_y[]" value=""> </td> <td> <input type="text" size="2" name="c_a_s[]" value=""> </td> <td> <input type="text" size="2" name="c_a_l[]" value=""> </td> <td> <input type="text" size="2" name="c_a_o_s[]" value=""> </td> <td> <input type="text" size="9" name="descenc[]" value=""> <input type="hidden" size="9" name="invisible3[]" value="3"> </td> </tr>'); [...] Array ( [styleenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [couleurenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_y] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_l] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_o_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [descenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [invisible3] => Array ( [0] => 3 [1] => 3 [2] => 3 [3] => 3 [4] => 3 ) [emplacement] => sdcwedf ) They should all have values i don't get it ... the only one that has values is invisible3 that has been manualy specified with value="3"
×
×
  • 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.