Пример #1
0
 private function doaction($name, $args)
 {
     if (!is_array($args)) {
         $args = array(0 => $args);
     }
     $class = $this->items[$name]['class'];
     $func = $this->items[$name]['func'];
     if (empty($class)) {
         if (!function_exists($func)) {
             unset($this->items[$name]);
             $this->Save();
             return new IXR_Error(404, 'The requested function not found');
         }
         //return $func($arg);
         try {
             return call_user_func_array($func, $args);
         } catch (Exception $e) {
             return new IXR_Error($e->getCode(), $e->getMessage());
         }
     } else {
         if (!class_exists($class)) {
             unset($this->items[$name]);
             $this->save();
             return new IXR_Error(404, 'The requested class not found');
         }
         $obj = getinstance($class);
         //return $obj->$func($arg);
         try {
             return call_user_func_array(array($obj, $func), $args);
         } catch (Exception $e) {
             return new IXR_Error($e->getCode(), $e->getMessage());
         }
     }
 }
Пример #2
0
 public static function i($pid = 0)
 {
     $result = getinstance(__CLASS__);
     if ($pid > 0) {
         $result->pid = $pid;
     }
     return $result;
 }
Пример #3
0
 public static function i($section = '')
 {
     if (!isset(self::$self)) {
         self::$self = getinstance(__CLASS__);
         self::$self->loadfile('default');
     }
     if ($section != '') {
         self::$self->section = $section;
     }
     return self::$self;
 }
Пример #4
0
 public function __get($name)
 {
     if (isset($this->mapoptions[$name])) {
         $prop = $this->mapoptions[$name];
         if (is_array($prop)) {
             list($classname, $method) = $prop;
             return call_user_func_array(array(getinstance($classname), $method), array($name));
         }
         return litepublisher::$options->data[$prop];
     }
     return parent::__get($name);
 }
 public function processform()
 {
     $plugin = tregservices::i();
     $plugin->lock();
     foreach ($plugin->items as $name => $classname) {
         $service = getinstance($classname);
         $service->processform();
     }
     $plugin->update_widget();
     $plugin->unlock();
     return '';
 }
Пример #6
0
 public static function getinstance($name)
 {
     if (isset(self::$instances[$name])) {
         return self::$instances[$name];
     }
     $result = getinstance(__CLASS__);
     if ($result->name != '') {
         $result = litepublisher::$classes->newinstance(__CLASS__);
     }
     $result->name = $name;
     $result->load();
     return $result;
 }
 public function processform()
 {
     $plugin = tmlstorage::i();
     foreach ($plugin->items as $classname => $items) {
         $obj = getinstance($classname);
         if (is_array($obj->data['tml'])) {
             foreach ($obj->data['tml'] as $key => $value) {
                 $obj->data['tml'][$key] = $_POST[$classname . '_text_' . $key];
             }
         } else {
             $obj->data['tml'] = $_POST[$classname . '_text'];
         }
         $obj->save();
     }
 }
Пример #8
0
 public static function init($usecookie = false)
 {
     if (!self::$initialized) {
         self::$initialized = true;
         ini_set('session.use_cookies', $usecookie);
         ini_set('session.use_only_cookies', $usecookie);
         ini_set('session.use_trans_sid', 0);
         session_cache_limiter(false);
         if (function_exists('igbinary_serialize')) {
             ini_set('igbinary.compact_strings', 0);
             ini_set('session.serialize_handler', 'igbinary');
         }
     }
     if (tfilestorage::$memcache) {
         return getinstance(__CLASS__);
     } else {
         //ini_set('session.gc_probability', 1);
     }
 }
Пример #9
0
 public function __get($name)
 {
     if (!isset($this->items[$name])) {
         return '';
     }
     $func = $this->items[$name]['func'];
     $class = $this->tags[$name]['class'];
     if (empty($class)) {
         if (function_exists($func)) {
             return $func($name);
         } else {
             $this->delete($name);
         }
     } elseif (class_exists($class)) {
         $obj = getinstance($class);
         return $obj->{$func}($name);
     } else {
         $this->delete($name);
     }
 }
Пример #10
0
 public function methodSignature($name)
 {
     $caller = TXMLRPC::i();
     if (!$caller->itemexists($name)) {
         return new IXR_Error(-32601, "server error. requested method {$name} does not exist.");
     }
     $item = $caller->getitem($name);
     if ($item['class'] != __CLASS__) {
         $obj = getinstance($item['class']);
         if (method_exists($obj, 'getsignature')) {
             return $obj->getsignature($name);
         } else {
             return new IXR_Error(-32601, "server error. requested signature of {$name} method does not exist.");
         }
     }
     switch ($name) {
         case 'system.listMethods':
         case 'mt.listMethods':
             return array('array');
         case 'system.methodSignature':
             return array('array', 'string');
         case 'system.methodHelp':
             return array('string', 'string');
         case 'system.multicall':
             return array('array', 'array');
         case 'methodExist':
             return array('boolean', 'string');
         case 'demo.addTwoNumbers':
         case 'sample.add':
             return array('int', 'int', 'int');
         case 'demo.sayHello':
             return array('string');
         default:
             return new IXR_Error(-32601, "server error. requested signature of {$name} method does not exist.");
     }
 }
Пример #11
0
 public function parsehtml()
 {
     $html = getinstance('tadminhtml');
     $html->ini = array();
     foreach ($this->html as $filename) {
         $realfilename = $this->getrealfilename($filename);
         if (!file_exists($realfilename)) {
             $this->error(sprintf('The file "%s" not found', $realfilename));
         }
         if (!($parsed = parse_ini_file($realfilename, true))) {
             $this->error(sprintf('Error parse "%s" ini file', $realfilename));
         }
         if (count($html->ini) == 0) {
             $html->ini = $parsed;
         } else {
             foreach ($parsed as $section => $itemsini) {
                 $html->ini[$section] = isset($html->ini[$section]) ? $itemsini + $html->ini[$section] : $itemsini;
             }
         }
     }
     tfilestorage::savevar(tlocal::getcachedir() . 'adminhtml', $html->ini);
 }
Пример #12
0
 public static function i(tpost $post)
 {
     $self = getinstance(__CLASS__);
     $self->post = $post;
     return $self;
 }
Пример #13
0
 public function execute()
 {
     while ($item = $this->db->getassoc(sprintf("date <= '%s' order by date asc limit 1", sqldate()))) {
         extract($item);
         $this->log("task started:\n{$class}->{$func}({$arg})");
         $arg = unserialize($arg);
         if ($class == '') {
             if (function_exists($func)) {
                 try {
                     $func($arg);
                 } catch (Exception $e) {
                     litepublisher::$options->handexception($e);
                 }
             } else {
                 $this->db->iddelete($id);
                 continue;
             }
         } elseif (class_exists($class)) {
             try {
                 $obj = getinstance($class);
                 $obj->{$func}($arg);
             } catch (Exception $e) {
                 litepublisher::$options->handexception($e);
             }
         } else {
             $this->db->iddelete($id);
             continue;
         }
         if ($type == 'single') {
             $this->db->iddelete($id);
         } else {
             $this->db->setvalue($id, 'date', sqldate(strtotime("+1 {$type}")));
         }
     }
 }
Пример #14
0
 private function getadminplugin($name)
 {
     $about = tplugins::getabout($name);
     if (empty($about['adminclassname'])) {
         return false;
     }
     $class = $about['adminclassname'];
     if (!class_exists($class)) {
         litepublisher::$classes->include_file(litepublisher::$paths->plugins . $name . DIRECTORY_SEPARATOR . $about['adminfilename']);
     }
     return getinstance($class);
 }
Пример #15
0
 public function createfiles()
 {
     $this->countfiles = 0;
     $this->count = 0;
     $this->date = time();
     $this->lastmod = date('Y-m-d', $this->date);
     $this->openfile();
     $home = thomepage::i();
     $this->prio = 9;
     $this->write('/', $home->showposts && $home->showpagenator ? ceil($home->archcount / litepublisher::$options->perpage) : 1);
     $perpage = 1000;
     foreach ($this->classes as $prio => $class) {
         $this->prio = max(9 - $prio, 1);
         $instance = getinstance($class);
         $from = 0;
         do {
             $links = $instance->getsitemap($from, $perpage);
             $from += count($links);
             foreach ($links as $item) {
                 $this->write($item['url'], $item['pages']);
             }
         } while (count($links) == $perpage);
     }
     //url's from items prop
     foreach ($this->items as $url => $prio) {
         $this->writeitem($url, $prio);
     }
     $this->closefile();
     $this->Save();
 }
Пример #16
0
 private function printclasspage($classname)
 {
     $cachefile = $classname . '.php';
     if ($this->cache_enabled) {
         if ($this->include_file($cachefile)) {
             return;
         }
     }
     $obj = getinstance($classname);
     $Template = ttemplate::i();
     $s = $Template->request($obj);
     eval('?>' . $s);
     if ($this->cache_enabled && $obj->cache) {
         $this->cache->set($cachefile, $result);
     }
 }
Пример #17
0
 public static function instance()
 {
     return getinstance(get_called_class());
 }
Пример #18
0
 public function delete($name)
 {
     if (!isset($this->items[$name])) {
         return false;
     }
     $item = $this->items[$name];
     unset($this->items[$name]);
     $this->save();
     $datafile = false;
     if (class_exists($item['class'])) {
         $plugin = getinstance($item['class']);
         if ($plugin instanceof tplugin) {
             $datafile = litepublisher::$paths->data . $plugin->getbasename();
         }
     }
     litepublisher::$classes->lock();
     if (!empty($item['adminclass'])) {
         litepublisher::$classes->delete($item['adminclass']);
     }
     litepublisher::$classes->delete($item['class']);
     litepublisher::$classes->unlock();
     if ($datafile) {
         tfilestorage::delete($datafile . '.php');
         tfilestorage::delete($datafile . '.bak.php');
     }
     $this->deleted($name);
 }
Пример #19
0
 public function oncomuser(array $values, $comfirmed)
 {
     //ignore $comfirmed, always return redirect
     $form = tcommentform::i();
     if ($err = $form->processcomuser($values)) {
         return $err;
     }
     $email = strtolower(trim($values['email']));
     $host = substr($email, strpos($email, '@') + 1);
     switch ($host) {
         case 'gmail.com':
             $name = 'google';
             break;
         case 'yandex.ru':
             $name = 'yandex';
             break;
         case 'mail.ru':
         case 'inbox.ru':
         case 'list.ru':
         case 'bk.ru':
             $name = 'mailru';
             break;
         default:
             return false;
     }
     if (!isset($this->items[$name])) {
         return false;
     }
     $service = getinstance($this->items[$name]);
     if (!$service->valid) {
         return false;
     }
     $service->sessdata['comuser'] = $values;
     $url = $service->getauthurl();
     if (!$url) {
         return false;
     }
     return $form->sendresult($url, array(ini_get('session.name') => $service->session_id));
 }
Пример #20
0
 public static function i($idview = 0)
 {
     $result = getinstance(__CLASS__);
     if ($idview > 0) {
         $view = tview::i((int) $idview);
         $result->items =& $view->sidebars;
     }
     return $result;
 }
Пример #21
0
 public function call($method, $args)
 {
     $this->callevent('beforecall', array($method, &$args));
     if (!isset($this->items[$method])) {
         return new IXR_Error(-32601, "server error. requested method {$method} does not exist.");
     }
     $class = $this->items[$method]['class'];
     $func = $this->items[$method]['func'];
     if (empty($class)) {
         if (function_exists($func)) {
             try {
                 return call_user_func_array($func, $args);
             } catch (Exception $e) {
                 return new IXR_Error($e->getCode(), $e->getMessage());
             }
         } else {
             $this->delete($method);
             return new IXR_Error(-32601, "server error. requested function \"{$Func}\" does not exist.");
         }
     } else {
         //create class instance
         if (!class_exists($class)) {
             $this->delete($method);
             return new IXR_Error(-32601, "server error. requested class \"{$class}\" does not exist.");
         }
         $obj = getinstance($class);
         /*
         if (!method_exists($Obj, $Func)) {
           $this->delete($method);
           return new IXR_Error(-32601, "server error. requested object method \"$Function\" does not exist.");
         }
         */
         //return $obj->$func($args);
         try {
             return call_user_func_array(array($obj, $func), $args);
         } catch (Exception $e) {
             //litepublisher::$options->handexception($e);
             //echo (litepublisher::$options->errorlog);
             return new IXR_Error($e->getCode(), $e->getMessage());
         }
     }
 }
Пример #22
0
 public function addcoclass($class)
 {
     if ($this->indexofcoclass($class) === false) {
         $this->coclasses[] = $class;
         $this->save();
         $this->coinstances = getinstance($class);
     }
 }
Пример #23
0
function installClasses()
{
    litepublisher::$urlmap = turlmap::i();
    litepublisher::$urlmap->lock();
    $posts = tposts::i();
    $posts->lock();
    $xmlrpc = TXMLRPC::i();
    $xmlrpc->lock();
    ttheme::$defaultargs = array();
    $theme = ttheme::getinstance('default');
    //  $html = tadminhtml::i();
    //      $html->loadinstall();
    foreach (litepublisher::$classes->items as $class => $item) {
        //echo "$class<br>\n";
        if (preg_match('/^(titem|titem_storage|titemspostsowner|tcomment|IXR_Client|IXR_Server|tautoform|tchildpost|tchildposts|tlitememcache)$/', $class)) {
            continue;
        }
        $obj = getinstance($class);
        if (method_exists($obj, 'install')) {
            $obj->install();
        }
    }
    $xmlrpc->unlock();
    $posts->unlock();
    litepublisher::$urlmap->unlock();
}
Пример #24
0
 public static function i($id = null)
 {
     return getinstance(__CLASS__);
 }
Пример #25
0
 public function processform()
 {
     //dumpvar($_POST);
     $result = '';
     switch ($this->name) {
         case 'views':
             $views = tviews::i();
             $idview = (int) tadminhtml::getparam('idview', 0);
             if (!$idview || !$views->itemexists($idview)) {
                 return '';
             }
             if ($this->action == 'delete') {
                 if ($idview > 1) {
                     $views->delete($idview);
                 }
                 return '';
             }
             $view = tview::i($idview);
             if ($idview > 1) {
                 $view->customsidebar = isset($_POST['customsidebar']);
                 $view->disableajax = isset($_POST['disableajax']);
             }
             $view->name = trim($_POST['name']);
             $view->themename = trim($_POST['theme_idview']);
             $view->menuclass = $_POST['menu'];
             $view->hovermenu = isset($_POST['hovermenu']);
             $this->set_custom($idview);
             if ($idview == 1 || $view->customsidebar) {
                 $widgets = twidgets::i();
                 foreach (range(0, 2) as $index) {
                     $view->sidebars[$index] = array();
                     $idwidgets = explode(',', trim($_POST["sidebar{$index}"]));
                     foreach ($idwidgets as $idwidget) {
                         $idwidget = (int) trim($idwidget);
                         if (!$widgets->itemexists($idwidget)) {
                             continue;
                         }
                         $view->sidebars[$index][] = array('id' => $idwidget, 'ajax' => isset($_POST["inline{$idwidget}"]) ? 'inline' : isset($_POST["ajax{$idwidget}"]));
                     }
                 }
             }
             $view->save();
             break;
         case 'addview':
             $name = trim($_POST['name']);
             if ($name != '') {
                 $views = tviews::i();
                 $id = $views->add($name);
             }
             break;
         case 'spec':
             foreach (self::getspecclasses() as $classname) {
                 $obj = getinstance($classname);
                 $obj->lock();
                 $obj->setidview($_POST["idview-{$classname}"]);
                 if (isset($obj->data['keywords'])) {
                     $obj->keywords = $_POST["keywords-{$classname}"];
                 }
                 if (isset($obj->data['description '])) {
                     $obj->description = $_POST["description-{$classname}"];
                 }
                 if (isset($obj->data['head'])) {
                     $obj->head = $_POST["head-{$classname}"];
                 }
                 $obj->unlock();
             }
             break;
         case 'group':
             switch ($_POST['action']) {
                 case 'posts':
                     $posts = tposts::i();
                     $idview = (int) $_POST['postview'];
                     if (dbversion) {
                         $posts->db->update("idview = '{$idview}'", 'id > 0');
                     } else {
                         foreach ($posts->items as $id => $item) {
                             $post = tpost::i($id);
                             $post->idview = $idview;
                             $post->save();
                             $post->free();
                         }
                     }
                     break;
                 case 'menus':
                     $idview = (int) $_POST['menuview'];
                     $menus = tmenus::i();
                     foreach ($menus->items as $id => $item) {
                         $menu = tmenu::i($id);
                         $menu->idview = $idview;
                         $menu->save();
                     }
                     break;
                 case 'themes':
                     $themename = $_POST['themeview'];
                     $views = tviews::i();
                     $views->lock();
                     foreach ($views->items as $id => $item) {
                         $view = tview::i($id);
                         $view->themename = $themename;
                         $view->save();
                     }
                     $views->unlock();
                     break;
             }
             break;
         case 'defaults':
             $views = tviews::i();
             foreach ($views->defaults as $name => $id) {
                 $views->defaults[$name] = (int) $_POST[$name];
             }
             $views->save();
             break;
         case 'headers':
             $template = ttemplate::i();
             $template->heads = $_POST['heads'];
             $template->save();
             $adminmenus = tadminmenus::i();
             $adminmenus->heads = $_POST['adminheads'];
             $adminmenus->save();
             $ajax = tajaxposteditor::i();
             $ajax->lock();
             $ajax->ajaxvisual = isset($_POST['ajaxvisual']);
             $ajax->visual = trim($_POST['visual']);
             $ajax->unlock();
             litepublisher::$options->show_file_perm = isset($_POST['show_file_perm']);
             break;
         case 'admin':
             return $this->adminoptionsform->processform();
     }
     ttheme::clearcache();
 }
Пример #26
0
 public static function singleinstance($class)
 {
     $single = getinstance($class);
     if ($id = $single->get_owner()->class2id($class)) {
         if ($single->id == $id) {
             return $single;
         }
         if ($single->id == 0 && $id > 0) {
             return $single->loaddata($id);
         }
     }
     return $single;
 }
Пример #27
0
 public static function instance()
 {
     return getinstance(__CLASS__);
 }
Пример #28
0
 public function getmenu()
 {
     if ($r = $this->ongetmenu()) {
         return $r;
     }
     //$current = $this->context instanceof tmenu ? $this->context->id : 0;
     $view = $this->view;
     $menuclass = $view->menuclass;
     $filename = $view->theme->name . sprintf('.%s.%s.php', $menuclass, litepublisher::$options->group ? litepublisher::$options->group : 'nobody');
     if ($result = litepublisher::$urlmap->cache->get($filename)) {
         return $result;
     }
     $menus = getinstance($menuclass);
     $result = $menus->getmenu($this->hover, 0);
     litepublisher::$urlmap->cache->set($filename, $result);
     return $result;
 }