diff --git a/deletePictures.php b/deletePictures.php index e3680de..24050e9 100644 --- a/deletePictures.php +++ b/deletePictures.php @@ -1,8 +1,8 @@ checkForCookieAgreement()) @@ -124,18 +120,20 @@ class deletePictures extends oxSuperCfg
- +
- Was geschieht hier: -

In den Unterverzeichnissen in '.$this->sFolder.' werden die enthalten Dateien ausgelesen. Bei diesem Vorgang wird sofort geprüft welche Dateien in der Tabelle oxarticles nicht mehr enthalten sind. + Was geschieht hier:

+

In den Unterverzeichnissen in '.$this->sFolder.' werden die enthalten Dateien ausgelesen. + Bei diesem Vorgang wird sofort geprüft welche Dateien in der Tabelle oxarticles nicht mehr enthalten sind. Ist ein Bild nicht mehr an einem Artikel hinterlegt, dann erfolgt die Abspeicherung in der Tabelle d3lostpictures. -
- Die Prüfung erfolgt pro Bildslot und nicht global auf alle Verzeichnisse und Bildfelder in der Tabelle oxarticles. Dies bedeuted: - z.B. die Bilder im Ordner "'.$this->sFolder.'1" werden nur gegen das Feld oxpic1 geprüft und nicht gegen oxpic2 oder oxthumb. +

+ Die Prüfung erfolgt pro Bildslot und nicht global auf alle Verzeichnisse und Bildfelder in der Tabelle oxarticles.
+ Dies bedeuted: + z.B. die Bilder im Ordner "'.$this->sFolder.'1" werden nur gegen das Feld oxpic1 geprüft und nicht gegen oxpic2 oder oxthumb.

@@ -282,6 +280,8 @@ class deletePictures extends oxSuperCfg */ public function getAgreementForm() { + $oRegistry = oxNew(Registry::class); + $sPath = $_SERVER["ORIG_PATH_INFO"]?$_SERVER["ORIG_PATH_INFO"]:$_SERVER['REQUEST_URI']; $sPath = basename($sPath); $sOutput = $this->getHtmlHeader(); @@ -304,7 +304,7 @@ class deletePictures extends oxSuperCfg
-
+
@@ -342,31 +342,35 @@ class deletePictures extends oxSuperCfg public function setAgreement() { + $oRegistry = oxNew(Registry::class); + $sPath = $_SERVER["ORIG_PATH_INFO"]?$_SERVER["ORIG_PATH_INFO"]:$_SERVER['REQUEST_URI']; $sPath = basename($sPath); //action=setAgreement - entfernen - $aUrl = parse_url(oxRegistry::getConfig()->getSslShopUrl().$sPath); + $aUrl = parse_url($oRegistry::getConfig()->getSslShopUrl().$sPath); $sPath = ltrim($aUrl['path'],'/'); - if(oxRegistry::getConfig()->getRequestParameter('agreement') == true) + if($oRegistry::getConfig()->getRequestParameter('agreement') == true) { setcookie($this->sCookieName, true, strtotime( '+7 days' )); } - oxRegistry::getUtils()->redirect(oxRegistry::getConfig()->getSslShopUrl().$sPath,false); + $oRegistry::getUtils()->redirect($oRegistry::getConfig()->getSslShopUrl().$sPath,false); } public function removeAgreement() { + $oRegistry = oxNew(Registry::class); + $sPath = $_SERVER["ORIG_PATH_INFO"]?$_SERVER["ORIG_PATH_INFO"]:$_SERVER['REQUEST_URI']; $sPath = basename($sPath); //action=removeAgreement - entfernen - $aUrl = parse_url(oxRegistry::getConfig()->getSslShopUrl().$sPath); + $aUrl = parse_url($oRegistry::getConfig()->getSslShopUrl().$sPath); $sPath = ltrim($aUrl['path'],'/'); setcookie($this->sCookieName, false, time()-1000); - oxRegistry::getUtils()->redirect(oxRegistry::getConfig()->getSslShopUrl().$sPath,false); + $oRegistry::getUtils()->redirect($oRegistry::getConfig()->getSslShopUrl().$sPath,false); } /** @@ -436,17 +440,16 @@ class deletePictures extends oxSuperCfg /** * todo: Prüfung af unvollständig eingelesenen Ordner - * - * @throws oxConnectionException - * @throws oxSystemComponentException */ public function getFolderContents() { + //Tabelle leeren //$this->truncateTable(); $aSlotsFromLostPictures = $this->getLostPicturesSlotsFromTable(); $sFolder = $this->getPathToShop().$this->sFolder; + $aFolder = $this->getFolders(); natsort($aFolder); @@ -470,7 +473,9 @@ class deletePictures extends oxSuperCfg if ($handle = opendir($sFolder.$sTmpFolder)) { $aFilesOxPics = $this->getAllPicturesFromTable($sTmpFolder); + $this->setStartStopFlag($sTmpFolder,'START'); + while (false !== ($entry = readdir($handle))) { if ($entry == "." || $entry == ".." || $entry == "dir.txt" || trim($entry) == '') @@ -497,12 +502,12 @@ class deletePictures extends oxSuperCfg $aPictureData['D3DATE'] = date ("Y-m-d H:i:s"); $aPictureData['OXID'] = md5($entry.$sTmpFolder.date ("Y-m-d H:i:s")); - /** @var oxbase $oItem */ - $oItem = oxNew("oxbase"); + $oItem = oxNew(BaseModel::class); $oItem->init("d3lostpictures"); $oItem->assign($aPictureData); $oItem->save(); + } //die(); $this->setStartStopFlag($sTmpFolder,'STOP'); @@ -521,11 +526,12 @@ class deletePictures extends oxSuperCfg /** * @return array - * @throws DatabaseConnectionException|DatabaseErrorException */ public function getLostPicturesSlotsFromTable() { - $oDb = DatabaseProvider::getDb('FETCH_MODE_ASSOC'); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<getConfigParam('sShopDir'); + $oRegistry = oxNew(Registry::class); + + return $oRegistry::getConfig()->getConfigParam('sShopDir'); } @@ -628,8 +637,6 @@ MYSQL; /** * @param $sSlot - * - * @throws oxConnectionException */ public function getLostPicturesSlot($sSlot) { @@ -641,14 +648,15 @@ MYSQL; * @param $sSlot * * @return string - * @throws oxConnectionException */ public function getLostPictureAsTableContent($aPictures) { + $oRegistry = oxNew(Registry::class); + $this->sOutPutTitle = 'Anzeige Bilder'; //dumpvar($aPictures); - $sUrlToFolder = oxRegistry::getConfig()->getShopUrl().$this->sFolder; + $sUrlToFolder = $oRegistry::getConfig()->getShopUrl().$this->sFolder; $sContent = ' @@ -666,7 +674,7 @@ MYSQL; $sContent .= ' - + @@ -681,10 +689,11 @@ MYSQL; /** * @param $sSlot - * @throws oxConnectionException */ public function getLostPicturesInCsvFile($sSlot) { + $oRegistry = oxNew(Registry::class); + //$sUrlToFolder = oxRegistry::getConfig()->getShopUrl().$this->sFolder; $sSeparator = '"'; $sColumn = ";".PHP_EOL; @@ -699,7 +708,7 @@ MYSQL; $sFileContent .= $sSeparator.$this->sFolder.$aPicture['D3FOLDER'].'/'.$sFileName.$sSeparator.$sColumn; } - $oUtils = oxRegistry::getUtils(); + $oUtils = $oRegistry::getUtils(); $sFilename = 'Folder_'.$sSlot.'.csv'; ob_start(); //$sPDF = ob_get_contents(); @@ -710,7 +719,7 @@ MYSQL; $oUtils->setHeader("Expires: 0"); $oUtils->setHeader("Content-type: application/csv"); $oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename); - oxRegistry::getUtils()->showMessageAndExit($sCsv); + $oRegistry::getUtils()->showMessageAndExit($sCsv); } @@ -718,12 +727,12 @@ MYSQL; * @param $sSlot * * @return mixed - * @throws oxConnectionException - * @throws DatabaseConnectionException|DatabaseErrorException */ public function getLostPictures($sSlot) { - $oDb = DatabaseProvider::getDb(oxDb::FETCH_MODE_ASSOC); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); /* $sPictureDbField = 'oxpic'.$sSlot; @@ -758,11 +767,12 @@ MYSQL; * @param $sSlot * * @return false|string - * @throws DatabaseConnectionException */ public function getCountLostPictures($sSlot) { - $oDb = DatabaseProvider::getDb('FETCH_MODE_ASSOC'); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<getAll($sQuery); @@ -808,7 +818,6 @@ MYSQL; * @param $sSlot * * @return false|string - * @throws DatabaseConnectionException */ public function getCountLostPictureGroupByFolder($sSlot) { @@ -817,7 +826,9 @@ MYSQL; $sPictureDbField = 'ox'.$sSlot; } - $oDb = DatabaseProvider::getDb('FETCH_MODE_ASSOC'); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<init("d3lostpictures"); $oItem->assign($aPictureData); @@ -1141,11 +1146,14 @@ MYSQL; * @param $sSlot * * @return object - * @throws DatabaseConnectionException|DatabaseErrorException */ public function deleteStartStopFlag($sSlot) { - $oDb = DatabaseProvider::getDb('FETCH_MODE_ASSOC'); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<tableExist() == true) { @@ -1257,7 +1261,6 @@ MYSQL; * @param $sSlot * * @return bool|void - * @throws oxConnectionException */ public function truncateTable($sSlot) { @@ -1268,7 +1271,6 @@ MYSQL; /** * @return bool - * @throws DatabaseConnectionException */ public function tableExist() { @@ -1291,17 +1293,18 @@ MYSQL; /** * Class setupDeletePicturesTable */ -class setupDeletePicturesTable extends oxSuperCfg +class setupDeletePicturesTable extends Base { public $_sTable = 'd3lostpictures'; /** - * @throws DatabaseConnectionException - * @throws DatabaseErrorException + * @throws oxConnectionException */ public static function createTable() { - $oDb = DatabaseProvider::getDb('FETCH_MODE_ASSOC'); + $oDatabaseProvider = oxNew(DatabaseProvider::class); + + $oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<getRequestParameter('action'); -$sParameter = $oRegistry->getRequestParameter('parameter'); +$sAction = $oRegistry::getConfig()->getRequestParameter('action'); +$sParameter = $oRegistry::getConfig()->getRequestParameter('parameter'); if(trim($sAction) != '') { $oDeletePictures->{$sAction}($sParameter);
'.$sPathWithPicture.' '.$this->sFolder.$aPicture['D3FOLDER'].'/'.$sFileName.' '.$aPicture['D3WIDTH'].'px * '.$aPicture['D3HEIGHT'].'px '.$this->formatBytes($aPicture['D3FILESIZE']).'