z

Young Writers Society


Interested In How YWS Is Coded?



User avatar
425 Reviews



Gender: Male
Points: 11417
Reviews: 425
Thu Jun 11, 2009 5:07 am
Nate says...



If you've ever been interested in the structure behind YWS, I will be releasing all the code once we make the switch to the new YWS. It's a ton of code, and I'd say only 5% is the vanilla phpbb stuff. Of the remaining 95%, 40% is probably stuff I borrowed from other people with the remainder all me.

But, in the meantime, here's the code for the new User Stats page I did. Beware, it's not very well written. If it was a heavily trafficked page, I'd spend a lot more time optimizing it, but since I designed it mostly for me, I don't really care how horrible the code looks.

Code: Select all
<?

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

$user = $HTTP_POST_VARS['username'];
$time15 = time() - (15*24*60*60);
$time30 = time() - (30*24*60*60);
$time60 = time() - (60*24*60*60);
$time90 = time() - (90*24*60*60);

if ($user!='')
{
   $sql = "SELECT user_id, user_reviews, user_lastvisit, user_regdate FROM " . USERS_TABLE . " WHERE username = '" . $user . "'";
   if($result = $db->sql_query($sql))
   {
      $row = $db->sql_fetchrow($result);
      $user_reviews = $row['user_reviews'];
      $user_regdate = date("F j, Y, g:i a", $row['user_regdate']);
      $user_lastvisit = date("F j, Y, g:i a", $row['user_lastvisit']);
      $id = $row['user_id'];
      $message = "User Information For " . $user;
   } else {
      $message = "No person by " . $user . ".  Did you spell it correctly?";
   }

   if ($id != '')
   {
      $sql = "SELECT
            COUNT(p.poster_id) as dp_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 8 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $dp_reviews = $row['dp_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as np_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 10 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $np_reviews = $row['np_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as lp_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 9 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $lp_reviews = $row['lp_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as op_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 17 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $op_reviews = $row['op_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as af_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 6 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $af_reviews = $row['af_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as fanf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 75 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $fanf_reviews = $row['fanf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as ff_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 16 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $ff_reviews = $row['ff_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as hf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 61 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $hf_reviews = $row['hf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as nf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 18 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $nf_reviews = $row['nf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as rf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 2 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $rf_reviews = $row['rf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as sf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 3 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $sf_reviews = $row['sf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as of_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 5 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $of_reviews = $row['of_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as am_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 159 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $am_reviews = $row['am_reviews'];
      }


      $sql = "SELECT
            COUNT(p.poster_id) as pm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 27 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $pm_reviews = $row['pm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as lm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 41 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $lm_reviews = $row['lm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as sm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 24 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $sm_reviews = $row['sm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as om_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 26 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $om_reviews = $row['om_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as low_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            char_length(t.post_text) < 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $low_reviews = $row['low_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time15
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.post_time >= " . $time15 . " AND
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time15_reviews = $row['time15'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time30
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time30 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time30_reviews = $row['time30'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time60
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time60 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time60_reviews = $row['time60'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time90
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time90 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time90_reviews = $row['time90'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings
         FROM
            " . POSTS_TABLE . "
         WHERE
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings = $row['greetings'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings15
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time15 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings15 = $row['greetings15'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings30
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time30 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings30 = $row['greetings30'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings60
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time60 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings60 = $row['greetings60'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings90
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time90 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings90 = $row['greetings90'];
      }

   $total = $of_reviews + $sf_reviews + $rf_reviews + $nf_reviews + $hf_reviews + $ff_reviews + $fanf_reviews + $af_reviews + $op_reviews + $np_reviews + $lp_reviews + $dp_reviews + $am_reviews + $sm_reviews + $pm_reviews + $om_reviews + $lm_reviews + $low_reviews;

   $total2 = $total - $low_reviews;

   }

}

$template->assign_vars(array(
   'MESSAGE' => $message,
   'LASTVISIT' => $user_lastvisit,
   'REGDATE' => $user_regdate,
   'REVIEWS' => $user_reviews,
   'DP_REVIEWS' => $dp_reviews,
   'LP_REVIEWS' => $lp_reviews,
   'NP_REVIEWS' => $np_reviews,
   'OP_REVIEWS' => $op_reviews,
   'AF_REVIEWS' => $af_reviews,
   'FANF_REVIEWS' => $fanf_reviews,
   'FF_REVIEWS' => $ff_reviews,
   'HF_REVIEWS' => $hf_reviews,
   'NF_REVIEWS' => $nf_reviews,
   'RF_REVIEWS' => $rf_reviews,
   'SF_REVIEWS' => $sf_reviews,
   'OF_REVIEWS' => $of_reviews,
   'AM_REVIEWS' => $am_reviews,
   'PM_REVIEWS' => $pm_reviews,
   'LM_REVIEWS' => $lm_reviews,
   'SM_REVIEWS' => $sm_reviews,
   'OM_REVIEWS' => $om_reviews,
   'LOW_REVIEWS' => $low_reviews,
   'TIME15' => $time15_reviews,
   'TIME30' => $time30_reviews,
   'TIME60' => $time60_reviews,
   'TIME90' => $time90_reviews,
   'GREETINGS' => $greetings,
   'GREETINGS15' => $greetings15,
   'GREETINGS30' => $greetings30,
   'GREETINGS60' => $greetings60,
   'GREETINGS90' => $greetings90,
   'TOTAL' => $total,
   'TOTAL2' => $total2,
   'USER' => $user
));

   //
   // Start output of page
   //
   $page_title = 'User Statistics';
   include($phpbb_root_path . 'includes/page_header.'.$phpEx);

   $template->set_filenames(array(
      'body' => 'user_stats_body.tpl')
   );

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);


?>
  





User avatar
537 Reviews



Gender: Female
Points: 60568
Reviews: 537
Thu Jun 11, 2009 2:48 pm
Evi says...



O.o

Holy guacamole.
"Let's eat, Grandma!" as opposed to "Let's eat Grandma!": punctuation saves lives.
  





User avatar
189 Reviews



Gender: Male
Points: 1040
Reviews: 189
Thu Jun 11, 2009 2:55 pm
Jon says...



Wow Nate.


Well, atleast you didn't type it all yourself? (Maybe you did!) :shock:
Gay Writing/Support Group. Gay or not, spread the word!

Support GLBT people -- God does.

Got YWS?
  





User avatar
35 Reviews



Gender: Female
Points: 1111
Reviews: 35
Thu Jun 11, 2009 3:12 pm
phantom_blackfire_wings says...



My brain is telling itself to explode.
"What are you doing?"
"I've got paint and rollers...water sking"~The Philanthropist

Don't push the Red Button
  





User avatar
425 Reviews



Gender: Male
Points: 11417
Reviews: 425
Thu Jun 11, 2009 4:08 pm
Nate says...



Everything before "End Session Management" up top is standard for any phpBB page, as is everything from "Start output of page" and below. The remaining 98% in between is me, but if you look at the code, it's mostly the same. So it's just a lot of copy and paste, then minor changes.
  





User avatar
277 Reviews



Gender: Male
Points: 7061
Reviews: 277
Thu Jun 11, 2009 4:14 pm
Master_Yoda says...



I don't really understand some of the PhpBB script, but I can't really imagine writing that much SQL. That's a lot of queries right there! :)

Well thanks for wasting so much time on YWS. :D
#TNT

The woods are lovely, dark and deep.
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.
-- Robert Frost

I review your reviews: viewtopic.php?f=188&t=94522
  





User avatar
312 Reviews

Supporter


Gender: Female
Points: 6403
Reviews: 312
Fri Jun 12, 2009 5:23 pm
Mars says...



:o

You. Are. Amazing.

Master_Yoda wrote:Well thanks for [s]wasting so much time on[/s] pouring your soul into YWS.
'life tastes sweeter when it's wrapped in poetry'
-the wombats


critiques // nano
  





User avatar
1272 Reviews



Gender: Other
Points: 89625
Reviews: 1272
Fri Jun 12, 2009 5:47 pm
Rosendorn says...



Catching all the little alterations must require a lot of previewing.

Ditto, Mars. ;)
A writer is a world trapped in a person— Victor Hugo

Ink is blood. Paper is bandages. The wounded press books to their heart to know they're not alone.
  





User avatar
1260 Reviews

Supporter


Gender: Female
Points: 1630
Reviews: 1260
Thu Jul 16, 2009 1:09 pm
Elinor says...



O_o Wow. That's a lot of complicated stuff. Did you come up with yourself?
  





User avatar
245 Reviews



Gender: Other
Points: 2570
Reviews: 245
Sun Aug 23, 2009 8:39 pm
LowKey says...



Holy guacamole. o.0

Mars has it right, completely. Holy cow. Wow. Thanks! But... wow.
  





User avatar



Gender: None specified
Points: 1114
Reviews: 1
Mon Aug 24, 2009 12:20 am
bbqueen says...



Holy cow! That is a lot of code!
  





User avatar
373 Reviews



Gender: None specified
Points: 49068
Reviews: 373
Sun Sep 27, 2009 12:37 am
Kamas says...



Holy sweet mother jesus.

Wow. Just Wow.
  





Random avatar


Gender: Male
Points: 1823
Reviews: 665
Sun Sep 27, 2009 6:57 pm
deleted6 says...



Nate wrote:If you've ever been interested in the structure behind YWS, I will be releasing all the code once we make the switch to the new YWS. It's a ton of code, and I'd say only 5% is the vanilla phpbb stuff. Of the remaining 95%, 40% is probably stuff I borrowed from other people with the remainder all me.

But, in the meantime, here's the code for the new User Stats page I did. Beware, it's not very well written. If it was a heavily trafficked page, I'd spend a lot more time optimizing it, but since I designed it mostly for me, I don't really care how horrible the code looks.

Code: Select all
<?

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

$user = $HTTP_POST_VARS['username'];
$time15 = time() - (15*24*60*60);
$time30 = time() - (30*24*60*60);
$time60 = time() - (60*24*60*60);
$time90 = time() - (90*24*60*60);

if ($user!='')
{
   $sql = "SELECT user_id, user_reviews, user_lastvisit, user_regdate FROM " . USERS_TABLE . " WHERE username = '" . $user . "'";
   if($result = $db->sql_query($sql))
   {
      $row = $db->sql_fetchrow($result);
      $user_reviews = $row['user_reviews'];
      $user_regdate = date("F j, Y, g:i a", $row['user_regdate']);
      $user_lastvisit = date("F j, Y, g:i a", $row['user_lastvisit']);
      $id = $row['user_id'];
      $message = "User Information For " . $user;
   } else {
      $message = "No person by " . $user . ".  Did you spell it correctly?";
   }

   if ($id != '')
   {
      $sql = "SELECT
            COUNT(p.poster_id) as dp_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 8 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $dp_reviews = $row['dp_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as np_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 10 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $np_reviews = $row['np_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as lp_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 9 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $lp_reviews = $row['lp_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as op_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 17 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $op_reviews = $row['op_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as af_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 6 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $af_reviews = $row['af_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as fanf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 75 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $fanf_reviews = $row['fanf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as ff_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 16 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $ff_reviews = $row['ff_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as hf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 61 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $hf_reviews = $row['hf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as nf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 18 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $nf_reviews = $row['nf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as rf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 2 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $rf_reviews = $row['rf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as sf_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 3 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $sf_reviews = $row['sf_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as of_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 5 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $of_reviews = $row['of_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as am_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 159 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $am_reviews = $row['am_reviews'];
      }


      $sql = "SELECT
            COUNT(p.poster_id) as pm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 27 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $pm_reviews = $row['pm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as lm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 41 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $lm_reviews = $row['lm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as sm_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 24 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $sm_reviews = $row['sm_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as om_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            p.forum_id = 26 AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $om_reviews = $row['om_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as low_reviews
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            char_length(t.post_text) < 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $low_reviews = $row['low_reviews'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time15
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.post_time >= " . $time15 . " AND
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time15_reviews = $row['time15'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time30
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time30 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time30_reviews = $row['time30'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time60
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time60 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time60_reviews = $row['time60'];
      }

      $sql = "SELECT
            COUNT(p.poster_id) as time90
         FROM
            " . POSTS_TABLE . " AS p,
            " . POSTS_TEXT_TABLE . " AS t,
            " . TOPICS_TABLE . " as tt
         WHERE
            p.topic_id = tt.topic_id AND
            p.post_id != tt.topic_first_post_id AND
            p.post_id = t.post_id AND
            p.poster_id = " . $id . " AND
            (p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10  || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41  || p.forum_id = 26) AND
            p.post_time >= " . $time90 . " AND
            char_length(t.post_text) >= 250";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $time90_reviews = $row['time90'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings
         FROM
            " . POSTS_TABLE . "
         WHERE
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings = $row['greetings'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings15
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time15 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings15 = $row['greetings15'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings30
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time30 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings30 = $row['greetings30'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings60
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time60 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings60 = $row['greetings60'];
      }

      $sql = "SELECT
            COUNT(poster_id) as greetings90
         FROM
            " . POSTS_TABLE . "
         WHERE
            post_time >= $time90 AND
            poster_id = " . $id . " AND
            forum_id = 1";
      if($result = $db->sql_query($sql))
      {
         $row = $db->sql_fetchrow($result);
         $greetings90 = $row['greetings90'];
      }

   $total = $of_reviews + $sf_reviews + $rf_reviews + $nf_reviews + $hf_reviews + $ff_reviews + $fanf_reviews + $af_reviews + $op_reviews + $np_reviews + $lp_reviews + $dp_reviews + $am_reviews + $sm_reviews + $pm_reviews + $om_reviews + $lm_reviews + $low_reviews;

   $total2 = $total - $low_reviews;

   }

}

$template->assign_vars(array(
   'MESSAGE' => $message,
   'LASTVISIT' => $user_lastvisit,
   'REGDATE' => $user_regdate,
   'REVIEWS' => $user_reviews,
   'DP_REVIEWS' => $dp_reviews,
   'LP_REVIEWS' => $lp_reviews,
   'NP_REVIEWS' => $np_reviews,
   'OP_REVIEWS' => $op_reviews,
   'AF_REVIEWS' => $af_reviews,
   'FANF_REVIEWS' => $fanf_reviews,
   'FF_REVIEWS' => $ff_reviews,
   'HF_REVIEWS' => $hf_reviews,
   'NF_REVIEWS' => $nf_reviews,
   'RF_REVIEWS' => $rf_reviews,
   'SF_REVIEWS' => $sf_reviews,
   'OF_REVIEWS' => $of_reviews,
   'AM_REVIEWS' => $am_reviews,
   'PM_REVIEWS' => $pm_reviews,
   'LM_REVIEWS' => $lm_reviews,
   'SM_REVIEWS' => $sm_reviews,
   'OM_REVIEWS' => $om_reviews,
   'LOW_REVIEWS' => $low_reviews,
   'TIME15' => $time15_reviews,
   'TIME30' => $time30_reviews,
   'TIME60' => $time60_reviews,
   'TIME90' => $time90_reviews,
   'GREETINGS' => $greetings,
   'GREETINGS15' => $greetings15,
   'GREETINGS30' => $greetings30,
   'GREETINGS60' => $greetings60,
   'GREETINGS90' => $greetings90,
   'TOTAL' => $total,
   'TOTAL2' => $total2,
   'USER' => $user
));

   //
   // Start output of page
   //
   $page_title = 'User Statistics';
   include($phpbb_root_path . 'includes/page_header.'.$phpEx);

   $template->set_filenames(array(
      'body' => 'user_stats_body.tpl')
   );

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);


?>


I'm doing a computer course and I understand very little of that XD. Although we'll be learning javascript in the course, not sure about phpp.
  





User avatar
425 Reviews



Gender: Male
Points: 11417
Reviews: 425
Sun Sep 27, 2009 7:33 pm
Nate says...



I wouldn't use it as an example for a computer course! There's at least one security vulnerability, and like I said, it's very badly written. In fact, I'm wondering right now why I made a few things needlessly complicated.
  








Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did. So throw off the bowlines, sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream.
— Mark Twain