ospap = Open Source Photo Album Program.
Well, I have something that works. I'll let y'all give it a try, if you want. I have a demo site set up:
http://www.javaop.com/~iago/ospap/index.php
Or you can download the source:
http://www.javaop.com/~iago/ospap.tgz
To run it yourself, you need the "imagemagick" program installed (specifically, the 'convert' utility). Using that was faster and easier than gd, so I'm sticking with it for now. Plus, gd tended to crash on larger images, and that just wasn't cool!
What I need to do:
- Remember the last category used. - done
- Allow comment posting. - done
- Add a button to promote/demote users to/from admin (this can be done with admin.php?action=promote&user_id=##).
- Let a user mark their images as "private"
- Allow users to delete their own images/categories (or admins delete them)
<edit> - Make default background color of JPEG's not-black. - don't think it's possible
Any other suggestions would be great!
Also, keep an eye out for XSS or SQL Injection or doing things a dumb way. This is the first time I ever used PHP, so I might be doing some things wrong. :)
The Demo site doesn't require admin authorization (which will be required in the final version). Do what you want with it, and try to break it. I'm going to wipe it before I call it done anyways.
Good luck!
Looks neat.
In your directory, what's that glowing thing in your lap? ;)
There are no pictures of me.
Read the caption!
Add line breaks in the error messages. :P
edit:
http://www.javaop.com/~iago/ospap/show_picture.php?picture_id=4#picture
Good work! :-*
Quote from: Blaze on September 14, 2005, 07:21:54 PM
Add line breaks in the error messages. :P
edit:
http://www.javaop.com/~iago/ospap/show_picture.php?picture_id=4#picture
Good work! :-*
Which error message?
<edit> New rule: No WoW stuff! ;)
Oops, that message was for debugging, it shouldn't have even been there. I fixed it.
Quote from: iago on September 14, 2005, 07:14:58 PM
There are no pictures of me.
Read the caption!
Haha, should have realized it was wires!
Once I'm satisified with the whole thing, I'll post some pictures of myself. Hopefully by early next week.
what about guild wars pictures :-) ???
I guess I should delete my post that I posted right before I read this.. Lmao!!
Moor Pictures > ospap
Add a last updated timestamp on the users sections.
Quote from: Blaze on September 14, 2005, 11:35:50 PM
Add a last updated timestamp on the users sections.
That'll be a little trickier, but for sure! I'll do that tomorrow.
haha ron that thing is leet. You got pwned by the backstabbers. ;)
Woah, 2 replies since I was fixing stuff!
Anyways, I just updated to ALPHA2. It has the changes I suggested for myself in the first post.
My new to-do list:
- Show a "last updated" on each page
- On the main page, show categories/total pictures
<edit> - Number of comments
<edit> - Email on new comment to one of my images
<edit> - (Optional) Email on any new picture
Alpha 2's comments are a good idea. :)
Very good job so far iago.
Unknown usernameLogin failed Redirecting....
Hm, do I detect a bit of a.. missing <br />?
Please enter a password that is at least 6 characters (it's for your own protection!)
Security zealot.
# Redistribution and use in source and binary forms
/compile =p
Quote from: Joe[e2] on September 15, 2005, 11:39:22 PM
Unknown usernameLogin failed Redirecting....
Hm, do I detect a bit of a.. missing <br />?
Bah, I fixed that, but overwrote the fix. oops!
And no, I'm missing a <BR>. I'm using HTML 4.01, not XHTML.
Quote from: Joe[e2] on September 15, 2005, 11:39:22 PM
Please enter a password that is at least 6 characters (it's for your own protection!)
Security zealot.
Well, anybody who uses a password shorter than 8 characters is stupid anyway. My original requirement was 8-character passwords, but I decided to let people be dumb and use 6 characters passwords.
And incidentally, the passwords are hashed; however, it's being sent over a plaintext link, so it's not totally safe.
Couldn't they be scrambled clientside? I'll write a quck VBScript hash() function if you'd like.
VBScript is garbage. Primarely because it only works on Linux, but also because if you're allowing VBScript to be run on your computer, the website can do anything it wants to you. I don't want to force people to do that.
The other option is to do it in JavaScript. But I don't like the idea of depending on JavaScript.
Looking awesome, will check out source when I get my comp fixed. :)
As far as I see it, VBScript is JavaScript in a different language. The only difference is the language="" variable of <script>, they even use the same tag to be executed.
Will it run on non-Windows systems?
Perhaps I misunderstand VBScript, but I thought you need a Windows system for it?
Anyway, hashing it before sending still doesn't protect against replay attacks.
Quote from: Joe[e2] on September 15, 2005, 11:39:22 PM
# Redistribution and use in source and binary forms
/compile =p
Hmm @ editing your post while I was replying, I didn't even see that.
Yes, I'm aware that the license mentions binary forms. And if somebody wants to compile PHP to a binary form (which is possible -- there's a program that converts PHP to C++, I'm told) and distribute it, I don't care. I mostly left that in because I wanted to leave the BSD license intact.
I updated to Alpha3 just now. I had to wipe the database, unfortunately. I have completed all the goals for this version successfully, and think it's ready to post. I shouldn't have to change the database anymore, so hopefully I won't have to wipe it again.
Please, everybody, try it! Try to break it!
And you can still get it at http://www.javaop.com/~iago/ospap.tgz
To-do:
- Handle newlines in comments properly
- "Cancel" after uploading picture
- Fix the "back" jumps
- Allow .bmp and other formats that "convert" can handle
- Display the newly-uploaded filename on the preview page (helps me with naming, others too probably)
- Allow each table to be sorted by different criteria
To-do+:
make it templated/skinnable
edit thread title
should I hand out that site to freinds?
Make it not so dull looking. Make it have some character. :D
[Edit]
I can't spell..
Quote from: Brandon on September 18, 2005, 10:11:54 PM
Make it not so dull looking. Make it have some character. :D
[Edit]
I can't spell..
iago doesn't do layouts.
rabbit's already provided the solution to your request, though.
Quote from: rabbit on September 18, 2005, 11:37:45 AM
To-do+:
make it templated/skinnable
edit thread title
Quote from: Toweliex86] link=topic=2860.msg28236#msg28236 date=1127088355]
should I hand out that site to freinds?
At this point, you can,
provided they know that I may wipe it if I need to. When I decide that I'm done with it (hopefully soon) then sure!
Quote from: Sidoh on September 18, 2005, 10:27:25 PM
iago doesn't do layouts.
Damn right!
Quote from: Sidoh on September 18, 2005, 10:27:25 PM
rabbit's already provided the solution to your request, though.
Quote from: rabbit on September 18, 2005, 11:37:45 AM
To-do+:
make it templated/skinnable
edit thread title
Yeah, somebody else (Romi, I think?) asked me to do that as well.
Perhaps this belongs in a different thread, but what's the common way to make a php program skinnable? I can think of ways, but I'm sure there's a "right way" (or maybe common way).. can somebody shared?
Hm. Not realy. Most programs have their own, custom template engine and several template files. As an example, a template file for a news post may look like:
Posted by <b>{postedBy}</b> at <b>{postedTime}</b> on <b>{postedDate}</b>
<hr />
<h3>{title}</h3>
{text}
This is just a very simple example. I'm sure you get the idea. :)
Quote from: Toweliex86] link=topic=2860.msg28236#msg28236 date=1127088355]
should I hand out that site to freinds?
QuoteTry to break it!
He sounds confident about its stability to me. =p
Quote from: Sidoh on September 19, 2005, 12:26:47 AM
Hm. Not realy. Most programs have their own, custom template engine and several template files. As an example, a template file for a news post may look like:
Posted by <b>{postedBy}</b> at <b>{postedTime}</b> on <b>{postedDate}</b>
<hr />
<h3>{title}</h3>
{text}
This is just a very simple example. I'm sure you get the idea. :)
Cool.
Next question then: how do you parse that? I know that regex's are pretty slow, especially doing them every line, but is there a better way to do it in PHP?
Quote from: Joe[e2] on September 19, 2005, 12:50:24 AM
Quote from: Toweliex86] link=topic=2860.msg28236#msg28236 date=1127088355]
should I hand out that site to freinds?
QuoteTry to break it!
He sounds confident about its stability to me. =p
The best way to break it is to let lots of people to use it.
Another thing, though, I don't plan on using ads or anything like that, so if a lot of people are using it, and I can't handle it with my connection, I will have to make it private. That, or be a whore and put an ad on it to make enough money to pay for a real connection :). But I don't see that happening.
QuoteThat, or be a whore and put an ad on it to make enough money to pay for a real connection Smiley. But I don't see that happening.
Private sounds good to me. :D
I really don't want it to be private :-/
Why not ask Thing for some bandwith then, hes good like that. :)
Lately, whenever I talk to him, he always seems pretty hostile. I assume it's because he's always busy (what with WoW and stuff), and I just annoy him. Half the time he doesn't reply.
So yeah, I don't want to bug him.
The image sizes are pretty small, though. The biggest one is 103kb. 640x480 with 85% compression is pretty good.
str_replace usually, iago.
Awesome, I'll do that for the next release :D
Well, this is the best photo album I've ever seen, and will be using it instead of my own code when I get a server up. Amazing job, iago.
Quote from: Blaze on September 19, 2005, 10:03:37 PM
Well, this is the best photo album I've ever seen, and will be using it instead of my own code when I get a server up. Amazing job, iago.
Thanks :-D
Feel free to host images on mine, at least, once it's done. I doubt I'll be wiping the db again, but you never know :)
You should thank me for the name! =P
This may or may not be a "working name". I still haven't decided whether or not I love it :)
Question: What about for the tables and the album page? In a template, how would you indicate a list?
Again, I could figure this out myself, but there is probably a "right"er way of doing it :)
<edit> Also, do you think each user should be able to choose a different template for his pages? Or an individual template for each category, maybe?
<edit2> To answer my first question, I've decided to go with a .php template system, like SMF does. Hopefully that'll work out ok, it seems like the better way for what I need to do :)
<edit3> Warning: once I get this template stuff set up, I'm probably going to wipe the database again, so don't bother uploading anything complicated :)
I liked OPM (opium) more, but eh, ospap for the win! ;p
Why do you wipe the DB anyway, iago? =p
Because I want to make sure my create_tables.sql file works, and because dropping the tables is easier than modifying them :)
ALPHA 1 IS NO LONGER!!!!
Quote from: iago on September 20, 2005, 08:25:24 PM
Because I want to make sure my create_tables.sql file works, and because dropping the tables is easier than modifying them :)
Is create_talbes.sql a sort of installation file?
Quote from: Sidoh on September 20, 2005, 11:14:35 PM
Quote from: iago on September 20, 2005, 08:25:24 PM
Because I want to make sure my create_tables.sql file works, and because dropping the tables is easier than modifying them :)
Is create_talbes.sql a sort of installation file?
Yes.
mysql -u root -p -D ospap < create_tables.sql
Quote from: iago on September 21, 2005, 08:30:14 AM
Yes.
mysql -u root -p -D ospap < create_tables.sql
Just put them in a different database! :)
I suggest on your next major release, you dub the version "Opium". I'll even make you a catchy slogan for it!
Quote from: Sidoh on September 21, 2005, 09:10:54 AM
Quote from: iago on September 21, 2005, 08:30:14 AM
Yes.
mysql -u root -p -D ospap < create_tables.sql
Just put them in a different database! :)
What difference would that make? Once I change how the database is being used, the original database is completely useless. It doesn't contain the proper columns!
You should make a column for the database version, and have a routine in the code to upgrade the database.
Two problems there
1. I don't plan on changing the database, which isn't a big deal; but
2. I don't want to give my mysql user that much power over the database. He has select/insert/update/delete, and that's all I'm comfortable with. I don't even want create/drop.
Or make new code in a different area, and assign it to another database containing the other tables. It's your project though, so there's no use in me arguing lol.
Quote from: Sidoh on September 21, 2005, 05:21:45 PM
Or make new code in a different area, and assign it to another database containing the other tables. It's your project though, so there's no use in me arguing lol.
Well, arguing is good, because it helps me learn! I've never used PHP before this, and I've never used MySQL from a user perspective either.
I don't really understand what you're saying. What do you mean by "different area"?
Make a copy of the files, then have it get its information from a different database (a near copy of the one that your users are using). Then you can apply the changes when you're sure it works. :)
Also -- if you run your queries correctly, you can add and drop columns with little problems.
Ah, ok. That would be useful in a production-type system, but this is "Alpha" and I tell people I'm going to be wiping it when I need to, so it's not such a big deal :)
Quote from: iago on September 22, 2005, 11:26:58 AM
Ah, ok. That would be useful in a production-type system, but this is "Alpha" and I tell people I'm going to be wiping it when I need to, so it's not such a big deal :)
hehe. :)
Ok, I did some adding. I added skinnability, but I suck at design so I just made a boring skin modelled after vL's old forum.
To-do:
- Fix require_authorization
- Fix require_registration
- Add more comments to default skin
- Extra information in the categories table (owner, private)
http://www.javaop.com/~iago/ospap/index.php
http://www.javaop.com/~iago/ospap.tgz
Let me know what you think! And if somebody is feeling energetic, make me a skin. Or even design the pages in static html, and I'll convert them to PHP, that's fine too.
Very, very nice work iago.
:)
Question1: Do you think users should be able to choose their own skins that they view?
I'm thinking no, because the person running the album might want it to have a particular look and feel, depending on what he's doing with it.
Question2: Should users be able to choose skins for each of their categories?
I'm thinking yes, because some categories might be special (Christmas one, for example). But I'm also thinking no, because the skin changing from page-to-page might be a little annoying to users.
Question1: I agree.
Question2: Maybe a user preference to not show the theme?
#1 - No.
#2 - No.
Quote from: Sidoh on September 24, 2005, 12:36:48 AM
#1 - No.
#2 - No.
I like those answers best, because that's how it is now and I don't have to implement anything new :)
It's not about you, its the "consumer"
yes to both.
Quote from: Mythix on September 24, 2005, 02:39:44 AM
It's not about you, its the "consumer"
yes to both.
I was actually thinking in the mindset of the type of program it is, not just the amount of work iago would have to put in to implement these features.
QuoteI'm thinking no, because the person running the album might want it to have a particular look and feel, depending on what he's doing with it.
No.
Justification: What iago said. The user may have a look/feel that they want to go along with that album, and allowing users to automatically overwrite that (often without their knowledge -- they probably won't know that the set template is different then the one they've specified they want globally) doesn't really seem sensical to me.
QuoteQuestion2: Should users be able to choose skins for each of their categories?
I'm thinking yes, because some categories might be special (Christmas one, for example). But I'm also thinking no, because the skin changing from page-to-page might be a little annoying to users.
No.
Justification: What iago said. I don't know about you, but I really don't like having a layout change on me that often. Especially when navigation and things of this manner are changed (which they often are from template to template).
A couple of suggestions instead of doing things like
function display_footer()
{
print("<HR>\n");
print("Written by <A HREF=\"mailto:iago@valhallalegends.com\">Ron Bowes</A>, 2005. Comments welcome!\n");
print("</BODY>\n");
print("</HTML>\n");
}
in the skins try something like
function display_footer()
{
$footer = <<< FOOTER
<HR>
Written by <A HREF="mailto:iago@valhallalegends.com">Ron Bowes</A>, 2005. Comments welcome!
</BODY>
</HTML>
FOOTER;
print($footer);
}
Much friendlier when you want to go and change it.
Also when viewing images you should use Previous/Next vs the image's title because it makes it nicer and prevents someone from making a short title and forcing me to move my mouse.
I'd recommend making a file 'header.php' or something to that affect.
Quote from: zorm on September 25, 2005, 05:18:56 PM
A couple of suggestions instead of doing things like
function display_footer()
{
print("<HR>\n");
print("Written by <A HREF=\"mailto:iago@valhallalegends.com\">Ron Bowes</A>, 2005. Comments welcome!\n");
print("</BODY>\n");
print("</HTML>\n");
}
in the skins try something like
function display_footer()
{
$footer = <<< FOOTER
<HR>
Written by <A HREF="mailto:iago@valhallalegends.com">Ron Bowes</A>, 2005. Comments welcome!
</BODY>
</HTML>
FOOTER;
print($footer);
}
Much friendlier when you want to go and change it.
I personally like print's better, in every language I've used I've stuck with that, but since I hope that Templates will be used by others, I'll change it.
Quote from: zorm on September 25, 2005, 05:18:56 PM
Also when viewing images you should use Previous/Next vs the image's title because it makes it nicer and prevents someone from making a short title and forcing me to move my mouse.
Good point. Why don't you hover your mouse over the arrow ("-->"), since that doesn't move? I'll fix that up anyway
Thanks!
I think your picture.php is broken right now, none of the pictures are working.
hmm, they work for me!
Can you view the picture alone (right click -> view image), then view source. Is there some kind of english text being stuck in there?
Your username is Blaze, but it requires authorization by an administrator<BR>In the meantime, you can log into a different account<BR><HR>
:-\
Fixed!
http://www.javaop.com/~iago/ospap/show_category.php?category_id=6
Quote
Error!
invalid category_id
After logging out in my private category, and it keeps refreshing.
Thats two so far. :P
Hmm, yeah, I could see that..
Ok, I'll make it so if it has to refresh more than once, it'll refresh to index.php :)
Sorry for digging up this topic, but I have a quick suggestion for you iago.
As you've probably noticed, thumbnails that are generated on the fly aren't cached, which can be somewhat annoying when you're navigating through a photo album like that.
You may want to consider generating a thumbnail file for each picture added to your gallery.
Why not just have a link to the image where if it's bigger then say, 300w or 300h then make it have one side that is 300 w/h?
Example: I uploaded a 300x300 file. It stays that size, that's "thumbnail" size.
I uploaded a 500x400 file. It reduces in size by 25% to 375 x 300
Because that's a waste of bandwidth.
Since all thumbnails are displayed at the same size (or nearly the same size), resizing them in the image HTML tag is a complete waste of resources.
I generate thumbnails when images are uploaded.
Oh?
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22
That's the URL to one of your picture thumbnails.
Quote from: Sidoh on October 11, 2005, 08:14:44 PM
Oh?
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22
That's the URL to one of your picture thumbnails.
Yep, and that loads the thumbnail file:
Quote
if(isset($_GET['tn']) && $_GET['tn'] == "true")
$tn = true;
else
$tn = false;
// ...................
if($tn == true)
show_image("$upload_directory/tn-$file");
else
show_image("$upload_directory/$file");
Oh, I see what you're doing.
However, you may want to veer form using that methodology because it still prevents the thumbnails from caching.
Does it? I made sure I didn't put header("pragma: no-cache") in the thumbnail code.. :/
I wanted to make it possible to have "private" images, and to do that it has to go through the .php file.
Couldn't people just type in the picture name manually then?
Yeah, the thumbnails don't cache -- it's annoying for navigating, but I suppose it makes sense if you're trying to accomplish some level of private-ness.
Additionally, if you want images to be REALLY private, you could store them in a mysql database as blob data.
You should be able to append a .jpg/.gif/.whatever to the end of the url and have the browser cache it. Then use mod_rewrite or such on the server to fix it so that it gets processed by the php script.
Quote from: zorm on October 12, 2005, 02:47:54 AM
You should be able to append a .jpg/.gif/.whatever to the end of the url and have the browser cache it. Then use mod_rewrite or such on the server to fix it so that it gets processed by the php script.
The thumbnail files do end in image extentions, but he's listing them in the gallery using his php script to load them. He wanted to do that so the URL's of the thumbnails weren't public, but I'm suggesting that he doesn't load them through the script because they don't cache.
Quote from: Sidoh on October 12, 2005, 06:00:48 PM
The thumbnail files do end in image extentions, but he's listing them in the gallery using his php script to load them. He wanted to do that so the URL's of the thumbnails weren't public, but I'm suggesting that he doesn't load them through the script because they don't cache.
No they don't.
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22
Doesn't look like an image extention to me.
What I am suggesting is that he could do
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22.jpg
or
http://www.javaop.com/~iago/ospap/picture/tn-22.jpg
and then use mod_rewrite to force his php script (picture.php) to handle the request. This will allow browsers to cache the images but also allow access control in the event of private images.
Quote from: zorm on October 12, 2005, 11:10:02 PM
Quote from: Sidoh on October 12, 2005, 06:00:48 PM
The thumbnail files do end in image extentions, but he's listing them in the gallery using his php script to load them. He wanted to do that so the URL's of the thumbnails weren't public, but I'm suggesting that he doesn't load them through the script because they don't cache.
No they don't.
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22
Doesn't look like an image extention to me.
What I am suggesting is that he could do
http://www.javaop.com/~iago/ospap/picture.php?tn=true&picture_id=22.jpg
or
http://www.javaop.com/~iago/ospap/picture/tn-22.jpg
and then use mod_rewrite to force his php script (picture.php) to handle the request. This will allow browsers to cache the images but also allow access control in the event of private images.
I don't think the prior would work (I know you could get it to work, but it would defeat the purpose of what you're trying to accomplish), but the second thing you suggested is what I recommended to begin with.
Quote from: Sidoh on October 12, 2005, 11:39:42 PM
I don't think the prior would work (I know you could get it to work, but it would defeat the purpose of what you're trying to accomplish), but the second thing you suggested is what I recommended to begin with.
Its not at all, stop getting caught up in the urls and go read+learn about lovely things like mod_rewrite.
Hmm, that seems like a lot of trouble :-/
And yeah, if they're stored on a public path, then yeah, they can be viewed by directly typing in the URL. But I don't store them on a public path.
/me shrugs.
'twas a simple suggestion. :P
I don't really see the big deal behind having users knowing the URL to the thumbnail files. :P
Whats that checkbox next to "Create" do? (Create a category)
Log me in immediatly after registering =)
Quote from: Joe[e2] on October 13, 2005, 09:14:57 PM
Whats that checkbox next to "Create" do? (Create a category)
Makes the category private, if you read the mouse over. :P
Quote from: iago on October 11, 2005, 08:21:27 PM
Yep, and that loads the thumbnail file:
Quote
if(isset($_GET['tn']) && $_GET['tn'] == "true")
$tn = true;
else
$tn = false;
// ...................
if($tn == true)
show_image("$upload_directory/tn-$file");
else
show_image("$upload_directory/$file");
Your code could be more efficient ^^
IE: $tn is already assigned the value of $_GET['tn'], and since there is no type declaration, you can use
true instead of
"true". There, I just saved you a cycle or two.
Hehe.
Quote from: rabbit on October 14, 2005, 08:14:28 PM
Quote from: iago on October 11, 2005, 08:21:27 PM
Yep, and that loads the thumbnail file:
Quote
if(isset($_GET['tn']) && $_GET['tn'] == "true")
$tn = true;
else
$tn = false;
// ...................
if($tn == true)
show_image("$upload_directory/tn-$file");
else
show_image("$upload_directory/$file");
Your code could be more efficient ^^
IE: $tn is already assigned the value of $_GET['tn'], and since there is no type declaration, you can use true instead of "true". There, I just saved you a cycle or two.
Yeah, but I like my way better. It's a little more clear to read, in my opinion.
I really hate untyped languages. I even like Perl, which lets me declare variables (my $var), but php doesn't let me declare the existance of a variable. That bugs me.
But yeah, a couple cycles isn't worth a reduction in clarity.
Yes it does.
class img {
var $img;
var $color_back;
...
}
Hell, you don't even need a class to do it :\
Is there some way to make it show an error if you don't declare variables like that?
On Perl, it's "use strict;"
Quote from: rabbit on October 14, 2005, 11:22:54 PM
Hell, you don't even need a class to do it :\
Hehe, yeah. Was just an example. :)
Quote from: iago on October 14, 2005, 11:35:38 PM
Is there some way to make it show an error if you don't declare variables like that?
On Perl, it's "use strict;"
You might check in php.ini, but I kinda doubt it's possible. All PHP articles/books I've read state that PHP variable declarations are soley implicit (at least the datatype can never be explicitly defined, or at least that I'm aware of).
Quote from: iago on October 14, 2005, 11:35:38 PM
Is there some way to make it show an error if you don't declare variables like that?
On Perl, it's "use strict;"
Use
error_reporting(E_ALL); at the beginning of your core file (IE: the one that's always there, like the index.php or something). It will throw a warning when you use a variable that isn't
$_GET[],
$_POST[],
$_SESSION[], or
my.
There's also this entry in the php.ini file which usually (by default, on my box anyway) this:
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
Obviously, just change it to:
error_reporting = E_ALL
However, that's not going to stop your code from running, it will just display a Notice.
Just a note: using the error_reporting() function is easier than changing the PHP hard configuration.
Quote from: rabbit on October 15, 2005, 11:51:55 AM
Just a note: using the error_reporting() function is easier than changing the PHP hard configuration.
Not if you want to make a global change on your server. :P
It's easier to develop with E_ALL on in PHP.ini, then you don't have to worry about removing it when you deploy it (because people don't like error reporting in E_ALL, especially on scripts that are included as an addon or something to that affect).
Install a custom error handlers in your PHP code and treat the notices as fatal exceptions and exit your code.
Quote from: Warriorx86] link=topic=2860.msg33966#msg33966 date=1129492486]
Install a custom error handlers in your PHP code and treat the notices as fatal exceptions and exit your code.
That would be way too much work for such a silly thing.
It's surprisingly easy but yea I think it might be overdoing it a bit. Should help for other things though too.
Quote from: Warriorx86] link=topic=2860.msg34025#msg34025 date=1129502290]
It's surprisingly easy but yea I think it might be overdoing it a bit. Should help for other things though too.
I know, I've done it before. There's other unseen issues that it would affect too though. Doing it would be stupid. It's like having a car that doesn't work if it doesn't make a sound when the driver's side door is open. Quite useless.
You can of course filter the notice messages to the one you need :p
Quote from: Warriorx86] link=topic=2860.msg34073#msg34073 date=1129515392]
You can of course filter the notice messages to the one you need :p
Quote from: Sidoh on October 16, 2005, 10:08:33 PM
Quite useless.
: - P
Don't see how it's still useless if I showed how it could be singled out into one exception and handled from there instead of making the entire thing croak becauause of every notice. (Even though IMHO it should, it enforces nice programming)
Quote from: Warriorx86] link=topic=2860.msg34085#msg34085 date=1129522028]
Don't see how it's still useless if I showed how it could be singled out into one exception and handled from there instead of making the entire thing croak becauause of every notice. (Even though IMHO it should, it enforces nice programming)
I don't understand how not explicitly defining variables in a language that doesn't require it (or even imply that you should, unlike Visual Basic) is "nice programming." PHP's variable declarations work completely well when defined implicitly and I don't see a purpose in forcing code to define them explicitly. It's just stupid.
Having code croak on every notice would be
stupid for the lack of a better word.
Forcing all variables to be declared not only helps when debugging code, wait sometimes it eliminates the need to debug since the reason is right there. I fail to see where there is no advantage to this.
You *should* declare all of a functions's variables at the top of the function, along with comments on what they do. It helps you keep them straight, it forces you to stop and think about what you're doing, and it *greatly* helps anybody else who is looking at your code. Doing it that way really is *nice* code. Maybe it's not SO important in PHP, but right now I'm doing low level microcontroller programming, and it's very important.
It's not important in PHP. Debugging is a pretty negligible challenge in PHP, IMO.
Warrior, I'm not saying there's no advantage, I'm just saying its a moot effort. It's trying to make PHP something it's not. You're adding another unnecessary failure point.
Besides, if you use intuitive, predictable variable names, it doesn't do much for you declaring them at the beginning of a function. Most PHP code I use is outside of a function anyway. Most variables I handle are in a superglobal array, so moving them to a variable of lower scope is often a waste of time and resources.
Secondly, since variable types in PHP are determined completely by implicit methods, declaring variables doesn't increase the clarity of the code by that much. Declaring a variable in PHP (obviously) would look like this:
$int_variable = 0;
$str_variable = '0';
$flt_variable = '1.0';
$bol_variable = true;
Declaring a variable's scope in PHP is obviously a different story. I ALWAYS do this because not doing it is a complete waste of time, cleanliness of code and intelligence. If you have something like:
$db = new mysql_db();
function get_username($user_id, $db) {
// ...
}
get_username(1, $db);
It's pretty stupid when you can save a lot of trouble by doing:
$db = new mysql_db();
function get_username($user_id) {
global $db;
// ...
}
get_username(1);
You..actually use globals?
Quote from: Warriorx86] link=topic=2860.msg34158#msg34158 date=1129578198]
You..actually use globals?
Sometimes complexity makes code suck, you need to realize this. Developing some huge class hierarchy for some things is not only a complete waste of time, but you get caught up in doing that and it makes the entire system run slower and less efficiently.
This is straight from SMF's Sources/Profile.php. Unmodified (but clipped because I didn't want to copy the entire function).
function saveProfileChanges(&$profile_vars, &$post_errors, $memID)
{
global $db_prefix, $user_info, $txt, $modSettings, $user_profile, $newpassemail, $valida$
// These make life easier....
$old_profile = &$user_profile[$memID];
// Permissions...
if ($context['user']['is_owner'])
{
$changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own'$
$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
}
else
{
$changeIdentity = allowedTo('profile_identity_any');
$changeOther = allowedTo('profile_extra_any');
}
Note the global. :P
Don't think that I'm not capable of developing a class hierarchy, because it's quite easy. However, there's just some things in which it's worth isn't quite good enough.
Resurrected from the depths of page three, suggestion!
You might want to line up those rebelious textboxes in your register section.
Log in:<BR>
<FORM ACTION="login.php" METHOD="POST">
<TABLE>
<TR><TD>Username:</TD> <TD><INPUT TYPE="text" NAME="username"></TD></TR>
<TR><TD>Password:</TD> <TD><INPUT TYPE="password" NAME="password"></TD></TR>
<TR><TD><INPUT TYPE="submit" VALUE="Log in"></TR><TD>
</TABLE>
</FORM>
<HR>
If you haven't registered already, register an account:<BR>
<FORM ACTION="create_account.php" METHOD="post">
<TABLE>
<TR><TD>Username:</TD> <TD><INPUT TYPE="text" NAME="username" VALUE=""></TD></TR>
<TR><TD>Password:</TD> <TD><INPUT TYPE="password" NAME="password" VALUE=""></TD></TR>
<TR><TD>Confirm:</TD> <TD><INPUT TYPE="password" NAME="password2" VALUE=""></TD></TR>
<TR><TD>Email:</TD> <TD><INPUT TYPE="text" NAME="email" value=""></TD></TR>
<TR><TD>Email you when somebody posts a comment to your picture?</TD> <TD><INPUT TYPE="checkbox" NAME="notify_comments" CHECKED="checked"></TD></TR>
<TR><TD>Email you when somebody posts a new picture? (Note: this will probably get annoying)</TD> <TD><INPUT TYPE="checkbox" NAME="notify_pictures" VALUE="0"></TD></TR>
<TR><TD><INPUT TYPE="submit" VALUE="Create Account"></TR><TD>
</TABLE>
</FORM>
<HR>