PHP在调用外部函数时停止执行

时间:2015-03-30 12:34:13

标签: php execution

执行以下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 default



    class 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;
        }


    }




    ?>

我的脚本在该行停止执行而没有任何错误。

这个文件在localhost上运行得很好但是当我把它放到网上并执行它时就会出现这个问题。

0 个答案:

没有答案