public function actionPostFeed() { if (EnvUtil::submitCheck("formhash")) { $return = array("isSuccess" => true, "data" => ""); $d["content"] = isset($_POST["content"]) ? StringUtil::filterDangerTag($_POST["content"]) : ""; $d["body"] = $_POST["body"]; $d["rowid"] = isset($_POST["rowid"]) ? intval($_POST["rowid"]) : 0; foreach ($_POST as $key => $val) { $_POST[$key] = StringUtil::filterCleanHtml($_POST[$key]); } $uid = Ibos::app()->user->uid; $user = User::model()->fetchByUid($uid); if (isset($_POST["view"])) { $_POST["view"] = $d["view"] = intval($_POST["view"]); if ($_POST["view"] == WbConst::SELFDEPT_VIEW_SCOPE) { $d["deptid"] = $user["deptid"]; } if ($_POST["view"] == WbConst::CUSTOM_VIEW_SCOPE) { $scope = StringUtil::getId($_POST["viewid"], true); if (isset($scope["u"])) { $d["userid"] = implode(",", $scope["u"]); } if (isset($scope["d"])) { $d["deptid"] = implode(",", $scope["d"]); } if (isset($scope["p"])) { $d["positionid"] = implode(",", $scope["p"]); } } } $d["source_url"] = isset($_POST["source_url"]) ? urldecode($_POST["source_url"]) : ""; $d["body"] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", "#" . trim("\${1}") . "#", $d["body"]); if (isset($_POST["attachid"])) { $d["attach_id"] = trim(StringUtil::filterCleanHtml($_POST["attachid"])); if (!empty($d["attach_id"])) { $d["attach_id"] = explode(",", $d["attach_id"]); array_map("intval", $d["attach_id"]); } } $type = StringUtil::filterCleanHtml($_POST["type"]); $table = isset($_POST["table"]) ? StringUtil::filterCleanHtml($_POST["table"]) : "feed"; $module = isset($_POST["module"]) ? StringUtil::filterCleanHtml($_POST["module"]) : "weibo"; $data = Feed::model()->put(Ibos::app()->user->uid, $module, $type, $d, $d["rowid"], $table); if (!$data) { $return["isSuccess"] = false; $return["data"] = Feed::model()->getError("putFeed"); $this->ajaxReturn($return); } UserUtil::updateCreditByAction("addweibo", Ibos::app()->user->uid); $data["from"] = EnvUtil::getFromClient($data["from"], $data["module"]); $lang = Ibos::getLangSources(); $return["data"] = $this->renderPartial("feedlist", array("list" => array($data), "lang" => $lang), true); $return["feedid"] = $data["feedid"]; FeedTopic::model()->addTopic(html_entity_decode($d["body"], ENT_QUOTES, "UTF-8"), $data["feedid"], $type); $this->ajaxReturn($return); } }
public function shareFeed($data, $from = "share", $lessUids = null) { $return = array("isSuccess" => false, "data" => "转发失败"); if (empty($data["sid"])) { return $return; } $type = StringUtil::filterCleanHtml($data["type"]); $table = isset($data["table"]) ? $data["table"] : $type; $module = isset($data["module"]) ? $data["module"] : "weibo"; $forApi = isset($data["forApi"]) && $data["forApi"] ? true : false; if (!($oldInfo = Source::getSourceInfo($table, $data["sid"], $forApi, $data["module"]))) { $return["data"] = "此信息不可以被转发"; return $return; } $d["content"] = isset($data["content"]) ? str_replace(Ibos::app()->setting->get("siteurl"), "[SITE_URL]", $data["content"]) : ""; $d["body"] = str_replace(Ibos::app()->setting->get("siteurl"), "[SITE_URL]", $data["body"]); $feedType = "repost"; if (!empty($oldInfo["feedType"]) && !in_array($oldInfo["feedType"], array("post", "postimage"))) { $feedType = $oldInfo["feedType"]; } $d["sourceInfo"] = !empty($oldInfo["sourceInfo"]) ? $oldInfo["sourceInfo"] : $oldInfo; $isOther = $from == "comment" ? false : true; $d["curid"] = $data["curid"]; if ($oldInfo["rowid"] == 0) { $id = $oldInfo["source_id"]; $table = $oldInfo["source_table"]; } else { $id = $oldInfo["rowid"]; $table = $oldInfo["table"]; } $d["from"] = isset($data["from"]) ? intval($data["from"]) : 0; $res = $this->put(Ibos::app()->user->uid, $module, $feedType, $d, $id, $table, null, $lessUids, $isOther, 1); if ($res) { if (isset($data["comment"])) { $c["module"] = $module; $c["moduleuid"] = $data["curid"]; $c["table"] = "feed"; $c["uid"] = $oldInfo["uid"]; $c["content"] = !empty($d["body"]) ? $d["body"] : $d["content"]; $c["rowid"] = !empty($oldInfo["sourceInfo"]) ? $oldInfo["sourceInfo"]["source_id"] : $id; $c["from"] = EnvUtil::getVisitorClient(); $notCount = $from == "share" ? $data["comment"] == 1 ? false : true : false; Comment::model()->addComment($c, false, $notCount, $lessUids); } FeedTopic::model()->addTopic(html_entity_decode($d["body"], ENT_QUOTES), $res["feedid"], $feedType); $rdata = $res; $rdata["feedid"] = $res["feedid"]; $rdata["rowid"] = $data["sid"]; $rdata["table"] = $data["type"]; $rdata["module"] = $module; $rdata["isrepost"] = 1; switch ($module) { case "mobile": break; default: $rdata["from"] = EnvUtil::getFromClient($from, $module); break; } $return["data"] = $rdata; $return["isSuccess"] = true; if ($module == "weibo" && $type == "feed") { $this->updateCounters(array("repostcount" => 1), "feedid = " . $data["sid"]); $this->cleanCache($data["sid"]); if ($data["curid"] != $data["sid"] && !empty($data["curid"])) { $this->updateCounters(array("repostcount" => 1), "feedid = " . $data["curid"]); $this->cleanCache($data["curid"]); } } } else { $return["data"] = $this->getError("putFeed"); } return $return; }