Jump to content
MakeWebGames

Floydian

Members
  • Posts

    900
  • Joined

  • Last visited

    Never

Everything posted by Floydian

  1. Floydian

    PHP Load Times

    It seems like both of you are measuring the php processing time. The biggest time consuming part of delivering a web page to a user is sending the data over the wire. Another issue that hugely dominates over php processing time is javascript execution time (and possibly locking of the browser during script execution). One can easily shave a tenth of a second by focusing on those areas, which is far more time than all of the times listed in the first two posts (measured by the hundredths and thousandths, as opposed to tenths). Therefore, if you php execution time stays well below the time it takes to deliver a page to a user, then it's not worth focusing on optimizing the php execution times. Cheers
  2. Thanks TwiztedFake for posting the problem and the solution. I apologize for not responding sooner. I've been slammed busy. I'll push out a 1.0.3 version very soon to correct that error. The 1.0.3 will also contain one php 4 compatibility update as well. Cheers   PS Please post any bugs here. I will investigate any bugs that come up.
  3. @CrimGame.com: flattery will get you nowhere :P Thanks for the compliments. @Rasheed Saeed: Again, thanks for the compliments. @reek13: What character encoding is that page using? I need to know the character encoding that the browser uses. If you know how to change that, set it to UTF-8 @Enuf: Thanks for the suggestion. This is a replacement for the ***stock*** gangs. Therefore, it cannot have features the stock gangs do not have. However, there is a plugin system built into this mod and you are more than welcome to make a gang image staff menu plugin for this. Once they plugin is made, people that use your plugin would only need to edit their gang list to show these images, and add a field to the db. I'll definitely check out your work, if you rise to the task of making the plugin. Cheers
  4. Add this after the other functions you added: if(!function_exists(array_combine)) { function array_combine($arr1, $arr2) { $out = array(); $arr1 = array_values($arr1); $arr2 = array_values($arr2); foreach($arr1 as $key1 => $value1) { $out[(string)$value1] = $arr2[$key1]; } return $out; } }
  5. Add this code right after the array_diff_key() fix:   if (!function_exists(array_fill_keys)) { function array_fill_keys($keys, $value) { return array_combine($keys,array_fill(0,count($keys),$value)); } }   Cheers
  6. Alrighty, to fix the array_diff_key error, find this code at the very top of yourgang.php:   <?php   Replace that with this code:   <?php if (!function_exists('array_diff_key')) { function array_diff_key() { $arrs = func_get_args(); $result = array_shift($arrs); foreach ($arrs as $array) { foreach ($result as $key => $v) { if (array_key_exists($key, $array)) { unset($result[$key]); } } } return $result; } }   This fix is only needed for folks using php < 5.1 So if you're using php 5.0.x or php 4.x.x, you need this fix. This will also be included in the 1.1 release. Cheers
  7. Thanks for reporting the errors mixerman212. That was very helpful. I didn't realize array_diff_key() is only available in php 5.1 or greater. Both of those errors are php 4 compatibility issues. I'll look into a workaround for this. The array diff key one will take some time, but the first one can be fixed by finding this code in the public/gang_list.php file: /**/ $atoz = range('A', 'Z'); $all_selected = ' selected'; foreach ($atoz as $key => &$value) { if (strtoupper($letter) === $value) { $selected = ' selected'; $all_selected = ''; } else { $selected = ''; } $value = <<<EOT [url="gangs.php?action=gang_list&letter=$value"]$value[/url] EOT; } unset($value); $atoz = implode(' ', $atoz);   Replace the code above with the code below: /**/ $atoz = range('A', 'Z'); $all_selected = ' selected'; foreach ($atoz as $key => $value) { if (strtoupper($letter) === $value) { $selected = ' selected'; $all_selected = ''; } else { $selected = ''; } $atoz[$key] = <<<EOT [url="gangs.php?action=gang_list&letter=$value"]$value[/url] EOT; } $atoz = implode(' ', $atoz);   This edit is only necessary for folks running php 4. If you're running php 5, this edit is not needed. I'll post a fix for the other one, and include these in a 1.1 version very soon.
  8. GANG REPLACEMENT This is a replacement for Mccodes V2 gangs. It replaces all of the gang pages except for the organized crimes. If you are looking for a gang script that has none of the same old bugs that plague mccodes, then you have found the solution right here! The same programming excellence that has made the Horizons Game Engine the most secure browser game engine, has created the new fantastic gang replacement mod. Without further ado, the mod can be downloaded at the following link: http://makewebgames.io/index.php?page=DownloadDBData&dataID=33 SCREENSHOTS [tabmenu] [tab=Public Gang Pages] The list of gangs (note that it is paginated, and can be filtered by the gang's first letter of their name. Gang war list: Another view of the gang war list: A gang's public profile page: [tab=Private Gang Pages] Donation page: Your gang's member list: Your gang's index page: Your gang's summary: Your gang's wars: [tab=Gang Staff Pages] War management: Vault management: Staff management: Gang settings management: Gang staff menu: [tab=Official Plugins] Organized Crimes -- [go] Hit and Run -- [go] Coming soon! [/tabmenu] FEATURES Designed as a drop in replacement for mccodes version 2 gangs. Has a plugin design that allows new gang content to be dropped into the gangs. Gangs with no members are automatically deleted when a user attempts to view that gang. Players listed as being in a gang that doesn't exist are automatically reset. Gang wars between gangs that don't exist are automatically deleted. The page that lists all gangs is paginated and grouped alphabetically. No more mile long lists of gangs! Players are limited to a predetermined number of applications that can be pending at any given time. Therefore they can not apply to more gangs than the "max_application" setting. Players have the ability to see the applications they have submitted and they can cancel them as well. Gang files are consolidated into fewer files. Files like creategang.php, gangcentral.php, gangwars.php. You only need to keep gangs.php and yourgang.php. gangs.php is the portal to all public gang pages. yourgang.php is the portal to all private (my gang/my gang staff) pages. Players are asked for confirmation before kicking gang members, leaving the gang, or disbanding the gang. There are too many more features to list here! INSTALLATION First and foremost, this is a drop in replacement for mccodes gangs, and as such, you simply copy the files into your game. Make sure to preserve the relative paths. There are subfolders for most of the gang scripts. Secondly, the gangs.php and yourgang.php has an mccodes lite header code in it. You need to replace with your own header code. This is pretty straighforward, and pretty much means simply adding this: include('globals.php'); SUPPORT This mod is fully supported. Any bugs/errors will be addressed by an update/patch if needed. Errors arising from problems caused by the installation, or customizations resulting in incompatibility with the mod are not covered. The mod is distributed as is. You can pretty much do what you want with it. The only caveat is that any derived works must be distributed with a copy of software. Any plugins that are files that were not part of the "official" gang replacement mod can be distributed without any caveat. It's only when you edit one of the files that is included in the official mod, or you edit a file which is a descendant of a file that is included in the official mod that you need to distribute the software with your new file. FEEDBACK If you download this mod, please post some feedback here whether your feedback is positive or critical. I would love to hear your thoughts on this mod. TRY BEFORE YOU INSTALL You can see the mod in action by going here: PHP Horizons Mccode Mods Enjoy! VERSION HISTORY 1.0.0 Initial Release 1.0.1 Added a new css style ------- Fixed two php 4 compatibility issues ------- Added a call to $h->endpage() in gangs.php and yourgang.php ------- Added an instruction to the README to clarify the installation process. 1.0.2 ------- Fixed one php 4 compatibility issue 1.0.3 NOT YET RELEASED ------- Will hopefully fix any remaining php 4 compatibility issues. ------- This update will be available very soon.
  9. After a successful beta test, the gang mod is being released today! Once the download link becomes available in the script vault, I'll post an announcement in the free mods forum, along with screen shots. Cheers
  10. Just a quick update for the folks who are anxiously awaiting the release of the gang replacement mod. The beta test is going well. So far only one bug has been found and that bug was very minor. Gang attack logs showed any fights that were won as "drawn". That has been fixed. I want to thank the folks who are beta testing. The final release of the gang replacement mod should be within the week. I have the first official plugin for the gang replacement mod about 50% complete. It's a large mod that will be priced very attractively. The staff panel (the game staff, not the gang staff) for this will include an ajax simulator... :O now what might the game staff need a simulator for? Feel free to post your speculations!
  11. Ignore the code posted below, it's just to document the yourgang.php file and put a timestamp on it.   <?php /** * @name gangs.php * @author Floydian * @link [url]http://www.phphorizons.com/[/url] * @version P1.0.0 * @copyright All rights reserved by Floydian and PHP Horizons 2009,2010 */ ##################################################### # HEADER CODE -- You may need to use the header # # code that is included in your game. For instance, # # if you are running mccodes vs 2, you would need # # to remove the below code and include globals.php # ##################################################### session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); $gq=mysql_query("SELECT g.* FROM gangs g WHERE g.gangID={$ir['gang']}"); $gangdata=mysql_fetch_array($gq); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); ###################### # END OF HEADER CODE # ###################### error_reporting(E_ALL); define('GANG_MODULE', true, true); // gangID, gangNAME, gangDESC, gangPREF, gangSUFF, gangMONEY, gangCRYSTALS, gangRESPECT, gangPRESIDENT, gangVICEPRES, gangCAPACITY, gangCRIME, gangCHOURS, gangAMENT include('./gangs/config.php'); $gvars = new GangVars(); $gvars->setPage('private'); include('./gangs/content.php');
  12. Thanks for the offer. I'm very interested in getting folks using the mod in number. I am 99.99% confident about it working fine on a version 2 game. The aspects of testing I'm looking to flesh out are what happens when there are 20 gangs, 15 wars, and lots of activity.   You certainly may add your 2 pence ;) This mod only includes stock mccodes version 2 features because it's intended to be a drop in replacement. I.e., it does not require altering the gangs table and adding a gangPIC field. It would be great to see a mod that adds in those features. Cheers and thanks for your replies and interest in the gang mod.
  13. I'm looking for one or two game owners to beta test my new free gang mod. The mod is finished, and ready to be released, but I want to put it into a live game for real testing before I release this to the general public. This gang mod is and will always be entirely free. Anyone will be allowed to make mods that can plugin to it. They can give those mods away for free or they can sell them. I haven't decided on the exact license that I will release this under because I need a license that will allow folks to make additions to the software and sell it. Now you know that the software you would be beta testing will always be freely available and you will not ever have to remove it from your game. Why replace mccodes gangs with my gang mod? There are many reasons. Below are a number of those reasons:   If you want to see what this mod looks like, you can go to my site and make an account: http://mccode.phphorizons.com/ This is a drop in replacement for mccodes version 2 gangs. If you aren't running version 2 software, please don't contact me about beta testing. You will be able to install the mod yourself when I release it, but I am looking to test this mod on an mccodes version 2 game.   I should also mention that this mod comes with support. Whist I can tell you that the code is a million times more secure than standard mccodes, and that I've taken every precaution against allowing any bugs/exploitable code, there is always a chance that I did something wrong. If any are found, patches will be released. Game owners will be expected to install these patches themselves, but I will be supporting this mod for free. There will be a max of two beta testers, so hurry and contact me as soon as possible so that you can be the first to use this kick ass mod!   This mod does not require editing any of your existing files. You simply replace gangs.php and yourgang.php, and then copy a new folder to your game called gangs which contains the files that form the basis of the gang plugin system. Once you have done that, your gangs should work as they did before, so long as they are pretty close to stock mccodes 2 gangs.
  14. Floydian

    question

    That's a good way to do things. Selecting all the fields from the users table might be inefficient if there are lots of fields. What really costs the most is doing the query in the first place, regardless of whether you select 2 or 20 fields. But if your users table has 100 fields, and you can select just 10 of them, that might start getting into a situation where there's a good savings in not selecting everything. Now your script could use some improvements though. Number one, instead of using -1 as the default, null is prefered. null is the default value for unset php variables, and it really makes sense to use that. And secondly, you run a mysql escape on the userid. What you really should do is run abs(intval()) on that. Lastly, that concatenation you're doing in that query is not doing anything for ya there. It'd be easier to read the code if you didn't use concatenation there. Now if that concatenation was having an effect, I'd say keep it, but it really isn't doing anything different from just plugging the variable into a string.   function user($sql, $user=null) { global $connect; $sql=mysql_real_escape_string($sql); if (is_null($user)) { $user=$_SESSION['id']; } else { $user=abs(intval($user)); } $qry = mysql_query("SELECT `$sql` FROM `users` WHERE id=$user"); return mysql_fetch_array($qry); }
  15. This is just my two cents. I personally use and recommend Zend Studio 5.5 Yeah, that's 5.5, not 6, and not 7. Reason: Since Zend 6 and the move from being a native windows app to being an Eclipse plugin, Zend changed a lot. If you like Eclipse PDT, then you will probably like Zend 7, but if you liked Zend 5.5, then you will definitely want to try Zend 7 before you pay for it... From what I can tell, Eclipse PDT has pretty much everything Zend 7 has. PDT = free and Zend 7 = $400 big ones. cheers! PS: I do use Eclipse PDT whenever I'm doing PHP 5.3 specific code since Zend 5.5 does not support PHP 5.3 style namespaces or anonymous functions.
  16. Thanks Big-Bad-Ass, Jordan - Pudda, and Zero-Affect for all your good words. Next on my agenda is a gang mod. It's going to be a plugin based gang mod. The main module will be free. It will have very little functionality on it's own, but plugins will provide all the functionality. For instance, a plugin can add new gang staff panel content like making alies. This same plugin can add in a gang panel that allows gang members to see their allies. The main gang module will load the plugins and provide a framework for plugging in links/tabs to the gang page. It will use variables for "gang", "gangs", "Gang", and "Gangs" so that people can easily change the nomenclature to fit their games. Anyways, I'm getting off topic here. Let me know if any of ya'll want to try out the slot mod. I have it up and running on my mccode lite demo site. Cheers
  17. Thanks for the nice words and thoughtful critique of my post! The suggestion about putting a contact email has been implemented.   Yes, I anticipate folks having questions about installing the mod. Whilst I'm not personally installing this, I am available to answer questions and point folks in the right direction. The donor features is an interesting angle. Perhaps folks who are interested in this mod might offer up their suggestions for a donor feature for this mod. Cheers
  18. Floydian

    $end issue

    You're welcome. It would apply to EOF. The letters used in heredoc identifiers don't matter, and the rules are the same for all. Cheers
  19. Slot Machine Upgrade for Mccode any version! Standard Version: $25 USD (no animation) Premium Version: $35 USD Paypal/contact email: [email protected] These slots have two major upgrades from the mccodes slots. #1 The premium version includes animated slots! it's javascript based and the users have the option of turning the animation on or off. For players that have javascript turned off, the slots will work as they would with animation turned off. #2 Both versions include virtual money! Players can play as much as they want without having to spend any money! Features included in both versions are: #1 Token based betting. Users get a certain number of tokens every day just like all the other slot mods. They can be their in game money until they run out of tokens. When they run out of tokens, they can still keep playing by using their virtual money! #2 Tokens can be based on real items or virtual tokens. Real item tokens are items that get given to players and placed in their inventory's. As they play the slots, these tokens are taken. Depending on your game settings, and how you make these token items, players will be able to trade tokens with other players! If you use the virtual tokens, those tokens are stored in a slot_data table. Players cannot trade these tokens. This option can be cofigured in the easy configuration file included with this mod. Simply change 'item' to 'virtual' or 'virtual' to 'item'. Please keep in mind that if using items, you need to specify an item id for the token item. If an item doesn't exist for that yet, you will need to create one. There is SQL code in the README to help you create an item. If using virtual items, you will need to create the slot_data table. There is SQL code for you in the README that you can run to easily create this table. #3 There are tons of configurable settings. I'll list some below: $money_field -- allows you to direct the script to use bankmoney or crystals instead of the default money users table field. $money_name -- If you use something other than money (Crystals, Diamonds, Euros, etc) you can specify the proper name for your currency here. (uppercase) $money_name_l -- Same as above but this is the lowercase version. $money_prefix -- Do you need a $ or the Euro sign, or perhaps the Pound sign? This field allows that. Leave it blank if no sign is needed. $max_bet_multiplier -- The max bet is defaulted to the player's level * $max_bet_multiplier. $tokens_type -- item | virtual (explained above) $slot_item_name -- If using virtual tokens, this allows you to name the tokens. It could be Ticket, or anything. When using real item tokens, the name of the actual item will override this. $tokens_max_daily -- The number of tokens players are credited with per day. $tokens_compounded -- Here's a quote from the cfg file's comments: $tokens_item_id -- the itmid of the item to use for tokens (this is not used if you are using virtual tokens) $tokens_credit_if_laston -- Only credit tokens to players who have been online since the last 3 days (3 days is the default, you can set it however you like) $slot_data_table -- You can name the slot_data table anything you like. It defaults to slot_data. $slot_session_name -- virtual money uses sessions to propagate the virtual money value from page to page. You can change the name of this session variable if you already have a session variable that conflicts with the default name (SLOT_MACHINE_DATA) $slot_session_starting_money -- This is how much virtual money players get to start with. They can refill at any time. This is mainly used to scale the starting point to an amount that makes sense and fits in with your game. If players have billions of dollars, you might consider increasing this number to 1 billion or more. $match_two_payout_multiplier -- When 2 numbers are matched on the slots, what is the payout multiplier. It defaults to 3. $match_three_payout_multiplier -- When 3 numbers are matched on the slots, what is the payout multiplier. It defaults to 10. (The default numbers seem to be slightly losing, so you should consider raising these a bit) $animation_defaults_on_off -- If you have purchased the premium version, you can set whether or not the slots are animated by default. The users will still be able to turn them on/off regardless. There are options for just about everything. The main idea with this mod is to make a visually appealing slot machine. This gives your game that little bit of bling that just might catch that new player's attention. I highly recommend purchasing the premium version of this mod. Another main idea is that this mod never prevents your users from playing the slots. They can't sit there all day and make money with it, but they can enjoy playing it whenever they want. It has a highly intuitive user interface. The animation is very short so that it doesn't make playing the slots take too long. No javascript is required. If the player does not have javascript, or it is turned off, the animation will simply not activate and they can play the slots as if they were using the standard version. I have this mod setup and is ready for you to demo today! Just send me a PM here and I'll get you hooked up. I fully support my mods. Any bugs will be promptly fixed. Installation is self serve. I have made this mod as easy to install as I can, and the low price means I cannot install it. I will install it for you though for a fee of $10. This mod is compatible with any version of mccodes. The header code is different from one version of mccodes to another, so you will need to copy your header code and place it into the slotsmachine.php file unless you are using mccdoes lite. The mod comes with a README that documents the entire installation process and all files have all relevant portions of code very clearly marked (like the header on slotsmachine.php and all settings in slotsmachine.cfg.php are fully documented.) I will answer any questions I can, so don't hesitate to get a hold of me. I have a very extensive list of references, so if you don't know me or haven't had me do work for you before, I can give you a list of 10 or so sites that I have done a lot of work for. I could list a lot more sites, but I'd only list sites with a substantial amount of work from me. I do have a portfolio on my business website and I'll link you to it upon request. This is a screenshot of the slots. Please click on it to enlarge. This screenshot shows the slot wheels in motion!
  20. I have a slightly different use case since my image function starts with html, and not bbcode, but you can apply the bbcode to html conversion and then apply a function like the one I use. A call to getimagesize() would make this code more secure. This function does a number of things: 1. It makes sure the image src ends with one of the $valid_imgs file extensions (this makes it difficult to load php pages from your own site like logout.php or itemsell.php?ID=23423) 2. It makes sure none of the strings in $invalid_imgs is contained in the string (and this makes it impossible to load php pages from your own site) One call to this function will clean all instances of images in one string. So you can clean out 100 images at once. It is possible to put in a string that ends with .jpg that links to a file that is actually a php page. But my code assumes that my own site does not have malicious php files masquerading as jpg files. It would be better to have getimagesize though in order to know 100% for sure the image is an image. It can easily be added in.   function clean_images($string) { $count = 0; $img_start = 0; $valid_imgs = array('.png', '.jpg', 'jpeg', '.gif', '.PNG', '.JPG', 'JPEG', '.GIF'); $invalid_imgs = array('.html', '.js', '.css', '.php', '.htm'); do { $count++; $img_start = stripos($string, '<img', $img_start); if ($img_start !== false) { $img_end = stripos($string, '>', $img_start); $image = substr($string, $img_start, $img_end - $img_start +1); $string_beginning = substr($string, 0, $img_start); $string_ending = substr($string, $img_end+1); $check_count = 0; foreach ($valid_imgs as $value) { if(strpos($image, $value) === false) { $check_count++; } } if ($check_count >= $valid_imgs) { $image = ''; } else { foreach ($invalid_imgs as $value) { if(strpos($image, $value) !== false) { $image = ''; break; } } } $string = $string_beginning . $image . $string_ending; $img_start++; } if ($img_start > strlen($string)) { $img_start = false; } } while ($img_start !== false); return $string; } // End clean_images() function.
  21. Floydian

    $end issue

    Hello War_Hero, When I put this code into my IDE and put each line of code onto it's own line, there were no syntax errors. The use of heredoc (<<<EOT and EOT;) is tricky and probably is the source of the errors. A line of code like this (from your code above) is invalid without line breaks: print <<<OUT</center></td></tr></table></td></tr></table></center></body></html>OUT;   This code below is valid: print <<<OUT </center></td></tr></table></td></tr></table></center></body></html> OUT;   Here are some things to note about heredoc formatting:   print <<<OUT // <---- nothing can come after this part of this line. not even a space </center></td></tr></table></td></tr></table></center></body></html> OUT;//<-------- nothing can come after this line either. heredoc must be ended on it's own line. //^ //| //| // \---------- OUT; must start on a new line, with nothing before it on that new line (you could use EOT; or //FFF; or any series of letters so long as it matches the series of letters that began the heredoc sequence)   Hope that helps.
  22. Hello bluegman991, The problem you have there is that you are calling secimg() before preg_replace can substitute a value for '//1'. Your idea of using preg_replace's ability to take a substring and place it into a placeholder is sweet, but you need to be able to execute that secimg() function in the context of the regex, which I don't know if you can do. You may need to break this down into more discreet steps. Hope that helps.
  23. Hey jon182, there is no difference between the two lines of code below: $db->query('blah blah blah'); $string = 'blah blah blah'; $db->query($string);   Securing a query requires knowing what the exploits/voulnerabilities are and how to secure them. It's taken me years to really get a good handle on it. If you have more specific code examples of queries that may or may not be secure, those can be looked at on an individual basis to see if they are secure. Hope that helps.
  24.   abstract class ForumPost { protected $desc = 'be careful and prepared when you ask a question about many topics, it may end up in a huge debate.'; public function getDesc() { return $this->desc; } abstract public function doPost(); }
  25. I'll second that. If you have [/img], then the browser actually attempts to load the current page as the image. Therefore, if you have three of these on a page, you get four page loads total. If you aren't sure what image you want in there, just put anything, even it it's not a real image. That way, the browser attempts to load a nonexisting page instead of the current page. Hope that helps.
×
×
  • Create New...