Re: [PHP] Easy Question
My Database functions are all wrapped up in an easy to use class. The methods look something like this: $db = new DB; $q = "SELECT * FROM ATable"; $db->query($q); while ($db->next_record()) { $db->p("SomethingOrOther"); } For the PHP script itself, the content management system I wrote up uses case statements in a single file engine and multple includes. for example: switch($func) { case("news"): include("/news/news.inc"); break; } and news.inc may contain: switch($task) { case("add"): include("/news/news.add.inc"); break; case("del"): include("/news/news.del.inc"); break; default: include("/news/news.view.inc"); } and then each would contain the actual code. It worked really well for a couple of reasons. For starts all the includes started as requires for testing purposes. If I edited several files but maybe didn't test them all, it'll will kick out any parse errors or warnings -- also useful since I've got another person working with me. Then when the site went live, I changed them to includes (well actually had to change a bunch of them part way through when I ran out of memory *s*). Also the code is very modular. I know what each file does and so does my partner who isn't a php programmer but may need to edit the HTML portions a little. Each file is clearly named as its its funciton so he knows where to look if there is a problem with a pages appearance. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Linux & PHP Install Problems (was: Oh and one more thing)
> > 1) format your harddrive > > 2) take out your motherboard and spraypaint it > > bright orange. Ok I did that. > > 3) dance around the desk three times holding the > > motherboard above your head chanting > > "mail mail, give me mail" > > "date date, give me date" > > "ga booga woooga shooga" I felt a little silly but I did that too. > > 4) install linux > > 5) install apache > > 6) install PHP I tried doing that but computer isn't working right. It smokes now when I turn it on and there is a strange smell coming from my computer vents. Did I use the right color orange? Please help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] New lists (was [PHP] Attitude of B van Ouwerkerk)
> Similarly the FAQ is easy to find, and I do believe the words "support" > suggest where help may be found. Actually my suggestion would be to take a page from way the Python lists are and call it tutor or PHP-tutor. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] New lists (was [PHP] Attitude of B van Ouwerkerk)
From: "Andreas D. Landmark" <[EMAIL PROTECTED]> > I'd second this suggestion, the general list has become flooded with posts that > seems like a pop-quiz taken straight from the manual... Right. I've just signed up the list and I've all but given up on trying to follow things. Just way too much traffic for a mailing list to have. If a seperate list for support or tutor or whatever you want to call gets started, I'll be happy to volunteer my time to assist people but I'd really like to be able to keep up with this list as I'm sure there are some great advanced threads that I'm missing. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What would you want in a PHP web host?
- Original Message - From: "Ryan Fischer" <[EMAIL PROTECTED]> > > Are hosting companies reluctant to give you more access rights? > > Usually, and that really sucks, because I've found myself having to set > up my own "pseudo-server" on my computer, with PHP4, Apache, and MySQL, > just to develop, because the hosts I've found are very reluctant to > either upgrade from PHP, or build PHP with the necessary extensions I > need. IMO, PHP4 on web hosts should always be compiles with *all* > options, so there will be no issue there. And it should always be > upgraded to the newest stable version within a week of its release. > This may be asking a lot, but people should get what they pay for, > right? I'm in the same boat but fortunately I've got a great web host who would give me access to set up my own install. Is this possible? Any relavent documentation anywhere? Thanks Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Pretty Formatter for PHP?
While I try and adhere to good formatting and punctuation practice in my coding, sometimes in my haste to write code I don't have time to properly format my code especially when I do a copy and paste and the indents don't follow the new code. Are there any apps available that will properly format PHP code particularly for a Win32 machine? Thanks Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] About PHP & Oracle
> Dear all, > Now i have an Oracle database. I have created a table contains 43 rows for example. I use PHP to contact with my oracle. I want to write a script access my Oracle for display data into table. Each time display 9 rows. So I dont't know how to program such as "Page 1 2 3 4 Next".Can anybody show me the way?And addition, when i use SQL command as "select * from table_name where id>'$id' ", it didn't display at all. > Thanks you in advance. > BaDu Below is some snippets of code from a project I just did where I did the same thing. You will have to do some editing for this but I hope it gives you the general idea. First of all, this was for MySQL but assuming that a LIMIT statement in Oracle works the same as in MySQL, you should be ok. Second of all, in some versions of MySQL numbering of table records for an offset on LIMIT starts at 0, newer versions at 1. I'm using the older version as you can see but you will want to check your Oracle documentation for future information. query($q); $db->next_record(); $numrows = $db->f("NumImage"); if (empty($offset)) { $offset=0; //Again, offset may be 1 or it may be 0.. check docs. } $q = "SELECT Photo_Image.*, Photo_Cat.Name FROM Photo_Image, Photo_Cat WHERE Photo_Image.Cat_ID = '$id' AND Photo_Cat.Cat_ID = '$id' ORDER BY SortOrder LIMIT $offset, $perpage"; $db->query($q); // print stuff here $pages = ceil($numrows/$perpage); if ($offset - $perpage >= 0) { ?> [Prev] 1) { for ($x = 0; $x < $pages; $x++) { ?> [Next] http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Am I doing this right? (PHP3/Login system)
I'm tring to get a login system going using PHP3 and MySQL. I'll have two tables -- one containing the username and passwords of each user plus a variable called Access which will hold what other parts of the scripts they'll have access to and another containing the actual logged in sessions. I'm trying to do this without using cookies so I'll be passng $sess_id around by get and post. These are my notes of what I'm thinking. Does anybody see any major problems with this? 1. If $sess_id doesn't exist, check for a username/password combination. a. if username/password exist, check validity i. if not valid, display error message/login b. if username/password doesn't exist i. display login. c. if username/password exist and valid (MySQL table check) i. create session id ii. find REMOTE_ADDR iii. fetch user information (Access, etc). iv. serialize REMOTE_ADDR, userinformation for table v. store session id, serialized information, and timestamp in sessions table. iv. continue 2. If $sess_id does exist, check table for session information. a. if session exists i. pull serialized data ii. find REMOTE_ADDR and compare to current. !. if not correct, display login iii. update timestamp in session table iv. continue b. if session doesn't exist i. display login. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Side Comment (was: Newbie Question: Converting PHP3 files to PHP4?)
: On Tue, 4 Sep 2001, Jason Murray wrote: : : > Nah, in Illegal Monopoly OS, its just as easy as Apache. : : Rather than the web server config, I was referring to renaming all the : .php3 files to have .php extensions, and combing through all the files, : finding all references to .php3 files, and changing them to refer to .php : files. I know exactly how to do it ... I do similar tasks routinely ... : on my Linux servers. I don't know how to make that task easy in Illegal : Monopoly OS. I do. I have to do it all the time (actually sometimes its to regress from php back to php3). from the command line: rename *.php3 *.php Then I use my text editor which has global file find and replace to make the changes. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Am I doing this right? (PHP3/Login system)
: Some people's REMOTE_ADDR changes every time they make a web request... : : For example a ISP i use, uses a array of invisible proxys, that change my IP : on each request.. Thanks for the advice. That would have been rather embarassing if people couldn't login! Then is just the session id secure enough? Does anybody see any problems? Below is the code I've got worked out and its functioning fine. Any body notice anything that I should know about? I guess I'm a little paranoid becuase I'd hate to not get it right and leave the site unsecure. My code is below. BTW, the Unserialize class uses a built in unserialize function that turns all the serialized data into object values. function show_login($err = "") { $Error["Login"] = $err; require("include/login.inc"); exit; } //phpinfo(); if (empty($sess_id) or !isset($sess_id) or !empty($username)) { if (empty($username) or !isset($username)) { ## First Login attempt show_login(); } elseif (!empty($username) or isset($username)) { $db = new a_DB; $q = "SELECT * FROM RPW_Users WHERE Username = '$username'"; $db->query($q); if (!$db->next_record()) { show_login("Error: Invalid Username or Password. (Rows = 0)"); } elseif ($db->f("Password") != $password) { print "Password in table = " . $db->f("Password") . ""; print "Password entered = " . $password . ""; show_login("Error: Invalid Username or Password. (Password doesn't match table)"); } else { $sess_id = md5(uniqid("antidisestablishmentarianism")); ; $data["Access"] = $db->f("Access"); $data = addslashes(serialize($data)); $db = new a_DB; $q = "INSERT INTO RPW_Sessions (sess_id, mdate, session_data) VALUES ('$sess_id', " . time() . ", '$data')"; $db->query($q); } } } if (!empty($sess_id) or isset($sess_id)) { $db = new a_DB; $q = "SELECT * FROM RPW_Sessions WHERE sess_id = '$sess_id'"; $db->query($q); if ($db->num_rows() == 0) { show_login("Previous session has expired. Please re-login."); } else { $Data = new Unserializable; $db->next_record(); $Data->unserialize($db->f("session_data")); $q = "UPDATE RPW_Sessions SET mdate = " . time() . " WHERE sess_id = '$sess_id'"; $db->query($q); } } : Andrew : - Original Message - : From: "Joel Ricker" <[EMAIL PROTECTED]> : To: <[EMAIL PROTECTED]> : Sent: Tuesday, September 04, 2001 1:26 AM : Subject: [PHP] Am I doing this right? (PHP3/Login system) : : : > I'm tring to get a login system going using PHP3 and MySQL. I'll have two : > tables -- one containing the username and passwords of each user plus a : > variable called Access which will hold what other parts of the scripts : > they'll have access to and another containing the actual logged in : sessions. : > I'm trying to do this without using cookies so I'll be passng $sess_id : > around by get and post. : > : > These are my notes of what I'm thinking. Does anybody see any major : > problems with this? : > : > 1. If $sess_id doesn't exist, check for a username/password combination. : > a. if username/password exist, check validity : > i. if not valid, display error message/login : > b. if username/password doesn't exist : > i. display login. : > c. if username/password exist and valid (MySQL table check) : > i. create session id : > ii. find REMOTE_ADDR : > iii. fetch user information (Access, etc). : > iv. serialize REMOTE_ADDR, userinformation for table : > v. store session id, serialized information, and timestamp in : > sessions table. : > iv. continue : > 2. If $sess_id does exist, check table for session information. : > a. if session exists : > i. pull serialized data : > ii. find REMOTE_ADDR and compare to current. : > !. if not correct, display login : > iii. update timestamp in session table : > iv. continue : > b. if session doesn't exist : > i. display login. : > : > Joel : > : > : > -- : > PHP General Mailing List (http://www.php.net/) : > To unsubscribe, e-mail: [EMAIL PROTECTED] : > For additional commands, e-mail: [EMAIL PROTECTED] : > To contact the list administrators, e-mail: [EMAIL PROTECTED] : > : > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] OOP Yea you know me... OOP yea you know me...
Hey all, I've been working on my first OPP driven PHP code and wanted to see what everyone thought and any ideas anybody can add to the code that I'm working on. I've had to make some concessions due to the limitations of PHP's OOP model and the fact that I'm using PHP3 which doesn't functions like get_class or get_parent so I'll have to explicity add those myself. In my example here, I've provided a Base Class which everything inherits from. It provides Methods for Getting and Setting variables, which checking to making sure those variables exist in the object declaration before setting them. Please let me know you think. Thanks Joel --- /* BaseClass.inc */ Set("_Class", "BaseClass"); } function Get($VarName) { return $this->$VarName; } function AddVar($VarName, $Value = "") { $this->$VarName = ""; } function Set($VarName, $Value) { if (!isset($this->$VarName)) { new Error("?", "?", "Invalid Variable Name at method call " . $this->Get("_Class") . "->Set($VarName, $Value)."); } else { $this->$VarName = $Value; } } } ?> /* Math.inc */ Set("_Class", "Math"); $this->Set("_Seed", (double) microtime() * 100); } /* SeedRandomNumbers (private) */ /* Seeds the Random Number Generator */ /* Parameters: */ /* None /* Returns: */ /* None */ function _SeedRandomNumbers() { mt_srand($this->Get("_Seed")); } /* RangeOfRandomNumbers (private) */ /* Returns a random number between a high and low number inclusive */ /* Parameters: */ /* Low - Lowest possible number of Random Number */ /* High - Highest possible number of Random Number */ /* Returns: */ /* (Integer) Random Number between two numbers inclusive */ function _RangeOfRandomNumbers($Low = 1, $High = 6) { return mt_rand($Low, $High); } function _GCD($m,$n) { if ($n==0) { return $m; } else { return ($this->_GCD($n,($m%$n))); } } } //End Math /* Fraction.inc */ Set("_Class", "Fraction"); $this->Set("_WholePart", $Whole); $this->Set("_Numerator", $Numerator); $this->Set("_Denominator", $Denominator); } function Add ($AddTo) { $Num = ($this->Get("_Numerator") * $AddTo->Get("_Denominator")) + ($AddTo->Get("_Numerator") * $this->Get("_Denominator")); $Den = ($this->Get("_Denominator") * $AddTo->Get("_Denominator")); if ($Num != 0 && $Den != 0) { $GCD = $this->_GCD($Num, $Den); $Num = $Num / $GCD; $Den = $Den / $GCD; $Whole = floor($Num / $Den); $Num = $Num % $Den; } $NewFraction = ($Num != 0) ? new Fraction($this->Get("_WholePart") + $AddTo->Get("_WholePart") + $Whole, $Num, $Den) : new Fraction($this->Get("_WholePart") + $AddTo->Get("_WholePart") + $Whole); return $NewFraction; } function Fetch() { $frac = ""; if ($this->Get("_WholePart")) { $frac .= $this->Get("_WholePart") . " "; } if ($this->Get("_Numerator")) { $frac .= $this->Get("_Numerator") . "/" . $this->Get("_Denominator"); } $frac = chop($frac); if (empty($frac)) { $frac = "0"; } return $frac; } function Show() { print $this->Fetch(); } } --- There are worlds out there where the sky is burning, the seas sleep, and the rivers dream; people made of smoke, and cities made of song. Somewhere there's danger; somewhere there's injustice, and somewhere else the tea is getting cold! Come on Ace, we've got work to do! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] quick question.
: I was just wondering if I could call some functions out side of the class : I'm making? The reason why I want to do this is so that I don't have to : rewrite the functions as methods in the class and I don't want to get too : far into what I'm doing before I find out it doesn't work. Sure you can. All functions in the Global scope can be called from inside the class. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] session & class driving me nuts
: hi , : : gallerie.php: : : Fatal error: Call to a member function on a non-object in : /home/sites/site76/web/galerie/shop.php on line XX If I'm following you right and the class code you are trying to run is in gallerie.php, then your error is in shop.php. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Namo Web Editor
> I always depreciated WYSIWYG software, especially when they mention > those things about HTML. HTML is the alphabet of the internet and as > such should be well known by any webmaster and whoever else is > interested in this kind of software. > > Still, it feels like it is better than Dreamveawer and Microsoft > FrontPage (oh boy, I pronounced devil's name) Exactly my thoughts but it seems we are more in the minority. My neighbor mentioned his girlfriend taking a web class and he complained that they use Notepad for their editing. "Who uses Notepad?", he asked. Yet he was suprised when she was showing him a thing or two. WYSIWYG editors are nice for general things like layout (I use Dreamweaver to help layout any table in a table stuff) but I haven't ran across a editor yet that makes solid code. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: images no appearing
To see exactly what image functions that are or aren't available to you, try running this script. Have: --"; } } ?>Don't Have: "; } } ?> - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "Adrian D'Costa" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, October 03, 2001 12:18 AM Subject: [PHP] Re: images no appearing > Older versions of GD will do GIF, but not JPEG, and vice versa... > > What versions of GD are on the two servers? > > -- > WARNING [EMAIL PROTECTED] address is an endangered species -- Use > [EMAIL PROTECTED] > Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm > Volunteer a little time: http://chatmusic.com/volunteer.htm > - Original Message - > From: Adrian D'Costa <[EMAIL PROTECTED]> > Newsgroups: php.general > To: php general list <[EMAIL PROTECTED]> > Sent: Monday, September 24, 2001 12:05 AM > Subject: images no appearing > > > > Hi, > > > > I wrote a php script to create a dynamic graph (image/jpeg). On my > > development system the image appears on my website it gives Image/Jpeg > > support not compiled. > > > > Below are the config settings: > > > > My system: > > Configure Command ^@ './configure' '--prefix=/usr' > > ^@'--with-config-file-path=/etc' '--disable-debug' > > ^@'--enable-pic' '--enable-inline-optimization' > > ^@'--enable-sockets' '--with-apxs=/usr/sbin/apxs' > > ^@'--disable-static' '--with-exec-dir=/usr/bin' > > ^@'--with-regex=system' '--with-gd' > > ^@'--with-jpeg-dir=/usr' '--with-png' '--with-gdbm' > > ^@'--enable-debugger' '--enable-magic-quotes' > > ^@'--enable-safe-mode' '--enable-track-vars' > > ^@'--enable-ftp' '--with-mysql' '--with-xml' > > ^@'--enable-trans-sid' > > ^@'--with-readline=/usr/include/readline' > > > > My webserver the info can be got from vvmm.net/phpinfo.php. > > > > They my provider has given --with-jpeg-dir=/usr/lib still the image does > > not appear. Even in the gd section it does not give JPG Support > > enabled. Only give. Right now I have changed the program to work with > > gif. My question, why not Jpg?? > > > > Adrian > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] crypt and decrypt a string
Does anybody have an easy way to crypt and decrypt a string? I see the Mcrypt Encryption module but thats a little more gung-ho than I'm looking for. I'm not trying to encrypt sensitive data rather I'm more trying obfuscate it a variable for a hidden tag. Thought I remember seeing something using XOR? Any ideas? Thanks Joel
Re: [PHP] crypt and decrypt a string
From: "Nathan" <[EMAIL PROTECTED]> > Here are some simple xor encoding functions that I wrote. This will keep > the average joe from peaking at your data. Exactly what I was looking for. Thanks Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] crypt and decrypt a string
> On Friday 05 October 2001 18:10, you wrote: > > Use crypt()/decrypt() couple. > > > > Andrey Hristov >From the PHP doumentation on crypt: There is no decrypt function, since crypt() uses a one-way algorithm." so that wouldn't have worked. Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Paging through MySQL results
- Original Message - From: "Andrey Hristov" <[EMAIL PROTECTED]> > select * from some_table Limit 10,30; Something to point out, in some of the older versions of MySQL, Offset starts counting at 0, while in the newer versions, it starts counting at 1. You'll want to check the documentation for your version. Joel > syntaxis > limit , > Andrey Hristov > IcyGEN Corporation > Building Solutions > > On Friday 05 October 2001 18:52, you wrote: > > I am a bit new to PHP -- normally use ASP (no booing, please) -- and trying > > to find an elegant solution to paging x number of records at a time through > > a result set returned to a php page from MySQL. > > > > Any ideas? > > > > TIA, > > Bill > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]