Jump to content

atholon

Members
  • Posts

    132
  • Joined

  • Last visited

    Never

Posts posted by atholon

  1. I am trying to find out how I can make a business class available to all the controllers in my application or at least  those related to a specific layout.

     

    Is there a way of doing this in Zend? I have looked all over and must be missing something.

     

    Also, with third party classes, how are you supposed to integrate them?

  2. Let me explain it better sometimes I am bad at making assumptions.

     

    I have a project I just created. I am not sure if I am going to have access to httpd config to do the virtual host stuff that they recommend in Zend's quickstart so I am trying to figure out how to do it with .htaccess.

     

    My project resides in a directory like /www/Leadership, I want to send everything to Zend's public folder in my project when they hit the Leadership directory. Maybe I am going about that the wrong way?

  3. I've just started looking into Zend Framework and glancing at the quickstart on their website I saw they used a virtual host to redirect to the public directory. What are you supposed to do if you only have access to .htaccess on a shared host?

     

    I don't know much about mod_rewrite or any of that. I just want to send the traffic to that folder.

  4. Have any of you guys run into the issue with XHTML and 100% body height? If I don't use any DTD on my pages I can specify 100% height for the body of my page but once that DTD is on there it removes that capability. I've seen somewhere that W3 has depreciated 100% height and width on the body... but I couldn't find anything on their site.

     

    Does anyone know what we are supposed to do now if we still want that DTD/W3 validation?

  5. umm.. possibly because I only found crap when I did?

     

    I actually found some good ones on hotscripts.com but then they reorganized their website and I can't find them now.

  6. Hi,

     

    I am trying to make a div have a semi transparent background using the filter and moz property on that div. The problem is is that it is making all the text and images placed inside of that div also transparent.

     

    Is there a way to fix that and just make the background itsself transparent?

  7. Is there a way to clear this array through PHP?

    I don't want the file to be in memory once I have the file saved to my server.

     

    But my script has other things it needs to do before redirecting.

  8. Hi there,

     

    I wrote a PHP class to crop images using the gd library...works fine on my local server but it appears my host has a smaller memory limit...any ideas of how to work around it? It seems I cannot upload any images larger than 300k with this cropping class.

     

    This is the error I get:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2048 bytes) in /home/digitalh/public_html/includes/ImageCropper.php on line 124

     

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

     

    The class is sort of long:

    <?php 
    class ImageCropper
    {
      var $mediumWidth, $mediumHeight, $resizeWidth, $resizeHeight, $theImage, $width, $height, $newWidth, $newHeight, $imageType, $thumbSize, $error; 
    
      function ImageCropper()
      {
        $this->mediumWidth = 275;
        $this->mediumHeight = 200;  
    
        $this->resizeWidth = 325;
        $this->resizeHeight = 250;
        $this->error = null;
      }  // Constructor
      
      function makeThumb($image, $iName, $iSize=110)     // Thumbnails are square so there are only three params
      {    
        $this->thumbSize = $iSize;
        
        list($this->width,$this->height, $this->imageType) = getimagesize($image);        
        
        if($this->generateImageFromType($image))
        {    
          if ($this->width > $this->height)
          {  
            $this->resizeWidth = $this->thumbSize + 100;
            $this->makeLandscape();
          }
          else if ($this->height > $this->width)         
          {    
            $this->makePortrait();
            $this->resizeHeight = $this->thumbSize + 100;
          }
          else
          {
            $this->resizeWidth = $this->thumbSize + 100;
            $this->makeLandscape();
          }
          
          if ($this->width > $this->resizeWidth || $this->height > $this->resizeHeight)
          {
              if($this->imageType != IMAGETYPE_GIF)
              {
                $tempImage = imagecreatetruecolor( $this->newWidth, $this->newHeight );
                $temp = imagecreatetruecolor( $this->thumbSize, $this->thumbSize);
              }
              else
              {
                 $tempImage = imagecreate( $this->newWidth, $this->newHeight );
                 $temp = imagecreate( $this->thumbSize, $this->thumbSize);          
              }
              
              imagecopyresampled( $tempImage, $this->theImage, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height );          
              imagecopy( $temp, $tempImage, 0, 0,($this->newWidth/2)-($this->thumbSize/2),($this->newHeight/2)-($this->thumbSize/2), $this->newWidth, $this->newHeight ); 
              $this->renderImage($temp, $iName);           
              imagedestroy( $temp );
              imagedestroy( $tempImage );
          }      
          else
          {
              if($this->imageType != IMAGETYPE_GIF)
              {
                $temp = imagecreatetruecolor( $this->thumbSize, $this->thumbSize);
              }
              else
              {
                 $tempImage = imagecreate( $this->newWidth, $this->newHeight );
                 $temp = imagecreate( $this->thumbSize, $this->thumbSize);          
              }
              imagecopy( $temp, $this->theImage, ($this->thumbSize/2)-($this->width/2), ($this->thumbSize/2)-($this->height/2),0,0, $this->width, $this->height ); // resize to width
              $this->renderImage($temp, $iName); 
              imagedestroy( $temp ); 
          }
        }
        else
          echo $this->error;
           
      } // End Make Thumb
    
      function makeOtherSize($image, $iName, $iWidth=275, $iHeight=200)
      {
        $this->mediumWidth = $iWidth;
        $this->mediumHeight = $iHeight;
        
        $this->resizeWidth = $iWidth + 50;
        $this->resizeHeight = $iHeight + 50;    
       
        list($this->width,$this->height, $this->imageType) = getimagesize($image);     
        if($this->generateImageFromType($image))
        {
             
          if ($this->width > $this->height)
          {       
            $this->makeLandscape();
          }
          else if ($this->height > $this->width)         
          {    
            $this->makePortrait();
          }
          else
          {
            $this->makeLandscape();
          }
          
          if ($this->width > $this->resizeWidth || $this->height > $this->resizeHeight)
          {
              if($this->imageType != IMAGETYPE_GIF)
              {          
                $tempImage = imagecreatetruecolor( $this->newWidth, $this->newHeight );
                $temp = imagecreatetruecolor( $this->mediumWidth, $this->mediumHeight);                                                       
              }
              else
              {
                $tempImage = imagecreate( $this->newWidth, $this->newHeight );
                $temp = imagecreate( $this->mediumWidth, $this->mediumHeight);
              }
              imagecopyresampled( $tempImage, $this->theImage, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height );
              imagecopy( $temp, $tempImage, 0, 0,($this->newWidth/2)-($this->mediumWidth/2),($this->newHeight/2)-($this->mediumHeight/2), $this->newWidth, $this->newHeight ); 
              
              $this->renderImage($temp, $iName);           
             
              imagedestroy( $temp );
              imagedestroy( $tempImage );
          }      
          else
          {      
              if($this->imageType != IMAGETYPE_GIF)
              {             
                $temp = imagecreatetruecolor( $this->mediumWidth, $this->mediumHeight);
              }
              else
              {
                $temp = imagecreate( $this->mediumWidth, $this->mediumHeight);          
              }
                imagecopy( $temp, $this->theImage, ($this->mediumWidth/2)-($this->width/2), ($this->mediumHeight/2)-($this->height/2),0,0, $this->width, $this->height ); // resize to width
                $this->renderImage($temp, $iName); 
                imagedestroy( $temp );
                imagedestroy( $tempImage );
                
           }
       }
       else
       {   
          echo $this->error;
       }  
      }
       
      function generateImageFromType($toBeMade)
      {
       switch($this->imageType)
       {
         case IMAGETYPE_GIF:  
            $this->theImage = imagecreatefromgif($toBeMade) or die("Error: Cannot find image!");
            return true; 
            break;
         case IMAGETYPE_JPEG:
            $this->theImage = imagecreatefromjpeg($toBeMade) or die("Error: Cannot find image!");
            return true;    
            break;
         case IMAGETYPE_PNG:
            $this->theImage = imagecreatefrompng($toBeMade) or die("Error: Cannot find image!");
            return true;     
            break;
        default:
          $this->error("This image type is not allowed:".$this->imageType);
          return false;
          break;
       }  
      }
      
      function renderImage($theImage,$iName)
      {
         switch ($this->imageType)
         {
          case IMAGETYPE_JPEG:
            imagejpeg($theImage, $iName); 
            break;   
          case IMAGETYPE_GIF: 
            imagegif($theImage, $iName);
            break;   
          case IMAGETYPE_PNG:
            imagepng($theImage, $iName);
            break;   
          default:
            break;     
         } 
      }
      function makeLandscape()
      {
        if ($this->width > $this->resizeWidth)
        {
             $ratio = $this->exceededAspectRatio();
             if ($ratio == true)
             {
                $this->newHeight = $this->resizeHeight;
                $this->newWidth = ceil( $this->newHeight*($this->width/$this->height));
                echo("got here");
             }
             else
             {          
                $this->newWidth = $this->resizeWidth;
                $this->newHeight = ceil( $this->newWidth*($this->height/$this->width));
             }
        }
        else
        {
            $this->newWidth = $this->width;
            $this->newHeight = $this->height;
        }
      } // End Make LandScape
      
      function makePortrait()
      {
        if ($this->height > $this->resizeHeight)
        {
             $ratio = $this->exceededAspectRatio();
             if ($ratio == true)
             {
                $this->newHeight = $this->resizeHeight;
                $this->newWidth = ceil( $this->newHeight*($this->width/$this->height));
                echo("got here");
             }
             else
             {          
                $this->newHeight = $this->resizeHeight;
                $this->newWidth = ceil( $this->newHeight*($this->width/$this->height));
             }   
        }
        else
        {
            $this->newWidth = $this->width;
            $this->newHeight = $this->height;
        }     
      }
    
      function exceededAspectRatio()
      {
        if ($this->width > $this->height)
        {
           if ($this->width / $this->height > 2)
           return true;        
        }
        else
        {
           return false;
        }
        if ($this->height > $this->width)
        {
           if ($this->height / $this->width > 2)  
           return true;       
        }
        else
        {
           return false;
        }
      }
    }
    
    ?>
    
    

  9. Here is a little bit better version:

    <?php
      class GetUserInfo
      {   
        var $permission;      
        function GetUserInfo($userName)
        {
          $this->permission = 0;
          if(isset($userName))
          {      
            $baseQuery = mysql_query("SELECT * FROM `staff` WHERE `name`='$userName'") or die ("<br />Error in MySQL-query: ".mysql_error());
            if (mysql_num_rows($baseQuery) > 0)
            {
              $getStaffInfo = mysql_fetch_array($baseQuery);
              $position = $getStaffInfo["position"];
              $positionQuery = mysql_query("SELECT * FROM `position` WHERE `sid`='$position'") or die ("<br />Error in MySQL-query: ".mysql_error());
              if (mysql_num_rows($positionQuery) > 0)
              {
                $getPosition = mysql_fetch_array($positionQuery);
                $this->permission = $getPosition["permission"]; 
              }  // End position query
            } // End check for staff query          
          }  // End check for user name    
        } // End GetUserInfo()
      } // End of class
    ?>
    

  10. Right...BUT....according to PHP documentation, you do not need to do that.

    The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level error is generated.

  11. GetUserInfo.php:

    <?php
      class GetUserInfo
      {   
        var $permission;      
        function GetUserInfo($userName)
        {
          $baseQuery = mysql_query("SELECT * FROM `staff` WHERE `name`='$userName'", $GLOBALS['connect']);
    
          $getStaffInfo = mysql_fetch_array($baseQuery);
          $position = $getStaffInfo["position"];
          $getPosition = mysql_fetch_array(mysql_query("SELECT * FROM `position` WHERE `sid`='$position'")); // Line with warning
          $this->permission = $getPosition["permission"];           
        }
      }
    ?>

  12. When I do that in the config file nothing happens. When I do a die in these other files with the warnings, it says no database has been selected for those queries.

     

    The query worked when I installed using my install script... but none of those other pages that are rendered together with my config.php file take it.

     

    The way it is set up is like this:

     

    index.php requires MasterPage

    MasterPage requires site_common.php

    SiteCommon requires many different pages...the first of which is the config.php

    some of those pages are strictly classes as well.

    GetUserInfo.php is required in site_common.php

     

  13. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/includes/GetUserInfo.php on line 14

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/includes/MasterPage.php on line 21

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 36

     

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 37

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 54

     

     

    Thing is that they are valid....I checked them in SQL. I am not having issues with the require .... it works on my dev machine but not my webserver .

     

    My site is www.digitalhelpfiles.com

  14. hey there,

     

    So I have been using an older version of PHP and mySQL and I tried uploading my site to a server with PHP5 and the newest version of mySQL...it seems like the link isn't being carried over to the other pages unless I specify it. Is this just due to the php version?

     

    I had just been using a config file for the default link and I've used that to determin the connection. On the actual server it won't let me.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.