Ejemplo n.º 1
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');
 }
Ejemplo n.º 2
0
 if ($_POST['p1'] != "") {
     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) {
Ejemplo n.º 3
0
        $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!');
        }
    }
}
$qry = 'SELECT *  FROM ' . PREFIX . 'codo_categories ORDER BY cat_order';
$res = $db->query($qry);
if ($res) {
    $res = $res->fetchAll(PDO::FETCH_CLASS);
}