예제 #1
0
파일: index.php 프로젝트: oanav/closetshare
                                    </div>
                                    <?php 
}
?>
                                        <input type="radio" name="df" id="df_custom" value="df_custom" <?php 
echo $custom_checked ? 'checked="checked"' : '';
?>
 />
                                        <input type="text" name="df_custom_text" id="df_custom_text" class="input-medium" <?php 
echo $custom_checked ? 'value="' . osc_esc_html(osc_date_format()) . '"' : '';
?>
 onchange="javascript:document.getElementById('dateFormat').value = this.value;" onkeyup="javascript:custom_date(this.value);" />
                                        <br />
                                        <span id="custom_date"></span>
                                        <input type="hidden" name="dateFormat" id="dateFormat" value="<?php 
echo osc_date_format();
?>
" />
                                </div>
                                <div id="time">
                                    <?php 
$custom_checked = true;
foreach ($timeFormats as $tf) {
    $checked = false;
    if ($tf == osc_time_format()) {
        $custom_checked = false;
        $checked = true;
    }
    ?>
                                    <div>
                                        <input type="radio" name="tf" id="<?php 
예제 #2
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);
        }
    }
예제 #3
0
파일: hUtils.php 프로젝트: naneri/Osclass
/**
 * Formats the date using the appropiate format.
 *
 * @param string $date
 * @return string
 */
function osc_format_date($date, $dateformat = null)
{
    if ($dateformat == null) {
        $dateformat = osc_date_format();
    }
    $month = array('', __('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December'));
    $month_short = array('', __('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec'));
    $day = array('', __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'), __('Sunday'));
    $day_short = array('', __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'), __('Sun'));
    $ampm = array('AM' => __('AM'), 'PM' => __('PM'), 'am' => __('am'), 'pm' => __('pm'));
    $time = strtotime($date);
    $dateformat = preg_replace('|(?<!\\\\)F|', osc_escape_string($month[date('n', $time)]), $dateformat);
    $dateformat = preg_replace('|(?<!\\\\)M|', osc_escape_string($month_short[date('n', $time)]), $dateformat);
    $dateformat = preg_replace('|(?<!\\\\)l|', osc_escape_string($day[date('N', $time)]), $dateformat);
    $dateformat = preg_replace('|(?<!\\\\)D|', osc_escape_string($day_short[date('N', $time)]), $dateformat);
    $dateformat = preg_replace('|(?<!\\\\)A|', osc_escape_string($ampm[date('A', $time)]), $dateformat);
    $dateformat = preg_replace('|(?<!\\\\)a|', osc_escape_string($ampm[date('a', $time)]), $dateformat);
    return date($dateformat, $time);
}
예제 #4
0
function osc_format_date($date)
{
    //$date = strtotime($item['dt_pub_date']) ;
    return date(osc_date_format(), strtotime($date));
}
예제 #5
0
 public static function meta($field = null, $search = false)
 {
     if ($field != null) {
         // date interval
         if ($field['e_type'] == 'DATEINTERVAL') {
             $field['s_value'] = array();
             $field['s_value']['from'] = '';
             $field['s_value']['to'] = '';
             if (!$search) {
                 $aInterval = Field::newInstance()->getDateIntervalByPrimaryKey($field['fk_i_item_id'], $field['pk_i_id']);
                 if (is_array($aInterval) && !empty($aInterval)) {
                     $temp['from'] = @$aInterval['from'];
                     $temp['to'] = @$aInterval['to'];
                     $field['s_value'] = $temp;
                 }
             } else {
                 $temp['from'] = Params::getParam('meta[' . $field['pk_i_id'] . '][from]');
                 $temp['to'] = Params::getParam('meta[' . $field['pk_i_id'] . '][to]');
                 $field['s_value'] = $temp;
             }
         }
         // end date interval
         if (Session::newInstance()->_getForm('meta_' . $field['pk_i_id']) != "") {
             $field['s_value'] = Session::newInstance()->_getForm('meta_' . $field['pk_i_id']);
         } else {
             if (!isset($field['s_value']) || $field['s_value'] == '') {
                 $s_value = Params::getParam('meta');
                 $field['s_value'] = '';
                 if (isset($s_value[$field['pk_i_id']])) {
                     $field['s_value'] = $s_value[$field['pk_i_id']];
                 }
             }
         }
         if ($field['e_type'] == "TEXTAREA") {
             if ($search) {
                 echo '<h6>' . $field['s_name'] . '</h6>';
                 echo '<input id="meta_' . $field['s_slug'] . '" type="text" name="meta[' . $field['pk_i_id'] . ']" value="' . osc_esc_html(isset($field) && isset($field["s_value"]) ? $field["s_value"] : "") . '" />';
             } else {
                 echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                 echo '<textarea id="meta_' . $field['s_slug'] . '" name="meta[' . $field['pk_i_id'] . ']" rows="10">' . (isset($field) && isset($field["s_value"]) ? $field["s_value"] : "") . '</textarea>';
             }
         } else {
             if ($field['e_type'] == "DROPDOWN") {
                 if ($search) {
                     echo '<h6>' . $field['s_name'] . '</h6>';
                 } else {
                     echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                 }
                 if (isset($field) && isset($field['s_options'])) {
                     $options = explode(",", $field['s_options']);
                     if (count($options) > 0) {
                         echo '<select name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '">';
                         if ($search) {
                             echo '<option value=""></option>';
                         }
                         foreach ($options as $option) {
                             echo '<option value="' . osc_esc_html($option) . '" ' . ($field['s_value'] == $option ? 'selected="selected"' : '') . '>' . $option . '</option>';
                         }
                         echo '</select>';
                     }
                 }
             } else {
                 if ($field['e_type'] == "RADIO") {
                     // radio at search page, becomes dropdown with radio options
                     if ($search) {
                         echo '<h6>' . $field['s_name'] . '</h6>';
                         if (isset($field) && isset($field['s_options'])) {
                             $options = explode(",", $field['s_options']);
                             if (count($options) > 0) {
                                 echo '<select name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '">';
                                 echo '<option value=""></option>';
                                 foreach ($options as $option) {
                                     echo '<option value="' . osc_esc_html($option) . '"' . ($field['s_value'] == $option ? ' selected="selected"' : '') . '>' . $option . '</option>';
                                 }
                                 echo '</select>';
                             }
                         }
                     } else {
                         echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                         if (isset($field) && isset($field['s_options'])) {
                             $options = explode(",", $field['s_options']);
                             if (count($options) > 0) {
                                 echo '<ul>';
                                 foreach ($options as $key => $option) {
                                     echo '<li><input type="radio" name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '_' . $key . '" value="' . osc_esc_html($option) . '"' . ($field['s_value'] == $option ? ' checked="checked"' : '') . ' /><label for="meta_' . $field['s_slug'] . '_' . $key . '">' . $option . '</label></li>';
                                 }
                                 echo '</ul>';
                             }
                         }
                     }
                 } else {
                     if ($field['e_type'] == "CHECKBOX") {
                         if (isset($field) && isset($field['s_options'])) {
                             echo '<input type="checkbox" name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '" value="1"' . (isset($field) && isset($field['s_value']) && $field['s_value'] == 1 ? ' checked="checked"' : '') . ' />';
                             echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ' </label>';
                         }
                     } else {
                         if ($field['e_type'] == "DATE") {
                             if ($search) {
                                 echo '<h6>' . $field['s_name'] . '</h6>';
                             } else {
                                 echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                             }
                             // timestamp/1000 (javascript timestamp)
                             echo '<input type="hidden" id="meta_' . $field['s_slug'] . '" name="meta[' . $field['pk_i_id'] . ']" value="" />';
                             echo '<input type="text" id="" class="meta_' . $field['s_slug'] . ' cf_date" value="" />';
                             FieldForm::initDatePicker('meta_' . $field['s_slug'], osc_date_format(), $field['s_value']);
                         } else {
                             if ($field['e_type'] == "DATEINTERVAL") {
                                 if ($search) {
                                     echo '<h6>' . $field['s_name'] . '</h6>';
                                 } else {
                                     echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                                 }
                                 echo __('from') . ' ';
                                 echo '<input type="hidden" id="meta_' . $field['s_slug'] . '_from" name="meta[' . $field['pk_i_id'] . '][from]" value="' . $field['s_value']['from'] . '" />';
                                 echo '<input type="text" id="" class="meta_' . $field['s_slug'] . '_from cf_date_interval" value="" />';
                                 FieldForm::initDatePicker('meta_' . $field['s_slug'] . '_from', osc_date_format(), $field['s_value']['from'], 'from');
                                 echo ' ' . __('to') . ' ';
                                 echo '<input type="hidden" id="meta_' . $field['s_slug'] . '_to" name="meta[' . $field['pk_i_id'] . '][to]" value="' . $field['s_value']['to'] . '" />';
                                 echo '<input type="text" id="" class="meta_' . $field['s_slug'] . '_to cf_date_interval" value="" />';
                                 FieldForm::initDatePicker('meta_' . $field['s_slug'] . '_to', osc_date_format(), $field['s_value']['to'], 'to');
                             } else {
                                 if ($search) {
                                     echo '<h6>' . $field['s_name'] . '</h6>';
                                 } else {
                                     echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
                                 }
                                 echo '<input id="meta_' . $field['s_slug'] . '" type="text" name="meta[' . $field['pk_i_id'] . ']" value="' . osc_esc_html(isset($field) && isset($field["s_value"]) ? $field["s_value"] : "") . '" />';
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #6
0
/**
 * Gets item meta value
 *
 * @return string
 */
function osc_item_meta_value()
{
    $meta = osc_item_meta();
    if ($meta['e_type'] == "DATEINTERVAL" || $meta['e_type'] == "DATE") {
        $value = osc_field(osc_item_meta(), 's_value', '');
        if (is_array($value)) {
            // from [date_from] to [date_to]
            if (isset($value['from']) && $value['from'] != '' && is_numeric($value['from']) && isset($value['to']) && $value['to'] != '' && is_numeric($value['to'])) {
                $return = __('From') . ' ' . htmlentities(date(osc_date_format(), $value['from']), ENT_COMPAT, "UTF-8");
                $return .= ' ' . __('to') . ' ' . htmlentities(date(osc_date_format(), $value['to']), ENT_COMPAT, "UTF-8");
                return $return;
            } else {
                return '';
            }
        } else {
            if ($value != '' && is_numeric($value)) {
                return htmlentities(date(osc_date_format(), $value), ENT_COMPAT, "UTF-8");
            } else {
                return '';
            }
        }
    } else {
        if ($meta['e_type'] == "CHECKBOX") {
            if (osc_field(osc_item_meta(), 's_value', '') == 1) {
                return '<img src="' . osc_current_web_theme_url('images/tick.png') . '" alt="" title=""/>';
            } else {
                return '<img src="' . osc_current_web_theme_url('images/cross.png') . '" alt="" title=""/>';
            }
        } else {
            if ($meta['e_type'] == "URL") {
                if (osc_field(osc_item_meta(), 's_value', '') != '') {
                    if (stripos(osc_field(osc_item_meta(), 's_value', ''), 'http://') !== false || stripos(osc_field(osc_item_meta(), 's_value', ''), 'https://') !== false) {
                        return '<a href="' . html_entity_decode(osc_field(osc_item_meta(), 's_value', ''), ENT_COMPAT, "UTF-8") . '" >' . html_entity_decode(osc_field(osc_item_meta(), 's_value', ''), ENT_COMPAT, "UTF-8") . '</a>';
                    } else {
                        return '<a href="http://' . html_entity_decode(osc_field(osc_item_meta(), 's_value', ''), ENT_COMPAT, "UTF-8") . '" >' . html_entity_decode(osc_field(osc_item_meta(), 's_value', ''), ENT_COMPAT, "UTF-8") . '</a>';
                    }
                } else {
                    return '';
                }
            } else {
                return nl2br(htmlentities(osc_field(osc_item_meta(), 's_value', ''), ENT_COMPAT, "UTF-8"));
            }
        }
    }
}
예제 #7
0
파일: utils.php 프로젝트: naneri/Osclass
/**
 * 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;
}
예제 #8
0
     foreach( $dateFormats as $df ) {
     $checked = false;
     if( $df == osc_date_format() ) {
     $custom_checked = false;
     $checked        = true;
     } ?>
     <div>
         <input type="radio" name="df" id="<?php echo $df; ?>" value="<?php echo $df; ?>" <?php echo ( $checked ? 'checked="checked"' : '' ); ?> onclick="javascript:document.getElementById('dateFormat').value = '<?php echo $df; ?>';" />
         <?php echo date($df); ?>
     </div>
     <?php } ?>
         <input type="radio" name="df" id="df_custom" value="df_custom" <?php echo ( $custom_checked ? 'checked="checked"' : '' ); ?> />
         <input type="text" name="df_custom_text" id="df_custom_text" class="input-medium" <?php echo ( $custom_checked ? 'value="' . osc_esc_html( osc_date_format() ) . '"' : '' ); ?> onchange="javascript:document.getElementById('dateFormat').value = this.value;" onkeyup="javascript:custom_date(this.value);" />
         <br />
         <span id="custom_date"></span>
         <input type="hidden" name="dateFormat" id="dateFormat" value="<?php echo osc_date_format(); ?>" />
 </div>
 <div id="time">
     <?php
     $custom_checked = true;
     foreach( $timeFormats as $tf ) {
     $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>
예제 #9
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;
     }
 }
예제 #10
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;
 }