コード例 #1
0
ファイル: contact.php プロジェクト: semul/Osclass
 function doModel()
 {
     switch ($this->action) {
         case 'contact_post':
             //contact_post
             $yourName = Params::getParam('yourName');
             $yourEmail = Params::getParam('yourEmail');
             $subject = Params::getParam('subject');
             $message = Params::getParam('message');
             if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
                 if (!osc_check_recaptcha()) {
                     osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                     Session::newInstance()->_setForm("yourName", $yourName);
                     Session::newInstance()->_setForm("yourEmail", $yourEmail);
                     Session::newInstance()->_setForm("subject", $subject);
                     Session::newInstance()->_setForm("message_body", $message);
                     $this->redirectTo(osc_contact_url());
                     return false;
                     // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                 }
             }
             if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                 osc_add_flash_error_message(_m('Please enter a correct email'));
                 Session::newInstance()->_setForm("yourName", $yourName);
                 Session::newInstance()->_setForm("subject", $subject);
                 Session::newInstance()->_setForm("message_body", $message);
                 $this->redirectTo(osc_contact_url());
             }
             $message = sprintf(__("%s (%s) left this message : %s"), $yourName, $yourEmail, $message);
             $params = array('reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact form') . ': ' . $subject, 'to' => osc_contact_email(), 'to_name' => __('Administrator'), 'body' => $message, 'alt_body' => $message);
             if (osc_contact_attachment()) {
                 $attachment = Params::getFiles('attachment');
                 $resourceName = $attachment['name'];
                 $tmpName = $attachment['tmp_name'];
                 $resourceType = $attachment['type'];
                 $path = osc_content_path() . 'uploads/' . time() . '_' . $resourceName;
                 if (!is_writable(osc_content_path() . 'uploads/')) {
                     osc_add_flash_error_message(_m('There have been some errors sending the message'));
                     $this->redirectTo(osc_contact_url());
                 }
                 if (!move_uploaded_file($tmpName, $path)) {
                     unset($path);
                 }
             }
             if (isset($path)) {
                 $params['attachment'] = $path;
             }
             osc_sendMail($params);
             osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
             $this->redirectTo(osc_contact_url());
             break;
         default:
             //contact
             $this->doView('contact.php');
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: oanav/closetshare
                        </div>
                    </div>
                    <h2 class="render-title separate-top"><?php 
_e('Contact Settings');
?>
</h2>
                    <div class="form-row">
                        <div class="form-label"><?php 
_e('Attachments');
?>
</div>
                        <div class="form-controls">
                            <div class="form-label-checkbox">
                                <label>
                                    <input type="checkbox" <?php 
echo osc_contact_attachment() ? 'checked="checked"' : '';
?>
 name="enabled_attachment" value="1" />
                            <?php 
_e('Allow people to attach a file to the contact form');
?>
                                </label>
                            </div>
                        </div>
                    </div>
                    <h2 class="render-title separate-top"><?php 
_e('Cron Settings');
?>
</h2>
                    <div class="form-row">
                        <div class="form-label"><?php 
コード例 #3
0
ファイル: contact.php プロジェクト: mylastof/os-class
    function doModel()
    {
        switch ($this->action) {
            case 'contact_post':
                //contact_post
                osc_csrf_check();
                $yourName = Params::getParam('yourName');
                $yourEmail = Params::getParam('yourEmail');
                $subject = Params::getParam('subject');
                $message = Params::getParam('message');
                if (osc_recaptcha_private_key() != '') {
                    if (!osc_check_recaptcha()) {
                        osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                        Session::newInstance()->_setForm('yourName', $yourName);
                        Session::newInstance()->_setForm('yourEmail', $yourEmail);
                        Session::newInstance()->_setForm('subject', $subject);
                        Session::newInstance()->_setForm('message_body', $message);
                        $this->redirectTo(osc_contact_url());
                        return false;
                        // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                    }
                }
                $banned = osc_is_banned($yourEmail);
                if ($banned == 1) {
                    osc_add_flash_error_message(_m('Your current email is not allowed'));
                    $this->redirectTo(osc_contact_url());
                } else {
                    if ($banned == 2) {
                        osc_add_flash_error_message(_m('Your current IP is not allowed'));
                        $this->redirectTo(osc_contact_url());
                    }
                }
                $user = User::newInstance()->newInstance()->findByEmail($yourEmail);
                if (isset($user['b_active']) && ($user['b_active'] == 0 || $user['b_enabled'] == 0)) {
                    osc_add_flash_error_message(_m('Your current email is not allowed'));
                    $this->redirectTo(osc_contact_url());
                }
                if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                    osc_add_flash_error_message(_m('Please enter a correct email'));
                    Session::newInstance()->_setForm('yourName', $yourName);
                    Session::newInstance()->_setForm('subject', $subject);
                    Session::newInstance()->_setForm('message_body', $message);
                    $this->redirectTo(osc_contact_url());
                }
                $message_name = sprintf(__('Name: %s'), $yourName);
                $message_email = sprintf(__('Email: %s'), $yourEmail);
                $message_subject = sprintf(__('Subject: %s'), $subject);
                $message_body = sprintf(__('Message: %s'), $message);
                $message_date = sprintf(__('Date: %s at %s'), date('l F d, Y'), date('g:i a'));
                $message_IP = sprintf(__('IP Address: %s'), get_ip());
                $message = <<<MESSAGE
{$message_name}
{$message_email}
{$message_subject}
{$message_body}

{$message_date}
{$message_IP}
MESSAGE;
                $params = array('from' => osc_contact_email(), 'to' => osc_contact_email(), 'to_name' => osc_page_title(), 'reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact'), 'body' => nl2br($message));
                $error = false;
                if (osc_contact_attachment()) {
                    $attachment = Params::getFiles('attachment');
                    if (isset($attachment['error']) && $attachment['error'] == UPLOAD_ERR_OK) {
                        $mime_array = array('text/php', 'text/x-php', 'application/php', 'application/x-php', 'application/x-httpd-php', 'application/x-httpd-php-source', 'application/x-javascript');
                        $resourceName = $attachment['name'];
                        $tmpName = $attachment['tmp_name'];
                        $resourceType = $attachment['type'];
                        if (function_exists('mime_content_type')) {
                            $resourceType = mime_content_type($tmpName);
                        }
                        if (function_exists('finfo_open')) {
                            $finfo = finfo_open(FILEINFO_MIME);
                            $output = finfo_file($finfo, $tmpName);
                            finfo_close($finfo);
                            $output = explode("; ", $output);
                            if (is_array($output)) {
                                $output = $output[0];
                            }
                            $resourceType = $output;
                        }
                        // check mime file
                        if (!in_array($resourceType, $mime_array)) {
                            $emailAttachment = array('path' => $tmpName, 'name' => $resourceName);
                            $error = false;
                        } else {
                            $error = true;
                        }
                        // --- check mime file
                    } else {
                        $error = true;
                    }
                }
                if (!$error) {
                    if (isset($emailAttachment)) {
                        $params['attachment'] = $emailAttachment;
                    }
                    osc_run_hook('pre_contact_post', $params);
                    osc_sendMail(osc_apply_filter('contact_params', $params));
                    if (isset($tmpName)) {
                        @unlink($tmpName);
                    }
                    osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
                } else {
                    osc_add_flash_error_message(_m('The file you tried to upload does not have a valid extension'));
                }
                $this->redirectTo(osc_contact_url());
                break;
            default:
                //contact
                $this->doView('contact.php');
        }
    }
コード例 #4
0
ファイル: item.php プロジェクト: ricktaylord/osclass-themes
ContactForm::your_name();
?>
                                <label for="yourEmail"><?php 
_e('Your e-mail address', 'masjob');
?>
:</label> <?php 
ContactForm::your_email();
?>
                                <label for="phoneNumber"><?php 
_e('Phone number', 'masjob');
?>
:</label> <?php 
ContactForm::your_phone_number();
?>
                                <?php 
if (osc_contact_attachment()) {
    ?>
                                    <label for="subject"><?php 
    _e('Your CV', 'masjob');
    ?>
</label> <?php 
    ContactForm::your_attachment();
    ?>
                                <?php 
}
?>
                                <label for="message"><?php 
_e('Message', 'masjob');
?>
:</label> <?php 
ContactForm::your_message();
コード例 #5
0
ファイル: contact.php プロジェクト: jmcclenon/Osclass
    function doModel()
    {
        switch ($this->action) {
            case 'contact_post':
                //contact_post
                osc_csrf_check();
                $yourName = Params::getParam('yourName');
                $yourEmail = Params::getParam('yourEmail');
                $subject = Params::getParam('subject');
                $message = Params::getParam('message');
                if (osc_recaptcha_private_key() != '') {
                    if (!osc_check_recaptcha()) {
                        osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                        Session::newInstance()->_setForm('yourName', $yourName);
                        Session::newInstance()->_setForm('yourEmail', $yourEmail);
                        Session::newInstance()->_setForm('subject', $subject);
                        Session::newInstance()->_setForm('message_body', $message);
                        $this->redirectTo(osc_contact_url());
                        return false;
                        // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                    }
                }
                if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                    osc_add_flash_error_message(_m('Please enter a correct email'));
                    Session::newInstance()->_setForm('yourName', $yourName);
                    Session::newInstance()->_setForm('subject', $subject);
                    Session::newInstance()->_setForm('message_body', $message);
                    $this->redirectTo(osc_contact_url());
                }
                $message_name = sprintf(__('Name: %s'), $yourName);
                $message_email = sprintf(__('Email: %s'), $yourEmail);
                $message_subject = sprintf(__('Subject: %s'), $subject);
                $message_body = sprintf(__('Message: %s'), $message);
                $message_date = sprintf(__('Date: %s at %s'), date('l F d, Y'), date('g:i a'));
                $message_IP = sprintf(__('IP Address: %s'), get_ip());
                $message = <<<MESSAGE
{$message_name}
{$message_email}
{$message_subject}
{$message_body}

{$message_date}
{$message_IP}
MESSAGE;
                $params = array('from' => osc_contact_email(), 'to' => osc_contact_email(), 'to_name' => osc_page_title(), 'reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact'), 'body' => nl2br($message));
                if (osc_contact_attachment()) {
                    $attachment = Params::getFiles('attachment');
                    if (isset($attachment['tmp_name'])) {
                        $resourceName = $attachment['name'];
                        $tmpName = $attachment['tmp_name'];
                        $resourceType = $attachment['type'];
                        $path = osc_content_path() . 'uploads/' . time() . '_' . $resourceName;
                        if (!is_writable(osc_content_path() . 'uploads/')) {
                            osc_add_flash_error_message(_m('There have been some errors sending the message'));
                            $this->redirectTo(osc_contact_url());
                        }
                        if (!move_uploaded_file($tmpName, $path)) {
                            unset($path);
                        }
                    }
                }
                if (isset($path)) {
                    $params['attachment'] = $path;
                }
                osc_run_hook('pre_contact_post', $params);
                osc_sendMail(osc_apply_filter('contact_params', $params));
                osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
                $this->redirectTo(osc_contact_url());
                break;
            default:
                //contact
                $this->doView('contact.php');
        }
    }
コード例 #6
0
ファイル: index.php プロジェクト: pombredanne/ArcherSys
     <div class="form-controls">
         <div class="form-label-checkbox">
             <label>
                 <input type="checkbox" <?php echo ( osc_selectable_parent_categories() ? 'checked="checked"' : '' ); ?> name="selectable_parent_categories" value="1" />
         <?php _e('Allow users to select a parent category as a category when inserting or editing a listing '); ?>
             </label>
         </div>
     </div>
 </div>
 <h2 class="render-title separate-top"><?php _e('Contact Settings'); ?></h2>
 <div class="form-row">
     <div class="form-label"><?php _e('Attachments'); ?></div>
     <div class="form-controls">
         <div class="form-label-checkbox">
             <label>
                 <input type="checkbox" <?php echo ( osc_contact_attachment() ? 'checked="checked"' : '' ); ?> name="enabled_attachment" value="1" />
         <?php _e('Allow people to attach a file to the contact form'); ?>
             </label>
         </div>
     </div>
 </div>
 <h2 class="render-title separate-top"><?php _e('Cron Settings'); ?></h2>
 <div class="form-row">
     <div class="form-label"><?php _e('Automatic cron process'); ?></div>
     <div class="form-controls">
         <div class="form-label-checkbox">
             <label>
                 <input type="checkbox" <?php echo ( osc_auto_cron() ? 'checked="checked"' : '' ); ?> name="auto_cron" />
         <?php printf(__('Allow Osclass to run a built-in <a href="%s" target="_blank">cron</a> automatically without setting crontab'), 'http://en.wikipedia.org/wiki/Cron' ); ?>
             </label>
         </div>