Advertisement
Derpost

nesne yönelimsiz

Jan 23rd, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 KB | None | 0 0
  1. <?php
  2. require_once 'insert.class.php';
  3. require_once 'get.class.php';
  4. Class Note
  5. {
  6.     public $ip;
  7.     private $ipid;
  8.     public $premiumid;
  9.     public $deger;
  10.     private $insert;
  11.     private $get;
  12.  
  13.     public function __construct()
  14.     {
  15.          $this->insert = new Insert();
  16.          $this->get = new Get();
  17.          $this->ip = $_SERVER["REMOTE_ADDR"];
  18.     }
  19.  
  20.     public function checkIp() // ismine aldanma..
  21.     {
  22.         $this->get->getSql("SELECT * FROM ip WHERE ip_ip='" . $this->ip . "'");
  23.         $data = $this->get->getData();
  24.         if($this->get->returnCount()<1)
  25.         {
  26.             $this->get->resetData();
  27.             $this->insert->getSql("INSERT INTO ip (ip_ip,ip_tarih) VALUES ('" . $this->ip . "','" . time() . "')");
  28.             if($this->insert->insertData())
  29.             {
  30.                 $this->ipid = $this->insert->insertid;
  31.                 return true;
  32.             }
  33.             else
  34.             {
  35.                 return false; // <------
  36.             }
  37.         }
  38.         else
  39.         {
  40.             $this->get->resetData();
  41.             $this->get->getSql("SELECT * FROM ip WHERE ip_ip='" . $this->ip . "'");
  42.             $data = $this->get->getData();
  43.             $this->ipid = $data[0]["ip_id"];
  44.             return true;
  45.         }
  46.     }
  47.  
  48.     public function checkPremium()
  49.     {
  50.         if($this->checkIp())
  51.         {
  52.             $this->get->resetData();
  53.             $this->get->getSql("SELECT * FROM ip_p WHERE
  54.                          ip='" . $this->ip .
  55.                         "' AND premium='" . $this->premiumid .
  56.                         "' AND deger='" . $this->deger . "'" );
  57.             $data = $this->get->getData();
  58.             $count = $this->get->returnCount();
  59.             if($count == 1)
  60.             {
  61.                 return false;
  62.             }
  63.             else
  64.             {
  65.                 $this->get->resetData();
  66.                 $this->get->getSql("SELECT * FROM ip_p WHERE ip='" . $this->ipid .
  67.                         "' AND premium='" . $this->premiumid . "'");
  68.                 $data = $this->get->getData();
  69.                 $count = $this->get->returnCount();
  70.                 if($count == 1)
  71.                 {
  72.                     return "Update";
  73.                 }
  74.                 else
  75.                 {
  76.                     return "Insert";
  77.                 }
  78.             }
  79.         }
  80.         else
  81.         {
  82.             return false;
  83.         }
  84.     }
  85.  
  86.     public function addNote()
  87.     {
  88.         if($this->checkPremium()==false)
  89.         {
  90.             return "You cannot give same note again..!";
  91.         }
  92.         if($this->checkPremium()=="Update")
  93.         {
  94.             $this->insert->getSql("UPDATE ip_p SET deger='" . $this->deger . "', `TIME` =  '" . time() . "' WHERE ip =  '" . $this->ipid . "' AND premium =  '" . $this->premiumid . "'");
  95.             $sonuc = $this->insert->insertData();
  96.             if($sonuc)
  97.             {
  98.                 return "Your note is Updated.";
  99.             }
  100.             else
  101.             {
  102.                 return "Sorry. Technical problem!1";
  103.             }
  104.         }
  105.         if($this->checkPremium()=="Insert")
  106.         {
  107.             $this->insert->getSql("INSERT INTO ip_p (ip,premium,deger,time) VALUES ('" . $this->ipid . "','" . $this->premiumid . "','" . $this->deger . "','" . time() . "')");
  108.             $sonuc = $this->insert->insertData();
  109.             if($sonuc)
  110.             {
  111.                 return "Your note is added";
  112.             }
  113.             else
  114.             {
  115.                 return "Sorry. Technical problem!2";
  116.             }
  117.         }
  118.     }
  119. }
  120. /*$note = new Note();
  121. $note->premiumid = 1;
  122. $note->deger = 1;
  123. $note->ip = "127.0.0.2";
  124. echo $note->addNote();
  125.  */
  126. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement