Jump to content

w3evolutions

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by w3evolutions

  1. I planned on using a registry to store the objects in, however storing the logger object in the registry limits every object to the same log object, in turn limiting their logging to one location as apposed to each object being able to use an existing log or one it has defined. I'm working on a solution I will post soon. Thanks, W3Evolutions
  2. Issues: 1.) Exceptions that are thrown must use a logger object from that object that threw it, without having to pass that logger object around as a parameter to every thrown exception. Inheritance Chain: Objects // contains all abstracted logic for must objects within the system class O_Abstract { $logger = NULL; public function getLogger() { return $this->logger; } } // contains all abstracted logic for any object of type "Bootstrap" class O_Bootstrap_Abstract extends O_Abstract { public function registerConfigs() { // do something but throw exception throw O_Bootstrap_Exception_Abstract::getInstance()->_throw("Message",O_Manager_Bootstrap_Abstract::ERROR); } } // the object that will actually be instantiated. class O_Manager_Bootstrap extends O_Bootstrap_Abstract { // in this level we will always know where to get the logger } Exceptions // contains all abstracted logic for all Exception objects within the system class O_Exception_Abstract extends Exception { public function __throw($message="", $code=0, $previous=NULL) { parent::__construct($message, $code, $previous); $this->__logLogger(); } public function setLogger($logger="") { if(!empty($logger)) { $this->logger = $logger; } } protected function __logLogger() { if(!empty($this->logger)) { $this->logger->log($this->message, $this->code); } } } // contains all abstracted logic for any object of type "Bootstrap" class O_Bootstrap_Exception_Abstract extends O_Exception_Abstract {} //contains all abstracted logic for any object of type "Manager_Bootstrap" class O_Manager_Bootstrap_Exception extends O_Bootstrap_Exception_Abstract { public function __throw($message="", $code=0, $previous=NULL) { parent::__throw($message, $code, $previous); $this->setLogger(O_Manager_Bootstrap_Exception::getInstance()->getLogger); } } Example: // init() throws O_Manager_Bootstrap_Exception O_Manager_Bootstrap::getInstance()->init(); /* this step is no big deal as the init() method resides inside the actual O_Manager_Bootstrap class it is the lowest level class so the lowest level exception "O_Manager_Bootstrap_Exception" can hard coded $logger = O_Manager_Bootstrap::getInstance()->getLogger(); */ // however this call: O_Manager_Bootstrap::getInstance()->registerConfigs(); /* resides in O_Manager_Bootstrap_Abstract object as other bootstrap type objects can use the same functionality. Int his case O_Manager_Bootstrap will actually throw a O_Bootstrap_Exception_Abstract exception. We can't throw a O_Manager_Bootstrap_Exception because it may how not came from a "Manager" bootstrap, maybe it came for a "Worker" bootstrap. */ The issue is that above the intermediate (or abstraction) level we can't directly code the "object"::getInstance()->getLogger() inside the Exception because don't know what sub-type of object called it. I need to find a better way to wither code the exception into the Objects or figure out how each abstraction layer can find the child object that actually called it. As, they are going to abstract objects they will never get instantiated therefore the exception throwing must come directly from a child at some point. Any suggestions? Thanks, W3Evolutions
  3. The code you put up as how your storing it looks like JSON as apposed to a PHP array. It may be easier to store them in the following manner: $startEndTime = "45"; //Seconds $rateToUse = array(); // This is an array as 45 sec can fall into 0-60, 30-45 $times["0-60"]["Rate"]=2; $times["0-15"]["Rate"]=0; $times["15-30"]["Rate"]=0; $times["30-45"]["Rate"]=0; foreach($times as $interval=>$rate) { $startEndTime = split($interval,'-'); if($timeTocheck >= $startEndTime[0] && $timeToCheck <= $startEndTime[1]) { $ratesToUse[] = $rate["Rate"]; } }
  4. I am trying to use PHP's XSLTProcessor() to generate some html pages. All is working well until I found out that you can't include multiple xsl sheets as they get overwritten, like the example on php.net. Just for reference, as of this writing, this function does not support importing multiple stylesheets. The following will output only the stylesheet transformation of the second imported sheet: <?php # LOAD XML FILE $XML = new DOMDocument(); $XML->load( 'data.xml' ); # START XSLT $xslt = new XSLTProcessor(); # IMPORT STYLESHEET 1 $XSL = new DOMDocument(); $XSL->load( 'template1.xsl' ); $xslt->importStylesheet( $XSL ); #IMPORT STYLESHEET 2 $XSL = new DOMDocument(); $XSL->load( 'template2.xsl' ); $xslt->importStylesheet( $XSL ); #PRINT print $xslt->transformToXML( $XML ); ?> the problem is I have the xsl files tempalted as: Header Content Footer which are to be included in the site_contianer.xsl. I need to figure out a way to dynamically create an: <xsl:include .. /> when I tried a str_replace() the transformation failed. any ideas?
  5. The factory needs to be able to handle the creation of both types of objects and needs to be able to handle method calls during creation that have required parameters. The reflection class will work for objects that can be created via the "new" keyword, but will not work for singleton objects, therefore it will not work in passing required parameters to a singleton object.
  6. Also the end result being: $args = array("User","Password","Localhost","db1"); Factory::_("ObjectName",$params)->query("SELECT * FROM table")->fetchRows(); // or Factory::_("ObjectName",$params)->query("SELECT * FROM table"); Factory::_("ObjectName")->fetchRows(); The factory object will interface directly with the registry so there will be a global placeholder for the object you are creating. Unless it is a singleton therefore does not need the be stored in the registry. The request -> response for that call would be as follows: 1.) Factory checks to see if "ObjectName" exists already 1a.) if so return it as is 1b.) if not call it's __construct or getInstance() 2.) Pass $args to the method in the correct order 3.) return the current instance of the object your working with 4.) call the remaining chained methods
  7. class MySQL_Instantiable { public function __construct($user, $pass, $location, $db) { // do some work } } class MySQL_Singleton { private static $instance; private function __construct() {} public static function getInstance($user, $pass, $location, $db) { //make a singleton } } The issue is the way these 2 objects are created. Respectively: $object = new MySQL_Instantiable(); $singleton = MySQL_Singleton::getInstance(); They are created two totaly different ways.
  8. Correct the reflection class will work, then the issue is making it work with singleton objects. From an API point-of-view being able to have 1 entry point for all objects.
  9. Issue: Create an object that gives 1 entry point for the creation of all objects, and act's as the API for all object calls. Problem: All (NON-Singleton) objects that need a __construct method must have ONLY optional parameters. Ex: class MySQL { private $a,$b,$c; public function __construct($a,$b,$c) { $this->a=$a; $this->b=$b; $this->c=$c; } public function reportVars() { echo("Vars: ".$a."<br />".$b."<br />".$c."<br />"); } } $args = array("This is a","This is b","This is c"); Factory::_("MySQL",$args)->reportVars(); //This call will fail because the parameters of MySQL->__constuct() are NOT optional Where the factory not only creates the object "MySQL" but it also will pass a given set of parameters to MySQL's constructor. This can almost be accomplished with call_user_func_array the only issue is that you have to create the object prior to using call_user_func_array which means the parameter's of MySQL's constructor must be optional.
  10. Not sure what the delivery failure is about I get emails all day everyday. Anyways, I'll send you a message with a different email. Thanks.
  11. Are all report_type required for each client_id?
  12. I would look into FFMPEG, and something like Red5.
  13. Maybe someone can add to this: function getCombinations($items, $string="", $i=0, &$return=array()) { if ($i >= count($items)) { return $return[] = $string; } else { if(is_array($items[$i])) { foreach ($items[$i] as $item) { getCombinations($items, "$string $item", $i + 1, $return); } } else { foreach ($items as $item) { getCombinations($items, "$string $item", $i + 1, $return); } } } return $return; } $Arrays = array("a","b","c"); $return = getCombinations($Arrays); print_r($return); results: Array ( [0] => a a a [1] => a a b [2] => a a c [3] => a b a [4] => a b b [5] => a b c [6] => a c a [7] => a c b [8] => a c c [9] => b a a [10] => b a b [11] => b a c [12] => b b a [13] => b b b [14] => b b c [15] => b c a [16] => b c b [17] => b c c [18] => c a a [19] => c a b [20] => c a c [21] => c b a [22] => c b b [23] => c b c [24] => c c a [25] => c c b [26] => c c c )
  14. When you post on here you can use [code=php:0] [/code] to show php code. Also on your fopen try w+, im still not sure why it is creating 2 files. I don't know what the $pdf object does whan you call ezOutput(); Try that.
  15. What version of php are you using and is simpleXML installed? You can run phpinfo() and check.
  16. I think this is the best way to use blob of images in mysql: //getImages.php?ID=17 // This will search the database for an image of id 17 then change the header of the file to output an image if(isset($_GET['ID']) && !empty($_GET['ID'])) { $_GET['ID'] = mysql_real_escape_string(strip_tags($_GET['ID'])); $connection = mysql_connect("localhost", "****_db", "****") or die(mysql_error()); mysql_select_db("****_db", $connection) or die(mysql_error()); $data = mysql_query("SELECT * FROM `images` WHERE `ID` = '{$_GET['ID']}'"); $anymatches=mysql_num_rows($data); if ($anymatches == 0) { exit(); } header("Content-type: image/gif"); // or whatever the mime type is print $data['ImageBlob']; // or whatever the blob field is exit(); } Now to use it! $imageID = 17; <p><img src="getImage.php?imageID=<?=$imageID;?>" /></p>
  17. It can be as long as the DB box allows outside connection to MySQL, port 3306.
  18. If your not worried about literal format, you can always regexp out any /\s\s+/.
  19. Not true, you can try to validate a user's account, if that account exists at that domain. Most of the time it won't reply but it can be done. karan23424, I guess are you asking for help with validating the string of an email or actually testing a server to see if that email account exists. It all depends on what your trying to do with your application.
  20. Try this: $dir = "/My/Dir/"; $maps = array(); if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != ".." && $file != ".") { $maps[] = $file; } } closedir($handle); } }
  21. You can add: ?PHPSESSID=<?=session_id() ;?> to all of the URLS on the site. This way if an ISP drops and the user clicks on the page they will be passing back the same SSID. You can store it in a cookie and reset the ssid.
  22. There is a few ways you can do this. You can save the original flyer value and check to see if they have uploaded a new one, if not then send the original back so that field still gets updated but either with the original value or a new one. Or you can use mysql INSERT....ON DUPLICATE KEY. http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html.
  23. Is there database connection code, and if there is does it have any errors?
  24. just set another cookie with: setcookie("origTime", microtime(true), time()+86400);
×
×
  • 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.