public function dbRemoval(array $Settings)
    {
        $ID = isset($Settings["Name"]) ? $Settings["Name"] : null;
        $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24 * 60 * 60);
        $TS = time() - $Expiry;

        /* Compute the paths */
        $Database = $this->CacheFolder . "/" . $this->CacheDB;
        $Index = $this->CacheFolder . "/" . $this->CacheIndex;
        $DatabaseTemp = $this->CacheFolder . "/" . $this->CacheDB . ".tmp";
        $IndexTemp = $this->CacheFolder . "/" . $this->CacheIndex . ".tmp";

        /* Single file removal */
        if ($ID != null) {
            /* Retrieve object informations */
            $Object = $this->isInCache($ID, true);

            /* If it's not in the cache DB, go away */
            if (!$Object) {
                return(0);
            }
        }

        /* Create the temporary files */
        if (!file_exists($DatabaseTemp)) {
            touch($DatabaseTemp);
        }
        if (!file_exists($IndexTemp)) {
            touch($IndexTemp);
        }

        /* Open the file handles */
        $IndexHandle = @fopen($Index, "r");
        $IndexTempHandle = @fopen($IndexTemp, "w");
        $DBHandle = @fopen($Database, "r");
        $DBTempHandle = @fopen($DatabaseTemp, "w");

        /* Remove the selected ID from the database */
        while (!feof($IndexHandle)) {
            $Entry = fgets($IndexHandle, 4096);
            $Entry = str_replace("\r", "", $Entry);
            $Entry = str_replace("\n", "", $Entry);
            $Settings = preg_split("/,/", $Entry);

            if ($Entry != "") {
                $PicID = $Settings[0];
                $DBPos = $Settings[1];
                $PicSize = $Settings[2];
                $GeneratedTS = $Settings[3];
                $Hits = $Settings[4];

                if ($Settings[0] != $ID && $GeneratedTS > $TS) {
                    $CurrentPos = ftell($DBTempHandle);
                    fwrite(
                        $IndexTempHandle,
                        sprintf(
                            "%s,%s,%s,%s,%s\r\n",
                            $PicID,
                            $CurrentPos,
                            $PicSize,
                            $GeneratedTS,
                            $Hits
                        )
                    );

                    fseek($DBHandle, $DBPos);
                    $Picture = fread($DBHandle, $PicSize);
                    fwrite($DBTempHandle, $Picture);
                }
            }
        }

        /* Close the handles */
        fclose($IndexHandle);
        fclose($IndexTempHandle);
        fclose($DBHandle);
        fclose($DBTempHandle);

        /* Remove the prod files */
        unlink($Database);
        unlink($Index);

        /* Swap the temp & prod DB */
        rename($DatabaseTemp, $Database);
        rename($IndexTemp, $Index);
    }
public function dbRemoval(array $Settings)
    {
        $ID = isset($Settings["Name"]) ? $Settings["Name"] : null;
        $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24 * 60 * 60);
        $TS = time() - $Expiry;

        /* Compute the paths */
        $Database = $this->CacheFolder . "/" . $this->CacheDB;
        $Index = $this->CacheFolder . "/" . $this->CacheIndex;
        $DatabaseTemp = $this->CacheFolder . "/" . $this->CacheDB . ".tmp";
        $IndexTemp = $this->CacheFolder . "/" . $this->CacheIndex . ".tmp";

        /* Single file removal */
        if ($ID != null) {
            /* Retrieve object informations */
            $Object = $this->isInCache($ID, true);

            /* If it's not in the cache DB, go away */
            if (!$Object) {
                return(0);
            }
        }

        /* Create the temporary files */
        if (!file_exists($DatabaseTemp)) {
            touch($DatabaseTemp);
        }
        if (!file_exists($IndexTemp)) {
            touch($IndexTemp);
        }

        /* Open the file handles */
        $IndexHandle = @fopen($Index, "r");
        $IndexTempHandle = @fopen($IndexTemp, "w");
        $DBHandle = @fopen($Database, "r");
        $DBTempHandle = @fopen($DatabaseTemp, "w");

        /* Remove the selected ID from the database */
        while (!feof($IndexHandle)) {
            $Entry = fgets($IndexHandle, 4096);
            $Entry = str_replace("\r", "", $Entry);
            $Entry = str_replace("\n", "", $Entry);
            $Settings = preg_split("/,/", $Entry);

            if ($Entry != "") {
                $PicID = $Settings[0];
                $DBPos = $Settings[1];
                $PicSize = $Settings[2];
                $GeneratedTS = $Settings[3];
                $Hits = $Settings[4];

                if ($Settings[0] != $ID && $GeneratedTS > $TS) {
                    $CurrentPos = ftell($DBTempHandle);
                    fwrite(
                        $IndexTempHandle,
                        sprintf(
                            "%s,%s,%s,%s,%s\r\n",
                            $PicID,
                            $CurrentPos,
                            $PicSize,
                            $GeneratedTS,
                            $Hits
                        )
                    );

                    fseek($DBHandle, $DBPos);
                    $Picture = fread($DBHandle, $PicSize);
                    fwrite($DBTempHandle, $Picture);
                }
            }
        }

        /* Close the handles */
        fclose($IndexHandle);
        fclose($IndexTempHandle);
        fclose($DBHandle);
        fclose($DBTempHandle);

        /* Remove the prod files */
        unlink($Database);
        unlink($Index);

        /* Swap the temp & prod DB */
        rename($DatabaseTemp, $Database);
        rename($IndexTemp, $Index);
    }
public function dbRemoval ( array $ Settings ) { $ ID = isset ( $ Settings [ "Name" ] ) ? $ Settings [ "Name" ] : null ; $ Expiry = isset ( $ Settings [ "Expiry" ] ) ? $ Settings [ "Expiry" ] : - ( 24 * 60 * 60 ) ; $ TS = time ( ) - $ Expiry ; /* Compute the paths */ $ Database = $ this -> CacheFolder . "/" . $ this -> CacheDB ; $ Index = $ this -> CacheFolder . "/" . $ this -> CacheIndex ; $ DatabaseTemp = $ this -> CacheFolder . "/" . $ this -> CacheDB . ".tmp" ; $ IndexTemp = $ this -> CacheFolder . "/" . $ this -> CacheIndex . ".tmp" ; /* Single file removal */ if ( $ ID != null ) { /* Retrieve object informations */ $ Object = $ this -> isInCache ( $ ID , true ) ; /* If it's not in the cache DB, go away */ if ( ! $ Object ) { return ( 0 ) ; } } /* Create the temporary files */ if ( ! file_exists ( $ DatabaseTemp ) ) { touch ( $ DatabaseTemp ) ; } if ( ! file_exists ( $ IndexTemp ) ) { touch ( $ IndexTemp ) ; } /* Open the file handles */ $ IndexHandle = @ fopen ( $ Index , "r" ) ; $ IndexTempHandle = @ fopen ( $ IndexTemp , "w" ) ; $ DBHandle = @ fopen ( $ Database , "r" ) ; $ DBTempHandle = @ fopen ( $ DatabaseTemp , "w" ) ; /* Remove the selected ID from the database */ while ( ! feof ( $ IndexHandle ) ) { $ Entry = fgets ( $ IndexHandle , 4096 ) ; $ Entry = str_replace ( "\r" , "" , $ Entry ) ; $ Entry = str_replace ( "\n" , "" , $ Entry ) ; $ Settings = preg_split ( "/,/" , $ Entry ) ; if ( $ Entry != "" ) { $ PicID = $ Settings [ 0 ] ; $ DBPos = $ Settings [ 1 ] ; $ PicSize = $ Settings [ 2 ] ; $ GeneratedTS = $ Settings [ 3 ] ; $ Hits = $ Settings [ 4 ] ; if ( $ Settings [ 0 ] != $ ID && $ GeneratedTS > $ TS ) { $ CurrentPos = ftell ( $ DBTempHandle ) ; fwrite ( $ IndexTempHandle , sprintf ( "%s,%s,%s,%s,%s\r\n" , $ PicID , $ CurrentPos , $ PicSize , $ GeneratedTS , $ Hits ) ) ; fseek ( $ DBHandle , $ DBPos ) ; $ Picture = fread ( $ DBHandle , $ PicSize ) ; fwrite ( $ DBTempHandle , $ Picture ) ; } } } /* Close the handles */ fclose ( $ IndexHandle ) ; fclose ( $ IndexTempHandle ) ; fclose ( $ DBHandle ) ; fclose ( $ DBTempHandle ) ; /* Remove the prod files */ unlink ( $ Database ) ; unlink ( $ Index ) ; /* Swap the temp & prod DB */ rename ( $ DatabaseTemp , $ Database ) ; rename ( $ IndexTemp , $ Index ) ; }
Remove with specified criterias.

@param array $Settings
@return int
Remove with specified criterias .