Jump to content
MakeWebGames

Anonymous

Members
  • Posts

    74
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Anonymous

  1. By the looks of the it, the forum hash mangled the code by adding smilies - should be easy to repair with an editor's replace function ie; replace <img src="images/smilies/tongue.png" border="0" alt="" title="Stick Out Tongue" class="inlineimg" /> with :p
  2. I refer you again to session_set_cookie_params() and indeed the remainder of the session_xxx function suite. It is far from useless as our talented friend above claims, as many web developers can attest to. The note referred to above was unfortunately written by somebody who failed to understand how session cookies themselves work both at server and client ends. "How do I get results from a MySQL database" may be answered simply by a link to the mysql_query() documentation, however it should be apparent to anybody how has taken the time to at least make a cursory glance at the documentation that mysql_connect(), mysql_close(), mysql_fetch_array(), mysql_free_result() are all important. Likewise in this case - my initial link is a pointer the primary reading point of the documentation - I would expect people to take the time to read further, to try and understand the ins and outs of the tools at their fingertips. Is this not after all a programming forum? If the OP simply can't be arsed to do the work him/herself, then fine - I say go ask Jeeves/Google or whatever your poison is, but don't clutter up the board with dumb requests. If however it is indeed a programming forum, then isn't it better to have a pointer in the right direction - which in turn may lead to the OP learning things that obviously other people here haven't taken the time to.
  3. session_set_cookie_params()
  4. Optimizing away cron jobs
  5. Anonymous

    New game

    Interesting although hardly surprising for this place how a simple request for a light-hearted critique turns into a "mines-bigger-than-yours" / "yours-blows" not to mention rather off-topic argument. I for one actually like the game; I've no wish to try and subvert it; I'm interested in seeing how a character, if that is the correct term, develops. Juggling resources in an effort to provide an optimal path through the various stages of the game is made complex by not having prior experience thus for me; it's fresh. I stand by my statements regarding the theme, however font-size and family are simple enough to tweak at my end with the facilities of any half decent browser to make it somewhat more readable. I installed a copy myself out of curiosity, though I've no intention of running a public facing game - the code is like a lot of open-source scripts - there are good points and bad points and I suspect that most if not all people here with an interest in PHP programming could benefit from at least one part or more. Minor grammatical, and spelling errors aside, I repeat again my earlier statement about there being some small errors, but they are just that. A decent team of testers paying attention to the site could report most of these within a few days. Fixing them; at least for me; is one of the reasons I enjoy programming, and I've no doubt the OP has a similar mindset. As was mentioned, the game is in Beta at the moment, thus I expect certain features to be offline or not functioning quite as expected; however the lack of screenshots is hardly something to be overly concerned about. Were it me, I'd be working hard on ensuring the gameplay itself works nicely; once that stage is complete, perhaps during RC phases I'd employ somebody to grab some decent screenies in number of browsers showing different aspects of the game - idealy both early and late game to show some of the features players can strive for. All in all - I like it; Whether I continue to play or not is based on my experiences within the game, not other peoples assumptions accurate or otherwise about the quality of the code or the security. Putting work into the game from what I can understand from the admin panel is not just limited to code / theme; but the ability to tune the parameters that control gameplay mean that many changes can be made hopefully gradually in a production server. Taking the time from there to add other building types, research forks, defensive measures etc - may be possible however like most things a good understanding of the database and code would be needed as well as the experience of listening to players and watching their interactions.
  6. echo <<<EOT No idea; I like using "heredoc" and 'nowdoc' myself. EOT;
  7. Anonymous

    New game

    And in other news... [ATTACH=CONFIG]154[/ATTACH]
  8. Anonymous

    New game

    I wasn't aware the source for that was open-source, however it's playable, it works and it has some appeal which is more than can be said for most of the products discussed here. Thematically, the reliance on a small serif font is not ideal as is the requirement to scroll many pages. I could also mention the starkness of the theme but perhaps I've just grown used to low-contrast colors. None of which is relevant to actual gameplay. As a whole, I tend to like the genre though perhaps it needs something else to really shine. What I know not, I just have the feeling it needs that extra "spark". There are certainly bugs; some visual, some logical, though nothing that cannot be sorted out with a little attention to detail. As for gameplay, too early to tell yet although going by other products that I've seen using a similar codebase, there are some minor grievances I had with certain aspects. That is however a personal viewpoint, rather than a criticism of the game itself
  9. I imagine the installer would create one - if not, it's possible there is a permission error; although if I recall correctly, the V2 mccodes did perform limited permission checking (not that that is much of a seal of approval)
  10. Going by what I've been able to learn from prior versions - modifying the values in config.php would solve this
  11. @newttster - Optimizing away cron jobs should be sufficient to explain the use of this type of technique.
  12. Indeed, but some pedants here dislike people suggesting CSS-3. At least this way there's a chance it will work in everything back to pre IE6 days.
  13. Tried replacing $db->query with mysql_query ?
  14. There is one key feature to it: echo sprintf('<tr class="%s">', $odd ? "odd" : "even"); which suggests you do similar. You are echo'ing a <tr> element ... change yours to suit. echo "<tr class=\"xxx\"><td align=left><a href='profile.php?viewuser=$d->username'>$d->username</a></td><td>$d->regged</td></tr>"; Replace xxx with odd/even to suit. You will of course have to provide a mechanism to flip odd to even and back again - and of course the css to support odd/even rows, but that I leave as an exercise. While I don't mean to sound harsh - perhaps the "Website Developer - Willing to help you!" tag in your sig is overly optimistic?
  15. echo "<table>"; $sql = "SELECT field1, field2, field3 FROM table ORDER BY field1 LIMIT 20"; $rs = mysql_query($sql); $odd = 1; while ($row = mysql_fetch_array($rs)) { echo sprintf('<tr class="%s">', $odd ? "odd" : "even"); # echo "<tr>"; commented out to appease the pedantic fool below echo "<td>" . htmlentities($row[0]) . "</td>"; echo "<td>" . htmlentities($row[1]) . "</td>"; echo "<td>" . htmlentities($row[2]) . "</td>"; echo "</tr>"; $odd = 1 - $odd; } mysql_free_result($rs); echo "</table>";
  16. Assuming a dedicated low-traffic box, then perhaps the prior poster is correct; however even with 500 odd actives it can be shown that these crons will exhibit visible lag from the users point of view. There is of course some question as to whether this is in part due to poorly optimized SQL however that's best left for a different topic. On shared boxes, where you have no control over what jobs other users may be running, adding to the load is not going to help in you or anybody else; it can only make it worse. I've noticed quite a few shared hosting companies using hard limits on the minimum period between crons to reduce peak loads; I can only assume they offset each user by a small amount to counteract the obvious problems with this. Using MySQL events is an interesting solution, but non-portable, difficult to maintain, and as far as I am aware, useless on replicated/clustered back-ends not to mention cloud based storage solutions. As a number of hosting organizations now use transparent data backup mechanisms; this could easily cause a range of problems that are not even visible until you come to perform a restore. This also suffers from the same problem as basic crons - in that many users sharing a box will put excessive load on the system each "tick". There are better solutions; one being using timestamps rather than countdown fields and only "regenerating" records only when they actually need it. This particular method is popular across larger products and is really not that difficult to implement on the MCCodes codebase. At the bare minimum, adding a "last_regenerated" field (for example) to your users table, you can dispose of the minute and five minute crons almost instantly. With a little extra work, most of the day-cron vanishes as well, followed with a little more work by the hour cron.
  17. Actually no, I wasn't - I was retrieving two values from the initial data-array: the user id who made the most recent hit, and the user id of the user making the most hits. No attempt was made to extract time-online at any stage.
  18. Sorry, please explain where the problem is - As stated, if you perform your median values, then the code as shown produces those results - which suggests that user B is more active than user A which is clearly not the case. Increasing the date past your 2 January 1970 05:46:40 marker still doesn't help: $data['user-a'] = array ( strtotime('Jan 1st 1980 12:00:00'), strtotime('Jan 1st 1980 12:30:00'), strtotime('Jan 1st 1980 13:00:00'), strtotime('Jan 1st 1980 13:30:00'), strtotime('Jan 1st 1980 14:00:00'), strtotime('Jan 1st 1980 14:30:00'), strtotime('Jan 1st 1980 15:00:00'), strtotime('Jan 1st 1980 15:30:00'), ); $data['user-b'] = array ( strtotime('Jan 2nd 1980 12:00:00'), ); echo "user-a : " . floor(array_sum($data['user-a']) / count($data['user-a'])) . "\n"; echo "user-b : " . floor(array_sum($data['user-b']) / count($data['user-b'])) . "\n"; >> user-a : 315,582,300 >> user-b : 315,662,400 (Comma's added for clarity) For comparison, a different tack: $now = time(); // cache the time $timestamps = array(); // the main data array(user => array(timestamp, ...)) foreach (range(1, 50) as $user) { $timestamps[$user] = array(); foreach (range(1, mt_rand(1, 10)) as $j) // random number of hits (1-10) per user { $timestamps[$user][] = $now + mt_rand(-999, 999); } } /** * Compute most recent active user * i.e.: for each user, compute the maximum timestamp * display the user the highest timestamp. */ $best = array(0, 'none'); /* highest timestamp, user # */ array_walk($timestamps, function($value, $key, $best){ if (($sum = max($value)) > $best[0]) { // if the highest timestamp > the best... $best = array($sum, $key); } }, &$best); // NB: Reference echo "Most recent user was " . $best[1] . " who's last access was at " . strftime('%Y-%m-%d %H:%M:%S', $best[0]) . "\n"; /** * Compute the most active user in respect of page hits * i.e.: for each user, compute the number of hits * display the user with the highest number of hits. */ $best = array(0, 'none'); /* number of hits, user # */ array_walk($timestamps, function($value, $key, $best){ if (($num = count($value)) > $best[0]) { // if the # of page hits > the best... $best = array($num, $key); } }, &$best); // NB: Reference echo "Most active user was " . $best[1] . " who made " . $best[0] . " page hits\n"; >> Most recent user was 35 who's last access was at 2011-08-19 01:15:24 >> Most active user was 29 who made 10 page hits Purely as an example - I realize we are stepping outside the bounds of the original topic. Results will differ due to random data.
  19. Sorry, still doesn't make sense:   cat x1.php <?php $data['user-a'] = array ( strtotime('Jan 1st 1970 12:00:00'), strtotime('Jan 1st 1970 12:30:00'), strtotime('Jan 1st 1970 13:00:00'), strtotime('Jan 1st 1970 13:30:00'), strtotime('Jan 1st 1970 14:00:00'), strtotime('Jan 1st 1970 14:30:00'), strtotime('Jan 1st 1970 15:00:00'), strtotime('Jan 1st 1970 15:30:00'), ); $data['user-b'] = array ( strtotime('Jan 2nd 1970 12:00:00'), ); echo "user-a : " . floor(array_sum($data['user-a']) / count($data['user-a'])) . "\n"; echo "user-b : " . floor(array_sum($data['user-b']) / count($data['user-b'])) . "\n"; php -f x1.php user-a : 45900 user-b : 126000
  20. Images appear for me and I don't have an account with the shack.
  21. If I may presume to simplify; assume user A logs in on Jan 1st 1970 @ midday, and is active for 2 more hits spread 30 minutes apart, and user B logs in on Jan 2nd 1970 @ midday, but leaves instantly: $array[ 'user-A' ] = array( 39600, 40400, 42200 ); $array[ 'user-B' ] = array( 126000 ); Summing these we get: $array[ 'user-A' ] = 122200 $array[ 'user-B' ] = 126000 Which user is more active? The basic assumption here is that you can add timestamps; which just doesn't work for me. The number produced is not a valid indication of activity, rather it's an arbitrary number with no meaning.
  22. No still not clear - why are you aggregating timestamps? The initial loop populates an array such that: $arr_usertimestamp[ <element> ] = array( <timestamp1>, <timestamp2>, <timestamp3>, ... ); Which is fine, but then you aggregate those timestamps creating $arr_usertimestamp[ <element> ] = <timestamp1> + <timestamp2> + <timestamp3> ... Why? What purpose does adding times together get you?   As for array_sum returning an int... does it? cat x1.php <?php $a = array(1,2,3,4,time()); $b = array_sum($a); echo "b is :\n"; echo $b . "\n"; echo "serialize(b) is\n"; echo serialize($b) . "\n"; echo "print_r(b) is\n"; print_r($b); echo "\nvardump(b) is\n"; var_dump($b); php -f x1.php b is : 1313705145 serialize(b) is i:1313705145; print_r(b) is 1313705145 vardump(b) is int(1313705145)   [edit] PHP manual states that array_sum returns an int or a float; so the result will be determined by the values store in the array and the bit-size of the machine although I've not verified the latter assumption. In my case, on a 64-bit machine the cast to int is redundant.
  23. foreach($arr_usertimestamp as $user => $timestamps) { $arr_usertimestamp[$user] = intval(array_sum($timestamps)); // PS. array_sum returns a float } what? Sorry, you lost me totally there - why are you aggregating timestamps? why the int cast? this makes no sense.
  24. 1. Use [code] ... [code] tags here 2. Don't use short open tags 3. Indent your code 4. Enable full error reporting 5. Syntax check your code 6. Validate (or least make some attempt to) the HTML
  25. Anonymous

    Waypoint 4

    Curiosity at first design had me firing up the graphics software ... [ATTACH=CONFIG]153[/ATTACH] (1600x1200; not watermarked)  
×
×
  • Create New...