Создание или изменение passkey git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@44 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
nanosimbiot 2011-06-29 09:33:52 +00:00
commit 7aa66bce93
5 changed files with 39 additions and 7 deletions

View file

@ -24,6 +24,7 @@ switch ($ajax->action)
case 'view_torrent':
case 'mod_action':
case 'change_tor_status':
case 'gen_passkey';
require(INC_DIR .'functions_torrent.php');
break;
@ -59,6 +60,8 @@ class ajax_common
'change_tor_status' => array('mod'),
'mod_action' => array('mod'),
'gen_passkey' => array('user'),
'view_post' => array('guest'),
'view_message' => array('guest'),
'view_torrent' => array('guest'),
@ -266,6 +269,25 @@ class ajax_common
require(AJAX_DIR .'edit_user_profile.php');
}
function gen_passkey ()
{
global $userdata, $lang;
$req_uid = (int) $this->request['user_id'];
if ($req_uid == $userdata['user_id'] || IS_ADMIN)
{
$force_generate = (IS_ADMIN);
if (!$passkey = generate_passkey($req_uid, $force_generate))
{
$this->ajax_die('Could not insert passkey');
}
tracker_rm_user($req_uid);
$this->response['passkey'] = $passkey;
}
}
function view_post ()
{
require(AJAX_DIR .'view_post.php');

View file

@ -38,7 +38,7 @@ if (IS_ADMIN)
{
$template->assign_vars(array(
'SHOW_PASSKEY' => true,
'S_GEN_PASSKEY' => "<a href=\"torrent.php?mode=gen_passkey&amp;u=". $profile_user_id .'&amp;sid='. $userdata['session_id'] .'">'. $lang['BT_GEN_PASSKEY_URL'] .'</a>',
'S_GEN_PASSKEY' => '<a href="#" onclick="ajax.exec({ action: \'gen_passkey\', user_id: '. $profile_user_id .' }); return false;">'. $lang['BT_GEN_PASSKEY_URL'] .'</a>',
'CAN_EDIT_RATIO' => IS_SUPER_ADMIN,
));
}

View file

@ -105,11 +105,11 @@ switch ($mode)
if (IS_ADMIN && !empty($_REQUEST['u']))
{
$pr_user_id = (int) $_REQUEST['u'];
$adm_edit = ($pr_user_id != $user->id);
$adm_edit = ($pr_user_id != $userdata['user_id']);
}
else
{
$pr_user_id = $user->id;
$pr_user_id = $userdata['user_id'];
}
$profile_fields_sql = join(', ', array_keys($profile_fields));
$sql = "
@ -748,7 +748,7 @@ if ($mode == 'editprofile' && $userdata['session_logged_in'])
$sql = 'SELECT auth_key
FROM '. BB_BT_USERS .'
WHERE user_id = '. $userdata['user_id'];
WHERE user_id = '. $pr_user_id;
if (!$result = DB()->sql_query($sql))
{
@ -762,7 +762,7 @@ if ($mode == 'editprofile' && $userdata['session_logged_in'])
'L_GEN_PASSKEY' => $lang['BT_GEN_PASSKEY'],
'L_GEN_PASSKEY_EXPLAIN' => $lang['BT_GEN_PASSKEY_EXPLAIN'],
'L_GEN_PASSKEY_EXPLAIN_2' => $lang['BT_GEN_PASSKEY_EXPLAIN_2'],
'S_GEN_PASSKEY' => "<a href=\"torrent.php?mode=gen_passkey&amp;u=" . $userdata['user_id'] . '&amp;sid=' . $userdata['session_id'] . '">' . $lang['BT_GEN_PASSKEY_URL'] . '</a>',
'S_GEN_PASSKEY' => '<a href="#" onclick="ajax.exec({ action: \'gen_passkey\', user_id: '. $pr_user_id .' }); return false;">' . $lang['BT_GEN_PASSKEY_URL'] . '</a>',
'CURR_PASSKEY' => $curr_passkey,
));
}

View file

@ -65,6 +65,11 @@ ajax.callback.user_register = function(data){
</tr>
<!-- ENDIF -->
<!-- BEGIN switch_bittorrent -->
<script type="text/javascript">
ajax.callback.gen_passkey = function(data){
$('#passkey').text(data.passkey);
};
</script>
<tr>
<th colspan="2"><a name="bittorrent"></a>TorrentPier</th>
</tr>
@ -74,7 +79,7 @@ ajax.callback.user_register = function(data){
</tr>
<tr>
<td>{L_CURR_PASSKEY}</td>
<td class="med">{CURR_PASSKEY}</td>
<td class="med" id="passkey">{CURR_PASSKEY}</td>
</tr>
<!-- END switch_bittorrent -->
<tr>

View file

@ -241,9 +241,14 @@ ajax.callback.edit_user_profile = function(data){
</td>
</tr>
<!-- IF SHOW_PASSKEY -->
<script type="text/javascript">
ajax.callback.gen_passkey = function(data){
$('#passkey').text(data.passkey);
};
</script>
<tr>
<th><a class="med" href="#" onclick="toggle_block('gen_passkey'); return false;" class="gen">Passkey:</a></th>
<td>{AUTH_KEY}</td>
<td id="passkey">{AUTH_KEY}</td>
</tr>
<tr id="gen_passkey" style="display: none;">
<td colspan="2" class="med tCenter">{S_GEN_PASSKEY}</td>