Jump to content
MakeWebGames

Zeggy

Members
  • Posts

    401
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Zeggy

  1. Zeggy

    Image Help

    Re: Image Help All it means is that the image can't be found. So either it doesn't exist or you made a mistake in the image's URL?
  2. Zeggy

    Time Stamp

    Re: Time Stamp You probably want to use the setInterval javascript function, use ajax to fetch a page for results and append that to a div.
  3. Re: Copyright issues - torncity No, because it's not even a design. It's a centered column on a grey page, with images and a little footer text. Their images are so dull they can be made in paint, so it doesn't take any effort to copy it or make something similar, so feel free to use theirs. However, you should probably leave their banner then. I'm talking about the public area of the website btw. As for the in-game area, you probably should leave their images alone as well, unless their also very generic. Anyways, I don't understand why you would want to copy their non-existant website design :)
  4. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code   It's fun :) I used smarty as well.
  5. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code PHP is removed in the cached function. It's still using the original code I started the topic with, I'll be changing it to nyna's regex as soon if I can get it working with all kinds of PHP start/close tags. Once the file is cached and it needs to be displayed later, the template system doesn't parse the template variables anymore since it's been converted into PHP. It just extracts the variables assigned to the template and includes it. This is the only part that's run if there's a cached file that hasn't expired yet: //Extract variables assigned extract($this->vars); //Include file with ouput buffering ob_start(); include('cache/' . $tempname . '.php'); $ret = ob_get_clean(); //Get contents of buffer and clear buffer   btw, if you're getting confused with the getContents function, ignore the part where NO_CACHE == 1, it's just a quick hack I'm using to stop caching (it creates a new cache file each time so that cache files stay up-to-date). I'll be changing that, but it's just something I'm using while developing.
  6. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code Even smarty gets rid of PHP (although you can set options for that). getContents function: public function getContents() { $tempname = md5($this->filename); if (NO_CACHE === 1) { $this->cache(); //Force recreating cache file each time } else { //If cache file exists, then check when it was last modified if (file_exists('cache/' . $tempname . '.php')) { $compare = time() - (60*60); //60 minutes ago if ($compare > filemtime('cache/' . $tempname . '.php')) { //Cache file exists and expired, so use cache $this->cache(); } } else { //Cache file does not exist, so create it $this->cache(); } } //Extract variables assigned extract($this->vars); //Include file with ouput buffering ob_start(); include('cache/' . $tempname . '.php'); $ret = ob_get_clean(); //Get contents of buffer and clear buffer return $ret; }   Cache function: protected function cache() { $tempname = md5($this->filename); $this->contents = str_replace('<?', '<?php echo \'<?\'; ?%TEMP%>', $this->contents); $this->contents = str_replace('?>', '<?php echo \'?>\'; ?>', $this->contents); $this->contents = str_replace('?%TEMP%>', '?>', $this->contents); foreach($this->vars as $var=>$value) { $this->contents = str_replace('{$' . $var . '}', '<?php echo $' . $var . '; ?>', $this->contents); } $template_header = '<?php /* Template \'' . $this->filename . '\' cached on ' . strftime("%d/%m/%Y %H:%M:%S") . ' */ ?>'; $this->contents = $template_header . $this->contents; //Save as cached php file touch('cache/' . $tempname . '.php'); file_put_contents('cache/' . $tempname . '.php', $this->contents); }   Example of a template file: <div class="category"> [url="category.php?id={$CAT_ID}"]{$CAT_TITLE}[/url] </div> {$BOARDS}   Example of a cached template file: <?php /* Template 'themes/island/bits/category.tpl' cached on 05/11/2008 22:53:02 */ ?><div class="category"> [url="category.php?id=<?php echo $CAT_ID; ?>"]<?php echo $CAT_TITLE; ?>[/url] </div> <?php echo $BOARDS; ?>   Basically, the script reads the template file, replaces template variables with real PHP code, and saves the file. When the template needs to be displayed, it automatically includes the cached template file, thus removing the need for parsing the file to replace variables and what not. The caching is meant to benefit the server, not the user.
  7. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code Yes, I know, I use fopen to read the file and file_put_contents to save the file :) The include part comes in later when the cached file is called. And I do need to use include because there's my own PHP code in there that needs to be run. The alternative is eval and that is just silly :P Then I use output buffering to capture the output from the included file. Would you like to see the code I have? It might help you to see what I'm doing. btw, I can't find the post you are referring to, but I'd like to see it. Do you have the link? :)
  8. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code I insert some PHP of my own into the page after all other PHP has been removed. Then I sav the file and leave it to be run for later. I'm making a simple cached template system. btw, thanks nyna :)
  9. Just wondering, since I don't use mccodes or know anybody that uses it... Do many people use the lite version of the script? Why/why not? Are there any problems with it? (Apart from near-illegible coding)
  10. Zeggy

    Filtering out PHP code

    Re: Filtering out PHP code No problems with encoding or control characters that might allow a PHP tag to get through? btw, what is the 'Uims' part of the Rx you posted?
  11. Re: Copyright issues - torncity Just because you have similar gameplay elements, theme or crappy layout doesn't mean you are breaking their copyright. It might be a problem if you stole their graphics and used them without permission though. But really, there are 10,000 games just like TC... I bet they threatened some poor kid trying to start a hosting company from their basement to stop providing hosting services to the game.
  12. Okay... So I have a file, and it contains PHP and HTML code. I intend to include() this file at some point later in time, however, I am not sure what PHP code is in the file. So I need to find some way to remove or neutralise that PHP code. How can I do this? So far I've come up with this:   $this->contents = str_replace('<?', '<?php echo \'<?\'; ?%TEMP%>', $this->contents); $this->contents = str_replace('?>', '<?php echo \'?>\'; ?>', $this->contents); $this->contents = str_replace('?%TEMP%>', '?>', $this->contents);   It seems to work fine. I just need to do the same for the ASP style tags and <script language="php"> tags, but... Does anybody spot any problems? Is there any easier way to remove PHP?
  13. Re: Crons VS. Time Stamp Not sure what you mean with your question, cron and timestamp are two different things. It would be better to compare specific implementations. Crons are good for certain things, while timestamps are good for others.
  14. Zeggy

    My own Game Engine.

    Re: My own Game Engine. lol, what do master securers do?
  15. Zeggy

    PBBG Contest

    Re: PBBG Contest   There is absolutely no mention on an 'engine'. It's best if you code stuff yourself (or get somebody to code it for you). I don't keep anything. You don't have to make anything open source, hand over any code, turn over control of your game or anything of the sort. There are prizes involved. Lots of them, sure to benefit your new game plenty. Please read next time :)
  16. Re: Task: the 10! minigame Hey, I'm really interested in this, but I don't really understand the task :P Could you give an example or something?
  17. Zeggy

    PBBG Contest

    Re: PBBG Contest Umm, you cannot use any pre-made scripts or game engines. I don't think that's explicitly stated in the rules, but it is a developer contest. Using a script or game engine takes a lot of work out of it. Since this is the first contest and I forgot to mention that rule, you can go ahead and use a game engine, but I'll warn you, the judges are looking for something that is also unique. So you should probably try to modify the game so much that you can't really tell it's made from a game engine :P
  18. Zeggy

    PBBG Contest

    Re: PBBG Contest Ummm, the game engine was a separate topic from the contest, but I figured I'd just put it all in one message. I hope there wasn't any misunderstanding :)
  19. Zeggy

    Security!

    Re: Security! If you only want a number value, you can simply use intval(). If it's got letters or tags or symbols, the value will be converted to 0, so no need to worry about injections.
  20. Zeggy

    Programs

    Re: Programs     err, notepad has line numbers? which notepad do you have? :D
  21. Zeggy

    Programs

    Re: Programs I use Textpad, and I would recommend it to anybody :)
  22. This is my engine, not really for mafia/criminal games but I suppose it could be adapted easily. It's just a PHP game engine to create a simple RPG game with all the basics (player battles, items, etc). http://www.ezrpgproject.com/ There are also many mods available on the forums. Here's a demo of the current stable version: http://www.ezrpgproject.com/demo/
  23. Re: [Competition Questions] Designing Dynamic Tables Revised code:   <?php $links = array ( array('text' => "one", 'href' => "one.php"), array('text' => "two", 'href' => "two.php"), array('text' => "three", 'href' => "three.php"), array('text' => "four", 'href' => "four.php"), array('text' => "five", 'href' => "five.php"), array('text' => "six", 'href' => "six.php"), array('text' => "seven", 'href' => "seven.php"), array('text' => "eight", 'href' => "eight.php"), array('text' => "nine", 'href' => "nine.php"), array('text' => "ten", 'href' => "ten.php"), array('text' => "eleven", 'href' => "eleven.php"), array('text' => "twelve", 'href' => "twelve.php"), array('text' => "thirteen", 'href' => "thirteen.php"), ); $columns = (isset($_GET['columns']))?intval($_GET['columns']):4; $num_links = count($links); $full_size = (ceil($num_links / $columns) * $columns); $links = array_pad($links, (ceil($num_links / $columns) * $columns), "0"); $i = 0; echo "<table>\n"; foreach($links as $l) { echo (($i % $columns) == 0)?"<tr>\n":""; echo ($l=="0")?"<td> </td>\n":"<td><a href=\"" . $l['href'] . "\">" . $l['text'] . "</a></td>\n"; echo (($i % $columns) == ($columns-1))?"</tr>\n":""; $i++; } echo "</table>\n"; ?>   Thanks for the push in the right direction, now the code is shorter :)
  24. Zeggy

    PHP encoding

    Re: PHP encoding Yes, there are of course much better solutions. To be honest, this isn't a product I am creating, or even a free service. It's more of a programming exercise. :) Personally, I don't have any use for this, but it's interesting for me. Plus I'll learn something new!
  25. Zeggy

    PHP encoding

    I'm trying to make a simple PHP encoder. Here's what I got so far: EDIT: See below It doesn't really do much, just uses base64 and gzdeflate to 'encode' chunks of code. I'm wondering, what else could I do to improve the encoding process? I've seen some other encoders (http://www.rightscripts.com/phpencode/index.php), and they seem to generate some extra code to confuse you. I'm also thinking of using tokens to possibly obfuscate some code, and optimize it at the same time. I don't have much experience using tokens, maybe somebody could give me some tips/warnings?   Updated code: <?php $compressed = stripslashes($_POST['code']); $newline = array("\r\n", "\n", "\r"); $replace = ' '; $compressed = str_replace($newline, $replace, $compressed); $code = token_get_all($compressed); $new_code = ""; foreach($code as $token) { if ($token == ";") { $new_code .= $token; } else { $name = token_name(intval($token[0])); if ($name != "T_COMMENT" && $name != "T_ML_COMMENT" && $name != "T_OPEN_TAG" && $name != "T_CLOSE_TAG") { $new_code .= $token[1]; } else { //echo $name . " thrown away. "; } } } for ($i = 1; $i <= 10; $i++) { $compressed = gzdeflate($new_code, 9); $compressed = chunk_split(base64_encode($compressed)); $compressed = "eval(gzinflate(base64_decode('" . $compressed . "')));"; } ?> <form method="post" action="encode.php"> <textarea style="width: 900px; height: 600px;" name="code"><?=$compressed?></textarea> <input type="submit" value="Encode!" /> </form>   I added some code to remove comments, php open/close tags (since they don't belong in an eval expression) and new lines.
×
×
  • Create New...