Esempio n. 1
0
 public function request($param)
 {
     global $HTTP_RAW_POST_DATA;
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     }
     if (isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
     }
     if (litepublisher::$debug) {
         tfiler::log("request:\n" . $HTTP_RAW_POST_DATA, 'xmlrpc.txt');
         $reqname = litepublisher::$paths->data . 'logs' . DIRECTORY_SEPARATOR . 'request.xml';
         file_put_contents($reqname, $HTTP_RAW_POST_DATA);
         @chmod($reqname, 0666);
         //$HTTP_RAW_POST_DATA = file_get_contents($GLOBALS['paths']['home'] . 'raw.txt');
     }
     $this->getmethods();
     $this->Server = new TXMLRPCParser($this);
     $this->Server->IXR_Server($this->items);
     $Result = $this->Server->XMLResult;
     $this->aftercall();
     if (litepublisher::$debug) {
         tfiler::log("responnse:\n" . $Result, 'xmlrpc.txt');
     }
     return $Result;
 }
 public function sendpost($id)
 {
     if ($this->host == '' || $this->login == '') {
         return false;
     }
     $post = tpost::i($id);
     ttheme::$vars['post'] = $post;
     $theme = ttheme::i();
     $content = $theme->parse($this->template);
     $date = getdate($post->posted);
     if ($post->status != 'published') {
         return;
     }
     $meta = $post->meta;
     $client = new IXR_Client($this->host, '/interface/xmlrpc');
     //$client = new IXR_Client($this->host, '/rpc.xml');
     if (!$client->query('LJ.XMLRPC.getchallenge')) {
         if (litepublisher::$debug) {
             tfiler::log('live journal: error challenge');
         }
         return false;
     }
     $response = $client->getResponse();
     $challenge = $response['challenge'];
     $args = array('username' => $this->login, 'auth_method' => 'challenge', 'auth_challenge' => $challenge, 'auth_response' => md5($challenge . md5($this->password)), 'ver' => "1", 'event' => $content, 'subject' => $post->title, 'year' => $date['year'], 'mon' => $date['mon'], 'day' => $date['mday'], 'hour' => $date['hours'], 'min' => $date['minutes'], 'props' => array('opt_nocomments' => !$post->commentsenabled, 'opt_preformatted' => true, 'taglist' => $post->tagnames));
     switch ($this->privacy) {
         case "public":
             $args['security'] = "public";
             break;
         case "private":
             $args['security'] = "private";
             break;
         case "friends":
             $args['security'] = "usemask";
             $args['allowmask'] = 1;
     }
     if ($this->community != '') {
         $args['usejournal'] = $this->community;
     }
     if (isset($meta->ljid)) {
         $method = 'LJ.XMLRPC.editevent';
         $args['itemid'] = $meta->ljid;
     } else {
         $method = 'LJ.XMLRPC.postevent';
     }
     if (!$client->query($method, $args)) {
         if (litepublisher::$debug) {
             tfiler::log('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage());
         }
         return false;
     }
     if (!isset($meta->ljid)) {
         $response = $client->getResponse();
         $meta->ljid = $response['itemid'];
     }
     return $meta->ljid;
 }
Esempio n. 3
0
 public function getpostbody()
 {
     global $HTTP_RAW_POST_DATA;
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     }
     if (isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
     }
     if (litepublisher::$debug) {
         tfiler::log("request:\n" . $HTTP_RAW_POST_DATA, 'json.txt');
         /*
         $reqname = litepublisher::$paths->data . 'logs' . DIRECTORY_SEPARATOR  . 'request.json';
         file_put_contents($reqname, $HTTP_RAW_POST_DATA);
         @chmod($reqname, 0666);
         $HTTP_RAW_POST_DATA = file_get_contents($GLOBALS['paths']['home'] . 'raw.txt');
         */
     }
     return $HTTP_RAW_POST_DATA;
 }
Esempio n. 4
0
 public function handexception($e)
 {
     $log = "Caught exception:\r\n" . $e->getMessage() . "\r\n";
     $trace = $e->getTrace();
     foreach ($trace as $i => $item) {
         if (isset($item['line'])) {
             $log .= sprintf('#%d %d %s ', $i, $item['line'], $item['file']);
         }
         if (isset($item['class'])) {
             $log .= $item['class'] . $item['type'] . $item['function'];
         } else {
             $log .= $item['function'];
         }
         if (isset($item['args']) && count($item['args'])) {
             $args = array();
             foreach ($item['args'] as $arg) {
                 $args[] = self::var_export($arg);
             }
             $log .= "\n";
             $log .= implode(', ', $args);
         }
         $log .= "\n";
     }
     $log = str_replace(litepublisher::$paths->home, '', $log);
     $this->errorlog .= str_replace("\n", "<br />\n", htmlspecialchars($log));
     tfiler::log($log, 'exceptions.log');
     if (!(litepublisher::$debug || $this->echoexception || $this->admincookie || litepublisher::$urlmap->adminpanel)) {
         tfiler::log($log, 'exceptionsmail.log');
     }
 }
Esempio n. 5
0
 public function log($s)
 {
     echo date('r') . "\n{$s}\n\n";
     flush();
     if (litepublisher::$debug) {
         tfiler::log($s, 'cron.log');
     }
 }
Esempio n. 6
0
 private function openfile()
 {
     $this->count = 0;
     $this->countfiles++;
     if ($this->fd = gzopen(litepublisher::$paths->files . litepublisher::$domain . ".{$this->countfiles}.xml.gz", 'w')) {
         $this->WriteHeader();
     } else {
         tfiler::log("error write file to folder " . litepublisher::$paths->files);
         exit;
     }
 }
Esempio n. 7
0
 public static function savemodified()
 {
     if (self::$modified) {
         if (self::$disabled) {
             return false;
         }
         $lock = litepublisher::$paths->data . 'storage.lok';
         if (($fh = @fopen($lock, 'w')) && flock($fh, LOCK_EX | LOCK_NB)) {
             self::savetofile(litepublisher::$paths->data . 'storage', serialize(self::$data));
             flock($fh, LOCK_UN);
             fclose($fh);
             @chmod($lock, 0666);
         } else {
             tfiler::log('Storage locked, data not saved');
         }
         self::$modified = false;
         return true;
     }
     return false;
 }
Esempio n. 8
0
 public function update()
 {
     $log = $this->log;
     false;
     if ($log) {
         tfiler::log("begin update", 'update');
     }
     tlocal::clearcache();
     $this->versions = self::getversions();
     $nextver = $this->nextversion;
     if ($log) {
         tfiler::log("update started from litepublisher::{$options->version} to {$this->version}", 'update');
     }
     $v = litepublisher::$options->version + 0.01;
     while (version_compare($v, $nextver) <= 0) {
         $ver = (string) $v;
         if (strlen($ver) == 3) {
             $ver .= '0';
         }
         if (strlen($ver) == 1) {
             $ver .= '.00';
         }
         if ($log) {
             tfiler::log("{$v} selected to update", 'update');
         }
         $this->run($v);
         litepublisher::$options->version = $ver;
         litepublisher::$options->savemodified();
         $v = $v + 0.01;
     }
     ttheme::clearcache();
     tlocal::clearcache();
     tsidebars::fix();
     if ($log) {
         tfiler::log("update finished", 'update');
     }
 }
Esempio n. 9
0
 public function request($arg)
 {
     if (isset($_POST['submit']) && isset($_POST['assoc_handle'])) {
         $h = $_POST['assoc_handle'];
         if (isset($this->keys[$h]['request'])) {
             $_REQUEST = $this->keys[$h]['request'];
         }
     }
     if (litepublisher::$debug) {
         $log = $_SERVER['REQUEST_URI'];
         $log .= var_export($_REQUEST, true);
         $log .= "\nget:\n";
         $log .= var_export($_GET, true);
         $log .= "\npost:\n";
         $log .= var_export($_POST, true);
         $log .= "\nkeys:\n";
         $log .= var_export($this->keys, true);
         $log .= "\nhas key\n";
         $log .= isset($this->keys[$_REQUEST['openid_assoc_handle']]) ? "true\n\n" : "false\n\n";
         tfiler::log($log, 'openid.log');
     }
     $this->LoadBigMath();
     ini_set('arg_separator.output', '&');
     if (!isset($_REQUEST['openid_mode'])) {
         return $this->nomode();
     }
     switch ($_REQUEST['openid_mode']) {
         case 'associate':
             return $this->associate();
         case 'cancel':
             return $this->cancel();
         case 'checkid_immediate':
             return $this->checkid_immediate();
         case 'checkid_setup':
             return $this->checkid_setup();
         case 'check_authentication':
             return $this->check_authentication();
         case 'error':
             return $this->DoError();
         case 'id_res':
             return $this->id_res();
         default:
             return $this->nomode();
     }
 }