function error($description, $error_place = '', $params = array())
{
    if (defined('DEVELOPER_ENVIROMENT')) {
        trigger_error('error', E_USER_WARNING);
        echo $description . '<br>' . $error_place . '<br><pre>';
        print_r($params);
        echo '</pre>';
    }
    debug::write_error($description, $error_place, $params);
    rollback_user_transaction();
    if (debug::is_console_enabled()) {
        echo debug::parse_html_console();
    } else {
        $message = '';
        if ($user_id = user::get_id()) {
            $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n";
        }
        $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}";
        $mail = new mime_mail();
        $mail->set_body($message);
        $mail->build_message();
        $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!');
    }
    ob_end_flush();
    exit;
}
 function _valid_perform()
 {
     $mail_data = $this->dataspace->export();
     $body = sprintf(strings::get('body_template', 'feedback'), $mail_data['sender_name'], $mail_data['sender_email'], $mail_data['body']);
     $body = str_replace('<br>', "\n", $body);
     $subject = sprintf(strings::get('message_subject', 'feedback'), $mail_data['subject'], $_SERVER['HTTP_HOST']);
     $mail = new mime_mail();
     $mail->set_body($body);
     $mail->build_message();
     $recipient_email = constant('ADMINISTRATOR_EMAIL');
     if (!$recipient_email || !$mail->send('administrator', $recipient_email, $mail_data['sender_name'], $mail_data['sender_email'], $subject)) {
         message_box::write_error(strings::get('mail_not_sent', 'feedback'));
         return false;
     }
     return true;
 }
 function send_activate_password_email(&$user_data, $password)
 {
     global $_SERVER;
     $http_host = $_SERVER['HTTP_HOST'];
     $filename = TEMPLATES_DIR . '/user/generated_password_mail.html';
     if (!file_exists($filename)) {
         error('template file for password notification email not found!', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file_name' => $filename));
     }
     $fd = fopen($filename, "r");
     $contents = fread($fd, filesize($filename));
     fclose($fd);
     $contents = str_replace('%website_name%', $http_host, $contents);
     $contents = str_replace('%user_name%', $user_data['name'] . ' ' . $user_data['lastname'], $contents);
     $contents = str_replace('%new_password%', $password, $contents);
     $contents = str_replace('%website_href%', $http_host, $contents);
     $contents = str_replace('%website_email%', ADMINISTRATOR_EMAIL, $contents);
     $activate_href = 'http://' . $http_host . '/root/activate_password?user='******'email'] . '&id=' . $user_data['password'];
     $contents = str_replace('%activate_href%', $activate_href, $contents);
     include_once LIMB_DIR . '/core/lib/mail/mime_mail.class.php';
     $mail = new mime_mail();
     $mail->set_body($contents);
     $mail->build_message();
     if (!$mail->send($user_data['name'] . ' ' . $user_data['lastname'], $user_data['email'], $http_host, ADMINISTRATOR_EMAIL, strings::get('generate_password_theme', 'user'))) {
         debug::write_error('error while sending password notification email', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     } else {
         return true;
     }
 }