"Fossies" - the Fresh Open Source Software Archive

Member "impresscms-1.4.2/htdocs/invite.php" (24 Dec 2020, 3116 Bytes) of package /linux/www/impresscms-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "invite.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 1.4.2_rc_vs_1.4.2 or 1.4.1_vs_1.4.2.

    1 <?php
    2 /**
    3  * All functions for Registering users by invitation are going through here.
    4  *
    5  * @copyright   http://www.impresscms.org/ The ImpressCMS Project
    6  * @license     LICENSE.txt
    7  * @package     Member
    8  * @subpackage  Users
    9  * @author      marcan <marcan@impresscms.org>
   10  * @author      Sina Asghari (aka stranger) <pesian_stranger@users.sourceforge.net>
   11  * @version     $Id: invite.php 11072 2011-03-14 15:52:14Z m0nty_ $
   12  */
   13 
   14 $xoopsOption['pagetype'] = 'user';
   15 
   16 include 'mainfile.php';
   17 
   18 // If not a user and invite needs one, redirect
   19 if ($icmsConfigUser['activation_type'] == 3 && $icmsConfigUser['allow_register'] == 0 && !is_object(icms::$user)) {
   20     redirect_header('index.php', 6, _US_INVITEBYMEMBER);
   21     exit();
   22 }
   23 
   24 $op = !isset($_POST['op']) ? 'invite' : $_POST['op'];
   25 $email = isset($_POST['email']) ? trim(icms_core_DataFilter::stripSlashesGPC($_POST['email'])) : '';
   26 
   27 switch ($op) {
   28     case 'finish':
   29         include 'header.php';
   30         $stop = '';
   31         if (!icms::$security->check()) {
   32             $stop .= implode('<br />', icms::$security->getErrors()) . "<br />";
   33         }
   34         $icmsCaptcha = icms_form_elements_captcha_Object::instance();
   35         if (! $icmsCaptcha->verify()) {
   36             $stop .= $icmsCaptcha->getMessage() . '<br />';
   37 
   38         }
   39         if (!icms_core_DataFilter::checkVar($email, 'email')) {
   40             $stop .= _US_INVALIDMAIL . '<br />';
   41         }
   42         if (empty($stop)) {
   43             $invite_code = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
   44             $sql = sprintf('INSERT INTO ' . icms::$xoopsDB->prefix('invites') . '
   45                             (invite_code, from_id, invite_to, invite_date, extra_info) VALUES
   46                             (%s, %d, %s, %d, %s)',
   47                             icms::$xoopsDB->quoteString(addslashes($invite_code)),
   48                             is_object(icms::$user) ? icms::$user->getVar('uid') : 0,
   49                             icms::$xoopsDB->quoteString(addslashes($email)),
   50                             time(),
   51                             icms::$xoopsDB->quoteString(addslashes(serialize(array())))
   52                         );
   53             icms::$xoopsDB->query($sql);
   54             // if query executed successful
   55             if (icms::$xoopsDB->getAffectedRows() == 1) {
   56                 $xoopsMailer = new icms_messaging_Handler();
   57                 $xoopsMailer->useMail();
   58                 $xoopsMailer->setTemplate('invite.tpl');
   59                 $xoopsMailer->assign('SITENAME', $icmsConfig['sitename']);
   60                 $xoopsMailer->assign('ADMINMAIL', $icmsConfig['adminmail']);
   61                 $xoopsMailer->assign('SITEURL', ICMS_URL . "/");
   62                 $xoopsMailer->assign('USEREMAIL', $email);
   63                 $xoopsMailer->assign('REGISTERLINK', ICMS_URL . '/register.php?code=' . $invite_code);
   64                 $xoopsMailer->setToEmails($email);
   65                 $xoopsMailer->setFromEmail($icmsConfig['adminmail']);
   66                 $xoopsMailer->setFromName($icmsConfig['sitename']);
   67                 $xoopsMailer->setSubject(sprintf(_US_INVITEREGLINK, ICMS_URL));
   68                 if (!$xoopsMailer->send()) {
   69                     $stop .= _US_INVITEMAILERR;
   70                 } else {
   71                     echo _US_INVITESENT;
   72                 }
   73             } else {
   74                 $stop .= _US_INVITEDBERR;
   75             }
   76         }
   77         if (! empty($stop)) {
   78             echo "<span style='color:#ff0000; font-weight:bold;'>$stop</span>";
   79             include 'include/inviteform.php';
   80             $invite_form->display();
   81         }
   82         include 'footer.php';
   83         break;
   84 
   85     case 'invite':
   86     default:
   87         include 'header.php';
   88         include 'include/inviteform.php';
   89         $invite_form->display();
   90         include 'footer.php';
   91         break;
   92 }