Source of trunk/cp_write.php at revision HEAD (02/11/2009 11:02:36, 5972 bytes, 158 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** Control Panel :: Write Post |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2005-2008 Codewise.org |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | ** This file is part of CodewiseBlog |
| 13 | ** |
| 14 | ** CodewiseBlog is free software; you can redistribute it and/or modify |
| 15 | ** it under the terms of the GNU General Public License as published by |
| 16 | ** the Free Software Foundation; either version 2 of the License, or |
| 17 | ** (at your option) any later version. |
| 18 | ** |
| 19 | ** CodewiseBlog is distributed in the hope that it will be useful, |
| 20 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | ** GNU General Public License for more details. |
| 23 | ** |
| 24 | ** You should have received a copy of the GNU General Public License |
| 25 | ** along with CodewiseBlog; if not, write to the Free Software |
| 26 | ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | */ |
| 28 | |
| 29 | $current = "write"; |
| 30 | |
| 31 | if(empty($_POST) || isset($_POST['resize'])) |
| 32 | { |
| 33 | $body = skinvoodoo( |
| 34 | "controlpanel_write", "", |
| 35 | array( |
| 36 | "posturl" => INDEX_URL . "?controlpanel:write", |
| 37 | "quicktags" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/quicktags.js", |
| 38 | "autoresize" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/autoresize.js", |
| 39 | "rows" => $_POST['rows'] ? $_POST['rows'] : 25, |
| 40 | "cols" => $_POST['cols'] ? $_POST['cols'] : 80, |
| 41 | "text" => $_POST['text'] ? $_POST['text'] : "", |
| 42 | "title" => "Title", |
| 43 | ) |
| 44 | ); |
| 45 | } else { |
| 46 | if(isset($_POST['preview'])) |
| 47 | { |
| 48 | $body = skinvoodoo("controlpanel_write", "preview_topic", array("text" => output_topic_text($_POST['text']))); |
| 49 | |
| 50 | $body .= skinvoodoo( |
| 51 | "controlpanel_write", "", |
| 52 | array( |
| 53 | "posturl" => INDEX_URL . "?controlpanel:write", |
| 54 | "quicktags" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/quicktags.js", |
| 55 | "autoresize" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/autoresize.js", |
| 56 | "rows" => $_POST['rows'] ? $_POST['rows'] : 25, |
| 57 | "cols" => $_POST['cols'] ? $_POST['cols'] : 80, |
| 58 | "text" => htmlspecialchars($_POST['text']), |
| 59 | "title" => $_POST['title'], |
| 60 | ) |
| 61 | ); |
| 62 | |
| 63 | } else { |
| 64 | |
| 65 | $q = $db->issue_query("SELECT tid,timestamp FROM topics WHERE title = " . $db->prepare_value($_POST['title']) . " AND blogid = '".BLOGID."'"); |
| 66 | if($db->num_rows[$q] > 0) |
| 67 | { |
| 68 | list($row,$timestamp) = $db->fetch_row($q, 0, L1SQL_NUM); |
| 69 | $GLOBALS['NOTIFY'] = "A post with that title already exists: <a href=\"" . INDEX_URL . "?tid=$tid\">" . $_POST['title'] . "</a>" |
| 70 | . " (posted " . date(DATE_FORMAT, $timestamp) . ")"; |
| 71 | |
| 72 | $body = skinvoodoo( |
| 73 | "controlpanel_write", "", |
| 74 | array( |
| 75 | "posturl" => INDEX_URL . "?controlpanel:write", |
| 76 | "quicktags" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/quicktags.js", |
| 77 | "autoresize" => HTTP.BASE_DOMAIN.INSTALLED_PATH."cwb/autoresize.js", |
| 78 | "rows" => $_POST['rows'] ? $_POST['rows'] : 25, |
| 79 | "cols" => $_POST['cols'] ? $_POST['cols'] : 80, |
| 80 | "text" => $_POST['text'], |
| 81 | "title" => $_POST['title'], |
| 82 | ) |
| 83 | ); |
| 84 | } else { |
| 85 | // tid blogid title timestamp text extra |
| 86 | $data = array |
| 87 | ( |
| 88 | "blogid" => BLOGID, |
| 89 | "title" => $_POST['title'], |
| 90 | "timestamp" => time(), |
| 91 | "text" => $_POST['text'], |
| 92 | ); |
| 93 | |
| 94 | $db->insert("topics", $data); |
| 95 | |
| 96 | $tid = $db->fetch_var( $db->issue_query("SELECT tid FROM topics WHERE timestamp = " . $data['timestamp']) ); |
| 97 | |
| 98 | if(EMAIL) |
| 99 | { |
| 100 | $q = $db->issue_query("SELECT * FROM subscriptions WHERE blogid = '" . BLOGID . "'"); |
| 101 | $rows = $db->fetch_all($q); |
| 102 | |
| 103 | foreach($rows as $row) |
| 104 | { |
| 105 | $email = $row['email']; |
| 106 | $password = $row['password']; |
| 107 | |
| 108 | $message = |
| 109 | "Hello, |
| 110 | |
| 111 | This is the " . html_entity_decode($BLOGINFO['title']) . " subscription service letting you know that there has been a new blog entry posted, entitled \"" . $_POST['title'] . "\" |
| 112 | You can view it here: " . INDEX_URL . "?tid=$tid |
| 113 | |
| 114 | Thanks for reading! |
| 115 | |
| 116 | -- |
| 117 | you may unsubscribe from these mailings by visiting this url: |
| 118 | " . INDEX_URL . "?unsubscribe&email=$email&password=$password |
| 119 | "; |
| 120 | |
| 121 | |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | if($_POST['weblogs.com'] == "checked") |
| 126 | { |
| 127 | global $BLOGINFO; |
| 128 | |
| 129 | file_get_contents("http://rpc.weblogs.com/pingSiteForm?name=".$BLOGINFO['title']."&url=".INDEX_URL.".&changesURL=".INDEX_URL."/rdf.php"); |
| 130 | /* |
| 131 | require(FSPATH . "/xmlrpc.inc"); |
| 132 | $client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80); |
| 133 | $msg = new xmlrpcmsg( |
| 134 | "weblogUpdates.extendedPing", array( |
| 135 | new xmlrpcval($BLOGINFO['title'], "string"), |
| 136 | new xmlrpcval(INDEX_URL, "string"), |
| 137 | new xmlrpcval(INDEX_URL, "string"), |
| 138 | new xmlrpcval(INDEX_URL . "/rdf.php", "string") |
| 139 | )); |
| 140 | $resp = $client->send($msg, 10); |
| 141 | if($resp->faultCode != 0) |
| 142 | { |
| 143 | $GLOBALS['NOTIFY'] = "weblogs.com ping failed"; |
| 144 | } else { |
| 145 | $rmsg = $resp->value(); |
| 146 | //oo |
| 147 | } |
| 148 | */ |
| 149 | } |
| 150 | |
| 151 | $body = skinvoodoo("controlpanel_write", "success_redirect", array("topic_url" => INDEX_URL . "?tid=$tid")); |
| 152 | } |
| 153 | |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | ?> |
| 158 |