示例#1
0
 public function processPasswordedReleases($echooutput = false)
 {
     $maxattemptstocheckpassworded = 5;
     $potentiallypasswordedfileregex = "/\\.(ace|cab|tar|gz)\$/i";
     $numfound = 0;
     $numpasswd = 0;
     $numpot = 0;
     $numnone = 0;
     $db = new DB();
     $nntp = new Nntp();
     $rar = new RarInfo();
     $rar->setMaxBytes(4000);
     if ($echooutput) {
         echo "Checking for passworded releases.\n\n";
     }
     //
     // Get out all releases which have not been checked more than max attempts for password.
     //
     $result = $db->query(sprintf("select ID from releases where passwordstatus between %d and -1", ($maxattemptstocheckpassworded + 1) * -1));
     if (count($result) > 0) {
         $nntp->doConnect();
         foreach ($result as $row) {
             //
             // get out all files for this release, if it contains no rars, mark as Releases::PASSWD_NONE
             // if it contains rars, try and retrieve the message for the first rar and inspect its filename
             // if rar file is encrypted set as Releases::PASSWD_RAR, if it contains an ace/cab etc
             // mark as Releases::PASSWD_POTENTIAL, otherwise set as Releases::PASSWD_NONE.
             //
             $numfound++;
             //
             // Go through the binaries for this release looking for a rar
             //
             $binresult = $db->query(sprintf("select binaries.ID, binaries.name, groups.name as groupname from binaries inner join groups on groups.ID = binaries.groupID where releaseID = %d order by relpart", $row["ID"]));
             $msgid = -1;
             $bingroup = "";
             foreach ($binresult as $binrow) {
                 if (preg_match("/\\W(?:part0*1|(?!part\\d+)[^.]+)\\.rar(?!\\.)/i", $binrow["name"])) {
                     $bingroup = $binrow["groupname"];
                     echo "Checking " . $binrow["name"] . " for password.\n";
                     $part = $db->queryOneRow(sprintf("select messageID from parts where binaryID = %d order by partnumber", $binrow["ID"]));
                     if (isset($part["messageID"])) {
                         $msgid = $part["messageID"];
                         break;
                     }
                 }
             }
             $passStatus = Releases::PASSWD_NONE;
             //
             // no part of binary found matching a rar, so it cant be progressed further
             //
             if ($msgid != -1) {
                 $fetchedBinary = $nntp->getMessage($bingroup, $msgid);
                 if ($fetchedBinary === false) {
                     $db->query(sprintf("update releases set passwordstatus = passwordstatus - 1 where ID = %d", $row["ID"]));
                     continue;
                 }
                 if ($rar->setData($fetchedBinary)) {
                     //
                     // whole archive password protected
                     //
                     if ($rar->isEncrypted) {
                         $passStatus = Releases::PASSWD_RAR;
                     } else {
                         $files = $rar->getFileList();
                         foreach ($files as $file) {
                             //
                             // individual file rar passworded
                             //
                             if ($file['pass'] == true) {
                                 $passStatus = Releases::PASSWD_RAR;
                                 break;
                             } else {
                                 if (preg_match($potentiallypasswordedfileregex, $file["name"])) {
                                     $passStatus = Releases::PASSWD_POTENTIAL;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             //
             // increment reporting stats
             //
             if ($passStatus == Releases::PASSWD_RAR) {
                 $numpasswd++;
             } elseif ($passStatus == Releases::PASSWD_POTENTIAL) {
                 $numpot++;
             } else {
                 $numnone++;
             }
             $db->query(sprintf("update releases set passwordstatus = %d where ID = %d", $passStatus, $row["ID"]));
         }
         $nntp->doQuit();
     }
     if ($echooutput) {
         echo sprintf("Finished checking for passwords for %d releases (%d passworded, %d potential, %d none).\n\n", $numfound, $numpasswd, $numpot, $numnone);
     }
 }
示例#2
0
文件: srrinfo.php 项目: kaibosh/nZEDb
 /**
  * Resets the instance variables before parsing new data.
  *
  * @return  void
  */
 protected function reset()
 {
     parent::reset();
     $this->client = '';
 }
示例#3
0
 public function isRar($rarfile)
 {
     // returns 0 if not rar
     // returns 1 if encrypted rar
     // returns 2 if passworded rar
     // returns array of files in the rar if normal rar
     unset($filelist);
     $rar = new RarInfo();
     if ($rar->setData($rarfile)) {
         if ($rar->isEncrypted) {
             return 1;
         } else {
             $files = $rar->getFileList();
             foreach ($files as $file) {
                 $filelist[] = $file['name'];
                 if ($file['pass'] == true) {
                     return 2;
                     // passworded
                 }
             }
             return $filelist;
             // normal rar
         }
     } else {
         return 0;
         // not a rar
     }
 }