plugins/SpecialUserFuncs.php
changeset 334 c72b545f1304
parent 326 ab66d6d1f1f4
child 335 67bd3121a12e
equal deleted inserted replaced
333:32429702305e 334:c72b545f1304
    20  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    20  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    21  */
    21  */
    22  
    22  
    23 global $db, $session, $paths, $template, $plugins; // Common objects
    23 global $db, $session, $paths, $template, $plugins; // Common objects
    24 
    24 
    25 $plugins->attachHook('base_classes_initted', '
    25 $plugins->attachHook('session_started', '
    26   global $paths;
    26   global $paths;
    27     $paths->add_page(Array(
    27     $paths->add_page(Array(
    28       \'name\'=>\'Log in\',
    28       \'name\'=>\'specialpage_log_in\',
    29       \'urlname\'=>\'Login\',
    29       \'urlname\'=>\'Login\',
    30       \'namespace\'=>\'Special\',
    30       \'namespace\'=>\'Special\',
    31       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    31       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    32       ));
    32       ));
    33     $paths->add_page(Array(
    33     $paths->add_page(Array(
    34       \'name\'=>\'Log out\',
    34       \'name\'=>\'specialpage_log_out\',
    35       \'urlname\'=>\'Logout\',
    35       \'urlname\'=>\'Logout\',
    36       \'namespace\'=>\'Special\',
    36       \'namespace\'=>\'Special\',
    37       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    37       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    38       ));
    38       ));
    39     $paths->add_page(Array(
    39     $paths->add_page(Array(
    40       \'name\'=>\'Register\',
    40       \'name\'=>\'specialpage_register\',
    41       \'urlname\'=>\'Register\',
    41       \'urlname\'=>\'Register\',
    42       \'namespace\'=>\'Special\',
    42       \'namespace\'=>\'Special\',
    43       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    43       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    44       ));
    44       ));
    45     $paths->add_page(Array(
    45     $paths->add_page(Array(
    46       \'name\'=>\'Edit Profile\',
    46       \'name\'=>\'specialpage_preferences\',
    47       \'urlname\'=>\'Preferences\',
    47       \'urlname\'=>\'Preferences\',
    48       \'namespace\'=>\'Special\',
    48       \'namespace\'=>\'Special\',
    49       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    49       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    50       ));
    50       ));
    51     
    51     
    52     $paths->add_page(Array(
    52     $paths->add_page(Array(
    53       \'name\'=>\'Contributions\',
    53       \'name\'=>\'specialpage_contributions\',
    54       \'urlname\'=>\'Contributions\',
    54       \'urlname\'=>\'Contributions\',
    55       \'namespace\'=>\'Special\',
    55       \'namespace\'=>\'Special\',
    56       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    56       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    57       ));
    57       ));
    58     
    58     
    59     $paths->add_page(Array(
    59     $paths->add_page(Array(
    60       \'name\'=>\'Change style\',
    60       \'name\'=>\'specialpage_change_theme\',
    61       \'urlname\'=>\'ChangeStyle\',
    61       \'urlname\'=>\'ChangeStyle\',
    62       \'namespace\'=>\'Special\',
    62       \'namespace\'=>\'Special\',
    63       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    63       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    64       ));
    64       ));
    65     
    65     
    66     $paths->add_page(Array(
    66     $paths->add_page(Array(
    67       \'name\'=>\'Activate user account\',
    67       \'name\'=>\'specialpage_activate_account\',
    68       \'urlname\'=>\'ActivateAccount\',
    68       \'urlname\'=>\'ActivateAccount\',
    69       \'namespace\'=>\'Special\',
    69       \'namespace\'=>\'Special\',
    70       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    70       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    71       ));
    71       ));
    72     
    72     
    73     $paths->add_page(Array(
    73     $paths->add_page(Array(
    74       \'name\'=>\'Captcha\',
    74       \'name\'=>\'specialpage_captcha\',
    75       \'urlname\'=>\'Captcha\',
    75       \'urlname\'=>\'Captcha\',
    76       \'namespace\'=>\'Special\',
    76       \'namespace\'=>\'Special\',
    77       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    77       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    78       ));
    78       ));
    79     
    79     
    80     $paths->add_page(Array(
    80     $paths->add_page(Array(
    81       \'name\'=>\'Forgot password\',
    81       \'name\'=>\'specialpage_password_reset\',
    82       \'urlname\'=>\'PasswordReset\',
    82       \'urlname\'=>\'PasswordReset\',
    83       \'namespace\'=>\'Special\',
    83       \'namespace\'=>\'Special\',
    84       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    84       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    85       ));
    85       ));
    86     
    86     
    87     $paths->add_page(Array(
    87     $paths->add_page(Array(
    88       \'name\'=>\'Member list\',
    88       \'name\'=>\'specialpage_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       
    93       
    94     $paths->add_page(Array(
    94     $paths->add_page(Array(
    95       \'name\'=>\'Language exporter\',
    95       \'name\'=>\'specialpage_language_export\',
    96       \'urlname\'=>\'LangExportJSON\',
    96       \'urlname\'=>\'LangExportJSON\',
    97       \'namespace\'=>\'Special\',
    97       \'namespace\'=>\'Special\',
    98       \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    98       \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    99       ));
    99       ));
   100       
   100       
   166         $response[$x] = $y;
   166         $response[$x] = $y;
   167       }
   167       }
   168       unset($x, $y);
   168       unset($x, $y);
   169     }
   169     }
   170     
   170     
   171     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
   171     $response = enano_json_encode($response);
   172     $response = $json->encode($response);
       
   173     echo $response;
   172     echo $response;
   174     return null;
   173     return null;
   175   }
   174   }
   176   
   175   
   177   $level = ( isset($_GET['level']) && in_array($_GET['level'], array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') ) ) ? intval($_GET['level']) : USER_LEVEL_MEMBER;
   176   $level = ( isset($_GET['level']) && in_array($_GET['level'], array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') ) ) ? intval($_GET['level']) : USER_LEVEL_MEMBER;
   367   global $__login_status;
   366   global $__login_status;
   368   global $lang;
   367   global $lang;
   369   if ( isset($_GET['act']) && $_GET['act'] == 'ajaxlogin' )
   368   if ( isset($_GET['act']) && $_GET['act'] == 'ajaxlogin' )
   370   {
   369   {
   371     $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\']);');
   372     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
   371     $data = enano_json_decode($_POST['params']);
   373     $data = $json->decode($_POST['params']);
       
   374     $captcha_hash = ( isset($data['captcha_hash']) ) ? $data['captcha_hash'] : false;
   372     $captcha_hash = ( isset($data['captcha_hash']) ) ? $data['captcha_hash'] : false;
   375     $captcha_code = ( isset($data['captcha_code']) ) ? $data['captcha_code'] : false;
   373     $captcha_code = ( isset($data['captcha_code']) ) ? $data['captcha_code'] : false;
   376     $level = ( isset($data['level']) ) ? intval($data['level']) : USER_LEVEL_MEMBER;
   374     $level = ( isset($data['level']) ) ? intval($data['level']) : USER_LEVEL_MEMBER;
   377     $result = $session->login_with_crypto($data['username'], $data['crypt_data'], $data['crypt_key'], $data['challenge'], $level, $captcha_hash, $captcha_code);
   375     $result = $session->login_with_crypto($data['username'], $data['crypt_data'], $data['crypt_key'], $data['challenge'], $level, $captcha_hash, $captcha_code);
   378     $session->start();
   376     $session->start();
   395           'result' => 'error',
   393           'result' => 'error',
   396           'data' => $result,
   394           'data' => $result,
   397           'captcha' => $captcha
   395           'captcha' => $captcha
   398         );
   396         );
   399     }
   397     }
   400     $response = $json->encode($response);
   398     $response = enano_json_encode($response);
   401     echo $response;
   399     echo $response;
   402     $db->close();
   400     $db->close();
   403     exit;
   401     exit;
   404   }
   402   }
   405   if(isset($_POST['login'])) {
   403   if(isset($_POST['login'])) {
   443   }
   441   }
   444 }
   442 }
   445 
   443 
   446 function SpecialLogin_SendResponse_PasswordReset($user_id, $passkey)
   444 function SpecialLogin_SendResponse_PasswordReset($user_id, $passkey)
   447 {
   445 {
   448   $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
       
   449   
   446   
   450   $response = Array(
   447   $response = Array(
   451       'result' => 'success_reset',
   448       'result' => 'success_reset',
   452       'user_id' => $user_id,
   449       'user_id' => $user_id,
   453       'temppass' => $passkey
   450       'temppass' => $passkey
   454     );
   451     );
   455   
   452   
   456   $response = $json->encode($response);
   453   $response = enano_json_encode($response);
   457   echo $response;
   454   echo $response;
   458   
   455   
   459   $db->close();
   456   $db->close();
   460   
   457   
   461   exit;
   458   exit;
  1720   if ( $lang->lang_id == $lang_id )
  1717   if ( $lang->lang_id == $lang_id )
  1721     $lang_local =& $lang;
  1718     $lang_local =& $lang;
  1722   else
  1719   else
  1723     $lang_local = new Language($lang_id);
  1720     $lang_local = new Language($lang_id);
  1724   
  1721   
  1725   $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
       
  1726   
  1722   
  1727   $timestamp = date('D, j M Y H:i:s T', $lang_local->lang_timestamp);
  1723   $timestamp = date('D, j M Y H:i:s T', $lang_local->lang_timestamp);
  1728   header("Last-Modified: $timestamp");
  1724   header("Last-Modified: $timestamp");
  1729   header("Date: $timestamp");
  1725   header("Date: $timestamp");
  1730   header('Content-type: text/javascript');
  1726   header('Content-type: text/javascript');
  1731   
  1727   
  1732   $lang_local->fetch();
  1728   $lang_local->fetch();
  1733   echo "if ( typeof(enano_lang) != 'object' )
  1729   echo "if ( typeof(enano_lang) != 'object' )
  1734   var enano_lang = new Object();
  1730   var enano_lang = new Object();
  1735 
  1731 
  1736 enano_lang[{$lang->lang_id}] = " . $json->encode($lang_local->strings) . ";";
  1732 enano_lang[{$lang->lang_id}] = " . enano_json_encode($lang_local->strings) . ";";
  1737   
  1733   
  1738 }
  1734 }
  1739 
  1735 
  1740 ?>
  1736 ?>