function uloginUninstall($self)
{
    tusers::i()->unbind('tregserviceuser');
    turlmap::unsub($self);
    $man = tdbmanager::i();
    $man->deletetable($self->table);
    if ($man->column_exists('users', 'phone')) {
        $man->alter('users', "drop phone");
    }
    $alogin = tadminlogin::i();
    $alogin->widget = $self->deletepanel($alogin->widget);
    $alogin->save();
    $areg = tadminreguser::i();
    $areg->widget = $self->deletepanel($areg->widget);
    $areg->save();
    $tc = ttemplatecomments::i();
    $tc->regaccount = $self->deletepanel($tc->regaccount);
    $tc->save();
    $js = tjsmerger::i();
    $js->lock();
    $js->deletefile('default', '/plugins/ulogin/resource/ulogin.popup.min.js');
    $js->deletefile('default', '/plugins/ulogin/resource/' . litepublisher::$options->language . '.ulogin.popup.min.js');
    $js->unlock();
    tcssmerger::i()->deletefile('default', '/plugins/ulogin/resource/ulogin.popup.css');
    tjsonserver::i()->unbind($self);
    litepublisher::$classes->delete('emailauth');
}
 private function getsubscribed($authorid)
 {
     $db = litepublisher::$db;
     $authorid = (int) $authorid;
     $users = tusers::i();
     if (!$users->itemexists($authorid)) {
         return '';
     }
     $html = $this->gethtml('moderator');
     $result = '';
     $res = $db->query("select {$db->posts}.id as id, {$db->posts}.title as title, {$db->urlmap}.url as url\n    from {$db->posts}, {$db->urlmap}\n    where {$db->posts}.id in (select DISTINCT {$db->comments}.post from {$db->comments} where author = {$authorid})\n    and {$db->urlmap}.id = {$db->posts}.idurl\n    order by {$db->posts}.posted desc");
     $items = $db->res2assoc($res);
     $subscribers = tsubscribers::i();
     $subscribed = $subscribers->getposts($authorid);
     $args = targs::i();
     foreach ($items as $item) {
         $args->add($item);
         $args->subscribed = in_array($item['id'], $subscribed);
         $result .= $html->subscribeitem($args);
     }
     return $html->fixquote($result);
     /*
     subscribeitem = "<tr>
     <td align ='center'><input type='checkbox' name='$id' id='$id' $subscribed /></td>
     <td  align='left'><a href='$site.url$url'>$title</a></td>
     </tr>"
     */
 }
function tregservicesUninstall($self)
{
    $name = basename(dirname(__FILE__));
    tcommentform::i()->unbind($self);
    turlmap::unsub($self);
    foreach ($self->items as $id => $classname) {
        litepublisher::$classes->delete($classname);
    }
    litepublisher::$classes->delete('tregserviceuser');
    litepublisher::$classes->delete('toauth');
    tfiler::delete(litepublisher::$paths->data . 'regservices', true, true);
    tusers::i()->unbind('tregserviceuser');
    tdbmanager::i()->deletetable('regservices');
    $css = tcssmerger::i();
    $css->deletestyle("/plugins/{$name}/regservices.min.css");
}
 public function delete($id)
 {
     if (!isset($this->items[$id])) {
         return false;
     }
     unset($this->items[$id]);
     $this->save();
     $users = tusers::i();
     $db = $users->db;
     $items = $db->res2assoc($users->getdb($users->grouptable)->select("idgroup = {$id}"));
     $users->getdb($users->grouptable)->delete("idgroup = {$id}");
     foreach ($items as $item) {
         $iduser = $item['iduser'];
         $idgroups = $db->res2id($db->query("select idgroup from {$db->prefix}{$users->grouptable} where iduser = {$iduser}"));
         $users->db->setvalue($iduser, 'idgroups', implode(',', $idgroups));
     }
 }
示例#5
0
 public function edit($id, array $values)
 {
     $users = tusers::i();
     if (!$users->itemexists($id)) {
         return false;
     }
     $item = $users->getitem($id);
     foreach ($item as $k => $v) {
         if (!isset($values[$k])) {
             continue;
         }
         switch ($k) {
             case 'password':
                 if ($values['password'] != '') {
                     $item['password'] = litepublisher::$options->hash($values['email'] . $values['password']);
                 }
                 break;
             case 'idgroups':
                 $groups = tusergroups::i();
                 $item['idgroups'] = $this->cleangroups($values['idgroups']);
                 break;
             default:
                 $item[$k] = trim($values[$k]);
         }
     }
     $users->items[$id] = $item;
     $item['id'] = $id;
     $users->setgroups($id, $item['idgroups']);
     $item['idgroups'] = implode(',', $item['idgroups']);
     $users->db->updateassoc($item);
     $pages = tuserpages::i();
     if (isset($values['status']) && 'approved' == $values['status'] && $item['status'] != $values['status']) {
         if ($pages->itemexists($id)) {
             if ($pages->createpage) {
                 $pages->addpage($id);
             }
         } else {
             $pages->add($id);
         }
     }
     $pages->edit($id, $values);
     return true;
 }
 public function getcontent()
 {
     $result = '';
     $html = $this->html;
     $lang = tlocal::admin();
     $args = new targs();
     if ($this->newreg) {
         $result .= $html->h4->newreg;
     }
     $subscribers = tsubscribers::i();
     $items = $subscribers->getposts($this->iduser);
     if (count($items) == 0) {
         return $html->h4->nosubscribtions;
     }
     tposts::i()->loaditems($items);
     $args->default_subscribe = tuseroptions::i()->getvalue($this->iduser, 'subscribe') == 'enabled';
     $args->formtitle = tusers::i()->getvalue($this->iduser, 'email') . ' ' . $lang->formhead;
     $result .= $html->adminform('[checkbox=default_subscribe]' . ($table = $html->tableposts($items, array(array('left', $lang->post, '<a href="$site.url$post.url" title="$post.title">$post.title</a>')))), $args);
     return $html->fixquote($result);
 }
 public function getuserlist()
 {
     $users = tusers::i();
     $pages = tuserpages::i();
     $perpage = 20;
     $count = $pages->count;
     $from = $this->getfrom($perpage, $count);
     $p = $pages->thistable;
     $u = $users->thistable;
     $items = $users->res2items($users->db->query("\n    select {$u}.*  from {$u}\n    left join {$p} on {$u}.id = {$p}.id\n    where not {$p}.id is null\n    order by {$u}.id desc limit {$from}, {$perpage}"));
     //dumpvar($items);
     $html = $this->gethtml('users');
     $lang = tlocal::admin('users');
     $args = new targs();
     $args->adminurl = $this->adminurl;
     $result = $html->h4->userstable;
     $result .= $html->items2table($users, $items, array(array('left', $lang->edit, sprintf('<a href="%s=$id">$name</a>', $this->adminurl))));
     $theme = ttheme::i();
     $result .= $theme->getpages($this->url, litepublisher::$urlmap->page, ceil($count / $perpage));
     return $result;
 }
/**
* Lite Publisher
* Copyright (C) 2010 - 2013 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/
* Dual licensed under the MIT (mit.txt)
* and GPL (gpl.txt) licenses.
**/
function tticketsInstall($self)
{
    if (version_compare(PHP_VERSION, '5.3', '<')) {
        die('Ticket system requires PHP 5.3 or later. You are using PHP ' . PHP_VERSION);
    }
    $dirname = basename(dirname(__FILE__));
    $l = tlocalmerger::i();
    $l->lock();
    $l->add('default', "plugins/{$dirname}/resource/" . litepublisher::$options->language . ".ini");
    $l->add('mail', "plugins/{$dirname}/resource/" . litepublisher::$options->language . ".mail.ini");
    $l->unlock();
    tadminhtml::i()->inidir(dirname(__FILE__) . '/resource/');
    $lang = tlocal::admin('tickets');
    $lang->addsearch('ticket', 'tickets');
    $self->data['cats'] = array();
    $self->data['idcomauthor'] = tusers::i()->add(array('email' => '', 'name' => tlocal::get('ticket', 'comname'), 'status' => 'approved', 'idgroups' => 'commentator'));
    $self->save();
    $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR;
    $filter = tcontentfilter::i();
    $filter->phpcode = true;
    $filter->save();
    litepublisher::$options->parsepost = false;
    $manager = tdbmanager::i();
    $manager->CreateTable($self->childtable, file_get_contents($dir . 'ticket.sql'));
    $manager->addenum('posts', 'class', 'tticket');
    $optimizer = tdboptimizer::i();
    $optimizer->lock();
    $optimizer->childtables[] = 'tickets';
    $optimizer->addevent('postsdeleted', 'ttickets', 'postsdeleted');
    $optimizer->unlock();
    litepublisher::$classes->lock();
    //install polls if its needed
    $plugins = tplugins::i();
    if (!isset($plugins->items['polls'])) {
        $plugins->add('polls');
    }
    litepublisher::$classes->Add('tticket', 'ticket.class.php', $dirname);
    //litepublisher::$classes->Add('tticketsmenu', 'tickets.menu.class.php', $dirname);
    litepublisher::$classes->Add('tticketeditor', 'admin.ticketeditor.class.php', $dirname);
    litepublisher::$classes->Add('tadmintickets', 'admin.tickets.class.php', $dirname);
    litepublisher::$classes->Add('tadminticketoptions', 'admin.tickets.options.php', $dirname);
    litepublisher::$options->reguser = true;
    $adminoptions = tadminoptions::i();
    $adminoptions->usersenabled = true;
    $adminmenus = tadminmenus::i();
    $adminmenus->lock();
    $parent = $adminmenus->createitem(0, 'tickets', 'ticket', 'tadmintickets');
    $adminmenus->items[$parent]['title'] = tlocal::get('tickets', 'tickets');
    $idmenu = $adminmenus->createitem($parent, 'editor', 'ticket', 'tticketeditor');
    $adminmenus->items[$idmenu]['title'] = tlocal::get('tickets', 'editortitle');
    $idmenu = $adminmenus->createitem($parent, 'opened', 'ticket', 'tadmintickets');
    $adminmenus->items[$idmenu]['title'] = tlocal::get('ticket', 'opened');
    $idmenu = $adminmenus->createitem($parent, 'fixed', 'ticket', 'tadmintickets');
    $adminmenus->items[$idmenu]['title'] = tlocal::get('ticket', 'fixed');
    $idmenu = $adminmenus->createitem($parent, 'options', 'admin', 'tadminticketoptions');
    $adminmenus->items[$idmenu]['title'] = tlocal::i()->options;
    $adminmenus->onexclude = $self->onexclude;
    $adminmenus->unlock();
    /*
    $menus = tmenus::i();
    $menus->lock();
    $ini = parse_ini_file($dir . litepublisher::$options->language . '.install.ini', false);
    
    $menu = tticketsmenu::i();
    $menu->type = 'tickets';
    $menu->url = '/tickets/';
    $menu->title = $ini['tickets'];
    $menu->content = $ini['contenttickets'];
    $id = $menus->add($menu);
    
    foreach (array('bug', 'feature', 'support', 'task') as $type) {
      $menu = tticketsmenu::i();
      $menu->type = $type;
      $menu->parent = $id;
      $menu->url = "/$type/";
      $menu->title = $ini[$type];
      $menu->content = '';
      $menus->add($menu);
    }
    $menus->unlock();
    */
    litepublisher::$classes->unlock();
    $linkgen = tlinkgenerator::i();
    $linkgen->data['ticket'] = '/tickets/[title].htm';
    $linkgen->save();
    $groups = tusergroups::i();
    $groups->lock();
    $idticket = $groups->add('ticket', 'Tickets', '/admin/tickets/editor/');
    $groups->defaults = array($idticket, $groups->getidgroup('author'));
    $groups->items[litepublisher::$options->groupnames['author']]['parents'][] = $idticket;
    $groups->items[litepublisher::$options->groupnames['commentator']]['parents'][] = $idticket;
    $groups->unlock();
}
 public function processform(array $values, $confirmed)
 {
     $lang = tlocal::i('comment');
     if (trim($values['content']) == '') {
         return $this->geterrorcontent($lang->emptycontent);
     }
     if (!$this->checkspam(isset($values['antispam']) ? $values['antispam'] : '')) {
         return $this->geterrorcontent($lang->spamdetected);
     }
     $shortpost = $this->getshortpost(isset($values['postid']) ? (int) $values['postid'] : 0);
     if ($err = $this->invalidate($shortpost)) {
         return $err;
     }
     if ((int) $shortpost['idperm']) {
         $post = tpost::i((int) $shortpost['id']);
         $perm = tperm::i($post->idperm);
         if (!$perm->hasperm($post)) {
             return 403;
         }
     }
     $cm = tcommentmanager::i();
     if ($cm->checkduplicate && $cm->is_duplicate($shortpost['id'], $values['content'])) {
         return $this->geterrorcontent($lang->duplicate);
     }
     unset($values['submitbutton']);
     if (!$confirmed) {
         $values['ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     }
     if (litepublisher::$options->ingroups($cm->idgroups)) {
         if (!$confirmed && $cm->confirmlogged) {
             return $this->request_confirm($values, $shortpost);
         }
         $iduser = litepublisher::$options->user;
     } else {
         switch ($shortpost['comstatus']) {
             case 'reg':
                 return $this->geterrorcontent($lang->reg);
             case 'guest':
                 if (!$confirmed && $cm->confirmguest) {
                     return $this->request_confirm($values, $shortpost);
                 }
                 $iduser = $cm->idguest;
                 break;
             case 'comuser':
                 //hook in regservices social plugin
                 if ($r = $this->oncomuser($values, $confirmed)) {
                     return $r;
                 }
                 if (!$confirmed && $cm->confirmcomuser) {
                     return $this->request_confirm($values, $shortpost);
                 }
                 if ($err = $this->processcomuser($values)) {
                     return $err;
                 }
                 $users = tusers::i();
                 if ($iduser = $users->emailexists($values['email'])) {
                     if ('comuser' != $users->getvalue($iduser, 'status')) {
                         return $this->geterrorcontent($lang->emailregistered);
                     }
                 } else {
                     $iduser = $cm->addcomuser($values['name'], $values['email'], $values['url'], $values['ip']);
                 }
                 $cookies = array();
                 foreach (array('name', 'email', 'url') as $field) {
                     $cookies["comuser_{$field}"] = $values[$field];
                 }
                 break;
         }
     }
     $user = tusers::i()->getitem($iduser);
     if ('hold' == $user['status']) {
         return $this->geterrorcontent($lang->holduser);
     }
     if (!$cm->canadd($iduser)) {
         return $this->geterrorcontent($lang->toomany);
     }
     if (!$cm->add($shortpost['id'], $iduser, $values['content'], $values['ip'])) {
         return $this->geterrorcontent($lang->spamdetected);
     }
     //subscribe by email
     switch ($user['status']) {
         case 'approved':
             if ($user['email'] != '') {
                 // subscribe if its first comment
                 if (1 == tcomments::i()->db->getcount("post = {$shortpost['id']} and author = {$iduser}")) {
                     if ('enabled' == tuseroptions::i()->getvalue($iduser, 'subscribe')) {
                         tsubscribers::i()->update($shortpost['id'], $iduser, true);
                     }
                 }
             }
             break;
         case 'comuser':
             if ('comuser' == $shortpost['comstatus'] && $cm->comuser_subscribe) {
                 tsubscribers::i()->update($shortpost['id'], $iduser, $values['subscribe']);
             }
             break;
     }
     //$post->lastcommenturl;
     $shortpost['commentscount']++;
     if (!litepublisher::$options->commentpages || $shortpost['commentscount'] <= litepublisher::$options->commentsperpage) {
         $c = 1;
     } else {
         $c = ceil($shortpost['commentscount'] / litepublisher::$options->commentsperpage);
     }
     $url = litepublisher::$urlmap->getvalue($shortpost['idurl'], 'url');
     if ($c > 1 && !litepublisher::$options->comments_invert_order) {
         $url = rtrim($url, '/') . "/page/{$c}/";
     }
     litepublisher::$urlmap->setexpired($shortpost['idurl']);
     return $this->sendresult(litepublisher::$site->url . $url, isset($cookies) ? $cookies : array());
 }
示例#10
0
 public function setid($id)
 {
     $comments = tcomments::i();
     $this->data = $comments->getitem($id);
     if (!isset($this->data['name'])) {
         $this->data = $this->data + tusers::i()->getitem($this->data['author']);
     }
     $this->_posted = false;
 }
 public function reguser($email, $name)
 {
     $email = strtolower(trim($email));
     if (!tcontentfilter::ValidateEmail($email)) {
         return $this->error(tlocal::get('comment', 'invalidemail'));
     }
     if (substr_count($email, '.', 0, strpos($email, '@')) > 2) {
         return $this->error(tlocal::get('comment', 'invalidemail'));
     }
     $users = tusers::i();
     if ($id = $users->emailexists($email)) {
         if ('comuser' != $users->getvalue($id, 'status')) {
             return $this->error(tlocal::i()->invalidregdata);
         }
     }
     tsession::start('reguser-' . md5(litepublisher::$options->hash($email)));
     $_SESSION['email'] = $email;
     $_SESSION['name'] = $name;
     $confirm = md5rand();
     $_SESSION['confirm'] = $confirm;
     $password = md5uniq();
     $_SESSION['password'] = $password;
     $_SESSION['backurl'] = isset($_GET['backurl']) ? $_GET['backurl'] : '';
     session_write_close();
     $args = new targs();
     $args->name = $name;
     $args->email = $email;
     $args->confirm = $confirm;
     $args->password = $password;
     $args->confirmurl = litepublisher::$site->url . '/admin/reguser/' . litepublisher::$site->q . 'email=' . urlencode($email);
     tlocal::usefile('mail');
     $lang = tlocal::i('mailusers');
     $theme = ttheme::i();
     $subject = $theme->parsearg($lang->subject, $args);
     $body = $theme->parsearg($lang->body, $args);
     tmailer::sendmail(litepublisher::$site->name, litepublisher::$options->fromemail, $name, $email, $subject, $body);
     return true;
 }
 public function cronsendmail($id)
 {
     $comments = tcomments::i();
     try {
         $item = $comments->getitem($id);
     } catch (Exception $e) {
         return;
     }
     $subscribers = $this->getitems($item['post']);
     if (!$subscribers || count($subscribers) == 0) {
         return;
     }
     $comment = $comments->getcomment($id);
     ttheme::$vars['comment'] = $comment;
     tlocal::usefile('mail');
     $lang = tlocal::i('mailcomments');
     $theme = ttheme::i();
     $args = new targs();
     $subject = $theme->parsearg($lang->subscribesubj, $args);
     $body = $theme->parsearg($lang->subscribebody, $args);
     $body .= "\n";
     $adminurl = litepublisher::$site->url . '/admin/subscribers/';
     $users = tusers::i();
     $users->loaditems($subscribers);
     $list = array();
     foreach ($subscribers as $uid) {
         $user = $users->getitem($uid);
         if ($user['status'] == 'hold') {
             continue;
         }
         $email = $user['email'];
         if (empty($email)) {
             continue;
         }
         if ($email == $comment->email) {
             continue;
         }
         if (in_array($email, $this->blacklist)) {
             continue;
         }
         $admin = $adminurl;
         if ('comuser' == $user['status']) {
             $admin .= litepublisher::$site->q . 'auth=';
             if (empty($user['cookie'])) {
                 $user['cookie'] = md5uniq();
                 $users->setvalue($user['id'], 'cookie', $user['cookie']);
             }
             $admin .= rawurlencode($user['cookie']);
         }
         $list[] = array('fromname' => litepublisher::$site->name, 'fromemail' => $this->fromemail, 'toname' => $user['name'], 'toemail' => $email, 'subject' => $subject, 'body' => $body . $admin);
     }
     if (count($list)) {
         tmailer::sendlist($list);
     }
 }
示例#13
0
 public function processform()
 {
     $users = tusers::i();
     $groups = tusergroups::i();
     if (isset($_POST['delete'])) {
         foreach ($_POST as $key => $value) {
             if (!is_numeric($value)) {
                 continue;
             }
             $id = (int) $value;
             $users->delete($id);
             //if (litepublisher::$classes->exists('tregservices')) $users->getdb('
         }
         return;
     }
     switch ($this->action) {
         case 'add':
             $_POST['idgroups'] = tadminhtml::check2array('idgroup-');
             if ($id = $users->add($_POST)) {
                 litepublisher::$urlmap->redir("{$this->adminurl}={$id}&action=edit");
             } else {
                 return $this->html->h4red->invalidregdata;
             }
             break;
         case 'edit':
             $id = $this->idget();
             if (!$users->itemexists($id)) {
                 return;
             }
             $_POST['idgroups'] = tadminhtml::check2array('idgroup-');
             if (!$users->edit($id, $_POST)) {
                 return $this->notfound;
             }
             if ($id == 1) {
                 litepublisher::$site->author = $_POST['name'];
                 //litepublisher::$site->email = $_POST['email'];
             }
             break;
     }
 }
示例#14
0
 public static function confirm_restore($email, $password)
 {
     tsession::start('password-restore-' . md5(litepublisher::$options->hash($email)));
     if (!isset($_SESSION['email']) || $email != $_SESSION['email'] || $password != $_SESSION['password']) {
         if (isset($_SESSION['email'])) {
             session_write_close();
         } else {
             session_destroy();
         }
         return false;
     }
     session_destroy();
     if ($email == strtolower(trim(litepublisher::$options->email))) {
         litepublisher::$options->changepassword($password);
         return 1;
     } else {
         $users = tusers::i();
         if ($id = $users->emailexists($email)) {
             $users->changepassword($id, $password);
         }
         return $id;
     }
 }
示例#15
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']);
 }
示例#16
0
 public function add($id)
 {
     $item = array('id' => $id, 'idurl' => 0, 'idview' => 1, 'registered' => sqldate(), 'ip' => '', 'avatar' => 0, 'content' => '', 'rawcontent' => '', 'keywords' => '', 'description' => '', 'head' => '');
     if ($this->createpage) {
         $users = tusers::i();
         if ('approved' == $users->getvalue($id, 'status')) {
             $item = $this->addurl($item);
         }
     }
     $this->items[$id] = $item;
     unset($item['url']);
     $this->db->insert($item);
 }
示例#17
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);
 }
 public function request($arg)
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 1;
     $users = tusers::i();
     if (!$users->itemexists($id)) {
         return "<?php litepublisher::{$urlmap->redir}('/');";
     }
     $item = $users->getitem($id);
     $url = $item['website'];
     if (!strpos($url, '.')) {
         $url = litepublisher::$site->url . '/';
     }
     if (!strbegin($url, 'http://')) {
         $url = 'http://' . $url;
     }
     return "<?php litepublisher::{$urlmap->redir}('{$url}');";
 }
示例#19
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);
}
示例#20
0
 public function getuserlink()
 {
     if ($id = litepublisher::$options->user) {
         if (!isset($this->users)) {
             $this->users = array();
         }
         if (isset($this->users[$id])) {
             return $this->users[$id];
         }
         $item = tusers::i()->getitem($id);
         if ($item['website']) {
             $result = sprintf('<a href="%s">%s</a>', $item['website'], $item['name']);
         } else {
             $page = $this->getdb('userpage')->getitem($id);
             if (intval($page['idurl'])) {
                 $result = sprintf('<a href="%s%s">%s</a>', $this->url, litepublisher::$urlmap->getvalue($page['idurl'], 'url'), $item['name']);
             } else {
                 $result = $item['name'];
             }
         }
         $this->users[$id] = $result;
         return $result;
     }
     return '';
 }
function tsubscribersUninstall($self)
{
    tcomments::i()->unbind($self);
    tusers::i()->unbind($self);
    tposts::i()->unbind($self);
}
示例#22
0
 protected function getusername($id, $link)
 {
     if ($id <= 1) {
         if ($link) {
             return sprintf('<a href="%s/" rel="author" title="%2$s">%2$s</a>', litepublisher::$site->url, litepublisher::$site->author);
         } else {
             return litepublisher::$site->author;
         }
     } else {
         $users = tusers::i();
         if (!$users->itemexists($id)) {
             return '';
         }
         $item = $users->getitem($id);
         if (!$link || $item['website'] == '') {
             return $item['name'];
         }
         return sprintf('<a href="%s/users.htm%sid=%s">%s</a>', litepublisher::$site->url, litepublisher::$site->q, $id, $item['name']);
     }
 }
 public function restore($email)
 {
     $lang = tlocal::admin('password');
     $email = strtolower(trim($email));
     if (empty($email)) {
         return $this->error($lang->error);
     }
     $id = $this->getiduser($email);
     if (!$id) {
         return $this->error($lang->error);
     }
     $args = new targs();
     tsession::start('password-restore-' . md5(litepublisher::$options->hash($email)));
     if (!isset($_SESSION['count'])) {
         $_SESSION['count'] = 1;
     } else {
         if ($_SESSION['count']++ > 3) {
             return $this->error($lang->outofcount);
         }
     }
     $_SESSION['email'] = $email;
     $password = md5uniq();
     $_SESSION['password'] = $password;
     $_SESSION['confirm'] = md5rand();
     $args->confirm = $_SESSION['confirm'];
     session_write_close();
     $args->email = urlencode($email);
     if ($id == 1) {
         $name = litepublisher::$site->author;
     } else {
         $item = tusers::i()->getitem($id);
         $args->add($item);
         $name = $item['name'];
     }
     $args->password = $password;
     tlocal::usefile('mail');
     $lang = tlocal::i('mailpassword');
     $theme = ttheme::i();
     $subject = $theme->parsearg($lang->subject, $args);
     $body = $theme->parsearg($lang->body, $args);
     tmailer::sendmail(litepublisher::$site->name, litepublisher::$options->fromemail, $name, $email, $subject, $body);
     return true;
 }
示例#24
0
 public function setcookies($cookie, $expired)
 {
     $this->setcookie('litepubl_user_id', $cookie ? $this->_user : '', $expired);
     $this->setcookie('litepubl_user', $cookie, $expired);
     $this->setcookie('litepubl_user_flag', $cookie && 'admin' == $this->group ? 'true' : '', $expired);
     if ($this->_user == 1) {
         $this->save_cookie($cookie, $expired);
     } else {
         if ($this->_user) {
             tusers::i()->setcookie($this->_user, $cookie, $expired);
         }
     }
 }
示例#25
0
 public function CreateFirstPost()
 {
     $html = tadminhtml::i();
     $html->section = 'installation';
     $lang = tlocal::i();
     $theme = ttheme::i();
     $post = tpost::i(0);
     $post->title = $lang->posttitle;
     $post->catnames = $lang->postcategories;
     $post->tagnames = $lang->posttags;
     $post->content = $theme->parse($lang->postcontent);
     $posts = tposts::i();
     $posts->add($post);
     $icons = ticons::i();
     $cats = tcategories::i();
     $cats->setvalue($post->categories[0], 'icon', $icons->getid('news'));
     $cm = tcommentmanager::i();
     $users = tusers::i();
     $cm->idguest = $users->add(array('email' => '', 'name' => tlocal::get('default', 'guest'), 'status' => 'hold', 'idgroups' => 'commentator'));
     $cm->save();
     $users->setvalue($cm->idguest, 'status', 'approved');
     tcomments::i()->add($post->id, $cm->idguest, $lang->postcomment, 'approved', '127.0.0.1');
     $plugins = tplugins::i();
     $plugins->lock();
     $plugins->add('oldestposts');
     //$plugins->add('adminlinks');
     //$plugins->add('nicedit');
     $plugins->unlock();
 }