Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'insert.class.php';
- require_once 'get.class.php';
- Class Note
- {
- public $ip;
- private $ipid;
- public $premiumid;
- public $deger;
- private $insert;
- private $get;
- public function __construct()
- {
- $this->insert = new Insert();
- $this->get = new Get();
- $this->ip = $_SERVER["REMOTE_ADDR"];
- }
- public function checkIp() // ismine aldanma..
- {
- $this->get->getSql("SELECT * FROM ip WHERE ip_ip='" . $this->ip . "'");
- $data = $this->get->getData();
- if($this->get->returnCount()<1)
- {
- $this->get->resetData();
- $this->insert->getSql("INSERT INTO ip (ip_ip,ip_tarih) VALUES ('" . $this->ip . "','" . time() . "')");
- if($this->insert->insertData())
- {
- $this->ipid = $this->insert->insertid;
- return true;
- }
- else
- {
- return false; // <------
- }
- }
- else
- {
- $this->get->resetData();
- $this->get->getSql("SELECT * FROM ip WHERE ip_ip='" . $this->ip . "'");
- $data = $this->get->getData();
- $this->ipid = $data[0]["ip_id"];
- return true;
- }
- }
- public function checkPremium()
- {
- if($this->checkIp())
- {
- $this->get->resetData();
- $this->get->getSql("SELECT * FROM ip_p WHERE
- ip='" . $this->ip .
- "' AND premium='" . $this->premiumid .
- "' AND deger='" . $this->deger . "'" );
- $data = $this->get->getData();
- $count = $this->get->returnCount();
- if($count == 1)
- {
- return false;
- }
- else
- {
- $this->get->resetData();
- $this->get->getSql("SELECT * FROM ip_p WHERE ip='" . $this->ipid .
- "' AND premium='" . $this->premiumid . "'");
- $data = $this->get->getData();
- $count = $this->get->returnCount();
- if($count == 1)
- {
- return "Update";
- }
- else
- {
- return "Insert";
- }
- }
- }
- else
- {
- return false;
- }
- }
- public function addNote()
- {
- if($this->checkPremium()==false)
- {
- return "You cannot give same note again..!";
- }
- if($this->checkPremium()=="Update")
- {
- $this->insert->getSql("UPDATE ip_p SET deger='" . $this->deger . "', `TIME` = '" . time() . "' WHERE ip = '" . $this->ipid . "' AND premium = '" . $this->premiumid . "'");
- $sonuc = $this->insert->insertData();
- if($sonuc)
- {
- return "Your note is Updated.";
- }
- else
- {
- return "Sorry. Technical problem!1";
- }
- }
- if($this->checkPremium()=="Insert")
- {
- $this->insert->getSql("INSERT INTO ip_p (ip,premium,deger,time) VALUES ('" . $this->ipid . "','" . $this->premiumid . "','" . $this->deger . "','" . time() . "')");
- $sonuc = $this->insert->insertData();
- if($sonuc)
- {
- return "Your note is added";
- }
- else
- {
- return "Sorry. Technical problem!2";
- }
- }
- }
- }
- /*$note = new Note();
- $note->premiumid = 1;
- $note->deger = 1;
- $note->ip = "127.0.0.2";
- echo $note->addNote();
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement