author_id != $login_uid) { header("Location: $base_url/homepage.php?&msg=".urlencode('Error: You are not authorized to access this page.')); exit; } } if (isset($_POST['publish']) && $content_type == 'BlogPost') { /* data_array is used to populate the form with the values in case of error */ $data_array["blog_title"] = $_POST["blog_title"]; $data_array["description"] = $_POST["description"]; $data_array["tags"] = $_POST["tags"]; $data_array["trackback"] = $_POST["trackback"]; if (empty($_POST['blog_title'])) { $error = "Title is empty or contains illegal chracters. Please try again."; } elseif (empty($_POST['description']) ) { $error = "Description cannot be empty."; } else { $tags = explode(',', $_POST['tags']); foreach ($tags as $term) { $tr = trim($term); if ($tr) { $terms[] = $tr; } } $title = $_POST['blog_title']; $body = $_POST['description']; $tag_entry = $_POST['tags']; $trackback = $_POST['trackback']; $tb = explode(',', $_POST['trackback']); foreach ($tb as $t) { $trback = trim($t); if ($trback) { $track[] = validate_url($trback); } } // sanitize the POSTed blog data filter_all_post($data_array); // validate it $error = BlogPost::validate_post_data($data_array); if (!$error) { $terms = Tag::split_tags($data_array['tags']); $title = $data_array['blog_title']; $body = $data_array['description']; $track = Content::split_trackbacks($data_array['trackback']); if (!empty($cid)) { // updating an existing post //invalidate cache $r = BlogPost::save_blogpost($cid, $login_uid, $title, $body, $track, $terms, $ccid); $cid = $r['cid']; //invalidate cache of post if($network_info) { $nid = '_network_'.$network_info->network_id; } else { $nid=''; } //unique name $cache_id = 'content_'.$cid.$nid; CachedTemplate::invalidate_cache($cache_id); $location = "$base_url/content.php?cid=$cid"; } else { $skip=FALSE; // creating a new post if($count_targets_internal > 0) { $skip = TRUE; // ... in one or more groups foreach ($internal_targets as $ccid) { if($ccid == -1) { //if all of my groups selected $all_groups = explode(',', $Allgroup); foreach ($all_groups as $group_ccid) { $res = BlogPost::save_blogpost(0, $login_uid, $title, $body, $track, $terms, $group_ccid, $is_active = 1); $cid = $res['cid']; if ($res['moderation_required']) { $location = "$base_url/group.php?msg=blog&gid=".$group_ccid; } else { $location = "$base_url/group.php?gid=".$group_ccid; } } } else if($ccid == -2) { //if none of my groups selected $skip = TRUE; $ccid = 0; $res = BlogPost::save_blogpost(0, $login_uid, $title, $body, $track, $terms, -1, $is_active = 1, $display_on = 1); $cid = $res['cid']; $location = "$base_url/content.php?cid=$cid"; } else { $res = BlogPost::save_blogpost(0, $login_uid, $title, $body, $track, $terms, $ccid, $is_active = 1); $skip = TRUE; $cid = $res['cid']; if ($res['moderation_required']) { $location = "$base_url/group.php?msg=blog&gid=".$ccid; } else { $location = "$base_url/group.php?gid=".$ccid; } } } } // ... in the user's blog if($display_on == 0 || !$skip) { $skip = TRUE; $ccid = -1; $res = BlogPost::save_blogpost(0, $login_uid, $title, $body, $track, $terms, $ccid, $is_active = 1, $display_on); $cid = $res['cid']; $location = "$base_url/content.php?cid=$cid"; } } /* ---- Code for Outputthis ----*/ if (is_array($_POST['route_targets_external']) && sizeof($_POST['route_targets_external'])) { if (in_array('-2',$_POST['route_targets_external'])) { //do nothing } else { if (in_array('-1',$_POST['route_targets_external'])) { $route_to = explode(',',$_POST['Allexternal_blog']); } else { $route_to = $_POST['route_targets_external']; } } if (is_array($route_to) && sizeof($route_to)) { $route_destination_name = $route_to; for($i = 0; $i < count($route_destination_name); $i++) { $blog_post = array('title'=>$title,'body'=>$body); if (is_array($route_destination_name) && count($route_destination_name)>0) { if (!empty($outputthis_username) && !empty($outputthis_password)) { $return = OutputThis::send($blog_post, $route_destination_name, $outputthis_username,$outputthis_password); // FIX ME:if sending to output this is not successful :( then what to do } } }//..for }//..$route_to }//..$_POST['route_targets_external'] /* ----END OF Code for Outputthis ----*/ if(!empty($_POST['ccid']) && $_POST['ccid'] > 0) { $new = new Group(); $new->load($_POST['ccid']); if ($new->is_moderated==IS_MODERATED) { $location = "$base_url/group.php?gid=".$_POST['ccid']."&msg=blog"; } else { $location = "$base_url/group.php?gid=".$_POST['ccid']; } } //header("Location: $base_url/createcontent.php?cid=".$content_id); header("Location: $location"); exit; } } } ?>