Jump to content
xisto Community

peroim

Members
  • Content Count

    33
  • Joined

  • Last visited

About peroim

  • Rank
    Member [ Level 1 ]
  • Birthday 08/16/1991

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Male
  • Location
    Belgium
  1. As far as I know, Ajax works great, but if the user turns JavaScript off, it will not work. If I were you, I would use Java.(Try searching with google for a java chatbox.)
  2. Thanks Ghostrider, the double quotes were wrong as you said.After changing that, and some testing it still didn't work... But after some more testing, I finally found out what was wrong too: better avoid arrays in arrays...And thanks for the numeric array-tip, that's indeed a lot easyer! Peroim
  3. I've got a problem with global variables. I've read and re-read the stuff about that on php.net and did that a few times more, and I'm still not able to make it work.Could somebody please fix my code?This is the primary page: <?phpinclude "getLvlFromHigh.func";$user = $_GET["user"];$skill = $_GET["skill"];$goal = $_GET["goal"];$userXp = getLvlFromHigh($user);$xpTable = array( 31 => 14833, 32 => 16456, 33 => 18247, 34 => 20224, 35 => 22406, 36 => 24815, 37 => 27473, 38 => 30408, 39 => 33648, 40 => 37224, 41 => 41171, 42 => 45529, 43 => 50339, 44 => 55649, 45 => 61512, 46 => 67983, 47 => 75127, 48 => 83014, 49 => 91721, 50 => 101333, 51 => 111945, 52 => 123660, 53 => 136594, 54 => 150872, 55 => 166636, 56 => 184040, 57 => 203254, 58 => 224466, 59 => 247886, 60 => 273742, 61 => 302288, 62 => 333804, 63 => 368599, 64 => 407015, 65 => 449428, 66 => 496254, 67 => 547953, 68 => 605032, 69 => 668051, 70 => 737627, 71 => 814445, 72 => 899257, 73 => 992895, 74 => 1096278, 75 => 1210421, 76 => 1336443, 77 => 1475581, 78 => 1629200, 79 => 1798808, 80 => 1986068, 81 => 2192818, 82 => 2421087, 83 => 2673114, 84 => 2951373, 85 => 3258594, 86 => 3597792, 87 => 3972294, 88 => 4385776, 89 => 4842295, 90 => 5346332, 91 => 5902831, 92 => 6517253, 93 => 7195629, 94 => 7944614, 95 => 8771558, 96 => 9684577, 97 => 10692629, 98 => 11805606, 99 => 13034431);if($goal > 99) $goal = 99;$procent = floor($userXp / $xpTable[$goal] * 100);if($procent >= 100){ echo "You have accomplished your goal.";}else{// echo "You have ".$procent."% of your goal.";}?> And this is getLvlFromHigh.func: <?phpfunction getLvlFromHigh($user){ global $highData; $data1 = file_get_contents("<A href="http://forums.xisto.com/no_longer_exists/); $data2 = explode("<td width=\"380\">\n<table>", $data1); $data3 = explode("</table>\n</div>\n</div>\n</div>", $data2[1]); $data3 = $data3[0]; $data3 = explode("\n", $data3); $data4 = ""; foreach($data3 as $i => $contains){ if(($i > 13) && ($i < 212)) $data4 = $data4."\n".$contains; } $data4 = explode("</tr>\n<tr>", $data4); foreach($data4 as $skill => $contains){ if(stristr($contains, "Not ranked")){ $data[$skill] = false; } else { $data5 = explode("\n", $contains); $data5 = preg_replace("|<td align=\"right\">(.*?)</td>|","$1",$data5); $data5 = str_replace(",","",$data5); $highData = array(); $highData[$skill]["rank"] = $data5[5]; $highData[$skill]["lvl"] = $data5[6]; $highData[$skill]["xp"] = $data5[7]; } }}echo "Overall rank: ".$highData[0]["rank"]."; lvl: ".$highData[0]["lvl"]."; xp: ".$highData[0]["xp"].";<br />";?> I know goal.php won't work yet, but I'm currently working on getting the data with getLvlFromHigh.func...The output of this script is:Overall rank: ; lvl: ; xp: ;While it should give some data from the RuneScape-highscores.Please help me with this...Peroim
  4. Thanks Buffalo & Electriic.Buffalo, your code codes are v?ry usefull if you want to redirect one page to another, but I need Electriic's solution, because I want to redirect every possible filename to another page.
  5. Is it possible to redirect all possible urls to one page? So that if you would go to http://ww38.yoursite.com/dir/(and then a file name) this would automaticly go to http://ww38.yoursite.com/dir/index.php ? Something like a 404 page? Thanks, Peroim
  6. I'm correcting a 'few' php-files for a friend, but I got this line of code: $ban = ($data->login) ? $lban : $iban;and I don't know what it does xD Could someone please explain me what this line does? Thanks
  7. a short answer on your question: if the file is on another server, you will get the output of the script, not the real contents.
  8. as i said, there is a bug (or more then one ) it might be fixed, but the fixed code isn't here yet.. Problem: This is how the example looks for somebody: While it should look like this: I've already tried to make the stylesheet better (jup, found some small mistakes) but if you encounter a problem, please tell me!
  9. Hi everybody, I made a HTML, JavaScript, PHP and MySQL chatbox For a working example: click here I'll put the code here (you can use it for free as long as you keep the message in the help that it is made by Marshian007) and explain it, so you can learn from it. I'm only 15 years old, so please tell me when you see something wrong. I can't be perfect... Yet... These are the special functions of the box: Customable stylesheet On page pop-up with the smilies (JavaScript on a DIV) Auto-deletion of the oldest messages (Stores 500 messages) Only 2 files required: chatbox.php and chatbox.css BB Code Automatic check for new messages in background (JavaScript) Works without JavaScript, but with less functions Older messages spread on a few pages Add-free! Block annoying ip's, with blocked-message Unable-to-connect-to-database-message If you wish to use this chatbox, download following file: the smilies. (14.6 kB)Unzip it in a subdirectory /smilies The box uses a MySQL-database with table `chatbox`. Fields: `id` int(11), `name` varchar(12), `time` int(11), `ip` varchar(15), `message` text. Here's a query to insert this table: CREATE TABLE `chatbox` (`id` int(11) NOT NULL auto_increment, `name` varchar(12) NOT NULL default '', `time` int(11) NOT NULL default '0', `ip` varchar(15) NOT NULL default '', `message` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; Your database won't be like 10 mB in 5 minutes, I've got about 300 messages in mine and it's only 40 kB. This is the code for the whole chatbox: (This is chatbox.php) (This forum has changed some stuff about it, download it here.) And here's the chatbox.css: you can edit it as you want to. LMAO, I'm typing this first in notepad, and I have already 600 lines! Here's some info about the code of the chatbox: [hide] $blocked_ips are the ip's that you wish to ban from your chatbox. $mysqlHost, User, Pass, Db are your mysql host, username, password and database you wish to connect to. Next is the code that will compare the ip of the client with the blocked ip's, and this will exit the script and print a message. The function bbcode(string message) will process the (new) message. First a few variables for later use. After that, all < and > will be changed to the unicode versions, so HTML, PHP ao are blocked in an easy but efficient way. Arrays $aListB and $aListA are before and after-strings. (BBCode into HTML) Preg_replace will change all elements it recognices from listB to the according element in array listA. It returns the processed message, which is ready to store in the database, and showing to a client later. Fist piece: if $_POST["name"] is set, store it in a cookie. (Valid for 604800 seconds = 1 week.) Second piece: there's a function in the help to allow users to try out the bbcode, this piece is called as output. We enter a switch() now with $_GET["info"]. 3 possible values: "true", "help" and default. Case: $_GET["info"] == "true". This is called by the JavaScript, and will tell it wether there are new messages or not. How do we know? An argument passed into the JavaScript is the last update. If there is a newer message, this code will echo true and the JavaScript will refresh the page. If not, this script echoes false, and the JavaScript will take the first piece of the echo: the new last update-time. Very clear, this is just an HTML-page with the help on it. It also contains the form for the test-script. We are now in the default part of the switch, this contains almost everything of the box. Clear as usual: this piece checks or the user entered a new message, and if so, processes it: if $name is set, $msg is set, $msg not empty is and $msg not "Message" is, the message will be processed with bbcode() and stored in the datebase. Next: if there are more then 500 messages, calculate how many messages there are too much. (Usually 1, but to be sure...) Delete that amout of messages, starting with the oldest message. In the default page, html, head. Fist of all: $new is the variable that 'knows' or the user requested older messages, or the newest. If the user wants the new messages: echo the script to refresh the page. (I won't explain the JavaScripts here, since this is the PHP-forum.) Always import the other functions: Onclick for the textboxes, popup the smilies, insert a smilie, hide the smilies. In the body This is the easy part: viewing the messages. Nothing hard here, so I'll hop to the next part. Fist piece: the form. Not hard or so... Second: nothing hard (again...). This code makes sure you get the right links: you want a link newer messages when you're watching the older, but this is useless if you're watching the new messages. Why did I put this here? This is without doubt the easyest part... Well, I think that's all you wouldn't want to know about this chatbox. I'm aware that nobody will ever read this, but explaining things to somebody else is a good exercise for you. Maybe somebody will use the code, if so, I wish you a lot of luck. Peroim PS: Marshian007 is me, I didn't copy it from him. PPS: I don't know how to stop it, but this forum changes some things in my code... (There's BBCode in it!!)
  10. Is it just me or is there no mysql_connect ? :PMaybe PHP is just complaining he doesn't have connection to a mysql-database.
  11. hi everybody,thanks for the replies. i've got NetBeans installed and now i know how to compile java files, i can start learning java Peroim
  12. thanks Saint_Michael, i'll try that.and shadowx, i don't think you really get the problem: for some people, it woks perfectly, but for some other people, they won't show up.EDIT:i tried with the " instead of ' -> no resultwith imageshack -> it worked! thanks!
  13. I've got a forum at invisionfree.com, and I've changed some of the images, but now some of my members are complaining that these images (sometimes) don't show up. http://z6.invisionfree.com/The_Slayers_of_Chaos/index.php is the forum. the images i'm talking about are the right of the names of the forums. The problem is seen with IE6. Does anyone have an idea why these images don't show up? <img src='runescape.com/lang/en/aff/runescape/img/hiscores/skill_icon_defence1.gif&%2339; border='0' width=16 height=16 alt=''>is the exact code for the images. Thanks in advance, Peroim
  14. when I first saw this post, I was wondering why there were so many \ and / in $main_search=array('/\[b\](.*?)\[\/b\]/is','/\[i\](.*?)\[\/i\]/is','/\[u\](.*?)\[\/u\]/is','/\[img\](.*?)\[\/img\]/is','/\[url\=(.*?)\](.*?)\[\/url\]/is','/\[url\](.*?)\[\/url\]/is'); But I think I know why now, but I'm not sure... Could somebody help me out with this please? Is it so that you must start and end all pieces you want to replace with preg_replace() with a non-alphanumeric character (and that they must be the same)? And that [ ] and / mean something in the statement? So that you must escape them with \ ? But, if so, what do they mean? (I'm already sure that .*? is some kind of wildcard. ) Thanks in advance, Peroim
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.