예제 #1
0
function md5uniq()
{
    return basemd5(mt_rand() . litepublisher::$secret . microtime());
}
예제 #2
0
 public function hash($s)
 {
     return basemd5((string) $s . $this->solt . litepublisher::$secret);
 }
예제 #3
0
 public function save()
 {
     extract($this->data, EXTR_SKIP);
     $this->db->UpdateAssoc(compact('id', 'post', 'author', 'parent', 'posted', 'status', 'content'));
     $this->getdb($this->rawtable)->UpdateAssoc(array('id' => $id, 'modified' => sqldate(), 'rawcontent' => $rawcontent, 'hash' => basemd5($rawcontent)));
 }
 public function is_duplicate($idpost, $content)
 {
     $comments = tcomments::i($idpost);
     $content = trim($content);
     $hash = basemd5($content);
     return $comments->raw->findid("hash = '{$hash}'");
 }
예제 #5
0
 public function adduser(array $item, $rawdata)
 {
     $users = tusers::i();
     $reguser = tregserviceuser::i();
     if (!empty($item['email'])) {
         if ($id = $users->emailexists($item['email'])) {
             $user = $users->getitem($id);
             if ($user['status'] == 'comuser') {
                 $users->approve($id);
             }
         } elseif (litepublisher::$options->reguser) {
             $id = $users->add(array('email' => $item['email'], 'name' => $item['name'], 'website' => isset($item['website']) ? tcontentfilter::clean_website($item['website']) : ''));
             if (isset($item['uid'])) {
                 $uid = $item['uid'];
                 if (strlen($uid) >= 22) {
                     $uid = basemd5($uid);
                 }
                 $reguser->add($id, $this->name, $uid);
             }
         } else {
             //registration disabled
             return 403;
         }
     } else {
         $uid = !empty($item['uid']) ? $item['uid'] : (!empty($item['website']) ? $item['website'] : '');
         if ($uid) {
             if (strlen($uid) >= 22) {
                 $uid = basemd5($uid);
             }
             if ($id = $reguser->find($this->name, $uid)) {
                 //nothing
             } elseif (litepublisher::$options->reguser) {
                 $id = $users->add(array('email' => '', 'name' => $item['name'], 'website' => isset($item['website']) ? tcontentfilter::clean_website($item['website']) : ''));
                 $users->approve($id);
                 $reguser->add($id, $this->name, $uid);
             } else {
                 //registration disabled
                 return 403;
             }
         } else {
             //nothing found and hasnt email or uid
             return 403;
         }
     }
     $expired = time() + 31536000;
     $cookie = md5uniq();
     litepublisher::$options->user = $id;
     litepublisher::$options->updategroup();
     litepublisher::$options->setcookies($cookie, $expired);
     if (litepublisher::$options->ingroup('admin')) {
         setcookie('litepubl_user_flag', 'true', $expired, litepublisher::$site->subdir . '/', false);
     }
     setcookie('litepubl_regservice', $this->name, $expired, litepublisher::$site->subdir . '/', false);
     $this->onadd($id, $rawdata);
     if (isset($this->sessdata['comuser'])) {
         return tcommentform::i()->processform($this->sessdata['comuser'], true);
     }
     if (!empty($_COOKIE['backurl'])) {
         $backurl = $_COOKIE['backurl'];
     } else {
         $user = $users->getitem($id);
         $backurl = tusergroups::i()->gethome($user['idgroups'][0]);
     }
     return litepublisher::$urlmap->redir($backurl);
 }
예제 #6
0
function update586()
{
    $menus = tadminmenus::i();
    $id = $menus->url2id('/admin/logout/');
    if (!$id) {
        $id = $menus->addfake('/admin/logout/', tlocal::i()->logout);
    }
    $menus->items[$id]['order'] = 9999999;
    $menus->save();
    tjsonserver::i()->addevent('comments_get_logged', 'tjsoncomments', 'comments_get_logged');
    $man = tdbmanager::i();
    $prefix = strtolower(litepublisher::$options->dbconfig['prefix']);
    $tables = $man->gettables();
    foreach ($tables as $table) {
        if (strbegin(strtolower($table), $prefix)) {
            $man->query("alter table {$table} ENGINE = MYISAM");
        }
    }
    if (isset(litepublisher::$options->solt)) {
        return;
    }
    litepublisher::$options->solt = md5uniq();
    litepublisher::$options->emptyhash = basemd5(litepublisher::$secret . litepublisher::$options->solt);
    litepublisher::$options->securecookie = false;
    litepublisher::$options->authenabled = true;
    if (function_exists('mcrypt_encrypt')) {
        litepublisher::$options->data['dbconfig']['password'] = _encrypt(str_rot13(base64_decode(litepublisher::$options->data['dbconfig']['password'])), litepublisher::$options->solt . litepublisher::$secret);
    }
    $expired = time() + 31536000;
    $cookie = md5uniq();
    //litepublisher::$options->setcookies($cookie, $expired);
    $subdir = litepublisher::$site->subdir . '/';
    setcookie('litepubl_user_id', litepublisher::$options->user, $expired, $subdir, false);
    setcookie('litepubl_user', $cookie, $expired, $subdir, false);
    setcookie('litepubl_user_flag', 'true', $expired, $subdir, false);
    $cookie = basemd5((string) $cookie . litepublisher::$options->solt . litepublisher::$secret);
    litepublisher::$options->data['cookiehash'] = $cookie;
    litepublisher::$options->cookieexpired = $expired;
    unset(litepublisher::$options->data['cookie'], litepublisher::$options->data['authcookie']);
    $password = md5uniq();
    litepublisher::$options->data['password'] = basemd5($password . litepublisher::$options->solt . litepublisher::$secret);
    unset(litepublisher::$classes->items['tauthdigest']);
    litepublisher::$classes->items['tableprop'] = array('kernel.admin.php', '', 'htmlresource.class.php');
    litepublisher::$classes->save();
    tusers::i()->db->update("password = ''", 'id > 0');
    $theme = ttheme::i();
    $args = new targs();
    $args->password = $password;
    $subj = $theme->parsearg('[$site.name] Смена пароля', $args);
    $body = $theme->parsearg('Внимание! Обновление LitePublisher 5.86 включает в себя новые алгоритмы безопасности и поэтому старые пароли больше не будут работать. Скрипт сгенерировал для вас новый пароль:
$password

Пожалуйста, используйте его или получите другой на странице восстановления пароля:
$site.url/admin/password/

Сохранение старых паролей невозможно потому, что в системе никогда не хранились пароли, а только их хеши. Приносим извенения за доставленные неудобства. Новые алгоритмы защиты значительно усиливают безопасность вашего сайта, также не забывайте регулярно менять пароли для лучшей безопасности.

На сайтах, у которых псетители могли залогиниватся также сброшены все пароли, но им не была сделана рассылка уведомлений о смене паролей. При попытки залогинится таким посетителям будет предложено восстановить пароль. Для залогинивающихся через соцсети будет просто предложено еще раз авторизоваться (ранее они даже и не имели паролей)
', $args);
    tmailer::sendtoadmin($subj, $body);
}
예제 #7
0
 public function auth($token)
 {
     if (!($s = http::get('http://ulogin.ru/token.php?token=' . $token . '&host=' . $_SERVER['HTTP_HOST']))) {
         return false;
     }
     if (!($info = json_decode($s, true))) {
         return false;
     }
     if (isset($info['error']) || !isset($info['network'])) {
         return false;
     }
     $name = !empty($info['first_name']) ? $info['first_name'] : '';
     $name .= !empty($info['last_name']) ? ' ' . $info['last_name'] : '';
     if (!$name && !empty($info['nickname'])) {
         $name = $info['nickname'];
     }
     $uid = !empty($info['uid']) ? $info['uid'] : (!empty($info['id']) ? $info['id'] : (!empty($info['identity']) ? $info['identity'] : (!empty($info['profile']) ? $info['profile'] : '')));
     if (strlen($uid) >= 22) {
         $uid = basemd5($uid);
     }
     $phone = !empty($info['phone']) ? self::filterphone($info['phone']) : false;
     $newreg = false;
     $users = tusers::i();
     if (!empty($info['email'])) {
         if ($id = $users->emailexists($info['email'])) {
             $user = $users->getitem($id);
             if ($user['status'] == 'comuser') {
                 $users->approve($id);
             }
             if ($phone && empty($user['phone'])) {
                 $users->setvalue($id, 'phone', $phone);
             }
         } elseif (litepublisher::$options->reguser) {
             $newreg = true;
             $id = $users->add(array('email' => $info['email'], 'name' => $name, 'website' => empty($info['profile']) ? '' : tcontentfilter::clean_website($info['profile'])));
             if ($phone) {
                 $users->db->setvalue($id, 'phone', $phone);
             }
             if ($uid) {
                 $this->add($id, $info['network'], $uid);
             }
         } else {
             //registration disabled
             return false;
         }
     } else {
         if ($uid) {
             if ($id = $this->find($info['network'], $uid)) {
                 //nothing
             } elseif (litepublisher::$options->reguser) {
                 $newreg = true;
                 $id = $users->add(array('email' => '', 'name' => $name, 'website' => empty($info['profile']) ? '' : tcontentfilter::clean_website($info['profile'])));
                 $users->approve($id);
                 if ($phone) {
                     $users->db->setvalue($id, 'phone', $phone);
                 }
                 $this->add($id, $info['network'], $uid);
             } else {
                 //registration disabled
                 return false;
             }
         } else {
             //nothing found and hasnt email or uid
             return false;
         }
     }
     $expired = time() + 31536000;
     $cookie = md5uniq();
     litepublisher::$options->user = $id;
     litepublisher::$options->updategroup();
     litepublisher::$options->setcookies($cookie, $expired);
     if (litepublisher::$options->ingroup('admin')) {
         setcookie('litepubl_user_flag', 'true', $expired, litepublisher::$site->subdir . '/', false);
     }
     setcookie('litepubl_regservice', $info['network'], $expired, litepublisher::$site->subdir . '/', false);
     $this->onadd($id, $info, $newreg);
     return array('id' => $id, 'pass' => $cookie, 'regservice' => $info['network']);
 }