Pastes:104901  Views:2331862 

Languages:

   ASP
   C#
   C++
   HTML
   Java
   PHP
   VB.NET
   Visual Basic 6

more languages available...


Looking to freelance?

( bids)

Source: GetAFreelancer.com


DirectX 3D Engine

 

 

 

 

 

 

Here's the requested code from the pastebin:

Wrap Lines   Use Line Numbers
<?php
  class Model 
  {
    private $Database;
    private $Users;
    public function getGeschenke($id,$key)
    {
      $i =1;
      foreach($this->Database->findAll() as $geschenke) {
        $return[$i]['id']=$geschenke->id;
          $return[$i]['text']=$geschenke->Text;
          $return[$i]['anzahl_geschenkt']=$geschenke->Anzahl_geschenkt;
          $return[$i]['anzahl_gewollt']=$geschenke->Anzahl_gewollt;
          $i++;
      }
      return json_encode($return);      
    }
 
    public function addVerschenkt($id)
    {
      $geschenk = $this->Database->find($id);
      $geschenk->Anzahl_geschenkt++;
      $geschenk->save();
      return $geschenk->Anzahl_geschenkt;
    }
 
    public function deleteGeschenk($id)
    {
      if ($this->Database->find($id)->delete())
      {
        return "ok";
      } else {
        return "error";
      }
    }
 
    public function modifyGeschenk($id, $whattomodify, $value)
    {
      if (!$_SESSION['loggedin']) {
        return "Error";
      }
      $geschenk = $this->Database->find($id);
      switch ($whattomodify) {
        case "text":
          $geschenk->Text=$value;
          $geschenk->save();
          return $geschenk->Text;
          break;
        case "anzahl_gewollt":
          $geschenk->Anzahl_gewollt=$value;
          $geschenk->save();
          return $geschenk->Anzahl_gewollt;
          break;
        case "anzahl_geschenkt":
          $geschenk->Anzahl_geschenkt=$value;
          $geschenk->save();
          return $geschenk->Anzahl_geschenkt;
          break;
 
        default:
          return "Error";
          break;
      }
 
    }
 
    public function addGeschenk($text,$anzahl_gewollt)
    {
      $new_geschenk = new Wunschliste();
      $new_geschenk['Text']=$text;
      $new_geschenk['Anzahl_gewollt']=$anzahl_gewollt;
      $new_geschenk['Anzahl_geschenkt']=0;      
      $new_geschenk->save();
      $return['id']=$new_geschenk['id'];
      $return['text']=$new_geschenk['Text'];
      $return['anzahl_gewollt']=$new_geschenk['Anzahl_gewollt'];
      $return['anzahl_geschenkt']=$new_geschenk['Anzahl_geschenkt'];
      return json_encode($return);
    }
    public function checkUsernamePassword($username,$password) {
      foreach($this->Users->findByDql("Username = '".$username."'") as $user) {
          if ($user->Password == md5($password)) return true;
      }
      return false;
    }
    public function Model()
    {
      Doctrine_Manager::connection('mysql://root:root@localhost/wunschliste');
      Doctrine::createTablesFromArray(array('Users'));
      Doctrine::createTablesFromArray(array('Wunschliste'));
      $this->Database = Doctrine::getTable('Wunschliste');
      $this->Users = Doctrine::getTable('Users');      
    }
  }
 
  class Controller
  {
    private $Model;
 
    private function getFramework()
    {
      return readfile("framework.inc.php");
    }
 
    public function handleQuery($GET)
    {
      if (isset($GET['password']) && isset($GET['username'])){
        return $this->authenticate($GET['username'],$GET['password']);
      }
      elseif (isset($GET['art'])){
        return $this->Model->$GET['art'](@$GET['param1'],@$GET['param2'],@$GET['param3'],@$GET['param4'],@$GET['param5'],@$GET['param6']);
      } else { 
        $this->getFramework();
      }
    }
    public function Controller(& $model)
    {
      $this->Model =& $model;
    }
    public function authenticate($username,$password)
    {
      if ($this->Model->checkUsernamePassword($username,$password))
      {
        $_SESSION['loggedin']=true;
        return "1";
      } else {
        $_SESSION['loggedin']=false;
        return "0";        
      }
 
    }
  }
?>
Syntax Highlighting:  



Copyright 2007 - NoMorePasting.com