public function request($arg) { $id = empty($_GET['id']) ? 1 : (int) $_GET['id']; $foaf = tfoaf::i(); if (!$foaf->itemexists($id)) { return 404; } $item = $foaf->getitem($id); $this->cache = false; return sprintf('<?php litepublisher::$urlmap->redir(\'%s\'); ?>', $item['url']); }
public function check() { $result = ''; $lang = tlocal::i('foaf'); $foaf = tfoaf::i(); $items = $foaf->getapproved(0); foreach ($items as $id) { $item = $foaf->getitem($item); if (!$this->checkfriend($item['foafurl'])) { $result .= sprintf($lang->mailerror, $item['nick'], $item['blog'], $item['url']); $foaf->lock(); $foaf->setvalue($id, 'errors', ++$item['errors']); if ($item['errors'] > 3) { $foaf->setstatus($id, 'error'); $result .= sprintf($lang->manyerrors, $item['errors']); } $foaf->unlock(); } } if ($result != '') { $result = $lang->founderrors . $result; $result = str_replace('\\n', "\n", $result); $args = targs::i(); $args->errors = $result; tlocal::usefile('mail'); $lang = tlocal::i('mailfoaf'); $theme = ttheme::i(); $subject = $theme->parsearg($lang->errorsubj, $args); $body = $theme->parsearg($lang->errorbody, $args); tmailer::sendtoadmin($subject, $body); } }
public function processform() { $foaf = tfoaf::i(); $html = $this->html; switch ($this->name) { case 'foaf': if (!isset($_POST['foaftable'])) { extract($_POST, EXTR_SKIP); if ($this->action == 'edit') { $id = $this->idget(); if (!$foaf->itemexists($id)) { return ''; } $status = $_POST["status-{$id}"]; $foaf->edit($id, $nick, $url, $foafurl, $status); return $html->h2->successedit; } else { if (empty($url)) { return ''; } if ($foaf->hasfriend($url)) { return $html->h2->erroradd; } $foaf->addurl($url); return $html->h2->successadd; } } else { $status = isset($_POST['approve']) ? 'approved' : (isset($_POST['hold']) ? 'hold' : 'delete'); $foaf->lock(); foreach ($_POST as $key => $id) { if (!is_numeric($id)) { continue; } $id = (int) $id; if ($status == 'delete') { $foaf->delete($id); } else { $foaf->changestatus($id, $status); } } $foaf->unlock(); return $html->h2->successmoderate; } case 'profile': $profile = tprofile::i(); foreach ($_POST as $key => $value) { if (isset($profile->data[$key])) { $profile->data[$key] = $value; } } $profile->gender = isset($_POST['gender']) ? 'male' : 'female'; $profile->save(); return $html->h2->successprofile; case 'profiletemplate': $profile = tprofile::i(); $profile->template = $_POST['template']; $profile->save(); return $html->h2->successprofile; } return ''; }
protected function getfriendslist() { $result = "<p>\n"; $foaf = tfoaf::i(); $widget = tfriendswidget::i(); $foaf->loadall(); foreach ($foaf->items as $id => $item) { $url = $widget->redir ? "litepublisher::{$site->url}{$widget->redirlink}{litepublisher::{$site->q}}friend={$id}" : $item['url']; $result .= "<a href=\"{$url}\" rel=\"friend\">{$item['nick']}</a>,\n"; } $result .= "</p>\n"; return $result; }