Exemple #1
0
function core_textarea($item, $editor = null, $info_item = null)
{
    switch ($item) {
        default:
            $content = Config::instance()->core[$item];
            break;
        case 'closed_text':
        case 'footer_text':
        case 'mail_signature':
        case 'rules':
            $content = get_core_ml_text($item);
    }
    return [h::info($info_item ?: $item), h::textarea($content, ['name' => "core[{$item}]", 'class' => $editor ? " {$editor}" : ''])];
}
$Config = Config::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
if (_getcookie('restore_password_confirm')) {
    _setcookie('restore_password_confirm', '');
    $Page->title($L->restore_password_success_title);
    $Page->success($L->restore_password_success);
    return;
} elseif (!$User->guest()) {
    $Page->title($L->you_are_already_registered_title);
    $Page->warning($L->you_are_already_registered);
    return;
} elseif (!isset($Config->route[2])) {
    $Page->title($L->invalid_confirmation_code);
    $Page->warning($L->invalid_confirmation_code);
    return;
}
$result = $User->restore_password_confirmation($Config->route[2]);
if ($result === false) {
    $Page->title($L->invalid_confirmation_code);
    $Page->warning($L->invalid_confirmation_code);
    return;
}
if (Mail::instance()->send_to($User->get('email', $result['id']), $L->restore_password_success_mail(get_core_ml_text('name')), $L->restore_password_success_mail_body($User->username($result['id']), get_core_ml_text('name'), $Config->core_url() . '/profile/settings', $User->get('login', $result['id']), $result['password']))) {
    _setcookie('restore_password_confirm', 1);
    header("Location: {$Config->base_url()}/System/profile/restore_password_confirmation");
} else {
    $Page->title($L->sending_reg_mail_error_title);
    $Page->warning($L->sending_reg_mail_error);
}
Exemple #3
0
    return;
}
$_POST['email'] = mb_strtolower($_POST['email']);
$result = $User->registration($_POST['email']);
if ($result === false) {
    error_code(400);
    $Page->error($L->please_type_correct_email);
    sleep(1);
    return;
} elseif ($result == 'error') {
    error_code(500);
    $Page->error($L->reg_server_error);
    return;
} elseif ($result == 'exists') {
    error_code(400);
    $Page->error($L->reg_error_exists);
    return;
}
$confirm = $result['reg_key'] !== true;
if ($confirm) {
    $body = $L->reg_need_confirmation_mail_body(strstr($_POST['email'], '@', true), get_core_ml_text('name'), $Config->core_url() . "/profile/registration_confirmation/{$result['reg_key']}", $L->time($Config->core['registration_confirmation_time'], 'd'));
} else {
    $body = $L->reg_success_mail_body(strstr($_POST['email'], '@', true), get_core_ml_text('name'), $Config->core_url() . '/profile/settings', $User->get('login', $result['id']), $result['password']);
}
if (Mail::instance()->send_to($_POST['email'], $L->{$confirm ? 'reg_need_confirmation_mail' : 'reg_success_mail'}(get_core_ml_text('name')), $body)) {
    $Page->json($confirm ? 'reg_confirmation' : 'reg_success');
} else {
    $User->registration_cancel();
    error_code(500);
    $Page->error($L->sending_reg_mail_error);
}
Exemple #4
0
 /**
  * Getting footer information
  *
  * @return Page
  */
 protected function get_footer()
 {
     $db = class_exists('cs\\DB', false) ? DB::instance() : null;
     $this->Footer .= h::div(get_core_ml_text('footer_text') ?: false, Config::instance()->core['show_footer_info'] ? Language::instance()->page_footer_info('<!--generate time-->', $db ? $db->queries : 0, format_time(round($db ? $db->time : 0, 5)), '<!--peak memory usage-->') : false, base64_decode('wqkgUG93ZXJlZCBieSA8YSB0YXJnZXQ9Il9ibGFuayIgaHJlZj0iaHR0cDovL2NsZXZlcnN0eW' . 'xlLm9yZy9jbXMiIHRpdGxlPSJDbGV2ZXJTdHlsZSBDTVMiPkNsZXZlclN0eWxlIENNUzwvYT4='));
     return $this;
 }
Exemple #5
0
 /**
  * Initialization: loading of module structure, including of necessary module files, inclusion of save file
  */
 protected function init()
 {
     $Config = Config::instance();
     $L = Language::instance();
     $Page = Page::instance();
     $User = User::instance();
     /**
      * Some routing preparations
      */
     $rc_path =& $this->route_path;
     $rc_ids =& $this->route_ids;
     foreach ($Config->route as &$item) {
         if (is_numeric($item)) {
             $rc_ids[] =& $item;
         } else {
             $rc_path[] =& $item;
         }
     }
     unset($item, $rc_path, $rc_ids);
     $rc =& $this->route_path;
     if ($Config->core['simple_admin_mode'] && file_exists(MFOLDER . '/index_simple.json')) {
         $structure_file = 'index_simple.json';
     } else {
         $structure_file = 'index.json';
     }
     if (file_exists(MFOLDER . "/{$structure_file}")) {
         $this->structure = file_get_json(MFOLDER . "/{$structure_file}");
         if (is_array($this->structure)) {
             foreach ($this->structure as $item => $value) {
                 if (!is_array($value)) {
                     $item = $value;
                 }
                 if ($User->get_permission($this->permission_group, $item)) {
                     $this->parts[] = $item;
                     if (isset($rc[0]) && $item == $rc[0] && is_array($value)) {
                         foreach ($value as $subpart) {
                             if ($User->get_permission($this->permission_group, "{$item}/{$subpart}")) {
                                 $this->subparts[] = $subpart;
                             } elseif (isset($rc[1]) && $rc[1] == $subpart) {
                                 error_code(403);
                                 return;
                             }
                         }
                     }
                 } elseif ($rc[0] == $item) {
                     error_code(403);
                     return;
                 }
             }
             unset($item, $value, $subpart);
         }
     } elseif (API && !file_exists(MFOLDER . '/index.php') && !file_exists(MFOLDER . "/index.{$this->request_method}.php")) {
         error_code(404);
         return;
     }
     unset($structure_file);
     _include_once(MFOLDER . '/index.php', false);
     if (API && $this->request_method) {
         _include_once(MFOLDER . "/index.{$this->request_method}.php", false);
     }
     if ($this->stop || defined('ERROR_CODE')) {
         return;
     }
     if ($this->parts) {
         if (!isset($rc[0]) || $rc[0] == '') {
             if (API) {
                 return;
             }
             $rc[0] = $this->parts[0];
             if (isset($this->structure[$rc[0]]) && is_array($this->structure[$rc[0]])) {
                 $this->subparts = $this->structure[$rc[0]];
             }
         } elseif ($rc[0] != '' && !empty($this->parts) && !in_array($rc[0], $this->parts)) {
             error_code(404);
             return;
         }
         /**
          * Saving of changes
          */
         if (IN_ADMIN && !_include_once(MFOLDER . "/{$rc['0']}/{$this->savefile}.php", false)) {
             _include_once(MFOLDER . "/{$this->savefile}.php", false);
         }
         IN_ADMIN && $this->title_auto && $Page->title($L->administration);
         if (!$this->api && $this->title_auto) {
             $Page->title($L->{HOME ? 'home' : MODULE});
         }
         if (!$this->api) {
             if (!HOME && $this->title_auto) {
                 $Page->title($L->{$rc}[0]);
             }
         }
         /**
          * Warning if site is closed
          */
         if (!$Config->core['site_mode']) {
             $Page->warning(get_core_ml_text('closed_title'));
         }
         _include_once(MFOLDER . "/{$rc['0']}.php", false);
         if (API && $this->request_method) {
             _include_once(MFOLDER . "/{$rc['0']}.{$this->request_method}.php", false);
         }
         if ($this->stop || defined('ERROR_CODE')) {
             return;
         }
         if ($this->subparts) {
             if (!isset($rc[1]) || $rc[1] == '' && !empty($this->subparts)) {
                 if (API) {
                     return;
                 }
                 $rc[1] = $this->subparts[0];
             } elseif ($rc[1] != '' && !empty($this->subparts) && !in_array($rc[1], $this->subparts)) {
                 error_code(404);
                 return;
             }
             if (!$this->api) {
                 if (!HOME && $this->title_auto) {
                     $Page->title($L->{$rc}[1]);
                 }
                 if ($this->action === null) {
                     $this->action = (IN_ADMIN ? 'admin/' : '') . MODULE . "/{$rc['0']}/{$rc['1']}";
                 }
             }
             _include_once(MFOLDER . "/{$rc['0']}/{$rc['1']}.php", false);
             if (API && $this->request_method) {
                 _include_once(MFOLDER . "/{$rc['0']}/{$rc['1']}.{$this->request_method}.php", false);
             }
             if ($this->stop || defined('ERROR_CODE')) {
                 return;
             }
         } elseif (!$this->api && $this->action === null) {
             $this->action = (IN_ADMIN ? 'admin/' : '') . MODULE . "/{$rc['0']}";
         }
         unset($rc);
         if ($this->post_title && $this->title_auto) {
             $Page->title($this->post_title);
         }
     } elseif (!$this->api) {
         IN_ADMIN && $Page->title($L->administration);
         if (!$this->api && $this->title_auto) {
             $Page->title($L->{HOME ? 'home' : MODULE});
         }
         if ($this->action === null) {
             $this->action = $Config->server['relative_address'];
         }
         _include_once(MFOLDER . "/{$this->savefile}.php", false);
     }
 }
Exemple #6
0
 /**
  * Sending of email
  *
  * @param array|string|string[]			$email			if emails without names - string (may be several emails separated by comma) or
  * 														1-dimensional array(<i>email</i>)<br>
  * 														else - 2-dimensional array(<i>email</i>, <i>name</i>) must be given
  * @param string						$subject		Mail subject
  * @param string						$body			html body
  * @param string|null					$body_text		plain text body
  * @param array|null|string				$attachments	1- or 2-dimensional array of array(<i>path</i>, <i>name</i>) or simply string
  * 														with path to the file in file system
  * @param array|null|string|string[]	$reply_to		Similar to <b>$email</b>
  * @param bool|string					$signature		<b>true</b> - add system signature<br>
  * 														<b>false</b> - without signature<br>
  * 														<b>string</b> - custom signature
  * @return bool
  */
 function send_to($email, $subject, $body, $body_text = null, $attachments = null, $reply_to = null, $signature = true)
 {
     if (empty($email) || empty($subject) || empty($body)) {
         return false;
     }
     if (is_array($email)) {
         if (count($email) == 2) {
             $this->AddAddress($email[0], $email[1]);
         } else {
             foreach ($email as $m) {
                 if (is_array($m)) {
                     $this->AddAddress($m[0], $m[1]);
                 } else {
                     $this->AddAddress($m);
                 }
             }
         }
     } else {
         $email = _trim(explode(',', $email));
         foreach ($email as $e) {
             $this->AddAddress($e);
         }
         unset($e, $email);
     }
     $this->Subject = $subject;
     if ($signature === true) {
         if ($signature = get_core_ml_text('mail_signature')) {
             $signature = "{$this->LE}-- {$this->LE}.{$signature}";
         }
     } elseif ($signature) {
         $signature = "{$this->LE}-- {$this->LE}" . xap($signature, true);
     } else {
         $signature = '';
     }
     $this->Body = $this->body_normalization($body, $signature);
     if ($body_text) {
         $this->AltBody = $body_text . strip_tags($signature);
     }
     if (is_array($attachments)) {
         if (count($attachments) == 2) {
             $this->AddStringAttachment($attachments[0], $attachments[1]);
         } else {
             foreach ($attachments as $a) {
                 if (is_array($a)) {
                     $this->AddStringAttachment($a[0], $a[1]);
                 } else {
                     $this->AddStringAttachment($a, pathinfo($a, PATHINFO_FILENAME));
                 }
             }
         }
     } elseif (is_string($attachments)) {
         $this->AddStringAttachment($attachments, pathinfo($attachments, PATHINFO_FILENAME));
     }
     if (is_array($reply_to)) {
         if (count($reply_to) == 2) {
             $this->AddReplyTo($reply_to[0], $reply_to[1]);
         } else {
             foreach ($reply_to as $r) {
                 if (is_array($r)) {
                     $this->AddReplyTo($r[0], $r[1]);
                 } else {
                     $this->AddReplyTo($r);
                 }
             }
         }
     } elseif (is_string($reply_to)) {
         $this->AddReplyTo($reply_to);
     }
     $result = $this->Send();
     $this->ClearAddresses();
     $this->ClearAttachments();
     $this->ClearReplyTos();
     return $result;
 }
Exemple #7
0
         } else {
             $User->registration_cancel();
             $Page->title($L->sending_reg_mail_error_title);
             $Page->warning($L->sending_reg_mail_error);
             header('Refresh: 5; url=' . (_getcookie('HybridAuth_referer') ?: $Config->base_url()));
             _setcookie('HybridAuth_referer', '');
         }
     } catch (Exception $e) {
         trigger_error($e->getMessage());
         header('Refresh: 5; url=' . (_getcookie('HybridAuth_referer') ?: $Config->base_url()));
         _setcookie('HybridAuth_referer', '');
     }
 } else {
     $profile_info = $HybridAuth_data['profile_info'];
     $body = $L->reg_need_confirmation_mail_body(isset($profile_info['username']) ? $profile_info['username'] : strstr($result['email'], '@', true), get_core_ml_text('name'), $Config->core_url() . '/profile/registration_confirmation/' . $result['reg_key'], $L->time($Config->core['registration_confirmation_time'], 'd'));
     if ($Mail->send_to($_POST['email'], $L->reg_need_confirmation_mail(get_core_ml_text('name')), $body)) {
         $contacts = $HybridAuth_data['contacts'];
         $existing_data = $User->get(array_keys($profile_info), $User->id);
         foreach ($profile_info as $item => $value) {
             if (!$existing_data[$item] || $existing_data[$item] != $value) {
                 $User->set($item, $value, $User->id);
             }
         }
         unset($existing_data, $item, $value);
         update_user_contacts($contacts, $rc[0]);
         _setcookie('HybridAuth_referer', '');
         $Index->content($L->reg_confirmation);
     } else {
         $User->registration_cancel();
         $Page->title($L->sending_reg_mail_error_title);
         $Page->warning($L->sending_reg_mail_error);
$Page = Page::instance();
$User = User::instance();
if (_getcookie('reg_confirm')) {
    _setcookie('reg_confirm', '');
    $Page->title($L->reg_success_title);
    $Page->success($L->reg_success);
    return;
} elseif (!$User->guest()) {
    $Page->title($L->you_are_already_registered_title);
    $Page->warning($L->you_are_already_registered);
    return;
} elseif (!isset($Config->route[2])) {
    $Page->title($L->invalid_confirmation_code);
    $Page->warning($L->invalid_confirmation_code);
    return;
}
$result = $User->registration_confirmation($Config->route[2]);
if ($result === false) {
    $Page->title($L->invalid_confirmation_code);
    $Page->warning($L->invalid_confirmation_code);
    return;
}
$body = $L->reg_success_mail_body(strstr($result['email'], '@', true), get_core_ml_text('name'), $Config->core_url() . '/profile/settings', $User->get('login', $result['id']), $result['password']);
if (Mail::instance()->send_to($result['email'], $L->reg_success_mail(get_core_ml_text('name')), $body)) {
    _setcookie('reg_confirm', 1);
    header("Location: {$Config->base_url()}/System/profile/registration_confirmation");
} else {
    $User->registration_cancel();
    $Page->title($L->sending_reg_mail_error_title);
    $Page->warning($L->sending_reg_mail_error);
}
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$Config = Config::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
/**
 * If AJAX request from local referer, user is guest - send request for password restore, otherwise - show error
 */
if (!$Config->server['referer']['local'] || !$Config->server['ajax'] || !isset($_POST['email']) || !$User->guest()) {
    sleep(1);
    error_code(403);
    return;
} elseif (!$_POST['email']) {
    error_code(400);
    $Page->error($L->please_type_your_email);
    return;
} elseif (!($id = $User->get_id(mb_strtolower($_POST['email'])))) {
    error_code(400);
    $Page->error($L->user_with_such_login_email_not_found);
    return;
}
if (($key = $User->restore_password($id)) && Mail::instance()->send_to($User->get('email', $id), $L->restore_password_confirmation_mail(get_core_ml_text('name')), $L->restore_password_confirmation_mail_body($User->username($id), get_core_ml_text('name'), $Config->core_url() . "/profile/restore_password_confirmation/{$key}", $L->time($Config->core['registration_confirmation_time'], 'd')))) {
    $Page->json('OK');
} else {
    error_code(500);
    $Page->error($L->restore_password_server_error);
}