Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP 1000lines


ghost's Avatar
0 0

Right,

As I have important GCSE exam coming up I decided to challenge myself. The challenge? To create various bits of software using only one file and less than 1000lines? The result

A complete blogging system, using 969, which includes, install, and

  • Add, Edit and Delete posts
  • Add, Edit and Delete comments
  • Modify the style sheet (stored in the same file)
  • Archive page
  • Various bits of Ajax

Thoughts?

  • Added RSS Functionality

ghost's Avatar
0 0

sweet, i know that i for one couldnt do that. maybe you could put it on an example site or something? and if your willing to give it away for free then you could offer a download. i would really like to see it anyway.


Neo_Chalchus's Avatar
Lover of Parkour
0 0

That's a pretty good challenge, what will it be programmed in? If it is one file then you can't change languages TOO much because it would take up lines for calling the languages. I am very interested to see how it will turn out.
Does your line count include comments and headers? Or is it only lines of code? This seems like it would be pretty tough, but I am mostly non-internet based dev, and alot of the online side of things are not my strong side when developing, but that is alot of stuff to fit in 1000 lines, but I am rooting for ya. Be sure to tell me how you did. :D NC


ghost's Avatar
0 0

At the moment I am working on improving the admin pannel, although with about 41 lines of leeway thats kinda tricky. The beta release is going out on monday, but an example is here

http://phpgsy.com/1000lines

Did I mention that the code has to be properly spaced and tabbed as well?

Its all in PHP and doesn't include any other files (although if you want it will overwrite the htaccess to make the url's pretty


spyware's Avatar
Banned
0 0

technically, you could put all the code on one line.


ghost's Avatar
0 0

spyware wrote: technically, you could put all the code on one line.

its wouldnt exactly be…user friendly


ghost's Avatar
0 0

spyware wrote: technically, you could put all the code on one line.

I did say that the PHP had to be properly formated… tabs etc

[EDIT]Not sure whether to create RSS stream or nice background?


What_A_Legend's Avatar
...Legend?
0 0

WOW Mozzer I Am Impressed and I must say I do like the CSS editor :P


ghost's Avatar
0 0

Yes, this is an awesome Idea indeed! I logged in and checked it out…sweet ;) I'd love to see some code when ur done :D Will it be publicly available??


ghost's Avatar
0 0

Erm… It appears to be broekeded, I get an unexpected T_STRING on line 24


ghost's Avatar
0 0

Damn, someone has found a serious exploit in the code, fixing it now :)

(That was the whole string error thing) although they didn't actually realize they had a hack for it =)

What were you saying about SQL DOS Spyware?

No comments on the RSS or admin panel?


ghost's Avatar
0 0

mozzer wrote: Damn, someone has found a serious exploit in the code, fixing it now :)

(That was the whole string error thing) although they didn't actually realize they had a hack for it =)

Erm… that was me trying to put Javascript in a stylesheet… Unless someone hacked it at same time


ghost's Avatar
0 0

Talking about sami?

Yeah, that was it


ghost's Avatar
0 0

Yup…


ghost's Avatar
0 0

I think I have a way to do both the admin pannel, rss and an html editor!

Thought I'd add the code for counting the number of lines

markup$this->footer = "Lines: " . count(file(__FILE__));


ghost's Avatar
0 0

Complete!

I will be releasing the source code tomorrow, I also expect people to point out all six bugs which need fixing

Night


ghost's Avatar
0 0

lol. I see teh uber 1337 blank page


ghost's Avatar
0 0

Not for me


richohealey's Avatar
Python Ninja
0 0

is niiiiice.

i wish i ahd enough spare time to pick through 998 lines of code….


ghost's Avatar
0 0

SORRY. It works now.

function blog ( ) { $this->{get_parent_class(CLASS)}(); $this->arrayActions = unserialize ( ACTIONS ); $this->action = isset ( $_GET['action'] ) && !is_array ( $_GET['action'] ) && isset ( $this->arrayActions[$_GET['action']] ) ? strtolower ( $_GET['action'] ) : 'home'; $this->request = isset ( $_GET['request'] ) ? true : false;

    $this->request  = isset ( $_GET['ajax'] ) ? true : false;
    $this->{$this->arrayActions[$this->action]}();
    echo $this->parsePage();
}

I think that you can make -2 lines here.

{ $this->{get_parent_class(CLASS)}();

and

    echo $this->parsePage(); }

I don't think it's cheating


ghost's Avatar
0 0

Lol, I need to improve it, but I think my GCSEs will get in the way. Damn them


ghost's Avatar
0 0

Yes. I noticed about 10 lines so far that are just blank.

You can have even 956 lines (although it's not cool as 998)


ghost's Avatar
0 0

Hmm, show me where you shortened it (without ruining the layout)


ghost's Avatar
0 0

mozzer wrote: Hmm, show me where you shortened it (without ruining the layout)

hmm well, if you look at the code, almost every 5. line is blank. At least for my monitor. I think you can see it also.

$this->request = isset ( $_GET['request'] ) ? true : false;

    $this->request  = isset ( $_GET['ajax'] ) ? true : false;

}

function showNews ( $rss = false )

}

function showRSS ( )

}

function updateMySQL ( )

And many more

CP's I am calling you


richohealey's Avatar
Python Ninja
0 0

jHe already said that it was to be well formatted. if he didn't care about readablility he could remove every new line on the page and a have a one line CMS


ghost's Avatar
0 0

Well, IMHO, I think that there should be lines between functions… makes code more readable

markup$preset[strtolower($constant)] = $this->{"clean".$constant} ( constant ($constant) );

^^ My favourite line


ghost's Avatar
0 0

richohealey wrote: jHe already said that it was to be well formatted. if he didn't care about readablility he could remove every new line on the page and a have a one line CMS

He wanted to know which lines. (Helpful kaksii always helps) ;)


ghost's Avatar
0 0

kaksii wrote: He wanted to know which lines. (Helpful kaksii always helps) ;)

Dude… there is trying to get CP and there is going insane… you're drifting :P

[/offtopic]

On topic… what do people think of the way I am storing the CSS as a serialized array which is converted from standard CSS? Keeps it on one line and allows for editting


ghost's Avatar
0 0

mozzer wrote: Dude… there is trying to get CP and there is going insane… you're drifting :P

O shit I know. Since Richo removed my 10 CP's I think I am going crazy.

nah. I am in the mood for doing nothing :p I'll stop. I don't want my precious 10 CP's to be deleted.

[/offtopic]


ghost's Avatar
0 0

/Applauds mozzer


ghost's Avatar
0 0

No comments about the way it has been done?


ghost's Avatar
0 0

No one cares :(


jaggedlancer's Avatar
The Localhost Hacker
20 0

I care :p Its pretty cool for something done in 1000 lines, good luck for the final version cant wait :D


ghost's Avatar
0 0

Damn GCSEs look like they're going to be in the way thought

French tomorrow


ghost's Avatar
0 0

mozzer wrote: Damn GCSEs look like they're going to be in the way thought

French tomorrow

i have french as well! had oral (ha ha very funny i said oral) about a week ago adn listening and reading on 8th. writing on 15th. NOT NICE!!!!! anyway, good luck in them!


ghost's Avatar
0 0

Just got back from French, kinda screwed it up…. ah well…


ghost's Avatar
0 0

the html editor only edits CSS note, it was me who made the text colours different ( to firebrick )