コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public function edit_profile($id)
 {
     $edit = \CODOF\User\User::get();
     $id = (int) $id;
     if (!$this->can_edit_profile($id)) {
         $this->view = 'access_denied';
         return false;
     }
     $values = array("name" => \CODOF\Filter::msg_safe($_POST['name']), "signature" => \CODOF\Format::omessage($_POST['signature']));
     $success = true;
     if (isset($_FILES) && $_FILES['avatar']['error'] != UPLOAD_ERR_NO_FILE) {
         $success = false;
         \CODOF\File\Upload::$width = 128;
         \CODOF\File\Upload::$height = 128;
         \CODOF\File\Upload::$resizeImage = true;
         \CODOF\File\Upload::$resizeIconPath = DATA_PATH . PROFILE_ICON_PATH;
         $result = \CODOF\File\Upload::do_upload($_FILES['avatar'], PROFILE_IMG_PATH);
         if (\CODOF\File\Upload::$error) {
             $this->smarty->assign('file_upload_error', $result);
         } else {
             $values["avatar"] = $result['name'];
             $success = true;
         }
     }
     $edited = $edit->set($values);
     if (!$edited) {
         Util::log("Failed to update user details profile/id/edit");
         $success = false;
     }
     $this->smarty->assign('user_profile_edit', $success);
     $this->profile($id, 'edit');
 }
コード例 #4
0
     if ($_POST['p1'] != $_POST['p2']) {
         $err = 1;
         $msg = "The passwords do not match!";
     } else {
         $hasher = new \CODOF\Pass(8, false);
         $hash = $hasher->HashPassword($_POST['p1']);
         $arr['pass'] = $hash;
     }
 }
 if (isset($_FILES['user_img']) && !empty($_FILES['user_img']['name'])) {
     $image = $_FILES['user_img'];
     \CODOF\File\Upload::$width = 128;
     \CODOF\File\Upload::$height = 128;
     \CODOF\File\Upload::$resizeImage = true;
     \CODOF\File\Upload::$resizeIconPath = DATA_PATH . PROFILE_ICON_PATH;
     $file_info = \CODOF\File\Upload::do_upload($image, PROFILE_IMG_PATH);
     if (\CODOF\File\Upload::$error) {
         $err = 1;
         $msg = "Error While uploading the image, try with a different image.";
     } else {
         $arr["avatar"] = $file_info["name"];
     }
 }
 $arr['user_status'] = 0;
 if (isset($_POST['user_status'])) {
     $arr['user_status'] = 1;
 }
 //update
 $u = CODOF\User\User::get((int) $_GET['user_id']);
 if ($err == 0) {
     $msg .= "Updates have been applied.";
コード例 #5
0
        //$_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!');
        }
    }
}
$qry = 'SELECT *  FROM ' . PREFIX . 'codo_categories ORDER BY cat_order';
$res = $db->query($qry);
if ($res) {
    $res = $res->fetchAll(PDO::FETCH_CLASS);
}
$frm = new CODOF\Forum\Forum();