Jump to content

KingOfHeart

Members
  • Posts

    222
  • Joined

  • Last visited

Everything posted by KingOfHeart

  1. I like creating php images, and linking them on other sites. Since I do not own the site I need to make sure I don't use up all their bandwith. So I created a htaccess file to only allow certain hosts to link to my image. I also created a php script. Is this a good php script for controlling the bandwith for an image? function UpdateTable() { $tsql="SELECT * FROM Bandwith"; $tresult=mysql_query($tsql); while($trows=mysql_fetch_array($tresult)) { $time = $trows['id']; if(date("His") > $time + 500 || date("His") < $time - 500) mysql_query("DELETE FROM Bandwith WHERE id='$time'"); } $tresult=mysql_query($tsql); if(mysql_num_rows($tresult) > 40)//too many views within 5 min so shut down { $Handle = fopen(".htaccess", 'a'); $Data = chr(10) . "Deny from all"; fwrite($Handle, $Data); } } I have this line later on in my script. mysql_query("INSERT INTO Bandwith (id, ip, host,page) VALUES('$time', '$ip', '$host','$page') "); mysql_query("Update Bandwith SET image = '$image' WHERE id = '$time' AND ip = '$ip'"); I now question myself on why I separated those two lines, which I think I'll combine. Anyways, is this a good method for controlling bandwith abuse?
  2. Is it possible to create a php image that animates? It would need to still animate if I linked in in a sig on a forum, and not just the page itself.
  3. If no one minds ads. You can try lycos which has many different versions for the site and different languages.
  4. Ok, this will probably be a strange question to ask here, but I'd assume some members here also create games in there spare time. So do you have a gaming project you been working on or finished? Do you have a place to host it? I'm searching around the net for decent Gaming Projects (even if it's not finished) for a forum I'm part of. Just Post a Link to your Gaming Project and what it's about if your interested it all. I won't do any linking because I'm not trying to really advertise.
  5. I'm doing this on my website to see what you can do with $_GET and $_POST exposed. I know you can use it for mysql hacking (mind pasting a few examples) but can it be used for creating files? Or how about echoing the entire php file as plain html? Any help would be appreciated so I know what a hacker could do to my site if I exposed any of these by acident.
  6. What php command can I use then? $lu = "20081103224334"; $year = $lu[0] . $lu[1] . $lu[2] . $lu[3]; $month = $lu[4] . $lu[5]; $day = $lu[6] . $lu[7]; I can easily move around the numbers in any order that is needed, guys. edit: I found exactly what I needed. $lu = "20081103224334"; $year = $lu[0] . $lu[1] . $lu[2] . $lu[3]; $month = $lu[4] . $lu[5]; $day = $lu[6] . $lu[7]; $time = time() - mktime(0, 0, 0, $month, $day, $year); $days = floor($time/86400); echo $days; I knew it was not that hard to do, so don't see why you did not suggest this for me. Sorry if I sound harsh guys. *Thread Closed*
  7. I'd rather not change it. If each number was separate (I can do this) would this help you create the formula?
  8. I use this to set up my dates date("YmdHis"); When I save it to the mysql I use var char(if this makes any difference) The field name is "lastupdate" So how can I return how many days has passed since "lastupdate"
  9. That script worked nicely. I got another question now. I have a list of files, descriptions, and links. After the files are sorted, I need to match those descriptions and the links in the same order? How would I go about doing that, because so far it's not going right.
  10. Anyway to ignore the case when sorting an array?
  11. Can you just paste the entire coded needed, showing the mysql line and $rows This is the part that throws me off. The last code I used just created an error.
  12. How do I set this up? $sql = mysql_query("( select i.img_name , i.img_description , u.user_name from image as i inner join user at t on ( t.user_id = i.img_user ) ) union all ( select d.name , d.description , a.username from downloads as d inner join accounts as a on ( a.id = d.userid ) ) "); while($rows= mysql_fetch_array($sql)) { $out .= $rows['name']; } $out is for just returning the data.
  13. I'll try it out later but I have a question first. When echoing the rows can I use $row['d.description'] at all? Or is this a wrong method to use?
  14. img_name, user_name, img_description, name, username, description would need to be echoed. The other fields will be needed though for getting certain data. Haven't had much practice with the JOIN command.
  15. I have a site that contains a file list . I also have a wiki that contains a file list. I want to list both of these files into one group. From Wiki image - Table img_name - Contains the name of the file img_description - Contains the description img_user - Returns the number of the user who uploaded it user - Table user_id - The id for the user user_name - Contains the name of the user From my File List Downloads - Table name - Name of the file userid - The user's id description - The description for the file type - The file's Type Accounts - Table id - The user's ID username - The user's name So first we need to get it organized for the image table to be combined with the user table. Then Downloads needs to be combined with Accounts. After all that is done, the two lists need to come together. So how tough would this be? I'd settle for keeping the Wiki data and the File List separated into two lists if necessary.
  16. I have not used this function much so I don't understand how to use it completely. How can I show the data of both tables with just one search. Here is my current script $sql = "SELECT w.pageid, w.WDuserid, w.timedate, w.data FROM Wiki_Data w, Wiki_Main m Where w.pageid = m.id"; $result=mysql_query($sql); if(mysql_num_rows($result) == 0) { return false;//should not even run } $rows = mysql_fetch_array($result); $context['index_body'] = $rows['m.id'] . "<br>"; $context['index_body'] .= $rows['m.pagename'] . "<br>"; $context['index_body'] .= $rows['w.WDuserid'] . "<br>"; $context['index_body'] .= $rows['w.timedate'] . "<br>"; $context['index_body'] .= $rows['w.data'] . "<br>"; Even though it can display some of the names by removing the w. I don't want to have it set up like this. I made things easier by giving all my needed fields a different name, but I want a script that will work even if the two tables had the same field names. $context['index_body'] < this is just for showing the data. In the guide it says I have to list my MYSQL version, but not even sure how to find this out.
  17. I have an e-mailer script. I have a field for sending option (single, non-activated, mailing list, or all) I have a title field, and a message field. I have a little save option for if they preview the message but I would also like to have a save option every 60 seconds. So can anyone help me?
  18. Is that for all values above 10 or just for apples? Sorry, just realized that my example was not that great for what I wanted. $string = "John had 3 apples, 100 Peter had 20 apples, Ralf had 8 apples. Susan had 30 oranges. Rick had 20 oranges"; Ok, lets say I want anyone who has more then 10 apples to be changed to 10. Anyone who has more then 20 oranges I want to be changed to 20. Your script is teaching me more about preg though at the same time, since I find it a bit confusing.
  19. How would I search a string and if a value is too high, it would modify it to something else. Example: John had 3 apples, Peter had 20 apples, Ralf had 8 apples. If value is above 10, change it to a 10. Guessing I need str_replace, but not sure how in this case.
  20. I have a function to convert BBCode to HTML. Guess what, it worked but there are two small problems. First there is no limit for the width and height for an image. There are also no limits for how big they can make the size. So can anyone help me create these limits? Then after that is done, I'll need to convert the HTML back into BBCode again for when they need to edit their page. Below is the function. function bbcode2html($message) { $preg = array( '/(?<!\\\\)\[color(?::\w+)?=(.*?)\](.*?)\[\/color(?::\w+)?\]/si' => "<span style=\"color:\\1\">\\2</span>", '/(?<!\\\\)\[size(?::\w+)?=(.*?)\](.*?)\[\/size(?::\w+)?\]/si' => "<span style=\"font-size:\\1\">\\2</span>", '/(?<!\\\\)\[font(?::\w+)?=(.*?)\](.*?)\[\/font(?::\w+)?\]/si' => "<span style=\"font-family:\\1\">\\2</span>", '/(?<!\\\\)\[align(?::\w+)?=(.*?)\](.*?)\[\/align(?::\w+)?\]/si' => "<div style=\"text-align:\\1\">\\2</div>", '/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<span style=\"font-weight:bold\">\\1</span>", '/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<span style=\"font-style:italic\">\\1</span>", '/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<span style=\"text-decoration:underline\">\\1</span>", '/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "<div style=\"text-align:center\">\\1</div>", // [email] '/(?<!\\\\)\[email(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>", '/(?<!\\\\)\[email(?::\w+)?=(.*?)\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>", // [url] '/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>", // [img] '/(?<!\\\\)\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si' => "<img src=\"\\1\" alt=\"\\1\" class=\"bb-image\" />", '/(?<!\\\\)\[img(?::\w+)?=(.*?)x(.*?)\](.*?)\[\/img(?::\w+)?\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" />", // [list] '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ol>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-d\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-lr\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ur\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-la\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ua\">", //line breaks '/\n/' => "<br>", // escaped tags like \[b], \[color], \[url], ... '/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1" ); $message = preg_replace(array_keys($preg), array_values($preg), $message); return $message; } If you don't want to do the actual work then can you help me try to figure out which command I need to look at to check to see if a value is too high or low? Also wonder if I have to change the formula out of an array.
×
×
  • 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.