Example #1
0
    function fn_email_user_forgot_password($user, $password_url) {
        $aPage = Page::newInstance()->findByInternalName('email_user_forgot_password');
        $locale = osc_current_user_locale();

        if(isset($aPage['locale'][$locale]['s_title'])) {
            $content = $aPage['locale'][$locale];
        } else {
            $content = current($aPage['locale']);
        }

        if (!is_null($content)) {
            $words   = array();
            $words[] = array(
                '{USER_NAME}',
                '{USER_EMAIL}',
                '{PASSWORD_LINK}',
                '{PASSWORD_URL}',
                '{DATE_TIME}'
            );
            $words[] = array(
                $user['s_name'],
                $user['s_email'],
                '<a href="' . $password_url . '">' . $password_url . '</a>',
                $password_url,
                date(osc_date_format()?osc_date_format():'Y-m-d').' '.date(osc_time_format()?osc_time_format():'H:i:00')
            );
            $title = osc_apply_filter('email_user_forgot_pass_word_title_after', osc_mailBeauty(osc_apply_filter('email_title', osc_apply_filter('email_user_forgot_pass_word_title', $content['s_title'], $user, $password_url)), $words), $user, $password_url);
            $body = osc_apply_filter('email_user_forgot_password_description_after', osc_mailBeauty(osc_apply_filter('email_description', osc_apply_filter('email_user_forgot_password_description', $content['s_text'], $user, $password_url)), $words), $user, $password_url);

            $emailParams = array(
                'subject'  => $title,
                'from'     => _osc_from_email_aux(),
                'to'       => $user['s_email'],
                'to_name'  => $user['s_name'],
                'body'     => $body,
                'alt_body' => $body
            );

            osc_sendMail($emailParams);
        }
    }
Example #2
0
                                    </div>
                                    <?php 
}
?>
                                    <input type="radio" name="tf" id="tf_custom" value="tf_custom" <?php 
echo $custom_checked ? 'checked="checked"' : '';
?>
 />
                                    <input type="text" class="input-medium" <?php 
echo $custom_checked ? 'value="' . osc_esc_html(osc_time_format()) . '"' : '';
?>
 onchange="javascript:document.getElementById('timeFormat').value = this.value;" onkeyup="javascript:custom_time(this.value);" />
                                    <br />
                                    <span id="custom_time"></span>
                                    <input type="hidden" name="timeFormat" id="timeFormat" value="<?php 
echo osc_esc_html(osc_time_format());
?>
" />
                                </div>
                            </div>
                            <div class="help-box" style="clear:both; float:none;"><a href="http://php.net/date" target="_blank"><?php 
_e('Documentation on date and time formatting');
?>
</a></div>
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="form-label"><?php 
_e('RSS shows');
?>
</div>
Example #3
0
/**
 * Formats the time using the appropriate format.
 *
 * @param string $date
 */
function osclass_pm_format_time($date)
{
    return date(osc_time_format(), strtotime($date));
}
Example #4
0
    echo osc_item_formated_price();
    ?>
</small> &middot; <?php 
}
echo osc_item_title();
?>
</h1>
                    <p class="no-margin"><?php 
printf(__('<strong>Published date:</strong> %s %s', 'twitter_bootstrap'), osc_format_date(osc_item_pub_date()), date(osc_time_format(), strtotime(osc_item_pub_date())));
?>
</p>
                    <?php 
if (osc_item_mod_date() != '') {
    ?>
                    <p class="no-margin"><?php 
    printf(__('<strong>Modified date:</strong> %s %s', 'twitter_bootstrap'), osc_format_date(osc_item_mod_date()), date(osc_time_format(), strtotime(osc_item_mod_date())));
    ?>
</p>
                    <?php 
}
?>
                    <?php 
$item_location = item_detail_location();
?>
                    <?php 
if (count($item_location) > 0) {
    ?>
                    <p class="no-margin"><?php 
    printf(__('<strong>Location:</strong> %s', 'twitter_bootstrap'), implode(', ', $item_location));
    ?>
</p>
Example #5
0
/**
 * Dump osclass database into path file
 *
 * @param type $path
 * @param type $file
 * @return type
 */
function osc_dbdump($path, $file)
{
    require_once LIB_PATH . 'osclass/model/Dump.php';
    if (!is_writable($path)) {
        return -4;
    }
    if ($path == '') {
        return -1;
    }
    //checking connection
    $dump = Dump::newInstance();
    if (!$dump) {
        return -2;
    }
    $path .= $file;
    $result = $dump->showTables();
    if (!$result) {
        $_str = '';
        $_str .= '/* no tables in ' . DB_NAME . ' */';
        $_str .= "\n";
        $f = fopen($path, "a");
        fwrite($f, $_str);
        fclose($f);
        return -3;
    }
    $_str = '/* OSCLASS MYSQL Autobackup (' . date(osc_date_format() ? osc_date_format() : 'Y-m-d') . ' ' . date(osc_time_format() ? osc_time_format() : 'H:i:s') . ') */' . "\n";
    $f = fopen($path, "a");
    fwrite($f, $_str);
    fclose($f);
    $tables = array();
    foreach ($result as $_table) {
        $tableName = current($_table);
        $tables[$tableName] = $tableName;
    }
    $tables_order = array('t_locale', 't_country', 't_currency', 't_region', 't_city', 't_city_area', 't_widget', 't_admin', 't_user', 't_user_description', 't_category', 't_category_description', 't_category_stats', 't_item', 't_item_description', 't_item_location', 't_item_stats', 't_item_resource', 't_item_comment', 't_preference', 't_user_preferences', 't_pages', 't_pages_description', 't_plugin_category', 't_cron', 't_alerts', 't_keywords', 't_meta_fields', 't_meta_categories', 't_item_meta');
    // Backup default Osclass tables in order, so no problem when importing them back
    foreach ($tables_order as $table) {
        if (array_key_exists(DB_TABLE_PREFIX . $table, $tables)) {
            $dump->table_structure($path, DB_TABLE_PREFIX . $table);
            $dump->table_data($path, DB_TABLE_PREFIX . $table);
            unset($tables[DB_TABLE_PREFIX . $table]);
        }
    }
    // Backup the rest of tables
    foreach ($tables as $table) {
        $dump->table_structure($path, $table);
        $dump->table_data($path, $table);
    }
    return 1;
}
Example #6
0
                                            <?php 
}
?>
                                        <input type="radio" name="tf" id="tf_custom" value="tf_custom" <?php 
echo $custom_checked ? 'checked="checked"' : '';
?>
 />
                                        <label for="tf_custom"><?php 
_e('Custom');
?>
:</label> <input type="text" <?php 
echo $custom_checked ? 'value="' . osc_time_format() . '"' : '';
?>
 onkeyup="javascript:document.getElementById('timeFormat').value = this.value;"/>
                                        <input type="hidden" name="timeFormat" id="timeFormat" value="<?php 
echo osc_time_format();
?>
" />
                                    </div>
                                </fieldset>
                            </div>

                            <div style="float: left; width: 50%;">
                                <fieldset>
                                    <legend><?php 
_e('Number of items in the RSS');
?>
</legend>
                                    <select name="num_rss_items" id="num_rss_items">
                                        <option value="10" <?php 
echo osc_num_rss_items() == '10' ? 'selected="selected"' : '';
Example #7
0
                 $checked = false;
                 if( $tf == osc_time_format() ) {
                 $custom_checked = false;
                 $checked        = true;
                 }
                 ?>
                 <div>
                     <input type="radio" name="tf" id="<?php echo $tf; ?>" value="<?php echo $tf; ?>" <?php echo ( $checked ? 'checked="checked"' : '' ); ?> onclick="javascript:document.getElementById('timeFormat').value = '<?php echo $tf; ?>';" />
                     <?php echo date($tf); ?>
                 </div>
                 <?php } ?>
                 <input type="radio" name="tf" id="tf_custom" value="tf_custom" <?php echo ( $custom_checked ? 'checked="checked"' : '' ); ?> />
                 <input type="text" class="input-medium" <?php echo ( $custom_checked ? 'value="' . osc_esc_html( osc_time_format() ) . '"' : ''); ?> onchange="javascript:document.getElementById('timeFormat').value = this.value;" onkeyup="javascript:custom_time(this.value);" />
                 <br />
                 <span id="custom_time"></span>
                 <input type="hidden" name="timeFormat" id="timeFormat" value="<?php echo osc_esc_html( osc_time_format() ); ?>" />
             </div>
         </div>
         <div class="help-box" style="clear:both; float:none;"><a href="http://php.net/date" target="_blank"><?php _e('Documentation on date and time formatting'); ?></a></div>
     </div>
 </div>
 <div class="form-row">
     <div class="form-label"><?php _e('RSS shows'); ?></div>
     <div class="form-controls">
         <input type="text" class="input-small" name="num_rss_items" value="<?php echo osc_esc_html(osc_num_rss_items()); ?>" />
         <?php _e('listings at most'); ?>
     </div>
 </div>
 <div class="form-row">
     <div class="form-label"><?php _e('Latest listings shown'); ?></div>
     <div class="form-controls">
Example #8
0
 function doModel()
 {
     switch ($this->action) {
         case 'login_post':
             //post execution for the login
             $admin = Admin::newInstance()->findByUsername(Params::getParam('user'));
             if ($admin) {
                 if ($admin["s_password"] == sha1(Params::getParam('password'))) {
                     if (Params::getParam('remember')) {
                         //this include contains de osc_genRandomPassword function
                         require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
                         $secret = osc_genRandomPassword();
                         Admin::newInstance()->update(array('s_secret' => $secret), array('pk_i_id' => $admin['pk_i_id']));
                         Cookie::newInstance()->set_expires(osc_time_cookie());
                         Cookie::newInstance()->push('oc_adminId', $admin['pk_i_id']);
                         Cookie::newInstance()->push('oc_adminSecret', $secret);
                         Cookie::newInstance()->push('oc_adminLocale', Params::getParam('locale'));
                         Cookie::newInstance()->set();
                     }
                     //we are logged in... let's go!
                     Session::newInstance()->_set('adminId', $admin['pk_i_id']);
                     Session::newInstance()->_set('adminUserName', $admin['s_username']);
                     Session::newInstance()->_set('adminName', $admin['s_name']);
                     Session::newInstance()->_set('adminEmail', $admin['s_email']);
                     Session::newInstance()->_set('adminLocale', Params::getParam('locale'));
                 } else {
                     osc_add_flash_message(_m('The password is incorrect'), 'admin');
                 }
             } else {
                 osc_add_flash_message(_m('That username does not exist'), 'admin');
             }
             //returning logged in to the main page...
             $this->redirectTo(osc_admin_base_url());
             break;
         case 'recover':
             //form to recover the password (in this case we have the form in /gui/)
             //#dev.conquer: we cannot use the doView here and only here
             $this->doView('gui/recover.php');
             break;
         case 'recover_post':
             //post execution to recover the password
             $admin = Admin::newInstance()->findByEmail(Params::getParam('email'));
             if ($admin) {
                 if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
                     if (!osc_check_recaptcha()) {
                         osc_add_flash_message(_m('The Recaptcha code is wrong'), 'admin');
                         $this->redirectTo(osc_admin_base_url(true) . '?page=login&action=recover');
                         return false;
                         // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                     }
                 }
                 require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
                 $newPassword = osc_genRandomPassword(40);
                 Admin::newInstance()->update(array('s_secret' => $newPassword), array('pk_i_id' => $admin['pk_i_id']));
                 $password_link = osc_forgot_admin_password_confirm_url($admin['pk_i_id'], $newPassword);
                 $aPage = Page::newInstance()->findByInternalName('email_user_forgot_password');
                 $content = array();
                 $locale = osc_current_user_locale();
                 if (isset($aPage['locale'][$locale]['s_title'])) {
                     $content = $aPage['locale'][$locale];
                 } else {
                     $content = current($aPage['locale']);
                 }
                 if (!is_null($content)) {
                     $words = array();
                     $words[] = array('{USER_NAME}', '{USER_EMAIL}', '{WEB_TITLE}', '{IP_ADDRESS}', '{PASSWORD_LINK}', '{DATE_TIME}');
                     $words[] = array($admin['s_name'], $admin['s_email'], osc_page_title(), $_SERVER['REMOTE_ADDR'], $password_link, date(osc_time_format() . '  ' . osc_date_format()));
                     $title = osc_mailBeauty($content['s_title'], $words);
                     $body = osc_mailBeauty($content['s_text'], $words);
                     $emailParams = array('subject' => $title, 'to' => $admin['s_email'], 'to_name' => $admin['s_name'], 'body' => $body, 'alt_body' => $body);
                     osc_sendMail($emailParams);
                 }
             }
             osc_add_flash_message(_m('A new password has been sent to your e-mail'), 'admin');
             $this->redirectTo(osc_admin_base_url());
             break;
         case 'forgot':
             //form to recover the password (in this case we have the form in /gui/)
             $admin = Admin::newInstance()->findByIdSecret(Params::getParam('adminId'), Params::getParam('code'));
             if ($admin) {
                 $this->doView('gui/forgot_password.php');
             } else {
                 osc_add_flash_message(_m('Sorry, the link is not valid'), 'admin');
                 $this->redirectTo(osc_admin_base_url());
             }
             break;
         case 'forgot_post':
             $admin = Admin::newInstance()->findByIdSecret(Params::getParam('adminId'), Params::getParam('code'));
             if ($admin) {
                 if (Params::getParam('new_password') == Params::getParam('new_password2')) {
                     Admin::newInstance()->update(array('s_secret' => osc_genRandomPassword(), 's_password' => sha1(Params::getParam('new_password'))), array('pk_i_id' => $admin['pk_i_id']));
                     osc_add_flash_message(_m('The password has been changed'), 'admin');
                     $this->redirectTo(osc_admin_base_url());
                 } else {
                     osc_add_flash_message(_m('Error, the password don\'t match'), 'admin');
                     $this->redirectTo(osc_forgot_admin_password_confirm_url(Params::getParam('adminId'), Params::getParam('code')));
                 }
             } else {
                 osc_add_flash_message(_m('Sorry, the link is not valid'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url());
             break;
     }
 }
Example #9
0
 function writeExplainMessages()
 {
     $filename = CONTENT_PATH . 'explain_queries.log';
     if (!file_exists($filename) || !is_writable($filename)) {
         return false;
     }
     $fp = fopen($filename, 'a');
     if ($fp == false) {
         return false;
     }
     fwrite($fp, '==================================================' . PHP_EOL);
     fwrite($fp, '=' . str_pad('Date: ' . date(osc_date_format() ? osc_date_format() : 'Y-m-d') . ' ' . date(osc_time_format() ? osc_date_format() : 'H:i:s'), 48, " ", STR_PAD_BOTH) . '=' . PHP_EOL);
     fwrite($fp, '==================================================' . PHP_EOL . PHP_EOL);
     $title = '|' . str_pad('id', 3, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('select_type', 20, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('table', 20, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('type', 8, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('possible_keys', 28, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('key', 18, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('key_len', 9, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('ref', 48, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('rows', 8, " ", STR_PAD_BOTH) . '|';
     $title .= str_pad('Extra', 38, " ", STR_PAD_BOTH) . '|';
     for ($i = 0; $i < count($this->explain_messages); $i++) {
         fwrite($fp, $this->explain_messages[$i]['query'] . PHP_EOL);
         fwrite($fp, str_pad('', 211, "-", STR_PAD_BOTH) . PHP_EOL);
         fwrite($fp, $title . PHP_EOL);
         fwrite($fp, str_pad('', 211, "-", STR_PAD_BOTH) . PHP_EOL);
         foreach ($this->explain_messages[$i]['explain'] as $explain) {
             $row = '|' . str_pad($explain['id'], 3, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['select_type'], 20, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['table'], 20, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['type'], 8, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['possible_keys'], 28, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['key'], 18, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['key_len'], 9, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['ref'], 48, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['rows'], 8, " ", STR_PAD_BOTH) . '|';
             $row .= str_pad($explain['Extra'], 38, " ", STR_PAD_BOTH) . '|';
             fwrite($fp, $row . PHP_EOL);
             fwrite($fp, str_pad('', 211, "-", STR_PAD_BOTH) . PHP_EOL);
         }
         if ($i != count($this->explain_messages) - 1) {
             fwrite($fp, PHP_EOL . PHP_EOL);
         }
     }
     fwrite($fp, PHP_EOL . PHP_EOL);
     fclose($fp);
     return true;
 }