public static function remove($uid, $list_id) { Model::Factory('user_lists_has_social_network')->where("user_lists_id='{$list_id}'")->delete(); Model::Factory('user_lists_has_category')->where("user_lists_id='{$list_id}'")->delete(); Model::Factory('user_lists')->where("user_id='{$uid}' AND id='{$list_id}'")->delete(); PhxMemcache::delete('lists_' . $this->session->user->id); }
public static function unlink_account($uid, $sid) { PhxMemcache::delete('social_networks_' . $uid); $m = Model::Factory('user_has_social_network'); $m->where("user_id='{$uid}' AND social_network_id='{$sid}'"); return $m->delete(); }
public function save_profile_list_data() { #Goodbye, XSS if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); return; } PhxMemcache::delete('lists_' . $this->session->user->id); Phalanx::loadClasses('Lists'); switch ($this->post->method) { case 'remove_list': Lists::remove($this->session->user->id, $this->post->list_id); header("Content-type:text/html;charset=utf-8"); $o->status = true; die(json_encode($o)); break; case 'add_list': $data = new stdClass(); $data->name = $this->post->list_title; $data->social_networks = $this->post->new_list_social_networks; $data->categories = $this->post->new_list_categories; $list_id = Lists::add($this->session->user->id, $data); header("Content-type:text/html;charset=utf-8"); $o->status = (bool) $list_id; die(json_encode($o)); break; } }
private static function getInstance() { self::$instance || (self::$instance = new PhxMemcache()); return self::$instance->connection; }
public function query($sql, $use_memcache, $seconds, $memcache_custom_key) { $connection = DBConnectionManager::getProperConnection($sql); $this->SetConnection($connection); #Hack to cache only the SELECTS $isSelectQuery = preg_match('/^SELECT/i', $sql); if ($use_memcache && !$isSelectQuery or USE_MEMCACHE == false) { $use_memcache = false; } if ($use_memcache) { $memcache_key = is_null($memcache_custom_key) ? md5($sql) : $memcache_custom_key; if ($data = PhxMemcache::get($memcache_key)) { return $data; } else { $data = mysqli_query($this->conn, $sql); $this->log($sql, $data); $data = $this->fetchObject($data); PhxMemcache::set($memcache_key, $data, $seconds); } } else { $data = mysqli_query($this->conn, $sql); if ($isSelectQuery) { $data = $this->fetchObject($data); } $this->log($sql, $data); if (preg_match('/^CALL/i', $sql)) { $this->switch_to_next_result = true; } } if (!$data && mysqli_error($this->conn) != '') { $logger = Logger::getInstance('txt'); $logger->file = 'query_error_.' . date('ymd') . '.txt'; $logger->message(mysqli_error($this->conn) . "\n\n" . print_r($sql, true)); } return $data; }