public function hapus($slug) { $artikel = Artikel::whereSlug($slug)->firstOrFail(); $artikel->delete(); File::delete($artikel->gambar); // / return redirect('profil')->with('pesan', 'Berita berhasil dihapus'); }
public function loadModel($id) { $model = Artikel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getJSON() { $itemid = $this->itemid; $apiuser = $GLOBALS["DB"]->executeQuery("SELECT username, apikey FROM xplugin_newsletter2go_keys", 1); // Query Artikel [tartikel] // Kann man irgendwie auch den Artikel als Objekt direkt so laden? $query = "SELECT `kArtikel` FROM `tartikel` WHERE `cArtNr` = '{$itemid}'"; $produkt = $GLOBALS["DB"]->executeQuery($query, 9); if (empty($produkt)) { return $this->getError(200); } $kArtikel = $produkt[0]['kArtikel']; $artikel = new Artikel(); $artikel->fuelleArtikel($kArtikel, false); $json = array("itemID" => $artikel->cArtNr, "name" => utf8_encode($artikel->cName), "url" => gibShopURL(), "link" => '/' . $artikel->cSeo, "short_description" => utf8_encode($artikel->cKurzBeschreibung), "description" => utf8_encode($artikel->cBeschreibung), "images" => array()); // Bilder zum Artikel $artikel->holBilder(); foreach ($artikel->Bilder as $bild) { $json['images'][] = gibShopURL() . '/' . $bild->cPfadNormal; } $json['price'] = $artikel->gibPreis(1, false); $json['taxes'] = (double) gibUst($artikel->kSteuerklasse) / 100; return json_encode($json); }
{ header('location: ' . $url); } function my_autoloader($class) { include 'classes/' . $class . '.php'; } spl_autoload_register('my_autoloader'); define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); define('HOST', dirname(BASE_URL) . '/'); $message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=oplossing_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("oplossing-file-upload-login-form.php"); } if (isset($_POST['activate'])) { $artikel = new Artikel($databaseWrapper); $id = $_POST['activate']; var_dump($_POST); $artikel->toggle($id); new Message('Het artikel is succesvol van activatiestatus veranderd', 'success'); relocate("oplossing-file-upload-artikels-overzicht.php"); }
spl_autoload_register('my_autoloader'); define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); define('HOST', dirname(BASE_URL) . '/'); $message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=opdracht_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("login-form.php"); } var_dump($_POST); if (isset($_POST['submit'])) { $id = $_POST['id']; $titel = $_POST['titel']; $artikelTekst = $_POST['artikel']; $kernwoorden = $_POST['kernwoorden']; $datum = $_POST['datum']; $is_active = isset($_POST['is_active']) ? 1 : 0; $artikel = new Artikel($databaseWrapper); $artikelEdited = $artikel->edit($id, $titel, $artikelTekst, $kernwoorden, $datum, $is_active); if ($artikelEdited) { new Message('Het artikel met titel "' . $titel . '" werd gewijzigd.', 'success'); relocate("artikels-overzicht.php"); } }
session_start(); isset($_SESSION["message"]) ? $bodschap = $_SESSION["message"] : ($bodschap = ""); var_dump($_GET); unset($_SESSION["message"]); function relocate($url) { header('location: ' . $url); } function __autoload($class) { include 'class/' . $class . '.php'; } try { $db = new PDO("mysql:host=localhost;dbname=blog", "anton", "paraplu"); $artikel = new Artikel($db); $alleArtikels = $artikel->get(); $bodschap = "artiekels gevonden"; } catch (PDOException $e) { $bodschap = 'Er ging iets mis: ' . $e->getMessage(); } ?> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <?php if ($bodschap) { echo $bodschap;
{ header('location: ' . $url); } function my_autoloader($class) { include 'classes/' . $class . '.php'; } spl_autoload_register('my_autoloader'); define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); define('HOST', dirname(BASE_URL) . '/'); $message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=oplossing_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("oplossing-file-upload-login-form.php"); } if (isset($_POST['delete'])) { $artikel = new Artikel($databaseWrapper); $id = $_POST['delete']; var_dump($_POST); $artikel->delete($id); new Message('Het artikel werd succesvol verwijderd', 'success'); relocate("oplossing-file-upload-artikels-overzicht.php"); }
/** * Get product informations. * * @return mixed Product info. */ public function getProductInfo() { // Article number $identifier = filter_input(INPUT_POST, 'identifier'); if ($identifier === null) { self::sendError('Indentifier not found.'); } $query = 'SELECT kArtikel FROM ' . self::PRODUCTS_TABLE . " WHERE cArtNr = '{$identifier}'"; $productInfoFromDb = $GLOBALS["DB"]->executeQuery($query, 9); if (empty($productInfoFromDb)) { self::sendError(sprintf('Product with article number %d has not been found.', $identifier)); } $language = filter_input(INPUT_POST, 'language'); $productInfo = $productInfoFromDb[0]['kArtikel']; $product = new Artikel(); $product->fuelleArtikel($productInfo, false, 0, $language); if ($product->cArtNr != $identifier) { self::sendError('Product not found in this language!'); } $productPrice = $product->gibPreis(1, false); $productTax = (double) gibUst($product->kSteuerklasse) / 100; $productToReturn = array(); foreach (self::getProductAttributeDefinitions() as $attributeDefinition) { $attributeName = $attributeDefinition['id']; // If attribute is not requested, don't add it. if (self::isProductAttributeRequested($attributeName) === false) { continue; } if ($attributeName === 'oldPrice' || $attributeName === 'newPrice') { $productToReturn[$attributeName] = isset($productPrice) ? round($productPrice * ($productTax + 1), 2) : false; continue; } if ($attributeName === 'oldPriceNet' || $attributeName === 'newPriceNet') { $productToReturn[$attributeName] = isset($productPrice) ? round($productPrice, 2) : false; continue; } if ($attributeName === 'url') { $productToReturn[$attributeName] = gibShopURL(); continue; } if ($attributeName === 'images') { $product->holBilder(); foreach ($product->Bilder as $bild) { $productToReturn[$attributeName][] = gibShopURL() . '/' . $bild->cPfadNormal; } continue; } if ($attributeName === 'fMwSt') { $productToReturn[$attributeName] = $productTax; continue; } $productToReturn[$attributeName] = isset($product->{$attributeName}) ? $product->{$attributeName} : ''; } return $productToReturn; }
$message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=oplossing_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("oplossing-file-upload-login-form.php"); } $artikel = false; if (isset($_GET['edit'])) { $artikelInstance = new Artikel($databaseWrapper); $id = $_GET['edit']; $artikelRaw = $artikelInstance->get($id); if ($artikelRaw) { $artikel = $artikelRaw[0]; } } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Oplossing file upload</title>
{ include 'classes/' . $class . '.php'; } spl_autoload_register('my_autoloader'); define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); define('HOST', dirname(BASE_URL) . '/'); $message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=opdracht_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("oplossing-CRUD-CMS-login-form.php"); } var_dump($_POST); $titel = $_POST['titel']; $artikelTekst = $_POST['artikel']; $kernwoorden = $_POST['kernwoorden']; $datum = $_POST['datum']; $is_active = isset($_POST['is_active']) ? 1 : 0; $artikel = new Artikel($databaseWrapper); $artikelToegevoegd = $artikel->add($titel, $artikelTekst, $kernwoorden, $datum, $is_active); if ($artikelToegevoegd) { new Message('Het artikel met titel "' . $titel . '" werd toegevoegd.', 'success'); relocate("oplossing-CRUD-CMS-artikels-overzicht.php"); }
public function actionAArtikel($id) { $Artikel = new Artikel(); $Views = View::model()->findAll(); $katagorys = Katagory::model()->findAll('view_id_view =' . $id); if (isset($_POST['Artikel'])) { $Artikel->attributes = $_POST['Artikel']; $Artikel->png_artikel = Yii::app()->user->name; $kats = $_POST['a']; if ($Artikel->save()) { foreach ($kats as $kat) { $hub = new KatagoryHasArtikel(); $hub->artikel_id_artikel = $Artikel->id_artikel; $hub->katagory_id_katagory = (int) $kat; $hub->save(); } } $this->redirect(array('lartikel', 'fitback' => 4)); } $this->render('aartikel', array('id' => $id, 'Artikel' => $Artikel, 'katagorys' => $katagorys, 'Views' => $Views)); }
define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); define('HOST', dirname(BASE_URL) . '/'); $message = false; if (Message::hasMessage()) { $message = Message::getMessage(); Message::remove(); } $db = new PDO('mysql:host=localhost;dbname=oplossing_file_upload', 'root', ''); // Connectie maken $databaseWrapper = new Database($db); $user = new User($databaseWrapper); if (!$user->validate()) { new Message("U moet eerst inloggen", "error"); relocate("oplossing-file-upload-login-form.php"); } $artikel = new Artikel($databaseWrapper); $artikels = $artikel->get(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Oplossing file upload</title> <style> html { font-family:sans-serif; }
<?php include 'include-config.php'; session_start(); function __autoload($class) { include 'class/' . $class . '.php'; } try { $db = new PDO("mysql:host=localhost;dbname=blog", "anton", "paraplu"); $artikel = new Artikel($db); if (isset($_GET["artikel"])) { $alleArtikels = $artikel->get(false, $_GET["artikel"], false); } if (isset($_GET["date"])) { $alleArtikels = $artikel->get(false, false, $_GET["date"]); } } catch (PDOException $e) { $bodschap = 'Er ging iets mis: ' . $e->getMessage(); } //echo $bodschap."<br>"; //var_dump($alleArtikels); ?> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body>
public function actionCon($pk) { $Menus = Menu::model()->findAll(); $Katagorys = Katagory::model()->findAll(); $criteria = new CDbCriteria(array('order' => 'like_artikel DESC', 'limit' => 10)); $hots = Artikel::model()->findAll($criteria); $Artikel = Artikel::model()->findByPk($pk); $jml = $Artikel->con_artikel; $Artikel->con_artikel = $jml + 1; $id = Katagory::model()->findByPk(KatagoryHasArtikel::model()->find('artikel_id_artikel =' . $Artikel->id_artikel)->katagory_id_katagory)->view_id_view; if ($Artikel->save()) { $this->render('view', array("id" => $id, 'pk' => $pk, "menus" => $Menus, "katagorys" => $Katagorys, 'Artikel' => $Artikel, 'hots' => $hots)); } }
session_start(); $_SESSION["message"] = array(); function relocate($url) { header('location: ' . $url); } function __autoload($class) { include 'class/' . $class . '.php'; } try { $db = new PDO("mysql:host=localhost;dbname=blog", "anton", "paraplu"); if (isset($_POST["submit"])) { $titel = $_POST['titel']; $artikelTekst = $_POST['artikel']; $kernwoorden = $_POST['kernwoorden']; $datum = $_POST['datum']; echo "werkt tot hier"; $artikel = new Artikel($db); $artikelToegevoegd = $artikel->add($titel, $artikelTekst, $kernwoorden, $datum); if ($artikelToegevoegd) { $_SESSION["message"] = 'Het artikel met titel "' . $titel . '" werd toegevoegd.'; } else { header("Location: artikel-toevoegen-form.php"); } } header("Location: artikel-overzicht.php"); } catch (PDOException $e) { $_SESSION["message"] = 'Er ging iets mis: ' . $e->getMessage(); header("Location: artikel-toevoegen-form.php"); }