Vergelijk commits

..

No commits in common. "modules/rel_mod_v6.x" and "master" have entirely different histories.

Bestand weergeven

@ -1,16 +1,11 @@
<?php
use OxidEsales\Eshop\Core\Base;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Model\BaseModel;
use OxidEsales\Eshop\Core\Registry;
include(__DIR__ . '/bootstrap.php');
/**
* Class deletePictures
*/
class deletePictures extends Base
class deletePictures extends oxSuperCfg
{
/*DO NOT CHANGE START */
public $sFolder = 'out/pictures/master/product/';
@ -45,6 +40,9 @@ class deletePictures extends Base
/*CHANGE BY USER END */
/**
* @throws oxConnectionException
*/
public function render()
{
if($this->checkForCookieAgreement())
@ -120,20 +118,18 @@ class deletePictures extends Base
<div class="row">
<div class="col-xs-12 col-md-6">
<form method="post">
<input type="hidden" name="action" value="'.$this->getFolderContents().'">
<input type="hidden" name="action" value="getFolderContents">
<input class="btn btn-sm btn-primary" type="submit" value="Bilder suchen / Verzeichnisse einlesen" title="Bilder suchen">
</form>
</div>
<div class="col-xs-12 col-md-6">
Was geschieht hier:<br><br>
<p>In den Unterverzeichnissen in <b>'.$this->sFolder.'</b> werden die enthalten Dateien ausgelesen.
Bei diesem Vorgang wird sofort gepr&uuml;ft welche Dateien <b>in der Tabelle oxarticles nicht</b> mehr enthalten sind.
Was geschieht hier:
<p>In den Unterverzeichnissen in '.$this->sFolder.' werden die enthalten Dateien ausgelesen. Bei diesem Vorgang wird sofort gepr&uuml;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.
<br><br>
Die Pr&uuml;fung erfolgt pro Bildslot und <b>nicht global</b> auf alle Verzeichnisse und Bildfelder in der Tabelle oxarticles.<br>
Dies bedeuted:
z.B. die Bilder im Ordner <b>"'.$this->sFolder.'1"</b> werden nur gegen das Feld <b>oxpic1</b> gepr&uuml;ft und nicht gegen oxpic2 oder oxthumb.
<br>
Die Pr&uuml;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&uuml;ft und nicht gegen oxpic2 oder oxthumb.
</p>
</div>
</div>
@ -280,8 +276,6 @@ class deletePictures extends Base
*/
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 +298,7 @@ class deletePictures extends Base
</div>
<div class="form-group col-xs-12">
<form method="get" action="'.$oRegistry::getConfig()->getSslShopUrl().$sPath.'">
<form method="get" action="'.oxRegistry::getConfig()->getSslShopUrl().$sPath.'">
<input type="hidden" name="action" value="setAgreement">
<div class="checkbox">
<label for="agreement"><input name="agreement" id="agreement" type="checkbox" value="true">Ich habe die oben genannten Punkte gelesen und f&uuml;hre das Script auf eigene Verantwortung aus.</label>
@ -342,35 +336,31 @@ class deletePictures extends Base
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($oRegistry::getConfig()->getSslShopUrl().$sPath);
$aUrl = parse_url(oxRegistry::getConfig()->getSslShopUrl().$sPath);
$sPath = ltrim($aUrl['path'],'/');
if($oRegistry::getConfig()->getRequestParameter('agreement') == true)
if(oxRegistry::getConfig()->getRequestParameter('agreement') == true)
{
setcookie($this->sCookieName, true, strtotime( '+7 days' ));
}
$oRegistry::getUtils()->redirect($oRegistry::getConfig()->getSslShopUrl().$sPath,false);
oxRegistry::getUtils()->redirect(oxRegistry::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($oRegistry::getConfig()->getSslShopUrl().$sPath);
$aUrl = parse_url(oxRegistry::getConfig()->getSslShopUrl().$sPath);
$sPath = ltrim($aUrl['path'],'/');
setcookie($this->sCookieName, false, time()-1000);
$oRegistry::getUtils()->redirect($oRegistry::getConfig()->getSslShopUrl().$sPath,false);
oxRegistry::getUtils()->redirect(oxRegistry::getConfig()->getSslShopUrl().$sPath,false);
}
/**
@ -440,16 +430,17 @@ class deletePictures extends Base
/**
* todo: Pr&uuml;fung af unvollst&auml;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);
@ -473,9 +464,7 @@ class deletePictures extends Base
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) == '')
@ -502,12 +491,12 @@ class deletePictures extends Base
$aPictureData['D3DATE'] = date ("Y-m-d H:i:s");
$aPictureData['OXID'] = md5($entry.$sTmpFolder.date ("Y-m-d H:i:s"));
$oItem = oxNew(BaseModel::class);
/** @var oxbase $oItem */
$oItem = oxNew("oxbase");
$oItem->init("d3lostpictures");
$oItem->assign($aPictureData);
$oItem->save();
}
//die();
$this->setStartStopFlag($sTmpFolder,'STOP');
@ -526,12 +515,11 @@ class deletePictures extends Base
/**
* @return array
* @throws oxConnectionException
*/
public function getLostPicturesSlotsFromTable()
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
select d3folder from d3lostpictures
@ -577,18 +565,17 @@ MYSQL;
* @param $sSlot
*
* @return array
* @throws oxConnectionException
*/
public function getAllPicturesFromTable($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
//echo $sSlot;
$sPictureDbField = 'oxpic'.$sSlot;
if($sSlot == 'thumb' || $sSlot == 'icon'){
$sPictureDbField = 'ox'.$sSlot;
}
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
select {$sPictureDbField} from oxarticles where {$sPictureDbField} != ''
@ -609,9 +596,7 @@ MYSQL;
*/
public function getPathToShop()
{
$oRegistry = oxNew(Registry::class);
return $oRegistry::getConfig()->getConfigParam('sShopDir');
return oxRegistry::getConfig()->getConfigParam('sShopDir');
}
@ -637,6 +622,8 @@ MYSQL;
/**
* @param $sSlot
*
* @throws oxConnectionException
*/
public function getLostPicturesSlot($sSlot)
{
@ -648,15 +635,14 @@ MYSQL;
* @param $sSlot
*
* @return string
* @throws oxConnectionException
*/
public function getLostPictureAsTableContent($aPictures)
{
$oRegistry = oxNew(Registry::class);
$this->sOutPutTitle = 'Anzeige Bilder';
//dumpvar($aPictures);
$sUrlToFolder = $oRegistry::getConfig()->getShopUrl().$this->sFolder;
$sUrlToFolder = oxRegistry::getConfig()->getShopUrl().$this->sFolder;
$sContent = '<table class="table table-striped table-hover table-sm">
<tr>
@ -674,7 +660,7 @@ MYSQL;
$sContent .= '
<tr>
<td><a href="'.$sPathWithPicture.'" target="_blank"><img src="'.$sPathWithPicture.'" style="max-height: 100px" alt="'.$sPathWithPicture.'"></a></td>
<td><a href="'.$sPathWithPicture.'" target="_blank"><img src="'.$sPathWithPicture.'" style="max-height: 100px"></a></td>
<td>'.$this->sFolder.$aPicture['D3FOLDER'].'/'.$sFileName.'</td>
<td>'.$aPicture['D3WIDTH'].'px * '.$aPicture['D3HEIGHT'].'px</td>
<td>'.$this->formatBytes($aPicture['D3FILESIZE']).'</td>
@ -689,11 +675,10 @@ MYSQL;
/**
* @param $sSlot
* @throws oxConnectionException
*/
public function getLostPicturesInCsvFile($sSlot)
{
$oRegistry = oxNew(Registry::class);
//$sUrlToFolder = oxRegistry::getConfig()->getShopUrl().$this->sFolder;
$sSeparator = '"';
$sColumn = ";".PHP_EOL;
@ -708,7 +693,7 @@ MYSQL;
$sFileContent .= $sSeparator.$this->sFolder.$aPicture['D3FOLDER'].'/'.$sFileName.$sSeparator.$sColumn;
}
$oUtils = $oRegistry::getUtils();
$oUtils = oxRegistry::getUtils();
$sFilename = 'Folder_'.$sSlot.'.csv';
ob_start();
//$sPDF = ob_get_contents();
@ -719,7 +704,7 @@ MYSQL;
$oUtils->setHeader("Expires: 0");
$oUtils->setHeader("Content-type: application/csv");
$oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename);
$oRegistry::getUtils()->showMessageAndExit($sCsv);
oxRegistry::getUtils()->showMessageAndExit($sCsv);
}
@ -727,12 +712,11 @@ MYSQL;
* @param $sSlot
*
* @return mixed
* @throws oxConnectionException
*/
public function getLostPictures($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
/*
$sPictureDbField = 'oxpic'.$sSlot;
@ -767,12 +751,11 @@ MYSQL;
* @param $sSlot
*
* @return false|string
* @throws oxConnectionException
*/
public function getCountLostPictures($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
select count(oxid) as files from d3lostpictures
@ -785,6 +768,7 @@ MYSQL;
/**
* @return array
* @throws oxConnectionException
*/
public function getLostPictureGroupByFolder()
{
@ -793,15 +777,13 @@ MYSQL;
return array();
}
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
select d3folder, count(oxid) as files, sum(d3filesize) as size from d3lostpictures
where 1
group by d3folder
order by LENGTH(cast(d3folder as CHAR)),d3folder
order by LENGTH(cast(d3folder as CHAR)),d3folder
MYSQL;
$aRes = $oDb->getAll($sQuery);
@ -818,6 +800,7 @@ MYSQL;
* @param $sSlot
*
* @return false|string
* @throws oxConnectionException
*/
public function getCountLostPictureGroupByFolder($sSlot)
{
@ -826,9 +809,7 @@ MYSQL;
$sPictureDbField = 'ox'.$sSlot;
}
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
select count(oxid) from
@ -847,6 +828,7 @@ MYSQL;
/**
* @return string
* @throws oxConnectionException
*/
public function getLostPictureGroupByFolderAsHtml()
{
@ -930,6 +912,7 @@ MYSQL;
/**
* @return string
* @throws oxConnectionException
*/
public function getLostPicturesDeleteButtonsAsHtml()
{
@ -974,6 +957,7 @@ MYSQL;
}
/**
* @return string
* @throws oxConnectionException
*/
public function getLostPicturesAsCsvFile()
{
@ -1018,6 +1002,7 @@ MYSQL;
/**
* @return string
* @throws oxConnectionException
*/
public function getLostPicturesDisplayButtonsAsHtml()
{
@ -1080,12 +1065,11 @@ MYSQL;
* @param $sSlot
*
* @return string
* @throws oxConnectionException
*/
public function deleteLostPictures($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
SELECT oxid, D3FILENAME as File
@ -1119,6 +1103,8 @@ MYSQL;
/**
* @param $sSlot
* @param $sType
*
* @throws oxSystemComponentException
*/
public function setStartStopFlag($sSlot,$sType)
{
@ -1135,7 +1121,8 @@ MYSQL;
$aPictureData['D3DATE'] = date ("Y-m-d H:i:s");
$aPictureData['OXID'] = md5($sType.$sSlot.date ("Y-m-d H:i:s"));
$oItem = oxNew(BaseModel::class);
/** @var oxbase $oItem */
$oItem = oxNew("oxbase");
$oItem->init("d3lostpictures");
$oItem->assign($aPictureData);
@ -1146,14 +1133,11 @@ MYSQL;
* @param $sSlot
*
* @return object
* @throws oxConnectionException
*/
public function deleteStartStopFlag($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
DELETE FROM `d3lostpictures`
@ -1167,12 +1151,11 @@ MYSQL;
* @param $sSlot
*
* @return false|string
* @throws oxConnectionException
*/
public function hasFinishedImport($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
SELECT count(oxid) as countflag FROM `d3lostpictures`
@ -1192,12 +1175,11 @@ MYSQL;
/**
* @return array
* @throws oxConnectionException
*/
public function checkAllSlotsIfFinished()
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
SELECT d3folder, count(oxid) as countflag FROM `d3lostpictures`
@ -1243,11 +1225,17 @@ MYSQL;
return true;
}
/**
* @throws oxConnectionException
*/
public function createTable()
{
return setupDeletePicturesTable::createTable();
}
/**
* @throws oxConnectionException
*/
public function dropTable()
{
if($this->tableExist() == true) {
@ -1261,6 +1249,7 @@ MYSQL;
* @param $sSlot
*
* @return bool|void
* @throws oxConnectionException
*/
public function truncateTable($sSlot)
{
@ -1271,6 +1260,7 @@ MYSQL;
/**
* @return bool
* @throws oxConnectionException
*/
public function tableExist()
{
@ -1293,7 +1283,7 @@ MYSQL;
/**
* Class setupDeletePicturesTable
*/
class setupDeletePicturesTable extends Base
class setupDeletePicturesTable extends oxSuperCfg
{
public $_sTable = 'd3lostpictures';
@ -1302,9 +1292,7 @@ class setupDeletePicturesTable extends Base
*/
public static function createTable()
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
@ -1337,9 +1325,7 @@ MYSQL;
*/
public static function dropTable()
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
Drop table `d3lostpictures`;
@ -1355,9 +1341,7 @@ MYSQL;
*/
public static function truncateTable($sSlot)
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery =
<<<MYSQL
TRUNCATE `d3lostpictures`;
@ -1381,9 +1365,7 @@ MYSQL;
*/
public static function tableExist()
{
$oDatabaseProvider = oxNew(DatabaseProvider::class);
$oDb = $oDatabaseProvider::getDb($oDatabaseProvider::FETCH_MODE_ASSOC);
$oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
$sQuery = <<<MYSQL
SHOW TABLES LIKE 'd3lostpictures';
MYSQL;
@ -1394,10 +1376,8 @@ MYSQL;
/** @var deletePictures $oBilderLesen */
$oDeletePictures = oxNew('deletePictures');
$oRegistry = oxNew(Registry::class);
$sAction = $oRegistry::getConfig()->getRequestParameter('action');
$sParameter = $oRegistry::getConfig()->getRequestParameter('parameter');
$sAction = oxRegistry::getConfig()->getRequestParameter('action');
$sParameter = oxRegistry::getConfig()->getRequestParameter('parameter');
if(trim($sAction) != '')
{
$oDeletePictures->{$sAction}($sParameter);