예제 #1
0
 public function queue()
 {
     ini_set('memory_limit', '512M');
     if ($this->request->get('password') != $this->config->get('CLONE_STORE_API_KEY')) {
         return new RawResponse('Wrong password: '******'password');
     }
     $fetch = new NetworkFetch($this->request->get('url') . '?file=' . urlencode($this->request->get('fileName')) . '&id=' . $this->request->get('id') . '&password='******'CLONE_STORE_API_KEY')));
     $fetch->setAuth('admin', 'Cloning123!');
     $fetch->fetch();
     // validate hash
     $hashFetch = new NetworkFetch($this->request->get('hashUrl') . '?file=' . urlencode($this->request->get('fileName')) . '&id=' . $this->request->get('id') . '&password='******'CLONE_STORE_API_KEY')));
     $hashFetch->setAuth('admin', 'Cloning123!');
     $hashFetch->fetch();
     if (md5_file($fetch->getTmpFile()) == file_get_contents($hashFetch->getTmpFile())) {
         rename($fetch->getTmpFile(), $this->getFileDir() . $this->request->get('fileName'));
         return new RawResponse('OK');
     } else {
         return new RawResponse('MD5 mismatch ' . file_get_contents($hashFetch->getTmpFile()) . ' ' . substr(file_get_contents($fetch->getTmpFile()) . ' ' . filesize($fetch->getTmpFile()), -200));
     }
 }