Jump to content

Salis

Members
  • Posts

    130
  • Joined

  • Last visited

    Never

Everything posted by Salis

  1. Wow, that's simple. Thanks effigy
  2. I'm writing a new pagination script. The idea is to have blocks based on 5s. For an example: << Prev :: Page 2 of 8 :: Next >> 1 - [2] - 3 - 4 - 5 Then once you hit page 6 to 10 a new block is generated like so: << Prev :: Page 8 of 8 :: Next >> 6 - 7 - [8] This is for an new kind of image gallery that I'm currently working on. 35 images are show at a time and at the bottom on the page there is the pagination. But How would I tell if a number is a multiple of 5? Cheers
  3. I agree. The ban list will be pulled from a database once i finalize the script. But even then I cannot think why any one would take the time to ban 5,000 domains... let alone 20 even.
  4. Thanks much drewjoh. I modified the if statement to check if there is a match, removed the echo, added a boolean and the break. Works great!. I do have a question about the speed though. I highly doubt that some one will ban 100 domains but just in case, how much of a slow down would be expected? Well.. given the banned domain is at the end of the array. Would I be safe using this method?
  5. I've been working on a multimedia web site for a while and one feature that I'd like to add is the ability to "ban" specific domains. I do have this working... kinda <?php $myDNS_Bans = explode(',', "siteA.com,siteB.com,siteC.com"); // This will be pulled from the DB later - Testing for now $ReqFrom = $_SERVER[HTTP_REFERER]; // Let's say the referer is siteB.com foreach( $myDNS_Bans as $Banned ) { preg_match('@(.*?)('. $Banned .'?)(.*?)@is', $ReqFrom, $Match); if( $Match[2] ) { echo "This site is on our ban list!<br />\n"; } else { echo "This site is NOT on our ban list!<br />\n"; } } ?> All right so let's just say a file was requested from siteB.com well in the out put, you'd get: This site is NOT on our ban list! This site is on our ban list! This site is NOT on our ban list! I like to my code to be fast and right to the point. My problem is that if the site is on the ban list I need to stop the loop and move on to a function that redirects the request. How can I stop the loop? Or is there a better way this can be done. Little background about this idea: The idea is to give control to the person who uploaded the file. So let's say there is a site that they really don't want their image hot linked to. They'd simply enter 'what_ever_site_it_is.com' and it'd be saved to the database. Then when the file is called it checks the ban list against the referer. ( I DO NOT want to modify my htaccess file ). Thanks guys.
  6. Thank you so much. This helps a lot! I started working with a for statement to match keys and values then go through an if else statement..... Your code works much better! Thanks jesirose and everyone.
  7. People can to this very easily. If we look at 0 - Blue 1 - Red 2 - White 3 - Yellow 4 - Black And want to move Yellow before Black we know that the list will look like 0 - Blue 1 - Yellow 2 - Red 3 - White 4 - Black But to do this in an array, I'd have to list all colors as a key, then their integer as a value. Then add 1 to the array_value up to the Yellows old value.. if that makes any since.... so array('balck'=>0, 'red'=>1, 'white'=>2, 'yellow'=>3, 'black'=>4)... I don't really know, thinking out loud here. Maybe one of you can come up with something Or what if I assign the colors a number and list the values like so. array(0=>0, 1=>2, 2=>3, 3=>2, 4=>4) the keys are the original order and the values are the new number... But I still need a way to add 1... I hope I'm not confusing any one.
  8. No, ordered. I've been working in VB lately, Keys to index... Any way, Yellow is #3 in the array and Red is #1. I want to "move" Yellow before Red.
  9. I'm having a little trouble writing a script that reorders an array. For an example, let's say I have the following array: Blue Red White Yellow Black Now, what I want to do is move "Yellow" before "Red" I know that "Yellow" will now take the place of "Red" and 1 should be subtracted to the index of each color until the value "Yellow" used to hold. 0 = Blue 1 = Red 2 = White 3 = Yellow 4 = Black I'm guessing any way, the process would be like this: 0 + 0 1 = 3 2 - 1 3 - 1 4 - 0 This should shift the array to look like: Blue Yellow Red White Black or is there an easier way? Thanks
  10. Jeez, I think I need to hit myself! That does make sense. I kinda hate it when it's something so simple like that! Thanks guys.
  11. I was thinking about using it. But what I can't figure out is how. I mean would I have to create a new table for the timestamps? This is what I know so far: When a member makes a post it's added to the "comments" table in the database, then the board timestamp is updated. Not too hard. But then how would I compare it to the members? Would they need a table with their last active time stamp to match the boards? This is what I can't figure out.
  12. I'd use stripslashes() to go from \\ to \
  13. Yeah it's a little hard to find but here ya go http://www.php.net/manual/en/language.operators.errorcontrol.php
  14. If you don't want to display the mktime() error just add the @ symbol in from like so: @mktime()
  15. You have to remember there is a difference between a quote " and a tick ' Also if you use a single / you're actually saying "look in my main home directory". In other words if you have /jen.jpg the script will look for the file in www.example.com/jen.jpg when you may be trying to look in www.example.com/gallery/images/jen.jpg But I'm glad to hear you got it to work. Happy to help.
  16. I'm working on my own forum system for my clan. I don't want any thing fancy for feature filled. Their soldier name, clan tag, email, xfire, aim, yim, avatar, clan site, and signature. Maybe a PM system too IDK. Well I've go the BBC code functions done and all that fun stuff but I'm having a problem. Topic Activity... Ok so lets say you read a board. Once you've been in that board the Icon next to the board changes. For an example: Indicates there has been activity in the board since you were last in. Indicates there has not been activity in the board since you were last in. How would I do this? Thanks
  17. try this: $ImageName = "myfile.jpg"; $ImageLoc = " ./$ImageName"; When we open a file to read the data, we need to know how much to read so we use filesize(). filesize need to know where the file is. Since it's in the same directory I've add the ./$ImageName to say "look in this folder for $ImageName" I hope this helps. If no could you post you full download code, including modifications?
  18. Could you post a demo for me to see? I'll rewite the script for ya.
  19. Oops.. sorry, my mistake. $Imagelog should be $ImageLoc
  20. You can give it a shot. I haven't tested this script yet. But the nice thing is this should work for ANY file you want to force download
  21. Thanks for clearing that up for me. From my understanding count returns the number of rows rather than data. Which is better to say than "select * from" and "mysql_num_rows"
  22. I'd say use a header to force a download. I'm not sure how your gallery is set up. I'm working on my my self. I would make a new file named download.php and stick the code below in it. Of course you'd have to modify it to fit your needs. Then if some one wants to download the image, they click the link and the download.php file "GET" the image name and forces a download. <?php $ImageName = stripslashes($_GET['img']); // I'd actually pull this from my database $ImageLoc = "./gallery/images/$ImageName"; // This too header("Cache-Control: public, must-revalidate"); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($ImageLog) ); header("Content-Disposition: attachment; filename=" .$ImageName); header("Content-Transfer-Encoding: binary\n"); $fp = fopen($ImageLoc, 'rb'); $buffer = fread($fp, filesize($ImageLoc)); fclose ($fp); print $buffer; ?>
  23. All right, I don't really use count but now that part of my site needs it.. I can't seem to get it to work. I've read tutorials and articles. Shouldn't this work? <?php mysql_connect("====","====", "===="); mysql_select_db("===="); $CntQ = mysql_query("SELECT COUNT(*) FROM ex_promo"); echo "Total Rows: " . mysql_num_rows($CntQ) . "<br>"; $ListQ = mysql_query("SELECT ID_PROMO, x_pB64 FROM ex_promo"); while( $ListR = mysql_fetch_array($ListQ) ) { echo "x_pB64: {$ListR['x_pB64']} <br>\n"; } ?> Shouldn't this echo the total number of rows in this table? This is the exact same code as in my page: http://exopsclan.com/2/chk.php I do have 4 entires and the while statement does post them but the count() doesn't work. Any ideas? Thanks
  24. Thanks. There shouldn't be. I'm just reading the board names then the categories. So far this was the only query I needed help on. I never knew you could order 2 tables this way. Thanks for your help Illusion.
  25. I'm working on my own forum for my gaming site. I need a lot of integrations and I'd rather make my own forum then mod the heck out of some one else's. I can do all the queries I need expect one. I need 1 query to read the boards then categories. Similar to this site. For an example: Welcome to the =Fire= Squad <- Board 1 General Chat <- Category 1 of Board 1 News & Events <- Category 2 of Board 1 =Fire= Squad Server <- Board 2 Dates & Times <- Category 1 of Board 2 This is what I started: ("SELECT * FROM sqd_boards LEFT JOIN sqd_categories.ID_Cat ON sqd_boards.ID_Board = sqd_categories.ID_Cat ORDER BY sqd_boards.Board_Sort ASC") As you can see it sorts the Boards but how can I also sort the Categories as well? Any ideas?
×
×
  • 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.