| 1 | <?php |
|---|
| 2 | include_once('.'.DIRECTORY_SEPARATOR.'auth.php'); |
|---|
| 3 | define("JLOG_ADMIN", true); |
|---|
| 4 | require_once('..'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'prepend.inc.php'); |
|---|
| 5 | require(JLOG_BASEPATH.'admin'.DIRECTORY_SEPARATOR.'blog.func.php'); |
|---|
| 6 | |
|---|
| 7 | $c['meta']['title'] .= $l['admin']['new_post']; |
|---|
| 8 | $c['main'] = output_admin_menu(); |
|---|
| 9 | $c['main'] .= "<h2>".$l['admin']['new_post']."</h2>"; |
|---|
| 10 | $form_input = strip($_POST); |
|---|
| 11 | $form_input['date'] = strftime("%Y-%m-%d %H:%M:%s"); |
|---|
| 12 | |
|---|
| 13 | if($_POST['form_submitted'] == $l['admin']['preview']) { |
|---|
| 14 | $c['main'] .= error_output(check_input($form_input)); |
|---|
| 15 | $c['main'] .= preview_output($form_input); |
|---|
| 16 | $c['main'] .= form_output($form_input); |
|---|
| 17 | } |
|---|
| 18 | elseif($_POST['form_submitted'] == $l['admin']['publish']) { |
|---|
| 19 | // Put data to database |
|---|
| 20 | if(!check_input($form_input)) { |
|---|
| 21 | if($id = insert_blog($form_input)) { |
|---|
| 22 | $c['main'] .= "<p>".$l['admin']['entry_saved']."</p>"; |
|---|
| 23 | include_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'update.php'); |
|---|
| 24 | |
|---|
| 25 | // ping blog services and pingback |
|---|
| 26 | if($form_input['section'] == 'weblog') { |
|---|
| 27 | $blogservices = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", JLOG_BLOGSERVICES))); |
|---|
| 28 | foreach($blogservices as $blogservice) { |
|---|
| 29 | if(strlen($blogservice) > 0) $pingresult[] = doPing(trim($blogservice)); |
|---|
| 30 | } |
|---|
| 31 | // if(is_array($pingresult)) $c['main'] .= "\n<ul>".join($pingresult)."\n</ul>"; |
|---|
| 32 | |
|---|
| 33 | if($form_input['allowpingback'] != '0') { |
|---|
| 34 | $blogentryForURL = get_blog($id); |
|---|
| 35 | require_once(JLOG_BASEPATH.'xmlrpc.php'); |
|---|
| 36 | $pingback = new Jlog_SendPingback($bbcode->parse($form_input['content']), blog($blogentryForURL['date'], $blogentryForURL['url']), " -- Jlog v".JLOG_SOFTWARE_VERSION); |
|---|
| 37 | |
|---|
| 38 | $responces = array(); |
|---|
| 39 | $responces = $pingback->doPingbacks(); |
|---|
| 40 | |
|---|
| 41 | /* Die Ergebnisse der Pings verwirren den User nur habe ich mittlerweile festgestellt. |
|---|
| 42 | |
|---|
| 43 | if(count($responces) > 0) { |
|---|
| 44 | $c['main'] .= " <ul>"; |
|---|
| 45 | foreach($responces as $responce) { |
|---|
| 46 | $c['main'] .= "\n <li>".$responce."</li>"; |
|---|
| 47 | } |
|---|
| 48 | $c['main'] .= "\n </ul>"; |
|---|
| 49 | } |
|---|
| 50 | */ |
|---|
| 51 | |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | else { |
|---|
| 57 | // show preview and form |
|---|
| 58 | $c['main'] .= error_output(check_input($form_input)); |
|---|
| 59 | $c['main'] .= form_output($form_input); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | else { |
|---|
| 63 | // show form |
|---|
| 64 | $c['main'] .= form_output($form_input); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | require(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'do_template.php'); |
|---|
| 68 | echo $body; |
|---|
| 69 | |
|---|
| 70 | // verschiedene Dienste anpingen bei neuem Eintrag |
|---|
| 71 | |
|---|
| 72 | function doPing($url) { |
|---|
| 73 | $blog_title = JLOG_WEBSITE; |
|---|
| 74 | $blog_url = JLOG_PATH; |
|---|
| 75 | $timeout = 30; //Sekunden |
|---|
| 76 | $url = parse_url($url); |
|---|
| 77 | |
|---|
| 78 | $fp = @fsockopen($url['host'], 80, $errno, $errstr, $timeout); |
|---|
| 79 | if(!$fp) { |
|---|
| 80 | $response = 'Fehler: '.$errstr.' ('.$errno.')<br />Es konnte keine Verbindung hergestellt werden'; |
|---|
| 81 | } else { |
|---|
| 82 | $data_string = '<?xml version="1.0" encoding="iso-8859-1"?'.'> |
|---|
| 83 | <methodCall> |
|---|
| 84 | <methodName>weblogUpdates.ping</methodName> |
|---|
| 85 | <params> |
|---|
| 86 | <param><value>'.$blog_title.'</value></param> |
|---|
| 87 | <param><value>'.$blog_url.'</value></param> |
|---|
| 88 | </params> |
|---|
| 89 | </methodCall>'; |
|---|
| 90 | $data_header = "POST ".$url['path']." HTTP/1.0\r\n". |
|---|
| 91 | "Host: $host\r\n". |
|---|
| 92 | "Content-Type: text/xml\r\n". |
|---|
| 93 | "User-Agent: qxm XML-RPC Client\r\n". |
|---|
| 94 | "Content-Length: ".strlen($data_string)."\r\n\r\n"; |
|---|
| 95 | fputs($fp, $data_header); |
|---|
| 96 | fputs($fp, $data_string); |
|---|
| 97 | unset($response); |
|---|
| 98 | fclose($fp); |
|---|
| 99 | } |
|---|
| 100 | if(isset($response)) return '<li>'.$url['host'].' '.$response.'</li>'; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | // eof |
|---|