$email = $row['email'];
         $token = generateRandomString(32);
         /**
          * Count how many request were made by this user today.
          * No more than 3 unused should exist at a time.
          */
         $sql_amount = $database->query("SELECT * FROM tbl_password_reset WHERE user_id = '{$id}' AND used = '0' AND timestamp > NOW() - INTERVAL 1 DAY");
         $count_requests = mysql_num_rows($sql_amount);
         if ($count_requests >= 3) {
             $errorstate = 'too_many_today';
         } else {
             $sql_pass = $database->query("INSERT INTO tbl_password_reset (user_id, token)" . "VALUES ('{$id}', '{$token}' )");
             /** Send email */
             $notify_user = new PSend_Email();
             $email_arguments = array('type' => 'password_reset', 'address' => $email, 'username' => $username, 'token' => $token);
             $notify_send = $notify_user->psend_send_email($email_arguments);
             if ($notify_send == 1) {
                 $state['email'] = 1;
             } else {
                 $state['email'] = 0;
             }
         }
         $show_form = 'none';
     } else {
         $errorstate = 'email_not_found';
     }
     break;
     /**
      * The form submited contains the new password
      */
 /**
Exemple #2
0
         * Check if the option to auto-add to a group
         * is active.
         */
        if (CLIENTS_AUTO_GROUP != '0') {
            $admin_name = 'SELFREGISTERED';
            $client_id = $new_response['new_id'];
            $group_id = CLIENTS_AUTO_GROUP;
            $add_to_group = $dbh->prepare("INSERT INTO " . TABLE_MEMBERS . " (added_by,client_id,group_id)" . " VALUES (:admin, :id, :group)");
            $add_to_group->bindParam(':admin', $admin_name);
            $add_to_group->bindParam(':id', $client_id, PDO::PARAM_INT);
            $add_to_group->bindParam(':group', $group_id);
            $add_to_group->execute();
        }
        $notify_admin = new PSend_Email();
        $email_arguments = array('type' => 'new_client_self', 'address' => ADMIN_EMAIL_ADDRESS, 'username' => $add_client_data_user, 'name' => $add_client_data_name);
        $notify_admin_status = $notify_admin->psend_send_email($email_arguments);
    }
}
?>

		<h2><?php 
echo $page_title;
?>
</h2>

		<div class="whiteform whitebox">
		
		<?php 
if (CLIENTS_CAN_REGISTER == '0') {
    $msg = __('Client self registration is not allowed. If you need an account, please contact a system administrator.', 'cftp_admin');
    echo system_message('error', $msg);
                 $files_list .= '<li style="margin-bottom:11px;">';
                 $files_list .= '<p style="font-weight:bold; margin:0 0 5px 0;">' . $mail_file['file_name'] . '</p>';
                 if (!empty($mail_file['description'])) {
                     $files_list .= '<p>' . $mail_file['description'] . '</p>';
                 }
                 $files_list .= '</li>';
                 /**
                  * Add each notification to an array
                  */
                 $this_admin_notifications[] = $mail_file['notif_id'];
             }
             $address = $mail_by_user[$mail_username];
             /** Create the object and send the email */
             $notify_admin = new PSend_Email();
             $email_arguments = array('type' => 'new_file_by_client', 'address' => $address, 'files_list' => $files_list);
             $try_sending = $notify_admin->psend_send_email($email_arguments);
             if ($try_sending == 1) {
                 $notifications_sent = array_merge($notifications_sent, $this_admin_notifications);
             } else {
                 $notifications_failed = array_merge($notifications_failed, $this_admin_notifications);
             }
         }
     } else {
         /** Admin is not active */
         foreach ($admin_files as $mail_files) {
             foreach ($mail_files as $mail_file) {
                 $notifications_inactive[] = $mail_file['notif_id'];
             }
         }
     }
 }