public function edit_smiley() { $id = (int) $_REQUEST['id']; if (isset($_POST['smiley_code']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $arr = array(); if (isset($_FILES['smiley_image'])) { $image = $_FILES['smiley_image']; if (!\CODOF\File\Upload::valid($image) or !\CODOF\File\Upload::not_empty($image) or !\CODOF\File\Upload::type($image, array('jpg', 'jpeg', 'png', 'gif', 'pjpeg', 'bmp'))) { $this->smarty->assign('err', 1); $this->smarty->assign('msg', "Error While saving the image."); } else { $file_info = \CODOF\File\Upload::save($image, NULL, DATA_PATH . 'assets/img/smileys', 0777); $arr["image_name"] = $file_info["name"]; } } $arr['symbol'] = $this->clean_lines($_POST['smiley_code']); $arr['weight'] = $_POST['weight']; DB::table(PREFIX . "codo_smileys")->where("id", $id)->update($arr); $this->smarty->assign('msg', "Smiley saved successfully."); } $smiley = DB::table(PREFIX . "codo_smileys")->where("id", $id)->first(); $smiley['image_name'] = A_DURI . 'assets/img/smileys/' . $smiley['image_name']; $this->smarty->assign('smiley', $smiley); }
public function upload() { if (!isset($_FILES)) { return; } $errors = array(); $file_info = array(); if (is_array($_FILES['file']['name'])) { $images = \CODOF\Util::re_array_files($_FILES['file']); } else { $images = array($_FILES['file']); } foreach ($images as $image) { if (!\CODOF\File\Upload::valid($image) or !\CODOF\File\Upload::not_empty($image) or !\CODOF\File\Upload::size($image, (int) \CODOF\Util::get_opt('forum_attachments_size')) or !\CODOF\File\Upload::type($image, explode(",", \CODOF\Util::get_opt('forum_attachments_exts')))) { $errors[] = "Error While uploading the image."; } else { $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); $file_info[] = \CODOF\File\Upload::save($image, uniqid() . "." . $ext, DATA_PATH . \CODOF\Util::get_opt('forum_attachments_path'), 0777); } } echo json_encode($file_info); }
if ($_POST['mode'] == 'new' && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $qry = 'INSERT INTO ' . PREFIX . 'codo_categories' . '(cat_pid,cat_name,cat_alias,cat_description,cat_img,no_topics,no_posts,cat_order)' . 'VALUES(:cat_pid,:cat_name,:cat_alias,:cat_description,:cat_img,:no_topics,:no_posts,:cat_order)'; $stmt = $db->prepare($qry); $arr[":cat_pid"] = 0; $arr[":cat_name"] = $_POST['cat_name']; $arr[":cat_alias"] = CODOF\Filter::URL_safe($_POST['cat_name']); // $arr[":cat_img"] = 1; //$_POST['cat_img']; // $arr[":cat_description"] = $_POST['cat_description']; $arr[":no_topics"] = 0; $arr[":no_posts"] = 0; $arr[":cat_order"] = 0; //$stmt->execute($arr); $image = $_FILES['cat_img']; if (!\CODOF\File\Upload::valid($image) or !\CODOF\File\Upload::not_empty($image) or !\CODOF\File\Upload::type($image, array('jpg', 'jpeg', 'png', 'gif', 'pjpeg', 'bmp', 'svg'))) { $smarty->assign('err', 1); $smarty->assign('msg', "Error While uploading the image."); } else { \CODOF\File\Upload::$width = 425; \CODOF\File\Upload::$height = 425; \CODOF\File\Upload::$resizeImage = true; \CODOF\File\Upload::$resizeIconPath = DATA_PATH . CAT_ICON_IMGS; $file_info = \CODOF\File\Upload::save($image, NULL, DATA_PATH . 'assets/img/cats', 0777); $arr[":cat_img"] = $file_info["name"]; $stmt->execute($arr); $cid = $db->lastInsertId('cat_id'); $manager = new \CODOF\Permission\Manager(); $manager->copyCategoryPermissionsFromRole($cid); $smarty->assign('msg', 'New Category Created!'); }