コード例 #1
0
ファイル: utils.php プロジェクト: lmcro/fcms
/**
 * getEmailHeaders 
 * 
 * @param string $name 
 * @param string $email 
 * 
 * @return string
 */
function getEmailHeaders($name = '', $email = '')
{
    if (empty($name)) {
        $name = getSiteName();
    }
    if (empty($email)) {
        $email = getContactEmail();
    }
    return "From: {$name} <{$email}>\r\n" . "Reply-To: {$email}\r\n" . "Content-Type: text/plain; charset=UTF-8;\r\n" . "MIME-Version: 1.0\r\n" . "X-Mailer: PHP/" . phpversion();
}
コード例 #2
0
ファイル: contact.php プロジェクト: lmcro/fcms
 function displayContactFormSubmit()
 {
     $subject = $_POST['subject'];
     $email = $_POST['email'];
     $name = $_POST['name'];
     $msg = $_POST['msg'];
     $email_headers = getEmailHeaders($name, $email);
     if (!mail(getContactEmail(), $subject, "{$msg}\r\n-{$name}", $email_headers)) {
         $this->displayHeader();
         $this->displayFooter();
     }
     $_SESSION['ok'] = '<p>' . cleanOutput($msg) . '<br/>- ' . cleanOutput($name) . '</p>';
     header("Location: contact.php");
 }
コード例 #3
0
ファイル: register.php プロジェクト: lmcro/fcms
    /**
     * displaySubmit 
     * 
     * @param string $formParams The params that have been submitted to the form.
     * 
     * @return void
     */
    function displaySubmit($formParams = '')
    {
        $this->displayHeader();
        if ($formParams == '') {
            $formData = $_POST;
        } else {
            $formData = $formParams;
        }
        // Make sure they filled out all required fields
        $required_fields = array('username', 'password', 'fname', 'lname', 'email');
        foreach ($required_fields as $f) {
            if (strlen($formData[$f]) < 1) {
                $this->displayHtmlForm('<p class="error">' . T_('You forgot to fill out a required field.') . '</p>');
                $this->displayFooter();
                return;
            }
        }
        $email = strip_tags($formData['email']);
        $username = strip_tags($formData['username']);
        $fname = strip_tags($formData['fname']);
        $lname = strip_tags($formData['lname']);
        $password = $formData['password'];
        if ($formParams == '') {
            $hasher = new PasswordHash(8, FALSE);
            $password = $hasher->HashPassword($password);
        }
        // Is email available?
        $sql = "SELECT `email` \n                FROM `fcms_users` \n                WHERE `email` = ?";
        $rows = $this->fcmsDatabase->getRows($sql, $email);
        if ($rows === false) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        if (count($rows) > 0) {
            $this->displayHtmlForm('<p class="error">' . T_('The email you have choosen is already in use.  Please choose a different email.') . ' <a href="lostpw.php">' . T_('If you have forgotten your password please reset it') . '</a></p>');
            $this->displayFooter();
            return;
        }
        // Is username availabel?
        $sql = "SELECT `username` \n                FROM `fcms_users` \n                WHERE `username` = ?";
        $rows = $this->fcmsDatabase->getRows($sql, $username);
        if ($rows === false) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        if (count($rows) > 0) {
            $this->displayHtmlForm('<p class="error">' . T_('Sorry, but that username is already taken.  Please choose another username.') . '</p>');
            $this->displayFooter();
            return;
        }
        $sex = 'M';
        if (isset($formData['sex'])) {
            $sex = $formData['sex'] == 'F' ? 'F' : 'M';
        }
        // Create new user
        $sql = "INSERT INTO `fcms_users`\n                    (`access`, `joindate`, `fname`, `lname`, `sex`, `email`, `username`, `phpass`) \n                VALUES \n                    (3, NOW(), ?, ?, ?, ?, ?, ?)";
        $params = array($fname, $lname, $sex, $email, $username, $password);
        $lastid = $this->fcmsDatabase->insert($sql, $params);
        if ($lastid === false) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        $fbAccessToken = isset($formData['accessToken']) ? $formData['accessToken'] : '';
        // Create user's settings
        $sql = "INSERT INTO `fcms_user_settings`\n                    (`user`, `fb_access_token`)\n                VALUES \n                    (?, ?)";
        if (!$this->fcmsDatabase->insert($sql, array($lastid, $fbAccessToken))) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        // Create user's address
        $sql = "INSERT INTO `fcms_address`\n                    (`user`, `updated`) \n                VALUES \n                    (?, NOW())";
        if (!$this->fcmsDatabase->insert($sql, array($lastid))) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        // Setup some stuff for sending email
        $sitename = getSiteName();
        $now = gmdate('F j, Y, g:i a');
        // TODO: use admin's tz?
        $subject = $sitename . ' ' . T_('Membership');
        $message = '';
        // Which activation method?
        $sql = "SELECT `value` AS 'auto_activate'\n                FROM `fcms_config`\n                WHERE `name` = 'auto_activate'";
        $row = $this->fcmsDatabase->getRow($sql);
        if ($row === false) {
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        // Auto activation
        if ($row['auto_activate'] == 1) {
            $this->handleAutoActivation($email, $subject, $lastid, $sitename);
        } else {
            $message = T_('Dear') . ' ' . $fname . ' ' . $lname . ', 

' . sprintf(T_('Thank you for registering at %s'), $sitename) . '

' . T_('In order to login and begin using the site, your administrator must activate your account.  You will get an email when this has been done.') . '

' . T_('After your account is activated you can login using the following information') . ':
' . T_('Username') . ': ' . $username . ' 

' . T_('Thanks') . ',  
' . sprintf(T_('The %s Webmaster'), $sitename) . '

' . T_('This is an automated response, please do not reply.');
            echo '
            <div id="msg">
                <h1>' . T_('Congratulations and Welcome') . '</h1>
                <p>
                    ' . sprintf(T_('You have been successfully registered at %s.'), $sitename) . ' 
                    ' . sprintf(T_('Your account information has been emailed to %s.'), $email) . '<br/>
                    <b>' . T_('Please remember your username and password for this site.') . '</b>
                </p>
                <p>' . T_('Unfortunately your account must be activated before you can  <a href="index.php">login</a> and begin using the site.') . '</p>
            </div>';
            mail($email, $subject, $message, getEmailHeaders());
        }
        // Email the admin
        $admin_subject = sprintf(T_('New User Registration at %s'), $sitename);
        $admin_message = sprintf(T_('A new user has registered at %s'), $sitename) . ':

' . T_('Time of Registration') . ': ' . $now . '

' . T_('Username') . ': ' . $username . '
' . T_('Name') . ': ' . $fname . ' ' . $lname;
        mail(getContactEmail(), $admin_subject, $admin_message, getEmailHeaders());
    }
コード例 #4
0
ファイル: privatemsg.php プロジェクト: lmcro/fcms
    /**
     * displayComposeFormSubmit 
     * 
     * @return void
     */
    function displayComposeFormSubmit()
    {
        $to = (int) $_POST['to'];
        $title = strip_tags($_POST['title']);
        $msg = strip_tags($_POST['post']);
        if (strlen($title) <= 0 || strlen($msg) <= 0) {
            header("Location: privatemsg.php");
            return;
        }
        // Insert the PM into the DB
        $sql = "INSERT INTO `fcms_privatemsg` \n                    (`to`, `from`, `date`, `title`, `msg`) \n                VALUES\n                    (?, ?, NOW(), ?, ?)";
        $params = array($to, $this->fcmsUser->id, $title, $msg);
        if (!$this->fcmsDatabase->insert($sql, $params)) {
            $this->displayHeader();
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        // Email the PM to the user
        $sql = "SELECT `email` FROM `fcms_users` \n                WHERE `id` = ?";
        $r = $this->fcmsDatabase->getRow($sql, $to);
        if ($r === false) {
            $this->displayHeader();
            $this->fcmsError->displayError();
            $this->displayFooter();
            return;
        }
        $from = $this->fcmsUser->displayName;
        $reply = $this->fcmsUser->email;
        $toName = getUserDisplayName($to);
        $sitename = getSiteName();
        $sitename = html_entity_decode($sitename);
        $subject = sprintf(T_('A new Private Message at %s'), $sitename);
        $email = $r['email'];
        $url = getDomainAndDir();
        $email_headers = 'From: ' . $sitename . ' <' . getContactEmail() . '>' . "\r\n";
        $email_headers .= 'Reply-To: ' . $reply . "\r\n";
        $email_headers .= 'Content-Type: text/plain; charset=UTF-8;' . "\r\n";
        $email_headers .= 'MIME-Version: 1.0' . "\r\n";
        $email_headers .= 'X-Mailer: PHP/' . phpversion();
        $email_msg = T_('Dear') . ' ' . $toName . ',

' . sprintf(T_('%s has sent you a new Private Message at %s'), $from, $sitename) . '

' . T_('The message has been attached below.') . '

' . sprintf(T_('To respond to this message either visit %s or respond to this email.'), $url . 'privatemsg.php') . '

----

' . T_('From') . ': ' . $from . '
' . T_('Message Title') . ': ' . $title . '

' . $msg . '

';
        mail($email, $subject, $email_msg, $email_headers);
        $_SESSION['success'] = 1;
        header("Location: privatemsg.php");
    }
コード例 #5
0
function getReportContactEmail($report_id = NULL)
{
    if (!$report_id) {
        return;
    }
    global $pearDB;
    $DBRESULT =& $pearDB->query("SELECT contact_contact_id FROM pdfreports_reports_contactgroup_relation rrcr, contactgroup_contact_relation ccr WHERE reports_rp_id = '" . $report_id . "' AND rrcr.contactgroup_cg_id = ccr.contactgroup_cg_id");
    for ($i = 0; $Cg =& $DBRESULT->fetchRow(); $i++) {
        $contacts[$i] = $Cg["contact_contact_id"];
    }
    $DBRESULT->free();
    $DBRESULT =& $pearDB->query("SELECT contact_c_id FROM pdfreports_reports_contact_relation  WHERE reports_rp_id = '" . $report_id . "'");
    for ($j = $i; $C =& $DBRESULT->fetchRow(); $j++) {
        $contacts[$j] = $C["contact_c_id"];
    }
    $contacts_email = array();
    foreach ($contacts as $key => $contact_id) {
        $contacts_email[$key] = getContactEmail($contact_id);
    }
    //print_r($contacts_email);
    return $contacts_email;
}
コード例 #6
0
ファイル: rss.php プロジェクト: lmcro/fcms
/**
 * displayFeedPhotoGallery 
 * 
 * @return void
 */
function displayFeedPhotoGallery()
{
    $fcmsError = FCMS_Error::getInstance();
    $fcmsDatabase = Database::getInstance($fcmsError);
    $url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $urlroot = $url;
    $pos = strrpos($url, "/");
    if ($pos === false) {
        $pos = strrpos($url, "\\");
    }
    if (!($pos === false)) {
        $urlroot = substr($url, 0, $pos);
    }
    $lastday = time() - 84 * 60 * 60 * 24;
    // 12 weeks
    $sql = "SELECT `caption`, p.`user`, `filename`, p.`date`, `name` \n            FROM `fcms_gallery_photos` AS p, `fcms_category` As c\n            WHERE p.`category` = c.`id` \n            AND UNIX_TIMESTAMP(p.`date`) >= ?\n            ORDER BY p.`date`";
    $rows = $fcmsDatabase->getRows($sql, $lastday);
    if ($rows === false) {
        print "Error getting data.";
        return;
    }
    $output = "<?xml version=\"1.0\"?" . "> \n<rss version=\"2.0\"> \n<channel> \n<title>" . getSiteName() . " - " . T_('Photo Gallery') . "</title> \n<link>" . $url . "</link> \n<description>" . getSiteName() . " - " . T_('Photo Gallery') . " " . T_('RSS Feed') . "</description> \n<language>" . T_pgettext('Language Code for this translation', 'lang') . "</language> \n<managingEditor>" . getContactEmail() . "</managingEditor> \n";
    if (count($rows) > 0) {
        foreach ($rows as $line) {
            $title = htmlentities($line['caption']);
            if ($title == "") {
                $title = htmlentities($line['name']);
            }
            $output .= "<item><title><![CDATA[{$title}]]></title> \n<pubDate>" . gmdate('D, d M Y H:i:s', strtotime($line['date'])) . " GMT</pubDate> \n<link>" . htmlentities($urlroot . "/gallery/photos/member" . $line['user'] . "/" . $line['filename']) . "</link>              \n<description><![CDATA[<img src=\"{$urlroot}/gallery/photos/member" . $line['user'] . "/" . $line['filename'] . "\" border=\"0\" />]]></description> \n<enclosure url=\"" . $urlroot . "/gallery/photos/member" . $line['user'] . "/" . $line['filename'] . "\" type=\"" . returnMIMEType("./gallery/photos/member" . $line['user'] . "/" . $line['filename']) . "\" length=\"" . filesize("./gallery/photos/member" . $line['user'] . "/" . $line['filename']) . "\" /> \n<guid isPermaLink=\"true\"><![CDATA[" . $urlroot . "/gallery/photos/member" . $line['user'] . "/" . $line['filename'] . "]]></guid> \n</item> \n";
        }
    }
    $output .= "</channel></rss>";
    echo $output;
}