To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Code Critique

Code Critique Having someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-29-2003, 07:53 PM   #1
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
Yeah, that looks like a custom function planetsim. Really needs some comments

Here's one I wrote to get around my proxy a while ago when pulling the slashdot RSS feed. It was a quick and dirty script, so i'm sure someone can make it better. Any ideas?

PHP Code:
<?
function damnProxy($page, $proxyHost, $proxyPort) {
    
$data = fsockopen($proxyHost, $proxyPort);  
    if(!
$data)  {
        
fclose($result);  
        echo
"Cannot access ".$page;
    }  
    else {  
        
fputs($data,"GET $page HTTP/1.0\n\n");  
        while(!
feof($data)) {
            
$cont=$cont.fread($data,4096);
        }
    }
    
fclose($data);
    return
substr($cont,strpos($cont,"\r\n\r\n")+4);
}

$slash = damnProxy("http://slashdot.org/slashdot.rdf", "proxy.yourcompany.com", 8080);
if(
$slash) {
    echo
$slash;
}
else {
    echo
"damned proxy";
}
?>
LordShryku is offline   Reply With Quote
Old 09-29-2003, 07:59 PM   #2
jstarkey
Civilian
 
jstarkey's Avatar
 
Join Date: Jul 2002
Location: 9500 ft
Posts: 1,104
Dear Lord,

I split your thread so that it doesn't get lost in thee hussle.
jstarkey is offline   Reply With Quote
Old 09-29-2003, 08:02 PM   #3
planetsim
code | beer > sleep
 
Join Date: Sep 2002
Location: aus
Posts: 4,826
Nice script there.. may come to use for many now as RSS feeds are becoming more popular
__________________
Dont be lazy Search
And use the Manual
Webmobo - Open Source News Script | Portfolio / Blog | Against TCPA
planetsim is offline   Reply With Quote
Old 09-29-2003, 08:04 PM   #4
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
What the hell's an RSS feed?
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Old 09-29-2003, 08:08 PM   #5
planetsim
code | beer > sleep
 
Join Date: Sep 2002
Location: aus
Posts: 4,826
Maybe this may help you

http://searchwebservices.techtarget....813358,00.html
__________________
Dont be lazy Search
And use the Manual
Webmobo - Open Source News Script | Portfolio / Blog | Against TCPA
planetsim is offline   Reply With Quote
Old 09-29-2003, 08:14 PM   #6
jstarkey
Civilian
 
jstarkey's Avatar
 
Join Date: Jul 2002
Location: 9500 ft
Posts: 1,104
We also have an RSS feed for the forums and articles here.

http://phpbuilder.com/linking.php
jstarkey is offline   Reply With Quote
Old 09-29-2003, 08:18 PM   #7
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
Thanks!
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Old 09-29-2003, 09:40 PM   #8
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
Man, just found my post. Thought jstarkey deleted it

So, that one just get's around the proxy. I got a class that parses the RDF file for me if anyone wants to see that also, I can post it tomorrow. I tried getting phpbuilder's feed, but didnt have much luck. Might need to try again sometime.

BTW....sorry for the lack of comments in the code, but I just never comment my code. Drawback from being the only coder at work I guess.
LordShryku is offline   Reply With Quote
Old 09-29-2003, 09:57 PM   #9
drawmack
Computers can do that?
 
drawmack's Avatar
 
Join Date: Apr 2003
Location: Pocono Mtns PA
Posts: 3,268
I started commenting when a client called me 18 months after originally programming his site for some changes.
drawmack is offline   Reply With Quote
Old 09-29-2003, 09:59 PM   #10
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
I'm sure I'd be commenting if I was selling my work, but I work for one company, doing internal apps. If I go, that means I'm fired. And screw em in that case
LordShryku is offline   Reply With Quote
Old 09-29-2003, 10:55 PM   #11
drawmack
Computers can do that?
 
drawmack's Avatar
 
Join Date: Apr 2003
Location: Pocono Mtns PA
Posts: 3,268
Lord, I understand your point but what about when they want a revision to something you wrote two years ago. When that happens, you'll probably start commenting.
drawmack is offline   Reply With Quote
Old 09-29-2003, 11:01 PM   #12
LordShryku
kung foo code monkey
 
LordShryku's Avatar
 
Join Date: Aug 2002
Location: Occupational Hypnotherapy
Posts: 7,473
Most of my stuff is pretty straight forward. Pull the info from the database. Display it. Not too much deviation. But yeah, I've been thinking for a while now that I need to adopt some sort of commenting standard. I just don;t find a need for it a lot. But you're right. No rebuttal needed. I know it
LordShryku is offline   Reply With Quote
Old 09-30-2003, 02:10 PM   #13
n00854180t
Senior Member
 
Join Date: Jun 2003
Posts: 479
Comments are a pain for me too. I appreciate them when they are there, but when I have a very limited time frame I tend to slack on using them.
n00854180t is offline   Reply With Quote
Old 09-30-2003, 06:57 PM   #14
planetsim
code | beer > sleep
 
Join Date: Sep 2002
Location: aus
Posts: 4,826
hmm.. i only tend to comment on complicated scripts.. which i will be modifying. If i know its not going to be modified i probably wouldnt waste my time but i guess its always a good idea..
__________________
Dont be lazy Search
And use the Manual
Webmobo - Open Source News Script | Portfolio / Blog | Against TCPA
planetsim is offline   Reply With Quote
Old 09-30-2003, 09:00 PM   #15
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
Yeah, I'd better comment and indent and improve and use better functions and shorten and add to my old calculator script. It's the second one I ever made. (First was MadLib, second was calculator, third was send me a message and that needs improving)

damn I need to improve all my scripts!
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:29 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.