Example #1
0
 public function buyTrack($trackid, $albumid)
 {
     $userid = $this->session->userdata('userid');
     $result = array("error" => FALSE);
     if (!$userid) {
         $result["error"] = "You must login!";
         echo json_encode($result);
     }
     $user = new User($userid);
     $track = Track::loadTrack($trackid);
     if ($user->getCredit() < $track->getCost()) {
         //The user can't afford the track!
         $result["error"] = "You have insufficient funds to buy the track as it costs &pound;" . sprintf("%01.2f", $track->getCost() / 100) . ", please top up your account";
         echo json_encode($result);
     } else {
         //Buy the rights to the track
         if ($user->aquireRightsToTrack($trackid, $albumid)) {
             //The track was bought successfully
             $result["bought"] = TRUE;
         } else {
             $result["error"] = "Sorry, there was a problem buying the track. Please try again later";
         }
         echo json_encode($result);
     }
 }
Example #2
0
//$newPoint = new Point(0, 'Foyer');
//echo $newPoint->getName();
echo '<h2>Ok id etu</h2>';
$User = new User('6362', 2, '', 1);
echo $User->getState();
echo '<h2>Ok id buckutt</h2>';
$User = new User('1', 3, '', 1);
echo $User->getState();
echo '<h2>Ok login</h2>';
$User = new User('bernardx', 1, '', 1);
echo $User->getState();
echo '<h2>usr inconnu</h2>';
$User = new User('636462', 2, '', 1);
echo $User->getState();
echo $User->getFirstname();
echo '<h2>Avec mot de passe</h2>';
$User = new User('bernardx', 1, 'toto');
echo $User->getState() . '<br />';
echo $User->getId() . '<br />';
echo $User->getFirstname() . '<br />';
echo $User->getLastname() . '<br />';
echo $User->getNickname() . '<br />';
echo $User->getMail() . '<br />';
echo $User->getCredit() . '<br />';
echo $User->getIp();
/*
echo '<h2>Avec mot de passe faux</h2>';
$User = new User('6362', 2, 'pezfzev');
echo $User->getState();
echo $User->getLastname();
*/
Example #3
0
 function topUp()
 {
     $userid = $this->session->userdata('userid');
     if ($userid == null) {
         redirect("/main");
     }
     $this->load->static_model('Playlist');
     $playlists = Playlist::getUsersPlaylists($userid);
     $user = new User($userid);
     $first_name = $user->getFName();
     $last_name = $user->getLName();
     $joined = $user->getJoined();
     $email = $user->getEmail();
     $credit = $user->getCredit();
     $data = array('userid' => $userid, 'user' => $user, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'joined' => $joined, 'credit' => $credit, 'page_title' => "Add Money", 'playlists' => $playlists);
     $this->load->view("common/header.php", $data);
     $this->load->view("account/topup_view.php", $data);
     $this->load->view("common/footer.php");
 }