Jump to content
xisto Community

peroim

Members
  • Content Count

    33
  • Joined

  • Last visited

Posts posted by peroim


  1. 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


  2. 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


  3. 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:

    Posted Image

    While it should look like this:

    Posted Image

     

    I've already tried to make the stylesheet better (jup, found some small mistakes) but if you encounter a problem, please tell me!


  4. 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... :P

     

    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? :D 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. :D

     

     

     

    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. :D

    PPS: I don't know how to stop it, but this forum changes some things in my code... (There's BBCode in it!!)


  5. 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 Posted Image 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


  6. 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. :lol: )

    Thanks in advance,

    Peroim

  7. Before somebody gets confused: Java and JavaScript have NOTHING to do with eachother. JavaScript just came out while Java was very popular, so they just wanted to be popular too. :lol: Java is made by Sun, and JavaScript is created by Brendan Eich of the Netscape Communications Corporation.There are some similarities in code, but you should really don't mix them up. Java is NOT JavaScript.


  8. it isn't hard or so. you just take the servertime and 'add' -5 hours. and since time() gives seconds, that will be -5*60*60 seconds. so here's an example script:

    <?php$timezone = -5;//rather clear, this is your timezone (in hours) (real timezone)$here = time() + $timezone*60*60;//the time in your timezone, long number, so not good for output;)echo gmdate("l j F Y, h:i A", $here);//echo some time?>

    gmdate() is exactly the same as date(), but it uses greenwich time, and not servertime. (If using an input time in UNIX-format.)

    Cya, Peroim

  9. In Windows:

     

    you run command prompt (or start-> run ->cmd). then type ping XX.XX.XX.XX (X = ip address). If you dont know the if address, just ping using the url (e.g. ping https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl :P).

     

    Or if you'd like to continuously ping someone, just add -t at the back. e.g. ping https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl -t. It won't cause that much of a fuss for the pinged (haha) person. Usually I use the continuous ping on my ISP. Why I do this? so that if I get a 404 error (page not found), I'd know whether its my ISP service or other networking problems.

     

    I don't know how to ping in Linux as i'm not a hacker as well :).

     

    Pinging is sending a packet of data to a certain computer. Once the packet is recieved it will be echoed back to you. The time it needs to go back and forth is call latency. Hence, the use of 'ping' is to find out the time it takes for the information to be sent to that computer and back. A low latency should be under 20 ms. If it goes over 1000 ms over an extended period of time, you should check with your ISP.

     

    Thank you, now I see pinging someone is useless.


  10. <script LANGUAGE="JavaScript">cookie_name = "dataCookie";function putCookie() {if(document.cookie != document.cookie)				 <-- This is a weird piece! (*){index = document.cookie.indexOf(cookie_name);}else{ index = -1;}</SCRIPT><script LANGUAGE="JavaScript">cookie_name = "dataCookie";function getName() {if(document.cookie){index = document.cookie.indexOf(cookie_name);if (index == -1){java script:go ('home.htm');}}</SCRIPT>

    (*): document.cookie will always be the same as document.cookie, so the following piece of code will never be executed.

    Now, what you do is looking if the cookie contains 'dataCookie', if it doesn't, it will go to 'home.htm' (I think the function go() doesn't excist, I always use 'window.location = something'.)

    If I see your code, I think there won't ever be a cookie. First: the code won't be executed (see (*)) and if it would be executed, it would be a session-only cookie. To be honest, if I were you, I would make this script all over again. (But I'll do it for you now.)

    <script language='JavaScript'>function setCookie(page){ //This is the function that sets the cookiesvar date = new Date(); //A date-varvar expires = 24*60*60*1000; //This is the time the cookie is valid in milliseconds (This is 1 day)date.setTime(date.getTime()+expires); //This is where we see when the cookie is no longer validvar expires = "; expires="+date.toGMTString(); //We're going to need this for the cookiedocument.cookie = "page=" + page + expires; //Filling the cookie with data (Important: this cookie needs the variable expires!window.location = page; //Redirecting to the given page}function getCookie(){ //This function will check the cookiesif(!document.cookie) return; //If no cookie: returnvar cookie = document.cookie; //Getting the data from the cookie to a varvar cookie = cookie.split("="); //Splitting the data at '='j=false; //This will be clear a few lines laterfor(i=0;i<cookie.length;i++){ //A for-loop that will run once for each piece of the array cookieif(cookie[i] == "page") j=i+1; //If the piece of the array is equal to "page" our var in the first function, we save the position + 1 in the var j. Why 'i+1': this is the piece of the array that will contain the page, since we splitted at '='}if(!j) return; //If j is not set, see the line 'j=false', return. (This is when there is a cookie, but it doesn't contain the right data.document.location = cookie[j]; //And again: redirect to the given page}window.onload = getCookie; //Makes the function getCookie() start when the page is loaded</SCRIPT>

    This script will check for cookies when you open the page, if the cookie is set, it will redirect to the given page.

    How to use it: in you page should be links, buttons, ... to the following url: 'java script:setCookie(page)'. (don't type 'page', but this should be the url you want to redirect to. Example: 'home_en.html'.)

    Hope this was usefull for you.

  11. You don't need the images (save your bandwidth):

    This is the script you'll need for that:

    <script  language="JavaScript">function goForm(){this.form.submit();}</SCRIPT>

    And this is how the link should look like:
    <A href="java script:goForm()">Set</A>
    (I tried to type 'JavaScript' and not 'java script', but it always changes it back.)
×
×
  • 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.