Example #1
0
 public function webfan_downloads_download($lid, &$r, $post = array(), $send_cookies = array())
 {
     $html = '';
     $html .= 'Download package...' . "\n";
     $C = new \webdof\Http\Client();
     @set_time_limit(ini_get('max_execution_time'));
     $idfile = time() . mt_rand(1000, 9999);
     $r = $C->request('http://www.webfan.de/dl/get.php?lid=' . $lid . '&idfile=' . $idfile, 'POST', $post, $send_cookies, E_USER_WARNING);
     @set_time_limit(ini_get('max_execution_time'));
     if (intval($r['status']) !== 200) {
         $html .= $this->e($this->lang('__DOWNLOAD_FAILED__'));
         return $html;
     }
     $check = sha1($r['body']);
     $url_checksum = 'http://www.webfan.de/dl/get.php?lid=' . $lid . '&ressource=checksum&';
     $url_checksum .= 'sha1=' . $check . '&idfile=' . $idfile;
     $checkfile = $C->SimpleGet($url_checksum);
     $checksum_server = trim($checkfile);
     if ($check !== $checksum_server) {
         $r['status'] = 409;
         $html .= $this->e($this->lang('__CHECKSUM_INVALID__'));
         return $html;
     }
     return $html;
 }
Example #2
0
 public function make_pass_3(&$opt)
 {
     if (isset($opt['pwdstate']) && $opt['pwdstate'] === 'decrypted') {
         return true;
     }
     if (isset($opt['pwdstate']) && $opt['pwdstate'] === 'error') {
         return false;
     }
     if (!isset(self::$rtc['CERTS'])) {
         self::$rtc['CERTS'] = array();
     }
     $hash = sha1($opt['CERT']);
     $u = parse_url($opt['CERT']);
     $url = $opt['CERT'];
     if (!isset(self::$rtc['CERTS'][$hash]) && ($u === false || !isset(self::$rtc['CERTS'][$url]))) {
         if ($u !== false && count($u) > 1 && !preg_match("/CERTIFICATE/", $opt['CERT'])) {
             if (isset($u['scheme']) && isset($u['host'])) {
                 $h = explode('.', $u['host']);
                 $h = array_reverse($h);
                 if ($h[0] === 'de' && ($h[1] === 'webfan' || $h[1] === 'frdl')) {
                     if (class_exists('\\webdof\\Http\\Client')) {
                         $Http = new \webdof\Http\Client();
                         $post = array();
                         $send_cookies = array();
                         $r = $Http->request($opt['CERT'], 'GET', $post, $send_cookies, E_USER_WARNING);
                     } else {
                         $c = file_get_contents($opt['CERT']);
                         $r = array();
                         $r['status'] = preg_match("/CERTIFICATE/", $c) ? 200 : 400;
                         $r['body'] = $c;
                     }
                     if (intval($r['status']) === 200) {
                         $CERT = trim($r['body']);
                     } else {
                         $opt['pwdstate'] = '404';
                         return false;
                     }
                 }
             } else {
                 $CERT = trim(file_get_contents($opt['CERT']));
             }
             $key = $url;
             if (!isset(self::$rtc['CERTS'][$key])) {
                 self::$rtc['CERTS'][$key] = array();
             }
             self::$rtc['CERTS'][$key]['crt'] = $CERT;
         } elseif (preg_match("/CERTIFICATE/", $opt['CERT'])) {
             $key = $hash;
             if (!isset(self::$rtc['CERTS'][$key])) {
                 self::$rtc['CERTS'][$key] = array();
             }
             $CERT = utf8_encode($opt['CERT']);
             $CERT = $this->loadPK($CERT);
             if ($CERT === false) {
                 trigger_error('Cannot procces certificate info in ' . __METHOD__ . ' line ' . __LINE__, E_USER_WARNING);
                 return false;
             }
             $CERT = $this->save($CERT, self::B_CERTIFICATE, self::E_CERTIFICATE);
             self::$rtc['CERTS'][$key]['crt'] = $CERT;
         } else {
             trigger_error('Cannot procces certificate info in ' . __METHOD__ . ' line ' . __LINE__, E_USER_WARNING);
             return false;
         }
     } elseif (isset(self::$rtc['CERTS'][$hash])) {
         $key = $hash;
     } elseif (isset(self::$rtc['CERTS'][$url])) {
         $key = $url;
     } else {
         trigger_error('Cannot procces certificate info in ' . __METHOD__ . ' line ' . __LINE__, E_USER_WARNING);
         return false;
     }
     $this->setLib(1);
     if (!isset(self::$rtc['CERTS'][$key]['PublicKey'])) {
         $PublicKey = $this->getPublKeyByCRT(self::$rtc['CERTS'][$key]['crt']);
         self::$rtc['CERTS'][$key]['PublicKey'] = $PublicKey;
     }
     $success = $this->decrypt($opt['pass'], self::$rtc['CERTS'][$key]['PublicKey'], $new_pass);
     if ($success === true) {
         $opt['pass'] = $new_pass;
         $opt['pwdstate'] = 'decrypted';
     } else {
         $opt['pwdstate'] = 'error';
         // unset(self::$rtc['CERTS'][$key]);
     }
     return $success;
 }