plugins/SpecialUserFuncs.php
changeset 1103 90225c988124
parent 1101 30d8bb88572d
child 1109 c424a15a1656
equal deleted inserted replaced
1102:faef5e62e1e0 1103:90225c988124
    10 }
    10 }
    11 **!*/
    11 **!*/
    12 
    12 
    13 /*
    13 /*
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    15  * Version 1.1.6 (Caoineag beta 1)
    15  * Copyright (C) 2006-2009 Dan Fuhry
    16  * Copyright (C) 2006-2008 Dan Fuhry
       
    17  *
    16  *
    18  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    17  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    19  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    18  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    20  *
    19  *
    21  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    20  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
   404         {
   403         {
   405           $get_string = htmlspecialchars(enano_json_encode($get_fwd));
   404           $get_string = htmlspecialchars(enano_json_encode($get_fwd));
   406           echo '<input type="hidden" name="get_fwd" value="' . $get_string . '" />';
   405           echo '<input type="hidden" name="get_fwd" value="' . $get_string . '" />';
   407         }
   406         }
   408       }
   407       }
       
   408       else if ( isset($_POST['get_fwd']) )
       
   409       {
       
   410         echo '<input type="hidden" name="get_fwd" value="' . htmlspecialchars($_POST['get_fwd']) . '" />';
       
   411       }
   409       ?>
   412       ?>
   410     </form>
   413     </form>
   411     <?php
   414     <?php
   412       echo $session->aes_javascript('loginform', 'pass');
   415       echo $session->aes_javascript('loginform', 'pass');
   413     ?>
   416     ?>
   420   global $db, $session, $paths, $template, $plugins; // Common objects
   423   global $db, $session, $paths, $template, $plugins; // Common objects
   421   global $__login_status;
   424   global $__login_status;
   422   global $lang;
   425   global $lang;
   423   require_once( ENANO_ROOT . '/includes/math.php' );
   426   require_once( ENANO_ROOT . '/includes/math.php' );
   424   
   427   
       
   428   $paths->fullpage = $GLOBALS['title'];
   425   if ( $paths->getParam(0) === 'action.json' )
   429   if ( $paths->getParam(0) === 'action.json' )
   426   {
   430   {
   427     if ( !isset($_POST['r']) )
   431     if ( !isset($_POST['r']) )
   428       die('No request.');
   432       die('No request.');
   429     
   433     
  1836    * @return string
  1840    * @return string
  1837    */
  1841    */
  1838   
  1842   
  1839   public static function format_date($time)
  1843   public static function format_date($time)
  1840   {
  1844   {
  1841     global $lang;
  1845     // merged into enano_date() :)
  1842     // Our formattting string to pass to enano_date()
  1846     return enano_date(ED_DATE, $time);
  1843     // This should not include minute/second info, only today's date in whatever format suits your fancy
       
  1844     $formatstring = 'F j, Y';
       
  1845     // Today's date
       
  1846     $today = enano_date($formatstring);
       
  1847     // Yesterday's date
       
  1848     $yesterday = enano_date($formatstring, (time() - (24*60*60)));
       
  1849     // Date on the input
       
  1850     $then = enano_date($formatstring, $time);
       
  1851     // "X days ago" logic
       
  1852     for ( $i = 2; $i <= 6; $i++ )
       
  1853     {
       
  1854       // hours_in_day * minutes_in_hour * seconds_in_minute * num_days
       
  1855       $offset = 24 * 60 * 60 * $i;
       
  1856       $days_ago = enano_date($formatstring, (time() - $offset));
       
  1857       // so does the input timestamp match the date from $i days ago?
       
  1858       if ( $then == $days_ago )
       
  1859       {
       
  1860         // yes, return $i
       
  1861         return $lang->get('userfuncs_ml_date_daysago', array('days_ago' => $i));
       
  1862       }
       
  1863     }
       
  1864     // either yesterday, today, or before 6 days ago
       
  1865     switch($then)
       
  1866     {
       
  1867       case $today:
       
  1868         return $lang->get('userfuncs_ml_date_today');
       
  1869       case $yesterday:
       
  1870         return $lang->get('userfuncs_ml_date_yesterday');
       
  1871       default:
       
  1872         return $then;
       
  1873     }
       
  1874     //     .--.
       
  1875     //    |o_o |
       
  1876     //    |!_/ |
       
  1877     //   //   \ \
       
  1878     //  (|     | )
       
  1879     // /'\_   _/`\
       
  1880     // \___)=(___/
       
  1881     return 'Linux rocks!';
       
  1882   }
  1847   }
  1883   function reg_time($time, $row)
  1848   function reg_time($time, $row)
  1884   {
  1849   {
  1885     return $this->format_date($time);
  1850     return $this->format_date($time);
  1886   }
  1851   }