Когда выполняется следующий скрипт PHP:
<?php
include "imageManager.php";
include "imageHandling/spritesheet.php";
include "updateWindow.php";
include_once "dbConnection.php";
class deleteSoftware{
private $conn;
private $tableName;
public function __construct($name){
//Database Connection
$this->connectDatabase();
//Delete the Icon from the image pool
$tempFileManagerObject = new fileManager();
$tempFileManagerObject->setSrc("../ICONS/");
$deletedImageName = $tempFileManagerObject->getImageNameFromSoftwareName($name);
$tempFileManagerObject->delete("../ICONS/", $deletedImageName);
$tempFileManagerObject->deleteImageRenaming($deletedImageName);
//Deleting the record from the database
$prio = $tempFileManagerObject->getPriorityFromSoftwareName($name);
$subCategory = $tempFileManagerObject->getSubCategoryFromSoftwareName($name);
$this->tableName = $subCategory;
$this->conn->query("delete from ".$subCategory." where priority=".$prio);
$this->decrementPriorityInTable($prio);
//Delete from updateWindow if exist
$updateObject = new updateWindow();
$updateObject->deleteUpdate($name);
//Making sprite Sheet and moving to home directory
echo "step-0";
$spriteSheetObject = new spriteSheet(18, 18, 5, "../ICONS/", "../");
echo "step-1";
for ($x = 1; $x <= $spriteSheetObject->getImageCount(); $x++){ $tempFileManagerObject->copy("../ICONS/", "../Processing/", $x); }
echo "step-3";
$spriteSheetObject->setImagesFolder("../Processing/");
echo "step-4";
$spriteSheetObject->setOutPutFolder("../");
$spriteSheetObject->processSpriteSheet();
$spriteSheetObject->processSpriteSheetCss($this->getTotalSoftwaresCount());
for ($x = 1; $x <= $spriteSheetObject->getImageCount(); $x++){ $tempFileManagerObject->delete("../Processing/",$x); }
$tempFileManagerObject->setSrc("../Processing/");
$tempFileManagerObject->setDes("../");
$tempFileManagerObject->rename("tempArea", "home");
$tempFileManagerObject->move("../Processing/", "../", "home");}
public function connectDataBase(){
$temp = new dbConnection();
$this->conn = $temp->connectDb();
}
public function getTheImageNameOfNewlyInsertedIcon($subCategory, $pri){//First of all calculate the iconName of newly inserted image
//-Get the total number of rows for each subCategory table and add it untill we reach at the subCategory table where software to be inserted (Not add subCategory table rows count)
//- RowCounts + maxPriority in that table + 1
//- If there is already software for//Calculating the total number of rows upto subCateogryTable excluding the subCategoryTable and then add up
$temp = false;
$rowCount = 0;
$this->tableName;
$this->conn->query("use windows");
$softwareTable = $this->conn->query("select * from software order by priority");
foreach ( $softwareTable as $row ) {
$categoryTable = $this->conn->query("select * from ".$row["tableName"]." order by priority");
foreach ( $categoryTable as $row2 ) {
$subCategoryTable = $this->conn->query("select * from ".$row2["tableName"]." order by priority");
if (!strcmp($row2["category"], $subCategory)){
$this->tableName = $row2["tableName"];
$temp = true;
break;
}
$rowCount = $subCategoryTable->rowCount() + $rowCount;
}
if ($temp){break;}
}$rowCount = $pri + $rowCount;
return $rowCount;//This will be the name of the image//Navigate to Tables
//According to priority set the iconName
//Record the iconName please
//Insert the record in table
//Execute the spritesheet
//make css
//finally iterate the whole database and send a string
}
public function decrementPriorityInTable($pri){
$this->conn->query("use windows");
$softwareTable = $this->conn->query("select * from ".$this->tableName." order by priority");
foreach ( $softwareTable as $row ) {
if($row["priority"] >= $pri+1){
$this->conn->query("update ".$this->tableName." set priority=".($row["priority"]-1)." where priority=".$row["priority"]);
}
}}
public function getTotalSoftwaresCount(){
$softwareCount = 0;
$softwareTable = $this->conn->query("select * from software order by priority");
foreach ( $softwareTable as $row ) {
$categoryTable = $this->conn->query("select * from ".$row["tableName"]." order by priority");
foreach ( $categoryTable as $row2 ) {
$subCategoryTable = $this->conn->query("select * from ".$row2["tableName"]." order by priority");
foreach ($subCategoryTable as $row3){
$softwareCount++;
}
}
}
$softwareCount++;
return $softwareCount;
}
}?>
Линия $spriteSheetObject = new spriteSheet(18, 18, 5, "../ICONS/", "../");
останавливает выполнение без каких-либо ошибок.
spriteSheet
класс приходит из этой библиотеки:
<?php
require("lib/WideImage.php");//All the images size must first be set to be placed on canvas
//Depends on only 1-Image "canvasArea.jpg"//image processing folder is by default a "imagesToBeProcessed"//output folder is empty by defaultclass spriteSheet{
private $canvasWidth;
private $canvasHeight;
private $eachImageWidth;
private $eachImageHeight;
private $imagesFolder = "";
private $outputFolder = "";
private $imageCount = 0;
private $maxImageInARow;
function __construct($imgW=43,$imgH=43, $maxInRow=5, $src, $des){
$this->imagesFolder = $src;
$this->outputFolder = $des;
$this->imageCounter();
$this->eachImageWidth = $imgW;
$this->eachImageHeight = $imgH;
$this->canvasWidth = $imgW * $maxInRow;
$this->canvasHeight = $imgH * ceil($this->imageCount/$maxInRow);
$this->maxImageInARow = $maxInRow;
}
public function setImagesFolder($src){
$this->imagesFolder = $src;
}
public function setOutPutFolder($des){
$this->outputFolder = $des;
}
public function imageCounter( ){
for ($x=1; true; $x++){
if (!file_exists($this->imagesFolder.$x.".jpg") and !file_exists($this->imagesFolder.$x.".png") and !file_exists($this->imagesFolder.$x.".gif")){
$this->imageCount = $x;
break;
}
}
$this->imageCount--;
}
public function setCanvasSize( ){
$canvas = WideImage::load($this->imagesFolder."canvasArea.jpg")->resize($this->canvasWidth, $this->canvasHeight, "fill");
$canvas->saveToFile($this->imagesFolder."tempArea.jpg");
}
public function resizeAllIcons( ){$loopEnable = true;
for ($x=1; $loopEnable == true; $x++){
if (file_exists($this->imagesFolder.$x.".jpg")){
$iconImage = WideImage::load($this->imagesFolder.$x.".jpg")->resize($this->eachImageWidth, $this->eachImageHeight, "fill");
$iconImage->saveToFile($this->imagesFolder.$x.".jpg");
}
else if (file_exists($this->imagesFolder.$x.".png")){
$iconImage = WideImage::load($this->imagesFolder.$x.".png")->resize($this->eachImageWidth, $this->eachImageHeight, "fill");
$iconImage->saveToFile($this->imagesFolder.$x.".png");
}
else if (file_exists($this->imagesFolder.$x.".gif")){
$iconImage = WideImage::load($this->imagesFolder.$x.".gif")->resize($this->eachImageWidth, $this->eachImageHeight, "fill");
$iconImage->saveToFile($this->imagesFolder.$x.".gif");
}
else{
$loopEnable = false;
}
}
}
public function processSpriteSheet( ){
$this->resizeAllIcons();
$this->setCanvasSize();
$row=0; $col=0; $tempImageCounter = 1;
while ($tempImageCounter<=$this->imageCount){
$icon;
if (file_exists($this->imagesFolder.$tempImageCounter.".jpg")){
$icon = WideImage::load($this->imagesFolder.$tempImageCounter.'.jpg');
}
else if (file_exists($this->imagesFolder.$tempImageCounter.".png")){
$icon = WideImage::load($this->imagesFolder.$tempImageCounter.'.png');
}
else if (file_exists($this->imagesFolder.$tempImageCounter.".gif")){
$icon = WideImage::load($this->imagesFolder.$tempImageCounter.'.gif');
}
else{
break;
}
$canvas = WideImage::load($this->imagesFolder."tempArea.jpg");
$canvas->merge($icon, $row*$this->eachImageWidth, $col*$this->eachImageHeight, 100)->saveToFile($this->imagesFolder."tempArea.jpg");
$tempImageCounter++;
$row++;
if ($row == $this->maxImageInARow){
$row=0;
$col++;
}
}}
public function processSpriteSheetCss($maxImageCss){
echo "maxImage:".$maxImageCss;
$imgCommon = "img.common{
width: ".$this->eachImageWidth."px;
height: ".$this->eachImageHeight."px;
background-image:url(home.jpg);
}";
$imgS=""; $y=0; $tempImageCounter = 1;
for($x=0; $tempImageCounter<=$maxImageCss; $x++){
$imgS = $imgS."img.s".$tempImageCounter."{background-position:".-1*($x*$this->eachImageWidth)."px ".-1*($y*$this->eachImageHeight)."px;}";
if ($tempImageCounter%$this->maxImageInARow == 0){
$x = -1;
$y++;
}
$tempImageCounter++;
}
echo "SpriteSheetCSS".$imgS;
$handle = fopen( "../css/sprite.css", "w" );
fwrite($handle, $imgS);
}public function getImageCount(){
echo "total number of images-->".$this->imageCount;
return $this->imageCount;
}}?>
Мой сценарий останавливает выполнение на этой строке без каких-либо ошибок.
Этот файл отлично работает на локальном хосте, но когда я подключаю его к сети и выполняю, возникает такая проблема.
Задача ещё не решена.
Других решений пока нет …