Topics - RedPillow [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 8next
1
Developer's Corner / [CSS] Problem with div height
« on: June 15, 2011, 01:05 AM »
I got this picture here: http://imageshack.us/photo/my-images/17/probmb.png/

What I need to do is to make that blue bordered div stretch in height so it fills the cyan bordered area, depending how long the red bordered area is.

So if there's lots of text in the red bordered area, the cyan-area will get a lot longer and therefore the blue area must stretch so it reaches the bottom of the wide area.

Lol do you get me  :huh:

The blue bordered area should be kind of 'anchored' into the bottom of the big white area so it stretches.

2
Developer's Corner / [JS] How to make this loop?
« on: March 30, 2011, 08:29 AM »
Code: Javascript [Select]
  1. $(document).ready(function(){
  2.  
  3.    var modTime = 0;
  4. setInterval(function(){
  5.   $.post("ChatClient.php", {"file":"chat.cht", "time":modTime}, function(rst) {
  6.     if (rst.time != modTime) {
  7.       modTime = rst.time;
  8.                 window.location.reload();
  9.         else {
  10.                        
  11.         }
  12.     }
  13.   });
  14. }, 1000);
  15. });

So that is my code, and I need to make it do the whole check again on the else-statemen.
This is supposed to check a file modification time and if it's changed - it should reload the page and if it's not changed, it should just keep checking infinitely again until it is.
It works nice, if I remove the else-statement but then it refreshes every seconds - no matter if the file is modified or not.

I tried this by myself:

Code: Javascript [Select]
  1. $(document).ready(function(){
  2. loopIt();
  3. function loopIt() {
  4.    var modTime = 0;
  5. setInterval(function(){
  6.   $.post("ChatClient.php", {"file":"chat.cht", "time":modTime}, function(rst) {
  7.     if (rst.time != modTime) {
  8.       modTime = rst.time;
  9.                 window.location.reload();
  10.         else {
  11.                 loopIt();      
  12.         }
  13.     }
  14.   });
  15. }, 1000);
  16. }
  17. });

3
Developer's Corner / [PHP] str_replace - is this even possible?
« on: March 28, 2011, 05:15 AM »
Hi again.
I'd like to make simple crypter by myself, this is what I've done so far:

Code: PHP [Select]
  1. //This is the key-table for crypter.
  2. $cryptkey = array('0' => 286, '1' => 949, '2' => 695, '3' => 348, '4' => 438, '5' => 977,
  3.         '6' => 320, '7' => 418, '8' => 970, '9' => 482, '[' => 466, ']' => 770, '.' => 569,
  4.         ' ' => 242, '-' => 166, 'A' => 583, 'B' => 575,  'C' => 247,  'D' => 564, 'E' => 192,
  5.          'F' => 513,  'G' => 653,  'H' => 605,  'I' => 450,  'J' => 404,  'K' => 831,  'L' => 315,  'M' => 953,
  6.           'N' => 439,  'O' => 266,  'P' => 231,  'Q' => 633,  'R' => 881,  'S' => 113,  'T' => 935,  'U' => 559,
  7.            'V' => 318,  'W' => 927,  'X' => 906,  'Y' => 463,  'Z' => 184, 'a' => 263,  'b' => 453,  'c' => 208,
  8.            'd' => 591,  'e' => 511, 'f' => 343,  'g' => 969,  'h' => 415,  'i' => 420,  'j' => 175,  'k' => 410,
  9.            'l' => 295,  'm' => 265, 'n' => 877,  'o' => 200,  'p' => 837,  'q' => 913,  'r' => 515,  's' => 262,
  10.            't' => 524,  'u' => 874, 'v' => 525,  'w' => 700,  'x' => 670,  'y' => 918,  'z' => 290, '<' => 331,
  11.            '>' => 533, "'" => 425, ',' => 101, ':' => 495, '$' => 114, '\\' => 268, '/' => 721, '=' => 454);
  12. //Don't mind about some fails in the table ... solving them later.
  13.  
  14. //This is the string we're going to crypt.
  15. $notcrypted1 = "[$curdate] - Rotation was <font color = '$color'><b>$rotation</b></font> degrees, done by <b>$ip</b>, who says: ''<b>$msg</b>''\r\n";
  16.  
  17. //Splitting the string here. (is this even needed?)
  18. $split1 = str_split($notcrypted1);
  19.  
  20. //And this is the problem area
  21. foreach ($split1 as $char) {
  22.         foreach ($cryptkey as $char2 => $key2) {
  23.                 $crypted1 = str_replace($char, $key2, $notcrypted1);
  24.                 }
  25.         }
  26.  
  27. //Im using this PHP.net's example
  28.  
  29. // Provides: Hll Wrld f PHP
  30. $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
  31. $onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

So basically, it is supposed to replace the characters in the $notcrypted1 with the key-table's corresponding int value.
But the problem is, that I'd like to know if there's any way to tell the program to switch the character it is going trought with the key-table's corresponding int value ... And like without doing 3000 if's.

Since it can replace the vowels with blank in the example - is it possible to switch the characters with the ints in my code?
My brains are jamming with this one ... I know it will not work like this and I even know why it isn't working - I just can't find a way to solve it ...


I wouldn't want to do it like so:

Code: PHP [Select]
  1. foreach ($split1 as $char) {
  2.         foreach ($cryptkey as $char2 => $key2) {
  3.                 if ($char == "A") {
  4.                         $crypted1 = str_replace($char, "A", $notcrypted1);
  5.                 }
  6.         }


4
Developer's Corner / [PHP] Confused with functions
« on: February 05, 2011, 05:18 PM »
This has nothing to do with the thread I made few minutes ago.

Anyways ... I need help with these thing related to PHP-functions:

- How do I set what the function needs to work?

Like ...

Code: PHP [Select]
  1. function countNumbers() {
  2. echo ($x + $y);
  3. }

Now, how do I declare, that the function I made needs parameters $x and $y to count like so:
countNumber(1, 2);


Second question is, can function return multiple values, like with a loop?

Code: PHP [Select]
  1. function countNumbers() {
  2. $rtnval = $x + $y;
  3.  
  4. for ($i = 0; $i <= 5; $i++) {
  5. return $rtnval;
  6. }
  7. }


Third is, can I use function directly to output something like so:

Code: PHP [Select]
  1. echo countNumbers();

or

Code: PHP [Select]
  1. $numbers = countNumbers();
  2. echo Numbers;

5
Developer's Corner / [PHP] 'Dynamic variable name' ?
« on: February 05, 2011, 03:53 PM »
This is something I've managed to do so far:
Code: PHP [Select]
  1. function generateMap {
  2.         $i = 0;
  3.                 $openMap = fopen("map/map_1-1.txt", "r");
  4.                         while (!feof($openMap)) {
  5.                                 $line = fgets($openMap, 1024);
  6.                                         $map = str_split($line);

The problem is, that I want to name the array $map like $map$i  or $map + $i...
So that it's like $map1 = blah, $map2 = blah, $map3 = blah ...

Do you get me?
How do I do that?

Pages: [1] 2 3 4 5 6 ... 8next
Go to full version