function savePost(&$loq, $postid = null)
{
    if (is_null($postid) || $postid === 0) {
        return;
    }
    // a post to be edited has been submitted
    if (isset($_POST['postedit']) && !is_numeric($postid)) {
        echo "Provided PostID value is not a Post ID. (Fatal error)";
        die;
    }
    if ($loq->_ph->edit_post($_POST)) {
        if (isset($_POST['send_trackback']) && $_POST['send_trackback'] == "TRUE") {
            // send a trackback
            include "includes/trackbackhandler.class.php";
            $tb = new trackbackhandler($loq->_adb);
            if (!isset($_POST['title_text'])) {
                $_POST['title_text'] = "";
            }
            if (!isset($_POST['excerpt'])) {
                $_POST['excerpt'] = "";
            }
            if (!isset($_POST['tburl'])) {
                $_POST['tburl'] = "";
            }
            $tb->send_trackback($ph->get_post_permalink($_POST['postid']), $_POST['title_text'], $_POST['excerpt'], $_POST['tburl']);
        }
    }
    defaultDisplay($loq);
}
Пример #2
0
 *
 * @version $Revision$
 */
if (!defined('IN_LOQUACITY')) {
    include_once './config.php';
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
    $post = null;
    $comment = null;
    if (defined('CLEANURLS')) {
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $num = count($url);
        if ($url[$num - 3] === 'trackback') {
            //a comment id is included
            $post = stringHandler::removeMagicQuotes($url[$num - 2]);
            $comment = stringHandler::removeMagicQuotes($url[$num - 1]);
        } else {
            $post = stringHandler::removeMagicQuotes($url[$num - 1]);
        }
    } else {
        $url = array();
        parse_str(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1), $url);
        $post = stringHandler::removeMagicQuotes($url['tbpost']);
        if (isset($url['cid'])) {
            $comment = stringHandler::removeMagicQuotes($url['cid']);
        }
    }
    include_once 'includes/trackbackhandler.class.php';
    $th = new trackbackhandler($loq->_adb, $post);
    $th->receiveTrackback($_SERVER['REMOTE_ADDR'], $_POST, $comment);
}
 /**
  * Adds a new or edits an existing post
  *
  * @param array $post
  * @param string $method Only accepts INSERT and UPDATE
  * @param string $where Optional unless $method == UPDATE
  * @return unknown
  */
 function modifyPost($post)
 {
     if ($method !== 'INSERT' && $method !== 'UPDATE') {
         $this->_last_error = 'Unknown method stipulated for modifyPost';
         return false;
     }
     $rval = false;
     $now = strtotime(gmdate("M d Y H:i:s"));
     $sections = ':';
     if (isset($post['frm_sections']) && count($post['frm_sections']) > 0) {
         $sections = ':' . implode(":", $post['frm_sections']) . ':';
     }
     $rs['title'] = $post['frm_post_title'];
     $rs['body'] = $post['frm_post_body'];
     if ($method !== 'UPDATE') {
         $rs['posttime'] = isset($post['posttime']) ? $post['posttime'] : $now;
     }
     $rs['modifytime'] = isset($post['modifytime']) ? $post['modifytime'] : $now;
     $rs['status'] = $post['frm_post_status'];
     $rs['modifier'] = $post['frm_modifier'];
     $rs['sections'] = $sections;
     $rs['ownerid'] = isset($post['ownerid']) ? intval($post['ownerid']) : $_SESSION['user_id'];
     $rs['hidefromhome'] = isset($post['frm_post_hidefromhome']) && $post['frm_post_hidefromhome'] == 1 ? 1 : 0;
     $rs['allowcomments'] = isset($post['frm_post_allowcomments']) && $post['frm_post_allowcomments'] == ('allow' or 'disallow' or 'timed') ? $post['frm_post_allowcomments'] : 'disallow';
     # TODO this needs refactored as everytime the post is edited, the disable date will auto-change (unintended). Make it use a definite date
     if (isset($post['disallowcommentsdays']) && in_array($post['disallowcommentsdays'], array(7, 14, 30, 90))) {
         $inc = $post['disallowcommentsdays'];
         $rs['autodisabledate'] = strtotime("+{$inc} days");
     }
     if ($this->_db->AutoExecute(T_POSTS, $rs, $method, $where, false, get_magic_quotes_runtime()) !== false) {
         if ($method === 'INSERT') {
             $rval = intval($this->_db->insert_id());
         } else {
             $rval = true;
         }
         if (isset($post['send_trackback']) && $post['send_trackback'] == true) {
             include_once LOQ_APP_ROOT . 'includes/trackbackhandler.class.php';
             $tb = new trackbackhandler($this->_db);
             $tb->send_trackback('', $post['title'], $post['excerpt'], $post['tburl']);
         }
     } else {
         $this->_last_error = $this->_db->ErrorMsg();
     }
     return $rval;
 }