Author - MrAK
Date - 29.11.2015
Version - 1.
Name - Invites for JohnCms 4.4.0

     .
   ,    ,   .

----------------------------------------
     :
----------------------------------------

-      
(  )
-     sql.txt

-   razdacha.php      .

-------------------------------------------------------------------------
      (   )
-------------------------------------------------------------------------
-     sql.txt

-   registration.php,  

echo '<div class="phdr"><b>' . $lng['registration'] . '</b></div>';
if (isset($_POST['submit'])) {
    //  
    $error = array();

!      

if ($set['mod_reg'] == 3){
if (!isset($_POST['invit']))
$error['invaite'][] = $lng_reg['error_invite_empty'];
$req_Invit = mysql_query("select * from `invites` where `inv`='" . mysql_real_escape_string($_POST['invit']) . "';");
if (mysql_num_rows($req_Invit) == 0) {
$error['invite'][] = $lng_reg['error_invite_no'];
}
$ac_Invit_go = mysql_result(mysql_query("SELECT `act` FROM `invites` WHERE `inv` = '".mysql_real_escape_string($_POST['invit'])."'"), 0);
if ($ac_Invit_go == 2) {
$error['invite'][] = $lng_reg['error_invite_go'];
}
}

!  

$preg = $set['mod_reg'] > 1 ? 1 : 0;

!    

$Invizer = mysql_result(mysql_query("SELECT `user_name` FROM `invites` WHERE `inv` = '".mysql_real_escape_string($_POST['invit'])."'"), 0);


$inv = $set['mod_reg'] > 2 ? 1 : 0;

!     

`inv` = '$inv',
`inv_u` = '$Invizer',

!  

 $usid = mysql_insert_id();

!   

$i = mysql_result(mysql_query("SELECT `id` FROM `invites` WHERE `inv` = '".mysql_real_escape_string($_POST['invit'])."'"), 0);
if ($set['mod_reg'] == 3){
mysql_query("UPDATE `invites` SET
`act` = '2',
`name_inv` = '".trim($_POST['nick'])."',
`id_inv` = '$usid',
`time` = '" . time() . "'
WHERE `id` = '$i' LIMIT 1");}

for($in=1; $in <= 3; $in++){
$inv = functions::InVgen(6);
mysql_query("INSERT INTO `invites` SET `id_user` = '$usid', `user_name` = '".trim($_POST['nick'])."', `inv` = '".$inv."', `name_inv` = '', `id_inv` = '', `act` = '1'");
}

!    

if($set['mod_reg'] == 3)
     echo '<p><h3>' . $lng_reg['invites'] . '</h3>' .
     (isset($error['invite']) ? '<span class="red"><small>' . implode('<br />', $error['invite']) . '</small></span><br />' : '') .
     '<input type="text" name="invit" maxlength="15" value="' . htmlspecialchars($_POST['invit']) . '"' . (isset($error['invite']) ? ' style="background-color: #FFCCCC"' : '') . '/><br />' .
     '<small>' . $lng_reg['invite_help'] . '</small></p>';

!  users,    invites.php.    profile.php,   

//  

!   

if ($user['inv'] && !empty($user['inv_u'])){
echo '<div class="menu">';
echo '<b><font color="dodgerblue">'.$lng_profile['priglasil'].': '.$user['inv_u'].'</font></b>';
echo '</div>';
}

!   users   includes,  profile,     office.php    ,     

 '<div><img src="../images/invites.png" width="16" height="16"/>&#160;<a href="../users/invites.php"></a></div>' .

!   images   invites.png  .
!   panel,   includes,   access.php,    

/*
-----------------------------------------------------------------
   
-----------------------------------------------------------------
*/

     

'<input type="radio" value="3" name="reg" ' . ($set['mod_reg'] == 3 ? 'checked="checked"' : '') . '/>&#160;' . $lng['access_invites'] . '<br />' .

!     incfiles,  classes,    function.php     

public static function InVgen($length) {
$vals = "aAbBcCdDeEfFgGhHiIjJkKLmMnNopPqQrRsStTuUvVwWxXyYzZ123456789";
for ($i = 1; $i <= $length; $i++) {
$result .= $vals{rand(0, strlen($vals))};
}
return $result;
}

!,     incfiles,  languages,   ru     invites.lng
    admin.lng    

access_invites                =   " "

!       profile.lng    

priglasil                     =   ""

!       registraton.lng   

invites                       =   " :"
invites_your                  =   "   "
error_invite_empty            =   "  "
error_invite_no               =   "    "
error_invite_go               =   "    "
invite_help                   =   " ,     "


!    ,       razdacha.php,           .


-------------------------------------------
          )))
--------------------------------------------

    ,      ,     ,    ,    ,
  )))
    )