Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Yes it's a short and simplified form of if-then-else. You use it where you want to use either one value or another value. For example, if you are generating html for a checkbox that may or may not be checked $checked_text = ($box_is_checked ? " CHECKED " : ""); Or if you want to set a number to 0 if it's less than 0 $num = ($num < 0 ? 0 : $num);
  2. How does this relate to the topic title? You can try this: $sqlzx = "UPDATE `cf_users`,`cf_users2` SET `cfusers`.`money`= `cfusers`.`money`+ `cfusers2`.`amount_supplydrop`*`cfusers2`.`amount_supplysize` WHERE cfusers.id = cfusers2.id"; Btw, in most cases the quotes aren't needed.
  3. What do you see if you print out each word as it's checked? Do it like this to capture any invisible characters foreach ($words as $word) { print "Checking " . urlencode($word) . "<br>"; if (md5($word) == $string) return $word; else return false; }
  4. Does it work if you try it with a known correct value? Your code that you pm'd me needs the following changes: //end hashcrack function $word = hashcrack($hash); echo $word; If it fails, it will echo nothing. If you want to display something different for failure, take a look at the code in my earlier post in this thread.
  5. You set table to cf_users2 if the column is not found .. but what if it is found?
  6. The function should stop where it stops. The code below is code that demonstrates how to use the function. Put another way, hashcrack() is the function, and the code at the end (with the call to hashcrack()) is the code that uses the function. The code at the end shouldn't be inside the function.
  7. What happens when you run it? Edit: Ok, here's what it should look like: function hashcrack($hash) { $words = str_ireplace(",", " ", file("http://www.site.com/dictionary.txt")); foreach ($words as $word) { $word = trim($word); if (md5($word) == $hash) { return $word; } } return false; } $word = hashcrack($hash); if ($word !== false) { echo "hash $hash matches $word\n"; } else { echo "no matches found\n"; }
  8. Here's a tutorial which has the basic curl example: http://www.higherpass.com/php/Tutorials/Using-Curl-To-Query-Remote-Servers/ Usually you'll want to switch header off and returntransfer on if you want to capture the response and process it.
  9. You don't need the "different" comparison here, because you are not checking against the same list, you are checking against an auxiliary list which serves only to remember which songs you've already seen. For dealing with the "two keys" problem, you can just combine them into a single string using a separator that cannot appear in either string (such as a space, in this case). Here's an example with sample data to show that it works: <?php $newsongs[] = array( 'artist' => 'Tool', 'title' => 'Rosetta Stoned', 'compartist' => 'tool', 'comptitle' => 'rosettastoned', ); $newsongs[] = array( 'artist' => 'Tool', 'title' => '10000 days', 'compartist' => 'tool', 'comptitle' => '10000days', ); $newsongs[] = array( 'artist' => 'Tool', 'title' => 'Rosetta-Stoned', 'compartist' => 'tool', 'comptitle' => 'rosettastoned', ); $seen = array(); foreach ($newsongs as $ns_key => $newsong) { $seen_key = $newsong['compartist'] . ' ' . $newsong['comptitle']; # space cannot occur in either key if ($seen[$seen_key]) { # Seen this one before, nuke it print "Nuking {$newsong['title']} by {$newsong['artist']}<br>\n"; unset($newsongs[$ns_key]); } else { # Not seen before, remember it $seen[$seen_key] = true; } $count++; } var_dump($newsongs); ?>
  10. I think you need to install the additional "binaries" from the download page as well. I'm not sure if you need the non-thread-safe or thread-safe unfortunately. I would try thread-safe first (the top one).
  11. Ok, so the problem is that the forum integration code is altering $_GET['page']. You can work around that by keeping a copy. For example $get_page_copy = $_GET['page'];# <-- at the very top Then inside content.php: $page = $get_page_copy; Better would be to find out why $_GET is being altered.. there's probably a good reason.
  12. That means that curl is not installed (or not enabled). Did you install php and apache as part of a package (and which package?)
  13. You'll need to put it at the top. Since $page is not available at the very top, you can do this instead. print "index.php page = " . $_GET['page'] . "<br>"; That must go before include './config.php' ;
  14. If by "source code" you mean the html output from a php script, then the answer is yes. You can fetch it with curl as a string and print it out, and it can be used to achieve what you would achieve with an iframe. Keep in mind that any delay in fetching the calendar will affect load times for the entire page.
  15. There were two typos <?PHP $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"; $LOGINURL = "http://www.myspace.com/imparanoid000"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$LOGINURL); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); # <-- missing curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); $result = curl_exec($ch); curl_close($ch); echo '<span style="font-size: 12px; font-family: Verdana">'; $pieces = explode("About me:(/span><br/>", $result); $aboutme = $pieces[1]; $pieces = explode("<span class=\"text\"><div style=\"display:none;\">", $aboutme); $aboutme = $pieces[1]; $pieces = explode("</div>", $aboutme); $aboutme = $pieces[0]; $aboutme = str_replace("\r\n", "<br>", $aboutme); echo "<b><u>Yo</u></b>".$aboutme."<br>" ; # <_ missing ?>
  16. Here's a method I use all the time for duplicate removal. $array_with_dups = array(1, 5, 3, 6, 5, 3, 5); $seen = array(); foreach ($array_with_dups as $key => $item) { if ($seen[$item]) { # Already seen this one unset($array_with_dups[$key]); } else { $seen[$item] = true; } } var_dump($array_with_dups); # No longer with dups The result will have all duplicates removed. If you want to check for duplicateness by another condition, such as $item['name'], then you should use $seen[$item['name']] instead of $seen[$item]. This method is much faster because it uses the $seen array to do lookups in constant time, instead of searching through a large array. For 20k files I would expect it to take under one second.
  17. It's to do with an option called "register_globals" For whatever reason, register_globals is on in your top directory but off in the other directory. As a result, $tid works in the top one, but the full form $_GET['tid'] must be used in the other one.
  18. someguy, I suspect the problem is not content.php, but is in the code that executes before content.php. Can you add this to the absolute top of index.php print "index.php page = " . $page . "<br>"; And change your print inside content.php to print "content.php page = " . $page . "<br>"; Are the values the same?
  19. It's tough to do it like that, because you need to reference the other owner as well. I would do it explicitly like this: $userid_id_query = mysql_query("SELECT id, trade_id FROM `usersitems2` WHERE `trade_id`='$trade_id' AND owner = '$userid'"); $user_id_id_query = mysql_query("SELECT id, trade_id FROM `usersitems2` WHERE `trade_id`='$trade_id' AND owner = '$user_id'"); $userid_id = mysql_fetch_array($userid_id_query); $user_id_id = mysql_fetch_array($user_id_id_query); print "User $userid will trade item {$userid_id['id']}, user $user_id will trade item {$user_id_id['id']}"; I think this is a good time to point out that $userid and $user_id are not great for variable names .. they look too similar. If $userid is what you already have, something like "$other_user_id" would be clearer. Anyway, once you have those two ids, you can do two updates using them.
  20. someguy, are you showing us your ENTIRE script or just part of it? What I need to know about how the script is called is, does it look like this: http://www.site.com/script.php?page=360news
  21. Hmm, actually I think there's a much easier way to do this. First, fetch a unique identifier for each item separately (also called "primary key". If you don't have one, it's time to make one). Then do the 2 update statements, but use the unique identifier as the condition, rather than userid and tradeid. That will do the swap correctly.
  22. Yes, someone TRIED to hack you. But from what you've said, they may not have succeeded. You said they were on your FTP? As long as your webserver doesn't allow scripts to be run from there, you are fine. Unless there is some other vulnerability allowing them to run those scripts.
  23. Wait a minute .. are you trying to swap two entries with only two updates? To swap items you need three updates (or one very well constructed one). For example $a = $b; $b = $a; After that, both values will be set to $b. But $t = $a; $a = $b; $b = $t; This will swap two values successfully. While I was typing, jcd pointed out another problem with the logic .. you'll need to fix both of those. THe item should only go out of "Trade mode" when the trade is complete, not part-way through.
  24. Then that's your problem. You must pass the page argument using $_GET in order to retreive it from $_GET. Can you show us how you call your script?
  25. Then it's not matching the right row. First check that your query is what you expect it to be by printing it out. Then check your program logic. If you are still having trouble, post the entire program, or a large enough portion that we can look through it.
×
×
  • 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.