-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
well its should be UK Pounds but i accepts anything lol
-
Okay heres a soultion, not 100% perfect but works well <?php $URLarray = array( "http://uk2.php.net", "http://gfdghdsfghsdgfhsdghj.net", "http://www.phpfreaks.com/" ); echo "<table>\n"; echo " <tr>\n"; echo " <td>\n"; echo "URL"; echo " </td>\n"; echo " <td>\n"; echo "Time"; echo " </td>\n"; echo " </tr>\n"; foreach($URLarray as $URL) { echo " <tr>\n"; $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; if( url_exists($URL) ) { $data = file_get_contents($URL); unset($data);//dump $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $UrlResults[$URL] = array("Access" => true, "Time"=>$totaltime); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "$totaltime seconds."; echo " </td>\n"; }else{ $UrlResults[$URL] = array("Access" => false); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "Failed"; echo " </td>\n"; } echo " </tr>\n"; flush(); } echo "</table>\n"; //Results from loop (if you want) //foreach($UrlResults as $URLs => $Tests) //{ // echo "$URLs: "; // if($Tests['Access']) // { // echo "Works access time:".$Tests['Time']; // }else{ // echo "Failed"; // } // echo "<br />"; //} function url_exists($strURL) { $resURL = curl_init(); curl_setopt($resURL, CURLOPT_URL, $strURL); curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1); curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'readHeader'); curl_setopt($resURL, CURLOPT_FAILONERROR, 1); $x = curl_exec($resURL); $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE); curl_close ($resURL); if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode != 304) { return false; }else{ return true ; } } function readHeader($data) { return $data; } ?> that will be $15 please, Just kidding the flaw is it downloads the html not the images, of course you can remove the $data = file_get_contents($URL); unset($data);//dump code to check the resolved rate instead of page download time, that will also work.. i hope this help
-
last bug i can see if(($totalrows - ($limit * $vpage)) > 0){ $pagenext = $vpage++; echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack?vpage=$pagenext\">NEXT".$limit."</a>"); }else{ to if(($totalrows - ($limit * $vpage)) > 0){ $pagenext = $vpage++; echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack&vpage=$pagenext\">NEXT".$limit."</a>"); }else{
-
[SOLVED] Accessing multiple arrays using foreach
MadTechie replied to kektex's topic in PHP Coding Help
quick example, maybe usless (untested) <?php $data = file_get_contents('http://www.example.com/'); //Find <a> tags preg_match_all('%<a.*</a>%i', $data, $result, PREG_PATTERN_ORDER); $aTags = $result[0]; //Loop through tags foreach($aTags as $aTag) { //find titles if (preg_match('/title=([\s"\'])*(.*?)\1/i', $aTag, $regs)) { $title = $regs[2]; } else { $title = ""; } //find href if (preg_match('/href=([\s"\'])*(.*?)\1/i', $aTag, $regs)) { $href = $regs[2]; } else { $href = ""; } //display results echo "found: $href with the title: $title"; } ?> -
the strange thing is $query_count = "SELECT count(*) FROM cf_users"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); hasn't changed! ok try changing to $query_count = "SELECT count(*) as totalcount FROM cf_users"; $result_count = mysql_query($query_count); $tmp = mysql_fetch_array($result_count); $totalrows = $tmp['totalcount'];
-
[SOLVED] Accessing multiple arrays using foreach
MadTechie replied to kektex's topic in PHP Coding Help
do you have an example of what you want to pull out i assume your looking for a url and pulling out the title, maybe searching for href would be better! -
did he solve it ?, you could of still used that thread.. a few bucks.. humm maybe i would wait for it to be move to the freelance section...
-
found a slight bug do you mean the links not showing ? try the below <?php // display information for each player in a table $link = mysql_connect( "localhost", "ace_ACE", "*****" ); if ( ! $link ) { die( "Couldn't connect to MySQL: ".mysql_error() ); } mysql_select_db( "ace_cf", $link ) or die ( "Couldn't open 'ace_cf': ".mysql_error() ); // workout the page pagination limits etc $limit = 5; $vpage = (int)$_GET['vpage']; $query_count = "SELECT count(*) FROM cf_users"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($vpage)){ $vpage = 1; } $limitvalue = $vpage * $limit - ($limit); $query = "SELECT * FROM cf_users LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } //print "<p>$num_rows people have money</p>\n"; echo '<div id = "attack"> <table align="center" class = "fix"> <tr> <td colspan="4"> <center><b>Players</b></center> </td> </tr> <tr> <td><b>Name</b></td> <td><b>Rank</b></td> <td><b>Race</b></td> <td><b>Money</b></td> </tr> <tr> <td colspan="4"> </td> </tr>'; while ($a_row = mysql_fetch_assoc( $result ) ) { $all_name = stripslashes($a_row['username']); $all_rank = stripslashes($a_row['rank']); $all_race = stripslashes($a_row['race']); $all_money = stripslashes($a_row['money']); // change the players race from a integer into a string if($all_race == 0) { $all_race = "British SAS"; } elseif($all_race == 1) { $all_race = "Navy Seal"; } elseif($all_race == 2) { $all_race = "Russian Spetsnaz"; } elseif($all_race == 3) { $all_race = "Australian SAS"; } echo ' <tr> <td>' . $all_name . '</td> <td>' . $all_rank . '</td> <td>' . $all_race . '</td> <td>$' . $all_money . '</td> </tr>'; } echo '</table>'; echo '<center>'; if($vpage != 1){ $pageprev = $vpage--; echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack&vpage=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $vpage){ echo($i." "); }else{ echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack&vpage=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $vpage){ echo($i." "); }else{ echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack&vpage=$i\">$i</a> "); } } if(($totalrows - ($limit * $vpage)) > 0){ $pagenext = $vpage++; echo("<a href=\"http://www.crikeygames.com.au/conflictingforces/index.php?page=attack?vpage=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); echo '</center>'; echo '</div>'; ?>
-
when looking for the protection remember thats statements like are only true of the system is NOT reversed.. These system have all been hacked. Zend Encoder * SafeGuard 3.6 ionCube up to 6.5 SourceGuardian * phpcipher * codelock * SourceCop (all version, from what i know - useless) unsure of version, i'm sure theirs been a few new releases since i last checked
-
has to be a problem in the code then..
-
i think you want something like this <?php $lines = file("newsadd.txt"); $lines = array_reverse($lines); foreach ($lines as $line) { $pieces = explode("|", $line); if($pieces[5] == "other") { echo htmlspecialchars($line)."<br />\n"; //}else{ // echo ""; } } ?>
-
if allow_url_fopen is on then you need to check allow_url_include
-
IonCube Encoder does not offer any protection against oparray_dumping or oparray disassembly but then again nor does ZendEncoder, its alittle better but with a littel time to can decrypt the opcodes, short and simple, if you give the source to someone they will hack it after X time.. its just how long X takes..
-
the 2 ways i use are #1 a database (easy) #2 many files (one for each language) on option 2, your only need to write the array contents <?php $lang = array('welcome' => 'Welcome to site', 'other_message' => 'Some other message' ); ?> but still its the whole file.. if its a configuration file, then its a bad idea, if its just the language file, then thats fine.. unless its going to happen many times (multiple people opening the file at ones will cause major problems) thats way i asked why they are doing it Personally when i language files, i write one in English and send that to be translated to XYZ languages, if the customer whats to change it themselfs i nomally go for a database.. of course if its a short amount of text then one file is fine, i just put all the arrays into thats file, but the idea is still the same.
-
no idea what you mean.. <?php if($pieces[5] == "other") { echo "other found"; }else{ echo "no other"; } ?>
-
$lang['welcome']= "New data"; mis-read your need to write the whole PHP file again.. kinda bad idea.. a database would be better.. why would you want to do this ?
-
well you could use a JOIN, like this **UNTESTED <?php $pac = mysql_query("select packages.* , res.pac_name as PacName from packages LEFT JOIN reservation AS res ON packages.pac_id = res.pac_id"); while($rows=mysql_fetch_assoc($pac)) { ?> <tr> <td><? echo $rows['Res_id'];?> </td> <td><? echo $rows['check_in'];?> </td> <td><? echo $rows['night_per_stay'];?> </td> <td><? echo $rows['R_no']; ?> </td> <td><? echo $rows['PacName']; ?> </td> <td><? echo $rows['Cid']; ?> </td> </tr> <?php } ?>
-
what are you trying to do ? also <td><? echo $rows['$p']; ?> should be <td><? echo $rows[$p]; ?>
-
as you can add spaces/returns to the word script and it will still run, i have tried to also block that.. requires testing try this <?php $text = ' hello all <script language="javascript"> alert("Goto www.phpfreaks.com"); </script>'; //test2 $text = ' hello all <script language="javascript"> alert("Goto www.phpfreaks.com"); </scr ipt>'; $$text = preg_replace('%<s\s*c\s*r\s*i\s*p\s*t\s*[^>]*>.*(?=\s</s\s*c\s*r\s*i\s*p\s*t\s*[^>]*>)\s</s\s*c\s*r\s*i\s*p\s*t\s*[^>]*>%sim', '', $text); ?>
-
RegEx has LOTS of advantages, the question isn't a bad question but it really all depends on what you want to do. If you don't need fancy matching rules, then explode is fine (in some cases better) but if you need 20 explode's to pull one thing out then regex it probably better! PS: Bad programmer rarely know they are bad, thats what makes them bad.. your probably just inexperanced.. but pratice makes per..... well longer nights and increased the price of coffee and/or red bull