Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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);
             }
         }
     }
 }
Esempio n. 4
0
 function __construct()
 {
     $db = Factory::getDatabase();
     $result = $db->query("select id from user");
     $this->ids = $result->fetch_all(MYSQLI_ASSOC);
 }
Esempio n. 5
0
 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']);
 }
Esempio n. 6
0
 function setUserName($id, $name)
 {
     $db = Factory::getDatabase('master');
     $db->query("update user set name = {$name} where id ={$id} limit 1");
 }