function __construct($id) { $this->db = Factory::getDatabase(); $res = $this->db->query("select * from user where id = {$id} limit 1"); $this->data = $res->fetch_assoc(); $this->id = $id; }
public function resolveDestinationPath($dir, $sourceInfo) { $log = Factory::getLogger(); $res = $this->mPeeler->resolveDestinationPath($dir, $sourceInfo); $c = $this->getConfig(); $db = Factory::getDatabase(); switch ($c['peeler']['unique_by']) { case 'url': if ($db->urlDownloaded($sourceInfo['url'])) { $log->message('Skipping %s (already downloaded)', $sourceInfo['url']); $res = null; } break; case 'checksum': break; } return $res; }
private function download($dir) { $c = $this->getConfig(); $db = Factory::getDatabase(); $log = Factory::getLogger(); $data = $this->mPeeler->getData(); $scraper = Factory::createScraper(); foreach ($data as $sourceInfo) { $url = $sourceInfo['url']; $log->message("Found %s", basename($url)); $scraper->get($url); $res = $scraper->getResponseCode(); if ($dest = $this->resolveDestinationPath($dir, $sourceInfo)) { if ($res == 200) { $log->message("Writing %s", $dest); file_put_contents($dest, $scraper->getResponseData()); $db->registerUrlDownloaded($url, $c['peeler']['name'], $dest, 'naming_ok'); } else { $log->error("Server status %s", $res, $url); } } } }
function __construct() { $db = Factory::getDatabase(); $result = $db->query("select id from user"); $this->ids = $result->fetch_all(MYSQLI_ASSOC); }
private function authenticate() { if (empty($_SESSION['login']) && isset($_SESSION['post'])) { $db = Factory::getDatabase(); $_SESSION['login'] = $db->verifyUser($_SESSION['post']['u'], $_SESSION['post']['p']); } unset($_SESSION['post']); return !empty($_SESSION['login']); }
function setUserName($id, $name) { $db = Factory::getDatabase('master'); $db->query("update user set name = {$name} where id ={$id} limit 1"); }