function commentsCount() { if (!isset($_POST) || !$_POST) { return; } $result = array(); foreach ($_POST as $v) { $v = trim(core::generateSlug($v)); $res = $this->db->query("SELECT COUNT(*) FROM `comments` as co,`content` as c WHERE co.`contentID`=c.`contentID` \n\t\t\t\tAND c.`slug`='?'", $v); $tmp = $res->fetch(); $result[$v] = array_shift($tmp); } if (!$result) { return; } echo json_encode($result); }
function addPageAjax() { system::setParam("page", "ajax"); if ($_POST) { $fill = array(); $slug = ""; $fill = $_POST; if (!empty($_POST["slug"])) { $slug = core::generateSlug($_POST["slug"]); } else { if (!empty($_POST["title"])) { $slug = core::generateSlug($_POST["title"]); } } $fill["slug"] = $slug; $savedPost = video::writePost($fill); // $this->smarty->assign ("fill", $fill); return true; } }
function addPage() { system::setParam("page", "addPage"); article::getAllCats(); $fill = array(); $doRedirect = false; if (!empty($_POST["slug"])) { $fill["slug"] = core::generateSlug($_POST["slug"]); } else { if (!empty($_POST["title"])) { $fill["slug"] = core::generateSlug($_POST["title"]); } } $fill += $_POST; if (isset($_POST["picRealUpload"])) { $uploadedPics = blog::uploadOnePicture($fill["slug"]); } $fill["poster"] = ""; if (isset($_FILES["poster"]) && $_FILES["poster"]["error"] == 0) { $uploadedPics = blog::uploadOnePicture($fill["slug"], "articleImages"); if (isset($uploadedPics["poster"]) && $uploadedPics["poster"]) { $fill["poster"] = serialize($uploadedPics["poster"]); } } if (isset($_POST["savePost"])) { $savedPost = blog::writePost($fill, "article"); if ($savedPost) { $doRedirect = true; } } blog::showAttachedPics($fill); $this->smarty->assign("fill", $fill); if ($doRedirect) { system::redirect(system::param("urlBase") . "listPage"); } }
private function editPost() { $id = intval($_GET["contentID"]); if (!$id) { return false; } $doRedirect = false; $fill = $_POST; if (isset($_POST["slug"]) && $_POST["slug"]) { $fill["slug"] = core::generateSlug($_POST["slug"]); } if (isset($_POST["uploadPicture"])) { $uploadedPics = blog::uploadOnePicture($fill["slug"]); } $fill["poster"] = ""; if (isset($_FILES["poster"]) && $_FILES["poster"]["error"] == 0) { $uploadedPics = blog::uploadOnePicture($fill["slug"], "posterImages"); if (isset($uploadedPics["poster"]) && $uploadedPics["poster"]) { $fill["poster"] = serialize($uploadedPics["poster"]); } } if (isset($_POST["savePost"])) { if (blog::updatePost($id, $fill)) { $doRedirect = true; } } blog::getAllCats($id); system::setParam("page", "editPost"); $sqlData = blog::buildForm("content", array("AND `contentID`={$id}")); blog::showAttachedPics($sqlData); $this->smarty->assign("annotationRestriction", system::param("annotationRestriction")); if ($doRedirect) { system::redirect("/adm/blog/posts"); } }
private function add($fill, $doRedirect = false) { $fill['picture'] = photo::UploadImage($_FILES); if (isset($_POST['x1']) && isset($_POST['y1']) && isset($_POST['w1']) && isset($_POST['h1'])) { $data = array('x1' => $_POST['x1'], 'y1' => $_POST['y1'], 'w1' => $_POST['w1'], 'h1' => $_POST['h1']); unset($_POST['x1'], $_POST['y1'], $_POST['w1'], $_POST['h1']); photo::imageCrop($_POST['picture'], $data, '200x200'); } if (isset($_POST['x2']) && isset($_POST['y2']) && isset($_POST['w2']) && isset($_POST['h2'])) { $data = array('x1' => $_POST['x2'], 'y1' => $_POST['y2'], 'w1' => $_POST['w2'], 'h1' => $_POST['h2']); unset($_POST['x2'], $_POST['y2'], $_POST['w2'], $_POST['h2']); photo::imageCrop($_POST['picture'], $data, '200x140'); } if (isset($_POST['width'])) { unset($_POST['width']); } if (isset($_POST['height'])) { unset($_POST['height']); } if (empty($fill["title"])) { $fill["title"] = time(); } $fill['type'] = 'news'; // echo '<pre>'.print_r($fill,1).'</pre>'; exit; if (!empty($fill["slug"])) { $slug = core::generateSlug($fill["slug"]); } else { if (!empty($fill["title"])) { $slug = core::generateSlug($fill["title"]); } } $fill["slug"] = $slug; $savedPost = photo::writePost($fill); $size = getimagesize(CONTENT_PATH . '/photo/resized/' . $fill['picture']); $fill['width'] = $size[0]; $fill['height'] = $size[1]; return $savedPost; }
public static function addCat($data, $type = "news") { if (!isset($data["catSlug"]) || !$data["catSlug"]) { $data["catSlug"] = core::generateSlug($data["catName"]); } return self::$db->query("INSERT INTO `categories` SET `catName`='?', `catSlug`='?', `catType`='{$type}'", $data["catName"], $data["catSlug"]); }