/** * Update cat. background to database * * @param integer $id cat. id * @param string $img cat. background-img * @param string $old old background * @return boolean * * @access public * @since 1.0 * @version 1.0 * @author Nguyen Van Hiep * @author Dao Anh Minh */ public static function save_bg($id, $img, $old = false) { try { if (!empty($old) and \Fuel\Core\File::exists(DOCROOT . 'assets/img/cat/' . $old)) { File::delete(DOCROOT . 'assets/img/cat/' . $old); } DB::update('cat')->value('bg', $img)->where('id', $id)->execute(); File::delete(DOCROOT . 'assets/img/cat/temp/' . $img); DB::commit_transaction(); return true; } catch (Exception $e) { DB::rollback_transaction(); return false; } }
public static function delete_photo($type, $photo_name) { $image_config = Config::get('app.image'); switch ($type) { case 'photo': $path = Config::get('app.path.root_photo'); foreach ($image_config[$type] as $version => $size) { if (File::exists($path . $version . '/' . $photo_name)) { File::delete($path . $version . '/' . $photo_name); } } break; default: break; } }