plugins/SpecialUserFuncs.php
changeset 210 2b283402e4e4
parent 209 8a00247d1dee
child 221 e5302cb1945c
equal deleted inserted replaced
209:8a00247d1dee 210:2b283402e4e4
    88       \'name\'=>\'Member list\',
    88       \'name\'=>\'Member list\',
    89       \'urlname\'=>\'Memberlist\',
    89       \'urlname\'=>\'Memberlist\',
    90       \'namespace\'=>\'Special\',
    90       \'namespace\'=>\'Special\',
    91       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    91       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    92       ));
    92       ));
       
    93       
       
    94     $paths->add_page(Array(
       
    95       \'name\'=>\'Language exporter\',
       
    96       \'urlname\'=>\'LangExportJSON\',
       
    97       \'namespace\'=>\'Special\',
       
    98       \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
       
    99       ));
       
   100       
    93     ');
   101     ');
    94 
   102 
    95 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
   103 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
    96 
   104 
    97 $__login_status = '';
   105 $__login_status = '';
   303              </td>
   311              </td>
   304            </tr>
   312            </tr>
   305            <?php
   313            <?php
   306          }
   314          }
   307          ?>
   315          ?>
   308          <?php if ( $level <= USER_LEVEL_MEMBER ) { ?>
       
   309          <tr>
   316          <tr>
   310            <td class="row3" colspan="3">
   317            <td class="row3" colspan="3">
   311              <?php
   318              <?php
   312              $returnpage_link = ( $return = $paths->getAllParams() ) ? '/' . $return : '';
   319              if ( $level <= USER_LEVEL_MEMBER && ( !isset($_GET['use_crypt']) || ( isset($_GET['use_crypt']) && $_GET['use_crypt']!='0' ) ) )
   313              $nocrypt_link = makeUrlNS('Special', "Login$returnpage_link", "level=$level&use_crypt=0", true);
   320              {
   314              echo '<p><b>' . $lang->get('user_login_nocrypt_title') . ':</b> ' . $lang->get('user_login_nocrypt_body', array('nocrypt_link' => $nocrypt_link)) . '</p>';
   321                $returnpage_link = ( $return = $paths->getAllParams() ) ? '/' . $return : '';
   315              echo '<p>' . $lang->get('user_login_nocrypt_countrylist') . '</p>';
   322                $nocrypt_link = makeUrlNS('Special', "Login$returnpage_link", "level=$level&use_crypt=0", true);
       
   323                echo '<p><b>' . $lang->get('user_login_nocrypt_title') . '</b> ' . $lang->get('user_login_nocrypt_body', array('nocrypt_link' => $nocrypt_link)) . '</p>';
       
   324                echo '<p>' . $lang->get('user_login_nocrypt_countrylist') . '</p>';
       
   325              }
       
   326              else if ( $level <= USER_LEVEL_MEMBER && ( isset($_GET['use_crypt']) && $_GET['use_crypt']=='0' ) )
       
   327              {
       
   328                $returnpage_link = ( $return = $paths->getAllParams() ) ? '/' . $return : '';
       
   329                $usecrypt_link = makeUrlNS('Special', "Login$returnpage_link", "level=$level&use_crypt=1", true);
       
   330                echo '<p><b>' . $lang->get('user_login_usecrypt_title') . '</b> ' . $lang->get('user_login_usecrypt_body', array('usecrypt_link' => $usecrypt_link)) . '</p>';
       
   331                echo '<p>' . $lang->get('user_login_usecrypt_countrylist') . '</p>';
       
   332              }
   316              ?>
   333              ?>
   317            </td>
   334            </td>
   318          </tr>
   335          </tr>
   319          <?php } ?>
       
   320          <tr>
   336          <tr>
   321            <th colspan="3" style="text-align: center" class="subhead"><input type="submit" name="login" value="Log in" tabindex="<?php echo ( $level <= USER_LEVEL_MEMBER ) ? '3' : '2'; ?>" /></th>
   337            <th colspan="3" style="text-align: center" class="subhead"><input type="submit" name="login" value="Log in" tabindex="<?php echo ( $level <= USER_LEVEL_MEMBER ) ? '3' : '2'; ?>" /></th>
   322          </tr>
   338          </tr>
   323       </table>
   339       </table>
   324     </div>
   340     </div>
   346 
   362 
   347 function page_Special_Login_preloader() // adding _preloader to the end of the function name calls the function before $session and $paths setup routines are called
   363 function page_Special_Login_preloader() // adding _preloader to the end of the function name calls the function before $session and $paths setup routines are called
   348 {
   364 {
   349   global $db, $session, $paths, $template, $plugins; // Common objects
   365   global $db, $session, $paths, $template, $plugins; // Common objects
   350   global $__login_status;
   366   global $__login_status;
       
   367   global $lang;
   351   if ( isset($_GET['act']) && $_GET['act'] == 'ajaxlogin' )
   368   if ( isset($_GET['act']) && $_GET['act'] == 'ajaxlogin' )
   352   {
   369   {
   353     $plugins->attachHook('login_password_reset', 'SpecialLogin_SendResponse_PasswordReset($row[\'user_id\'], $row[\'temp_password\']);');
   370     $plugins->attachHook('login_password_reset', 'SpecialLogin_SendResponse_PasswordReset($row[\'user_id\'], $row[\'temp_password\']);');
   354     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
   371     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
   355     $data = $json->decode($_POST['params']);
   372     $data = $json->decode($_POST['params']);
   401     {
   418     {
   402       $template->load_theme($session->theme, $session->style);
   419       $template->load_theme($session->theme, $session->style);
   403       if(isset($_POST['return_to']))
   420       if(isset($_POST['return_to']))
   404       {
   421       {
   405         $name = ( isset($paths->pages[$_POST['return_to']]['name']) ) ? $paths->pages[$_POST['return_to']]['name'] : $_POST['return_to'];
   422         $name = ( isset($paths->pages[$_POST['return_to']]['name']) ) ? $paths->pages[$_POST['return_to']]['name'] : $_POST['return_to'];
   406         redirect( makeUrl($_POST['return_to'], false, true), 'Login successful', 'You have successfully logged into the '.getConfig('site_name').' site as "'.$session->username.'". Redirecting to ' . $name . '...' );
   423         $subst = array(
       
   424             'username' => $session->username,
       
   425             'redir_target' => $name
       
   426           );
       
   427         redirect( makeUrl($_POST['return_to'], false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   407       }
   428       }
   408       else
   429       else
   409       {
   430       {
   410         redirect( makeUrl(getConfig('main_page'), false, true), 'Login successful', 'You have successfully logged into the '.getConfig('site_name').' site as "'.$session->username.'". Redirecting to the main page...' );
   431         redirect( makeUrl(getConfig('main_page'), false, true), 'Login successful', 'You have successfully logged into the '.getConfig('site_name').' site as "'.$session->username.'". Redirecting to the main page...' );
   411       }
   432       }
   435   exit;
   456   exit;
   436 }
   457 }
   437 
   458 
   438 function page_Special_Logout() {
   459 function page_Special_Logout() {
   439   global $db, $session, $paths, $template, $plugins; // Common objects
   460   global $db, $session, $paths, $template, $plugins; // Common objects
       
   461   global $lang;
   440   if ( !$session->user_logged_in )
   462   if ( !$session->user_logged_in )
   441     $paths->main_page();
   463     $paths->main_page();
   442   
   464   
   443   $l = $session->logout();
   465   $l = $session->logout();
   444   if ( $l == 'success' )
   466   if ( $l == 'success' )
   445   {
   467   {
   446     redirect(makeUrl(getConfig('main_page'), false, true), 'Logged out', 'You have been successfully logged out, and all cookies have been cleared. You will now be transferred to the main page.', 4);
   468     
       
   469     redirect(makeUrl(getConfig('main_page'), false, true), $lang->get('user_logout_success_title'), $lang->get('user_logout_success_body'), 4);
   447   }
   470   }
   448   $template->header();
   471   $template->header();
   449   echo '<h3>An error occurred during the logout process.</h3><p>'.$l.'</p>';
   472   echo '<h3>An error occurred during the logout process.</h3><p>'.$l.'</p>';
   450   $template->footer();
   473   $template->footer();
   451 }
   474 }
  1629   {
  1652   {
  1630     return $this->format_date($time);
  1653     return $this->format_date($time);
  1631   }
  1654   }
  1632 }
  1655 }
  1633 
  1656 
       
  1657 function page_Special_LangExportJSON()
       
  1658 {
       
  1659   global $db, $session, $paths, $template, $plugins; // Common objects
       
  1660   global $lang;
       
  1661   
       
  1662   $lang_id = ( $x = $paths->getParam(0) ) ? intval($x) : $lang->lang_id;
       
  1663   
       
  1664   if ( $lang->lang_id == $lang_id )
       
  1665     $lang_local =& $lang;
       
  1666   else
       
  1667     $lang_local = new Language($lang_id);
       
  1668   
       
  1669   $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
       
  1670   
       
  1671   $timestamp = date('D, j M Y H:i:s T', $lang_local->lang_timestamp);
       
  1672   header("Last-Modified: $timestamp");
       
  1673   header("Date: $timestamp");
       
  1674   header('Content-type: text/javascript');
       
  1675   
       
  1676   $lang_local->fetch();
       
  1677   echo "if ( typeof(enano_lang) != 'object' )
       
  1678   var enano_lang = new Object();
       
  1679 
       
  1680 enano_lang[{$lang->lang_id}] = " . $json->encode($lang_local->strings) . ";";
       
  1681   
       
  1682 }
       
  1683 
  1634 ?>
  1684 ?>