Copyright (C) 2006 Tomasz 'mrman' Sk�ski This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Plugin Name: Jogger publisher Plugin URI: http://private.hell.to/wp2jogger/ Description: While publishing a post, this plugin submits its copy to Jogger.pl so you can publish only once and have WordPress and Jogger entries posted simultaneously. Modification to Jogger2.0 by Tomasz Sk�ski. Author: Marcin Wrochniak Version: 1.1 Author URI: http://vrok.jogger.pl */ // Konfiguracja pluginu: // Nasz JID, ktory rozpoznaje Jogger. $jogger_login = 'Joggerowy_login'; // Nasz joggerowe haslo. $jogger_password = 'Joggerowe_haslo'; // Tu podajemy domyslny stopien, na ktorym maja byc dodawane notki. // Jednorazowo mozna zmienic poziom przy wpisywaniu notki, jest do tego specjalny element formularza. $jogger_level = 1; function wybierz($a) { $dlugosc_wpisu = 60; $koniec_notki = "...
Link: twojastrona.com"; $tmp=''; $a=explode(' ', $a); $ile=count($a); if($ile > $dlugosc_wpisu) $ile = $dlugosc_wpisu; $space=''; $count = 0; for ($i=0; $i<$ile; $i++) { $tmp.=$space.$a[$i]; $space=' '; } $tmp .= $koniec_notki; return $tmp; } function jogger_publish($id) { global $jogger_login, $jogger_password, $jogger_level, $_POST; $post = get_post($id); if ($_POST['not_for_jogger']) return; $fp = fsockopen("ssl://login.jogger.pl", 443, $errno, $errstr, 30); if (! $fp) { // var_dump($fp); // powiedzmy, ze tu jest jakies ostrzezenie o bledzie polaczenia. :) } else { $out = "POST /login/ HTTP/1.1\r\n"; $out .= "Host: login.jogger.pl\r\n"; $out .= "Connection: close\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $login_pass = 'user='.urlencode($jogger_login).'&pass='.urlencode($jogger_password); $out .= 'Content-Length: '. strlen($login_pass) . "\r\n\r\n"; $out .= $login_pass . "\r\n\r\n"; fwrite($fp, $out); while (! feof($fp)) { $ret .= fgets($fp, 128); } fclose($fp); if (preg_match('/PHPSESSID\=([a-zA-Z0-9]+);/', $ret, $regs)) { $sessionid = $regs[1]; } if (preg_match('/jid_id\=(\d+);/', $ret, $regs)) { $joggerid = $regs[1]; } if (preg_match('/lsid\=([a-zA-Z0-9]+);/', $ret, $regs)) { $lsid = $regs[1]; } if (preg_match('/csid\=([a-zA-Z0-9]+);/', $ret, $regs)) { $csid = $regs[1]; } $tekst = wybierz($post->post_content); $out = "POST /?tab=add_entry&op=add HTTP/1.1 \r\n"; $out .= "Host: login.jogger.pl\r\n"; $out .= "Connection: keep-Alive\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= 'Cookie: PHPSESSID=' . $sessionid.'; jid_id=' . $joggerid . '; csid=' . $csid . '; lsid='.$lsid."\r\n"; $data = 'subject='.urlencode($post->post_title).'&body='.urlencode(nl2br(wybierz($post->post_content))).'&submit=Opublikuj+wpis&cat_tbl%5B%5D=cat_tbl_0&level='.$_POST['jogger_level'].'&nocomment=0'; $out .= 'Content-Length: '.strlen($data) . "\r\n\r\n"; $out .= $data . "\r\n\r\n"; if ($fp = fsockopen("ssl://login.jogger.pl", 443, $errno, $errstr, 30)) { fwrite($fp, $out); while (! feof($fp)) { fgets($fp, 128); } } else { // dupa, jakies ostrzezenie by sie przydalo } fclose($fp); } } add_action('publish_post', 'jogger_publish'); function jogger_gui() { global $jogger_level; echo '

'; echo '

Jogger post level: '; echo '

'; } add_action('edit_form_advanced', 'jogger_gui'); ?>