"{$this->listing_id}", "artist" => "{$this->artist}", "title" => "{$this->title}", "label" => "{$this->label}", "catno" => "{$this->catno}", "format" => "{$this->format}", "release_id" => "{$this->release_id}", "status" => "{$this->status}", "price" => "{$this->price}", "listed" => "{$this->listed}", "media_condition" => "{$this->media_condition}", "sleeve_condition" => "{$this->sleeve_condition}", "accept_offer" => "{$this->accept_offer}", "weight" => "{$this->weight}", "format_quantity" => "{$this->format_quantity}", "flat_shipping" => "{$this->flat_shipping}" ); $lijst = $this->decode(); $i = count($lijst); $lijst = array($newmusic); $this->storemusic($lijst); } public function editmusic($id) { // todo! } public function checkForm() { isset($_POST['listing_id']) ? $this->listing_id = $this->cleanInput($_POST['listing_id']) : $listing_id = false; isset($_POST['artist']) ? $this->artist = $this->cleanInput($_POST['artist']) : $artist = false; isset($_POST['title']) ? $this->title = $this->cleanInput($_POST['title']) : $title = false; isset($_POST['label']) ? $this->label = $this->cleanInput($_POST['label']) : $label = false; isset($_POST['catno']) ? $this->catno = $this->cleanInput($_POST['catno']) : $catno = false; isset($_POST['format']) ? $this->format = $this->cleanInput($_POST['format']) : $format = false; isset($_POST['release_id']) ? $this->release_id = $this->cleanInput($_POST['release_id']) : $release_id = false; isset($_POST['status']) ? $this->status = $this->cleanInput($_POST['status']) : $status = false; isset($_POST['price']) ? $this->price = $this->cleanInput($_POST['price']) : $price = false; isset($_POST['listed']) ? $this->listed = $this->cleanInput($_POST['listed']) : $listed= false; isset($_POST['media_condition']) ? $this->media_condition = $this->cleanInput($_POST['media_condition']) : $media_condition = false; isset($_POST['sleeve_condition']) ? $this->sleeve_condition = $this->cleanInput($_POST['sleeve_condition']) : $sleeve_condition = false; isset($_POST['accept_offer']) ? $this->accept_offer = $this->cleanInput($_POST['accept_offer']) : $accept_offer = false; isset($_POST['weight']) ? $this->weight = $this->cleanInput($_POST['weight']) : $weight = false; isset($_POST['format_quantity']) ? $this->format_quantity = $this->cleanInput($_POST['format_quantity']) : $format_quantity = false; isset($_POST['flat_shipping']) ? $this->flat_shipping = $this->cleanInput($_POST['flat_shipping']) : $flat_shipping = false; $_SESSION['messages'] = array(); if($this->title != false) { if(strlen($this->title) > 60 ) { $this->message('Title may not be longer than 60 characters.'); return false; } } else { $this->message('Title may not be empty.'); return false; } if($this->weight != false) { if(!is_int((int)$this->weight) || preg_match("/[a-zA-Z]/i",$this->weight)) { $this->message('Weight may not contain characters.'); return false; } } else { $this->message('Weight must not be empty.'); return false; } if($this->artist != false) { if(strlen($this->artist) > 60 ) { $this->message('Artist may not be longer than 60 characters.'); return false; } } else { $this->message('Description may not be empty.'); return false; } } public function message($value) { if(isset($_SESSION['messages'])) { array_push($_SESSION['messages'],$value); } else { $_SESSION['messages'] = array(); } } public function showmessage() { if(isset($_SESSION['messages'])) { echo "
";
echo "Message:\r\n";
foreach($_SESSION['messages'] as $message) {
echo $message . "\r\n" ;
} echo "";
}
$_SESSION['messages'] = array();
}
/**
* Store music into musicLibrary
* @param array $music
* @return boolean, true for success, false for failure.
*/
public function storemusic($music)
{
// make a backup before doing anything.
$file = self::MUSICLIBRARY;
$copy = self::MUSICLIBRARY.'.bak';
@copy($file, $copy);
// convert encoding
$json = mb_convert_encoding($this->encode($music), self::FILE_ENC, self::FILE_OS);
// write file.
file_put_contents(self::MUSICLIBRARY,$json, LOCK_EX);
}
public function deletemusic($music)
{
$lijst = $this->decode();
if($lijst !== null) {
$libraylist = usort($lijst, $this->sortISBN('isbn'));
$musics = array();
foreach($lijst as $c) {
echo $music."