Jump to content

drkstr

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by drkstr

  1. I figured that much, but why would a PEAR package not be able to find PEAR.php? I shouldn't have to modify the source to a PEAR package so it makes me think there is something else wrong. I just don't know what. Any ideas? Thanks! ~Aaron **Edit** Just so I'm clear, the error is coming from the pear package, not my script. Here is my script in it's entireity: <?php // include class file require_once("XML/Serializer.php"); // create object $serializer = new XML_Serializer(); // create array to be serialized $xml = array ( "book" => array ( "title" => "Oliver Twist", "author" => "Charles Dickens")); // perform serialization $result = $serializer->serialize($xml); // check result code and display XML if success if($result === true) { echo $serializer->getSerializedData(); } ?> XML/Serializer.php is the PEAR package.
  2. Hello, I'm getting an error when I run a pear package and I'm not sure where to start looking. It seems like it might be some kind of configuration problem but I'm not sure. When I run the php file that includes the pear package, I get the following error: I opened the source file to the pear package and all it has on line 30 is "require_once(PEAR.php)". Any ideas what's wrong? Thanks! ~Aaron
  3. It was indeed a local configuration overriding the global settings. Resolved. Thanks for the help! ~Aaron
  4. Thanks for the quick reply! I updated the php.ini to use the quotes and restarted the server, but no help. When I copy the file to the site directory (which runs phpinfo() I noticed the open_basedir is set to: I also noticed the error indicates the '/var/www/vhosts/domain.com/httpdocs:/tmp' setting. I'm not quite sure what the difference is between the local value and master value, but do you think the 'main' setting is being overridden by a local one? Thanks again! ~Aaron
  5. Hello, I have a set of core files that I want to link to from various site directories and I was wondering if I could get a little help understanding the open_basedir restriction. I have /var/www/vhosts/base/php/phpinfo.php5 and a symlink to the absolute path at /var/www/vhosts/domain.com/httpdocs/php/phpinfo.php5 When I go to http://domain.com/php/phpinfo.php5 I get the following error: I tried setting this line in the php.ini open_basedir = /var/www/vhosts But I still get the same error. Could anyone give me a little insight to understand the problem? Thanks in advance! ~Aaron
  6. First of all, sorry if I seem curt, but it's late and my coding momentum ground to a halt as soon as I needed to do something in javascript (which I'm pretty sure is the devil's creation). Anyways, I have a fairly large form which consists of a long list of identical elements. For example, let's say my form has 10 lines, and each line contains the same 5 uniquely named form elements. So when submitted, the server side script will basically get a matrix of form elements (an array of the first element, an array of the second element, etc.). When any particular element on any particular line is changed, clicked, whatever, I need to be able to modify other elements on the same line. Furthermore, I don't think I can loop through the entire list to find the element being worked on because some of the lines could contain the same value for that element.  I have spent the past few hours digging though my javascript book (which is the biggest programming book I have by the way), and have come to the conclusion that javascript is completely useless for any real coding. Can anyone recommend some strategies for working on dynamically created form elements with such a "static" language? Any advice you can give me will probably add a year to this poor programmers life span. Thanks in advance! ...aaron PS: I can post code if you would like, but I am more interested in general strategies then a specific solution.
  7. heh, yeah, that would be quite a chore. And it is a lot better then my "array of function references" idea too. I'll have to remember these, could come in handy some day. ...drkstr
  8. Was this not the conclusion we came to earlier; We can call the methods, but don't have access to the properties, and in order to simulate it, you will need to declare an instance in your custom object and wrap the method calls to pull from the instantiated object? I would like to know if this is no longer the case, because I can use the method in my current project. I have a bunch of objects that have to pull data from an instantiated object. regards, ...drkstr **edit** Although I see your point, it is a pretty handy way to copy all the methods to your own class. I'm not sure what the original posters intentions were, but from my understanding, I think the problem was being able to extend the object, not use it in another object. I am interested to see if there is a way to modify the data, or if you are limitted to modyfying it with the provided methods.
  9. I had a hard time trying to find a way to get the terminal size (rows and cols) in a command line php script I'm writing. I was about to  give up and call a perl script to get the info, but I was wondering if there was a more efficient way. I need to be able to do this without recompiling php with ncurses support. Any ideas? thanks! ...drkstr
  10. Yup, that worked perfectly. updated code: [code]define( 'MONTHS', 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' ); class Date {   protected $myDay  = 0;   protected $myMonth = 0;   protected $myYear  = 0;   protected $myHour  = 0;   protected $myMin  = 0;   protected $mySec  = 0;   protected $myTimeStamp=0;    #Unix time stamp used for comparason;   public function __construct( $_arDateVars=array() ) {     $nMonth=0;     if(! is_null($_arDateVars)) {       $this->myDay    = (int) $_arDateVars[0];       $this->myMonth  = (int) (strpos(MONTHS, $_arDateVars[1])+4)/4;  #get month number       $this->myYear  = (int) $_arDateVars[2];       $this->myHour  = (int) $_arDateVars[3];       $this->myMin    = (int) $_arDateVars[4];       $this->mySec    = (int) $_arDateVars[5];       $this->myTimeStamp = mktime( $this->myHour, $this->myMin, $this->mySec,                                     $this->myMonth, $this->myDay, $this->myYear );     }   }   #returns True if the passed in date is greater then $this date.   public function greater( $_newDate ) {     return ($_newDate->myTimeStamp > $this->myTimeStamp);   } }[/code] Thanks for the help! ...drkstr
  11. Is there a good PHP manual page that will explain conditional expressions in detail? I'm getting strange results when comparing two objects. Here's the object (I included some debug output): [code]#global var used for month checking define( 'MONTHS', 'undef Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' ); class Date {     public $myDay  = 0;     public $myMonth = 'undef';     public $myYear  = 0;     public $myHour  = 0;     public $myMin  = 0;     public $mySec  = 0;     #pass Null to constructor for an "empty" object     public function __construct( $_arDateVars=array() ) {       if(! is_null($_arDateVars)) {         $this->myDay    = (int) $_arDateVars[0];         $this->myMonth  = (string) $_arDateVars[1];         $this->myYear  = (int) $_arDateVars[2];         $this->myHour  = (int) $_arDateVars[3];         $this->myMin    = (int) $_arDateVars[4];         $this->mySec    = (int) $_arDateVars[5];       }     }     #returns True if the passed in date is greater then $this date.     #otherwise returns False     public function greater( $_newDate ) {       print "checking if\n"; var_dump($_newDate);       print "is greater then \n"; var_dump($this);       switch (True) {         case ( $_newDate.myYear > $this->myYear ):           print "Year: ". gettype($_newDate->myYear)." ".$_newDate->myYear." > ".                           gettype($this->myYear)." ".$this->myYear."\n";           return True;         case strpos(MONTHS, $_newDate->myMonth) > strpos(MONTHS, $this->myMonth):           print "Months: ". gettype($_newDate->myMonth)." ".$_newDate->myMonth." > ".                           gettype($this->myMonth)." ".$this->myMonth."\n";           return True;         case ( $_newDate.myDay > $this->myDay ) :           print "Days: ". gettype($_newDate->myDay)." ".$_newDate->myDay." > ".                           gettype($this->myDay)." ".$this->myDay."\n";           return True;         case ( $_newDate.myHour > $this->myHour):           print "Hours: ". gettype($_newDate->myHour)." ".$_newDate->myHour." > ".                           gettype($this->myHour)." ".$this->myHour."\n";           return True;         case ( $_newDate.myMin > $this->myMin):           print "Mins: ". gettype($_newDate->myMin)." ".$_newDate->myMin." > ".                           gettype($this->myMin)." ".$this->myMin."\n";           return True;         case ( $_newDate.mySec > $this->mySec):           print "Sec: ". gettype($_newDate->mySec)." ".$_newDate->mySec." > ".                           gettype($this->mySec)." ".$this->mySec."\n";           return True;       }     return False;   } }[/code] And here is the output of a sample set: checking if object(Date)#2 (6) {   ["myDay"]=>   int(31)   ["myMonth"]=>   string(3) "Aug"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(9)   ["myMin"]=>   int(13)   ["mySec"]=>   int(21) } is greater then object(Date)#4 (6) {   ["myDay"]=>   int(0)   ["myMonth"]=>   string(5) "undef"   ["myYear"]=>   int(0)   ["myHour"]=>   int(0)   ["myMin"]=>   int(0)   ["mySec"]=>   int(0) } [color=red]Months: string Aug > string undef[/color] checking if object(Date)#4 (6) {   ["myDay"]=>   int(31)   ["myMonth"]=>   string(3) "Aug"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(9)   ["myMin"]=>   int(25)   ["mySec"]=>   int(13) } is greater then object(Date)#2 (6) {   ["myDay"]=>   int(31)   ["myMonth"]=>   string(3) "Aug"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(9)   ["myMin"]=>   int(13)   ["mySec"]=>   int(21) } checking if object(Date)#5 (6) {   ["myDay"]=>   int(1)   ["myMonth"]=>   string(3) "Sep"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(8)   ["myMin"]=>   int(14)   ["mySec"]=>   int(31) } is greater then object(Date)#2 (6) {   ["myDay"]=>   int(31)   ["myMonth"]=>   string(3) "Aug"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(9)   ["myMin"]=>   int(13)   ["mySec"]=>   int(21) } [color=red]Months: string Sep > string Aug[/color] checking if object(Date)#2 (6) {   ["myDay"]=>   int(7)   ["myMonth"]=>   string(3) "Sep"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(21)   ["myMin"]=>   int(31)   ["mySec"]=>   int(2) } is greater then object(Date)#5 (6) {   ["myDay"]=>   int(1)   ["myMonth"]=>   string(3) "Sep"   ["myYear"]=>   int(2006)   ["myHour"]=>   int(8)   ["myMin"]=>   int(14)   ["mySec"]=>   int(31) } As you can see, it's only returning True for the cases when the month is greater.  What am I doing wrong? Thanks for the help! ...drkstr
  12. It actually does involve a bit of log analizing, which perl is great for. I wanted to give php a shot with this project though, just to se  how it held up. The thing I really liked about PHP was how easy it was to take it to the next level. I started out doing a simple log mining to building an andvanced method for generating data reports based on whatever criteria you want, date ranges, IP ranges, service protocols, or a combenation thereof. I'm not saying this isn't possible in perl, but I think in a very object oriented kind of way and it was easire for me build complex data objects in this mindset, then the more linear perl approach. I am however, going to stick to perl for the simpeler tasks since I like it's low level syntax more. And it's regex kicks! [code]CPAN/modules, <>, map, grep, custom sorts, lists, slices, contexts, references (out the wazoo)?[/code]Not to long, I've only been using Linux for about a year now. Never I am a big fan of all the other trickery you mention though. Building objects as multidemensional arrays was fun (that is, if you like pain ..which I do). I guess I should look into some more of the advanced features you mentioned, such as 'map' (not really sure what that is). Thanks for the replies! This has been a fun learning process for me! ...drkstr
  13. Thanks for the link. After a litle bit of reading up on the pros/cons, I don't think I'm ready to give up on perl quite yet. I am going to give it a shot for this project however. I wanted to analyze my log files and store info in a database, and I think I can put my new found PHP knowledge to use with this. After some more reading, I found what I needed to get started. $argc is the number of arguments, and $argv is an array that contains command line arguments. Thanks for the pointer to the right direction! ...drkstr **edit** Just wanted to clear something up. I meant no disrespect when I said PHP was a better language. perl was actually my first language, so it will always hold a place in my heart. I'm a big OOP person however so I was excited when I started learning PHP. For the same reason, I'm thinking of picking up python at some point.
  14. I do a lot of perl scripting for my Linux desktop and server, and was wondering how PHP held up as a replacement. Does is support command line parameters? If so, how are the accessed in the PHP script? Also, does it support a shebang ( #!/usr/bin/php at the top of the file ), or do I have to tell it to run the script manually with 'php script name'? I would like to start doing my scripting in PHP since it's a much better language. Any input would be appreciated. Thanks! ...drkstr
  15. Ahh, That's a great idea! I'll just change the protected data/methods to public, and I'll be good to go. Thanks for the help! ...drkstr
  16. Darn, I guess it's not going to happen then. I have a data template and a service template and I wanted to extend them both into an actual "library" object which is customized for it's actual use. I'm going to have a *lot* of these objects, so I was trying to get around rewriting the same code over and over. I gues I will just extend the service template and make an isntance of the data object in the child. The data template doesn't have that much code, and the only thing that will change in the service template is the name of the class, so I guess it would make sence to just get rid of the data template and just duplicate the code in each of the data objects. Thanks for the quick reply! ...drkstr
  17. Great, thanks! This is exactly what I was looking for. Thanks for the advice! ...drkstr
  18. [quote author=mcmuney link=topic=106911.msg428788#msg428788 date=1157493578] Not really, I think I need more clarification. [/quote] $_SERVER['HTTP_REFERER'] contains the page (string) the person was directed from. You should check that this page is part of your site and direct to it, otherwise, direct to the default page. ...drkstr
  19. That's a handy little trick. I didn't know you could compare arrays directly with the '==' operator. I think I now have enough info to make sure nothing jiggy happens to my array in the Flash code. Thanks everyone for the help! ...drkstr
  20. Thanks for the sponce ober! I guess I'll just loop through and compare the data types of the array passed in through the parameter against those of the original. Hopefully I don't pick up/lose any keys. thanks again! ...drkstr
  21. Is there an easy way to make the keys of an associative array read-only, and preferably the data type of the value? I am passing an associative array of object vars to a client side Flash script where someone else will be writing the code to update it and pass it back. I want to make sure I can safely reassign the updated data back to the object, is there an elegant way to do this, or should I just loop through and compare the new array with the original and exit on error if anything changed? thanks! ...drkstr
  22. Like I said, using a constructor in the child object breaks the Flash remoting (amfphp). I'm not sure why, but it does. right now I am just adding a data member to the child object called myObjectVars, then in the init() method, I'm doing crating an instance of the parent: [code]class ServiceNetworkConfig extends NetworkConfig {   private $myObjectVars = array();   public function init() {     $netConfig = new NetworkConfig();     $this->myObjectVars = get_object_vars($netConfig);   }   #This function will be callable by the client side Flash script.   public function retrieveData() {     return $this->myObjectVars;   } }[/code] I don't like this though because it makes parsing the data back to the parent class difficult. Thanks for the reply! ...drkstr
  23. Hello, I need to be able to extend an object, but all the inherited data in the child object must allread be instantiated.  What are the best methods/practices to do this? The reason why I ask, is I am unable to use a constructor in the child. The child object needs to be formed in such a way that it can be made "callable" by client side Flash code. Constructors will break this functionality, but it will call an init() method if it exists. Can any one recommend the best way to get the data in the child object instantiated?  If I just call the parent constructor from a method in a child object, will the inherited data in the child object be instantiated as well? Should I just get rid of the parent constructor and put it in the init() function of the child? I would prefer not to do the later since the constructor of the parent uses some private helper functions that I would have to make public. Thanks for your time! ...drkstr
×
×
  • 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.