feed   myspace   facebook   last.fm   send an email   twitter   tumblr   send a message via aim to graykicksass

Posts tagged ‘php’

Writing webapps in QuickBasic 4.5

Disclaimer: I realize this has no real valuable use whatsoever.

First off, credit where credit is due, when I initially had to setup the CGI I ran into a problem solved buy a guy on reddit, who managed to write a website clone in quickbasic. You have to do a simple C++ stub app that can direct the output from quickbasic apps into the server.

In order to pull this off, you’ll need a copy of the following tools:
1. Dev C++ (For compiling the stub app, to make your life easier, grab the one with a compiler built into the install) here

2.Quickbasic 4.5 (capable of generating EXE files) here

I also recommend xampp, very quick installation, works perfectly for this example. Grab it here


Now, to actually install quickbasic from this zip on windows, you have to create a fake A drive, or copy the files to a floppy.

The trick to doing this is a command line trick called subst

So, copy the quickbasic disk1 folder from the download, place it in a folder on C: like, FLOPPY1 and run this:
subst a: C:\FLOPPY1

Run the quickbasic setup app on the fake disk, when prompted to insert another disk, copy the contents of disk2 into the fake drive. Hopefully you’ll be able to run quickbasic now, and be greeted by this screen:

QuickBasic 4.5 welcome screen

QuickBasic 4.5 welcome screen

Once your in quickbasic, navigate the menus with ALT or your mouse, type out this simple program:

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT “”

Move over to the run menu and hit make EXE file, save your app. The app will be in the saved file directory, take it, rename it something simple (e.g. ‘app.exe’) and close.

Now, open up dev C++, navigate to File->New->Project and select console application, select C++ for the language, copy and paste this code into main.cpp:

#include <iostream>
#include <string>
#include <stdio.h>
int main(int argc, char *argv[])
{
std::string piper;
FILE* data = popen(“app.exe”,”r”);

for(char c = getc(data);c != EOF;c = getc(data))
{
piper.push_back(c);
}
pclose(data);

std::cout << piper;
return 0;
}

Press ctrl+F9 to compile or select compile from the menu. Open the directory where you saved the project, and copy the generated EXE file over to your cgi-bin directory (in htdocs for apache, with xampp it’s in the root directory of xampp/cgi-bin).

Now, with the stub in cgi-bin, rename your compiled quickbasic app to ‘app.exe’, and copy it to cgi-bin. Navigate to http://localhost/cgi-bin/stub.exe where stub.exe is whatever your compiled C++ application is called, you should now see a screen something like this:

hello world from quickbasic

hello world from quickbasic

Now you can run your webapps and display output in the browser, all you need now is to parse CGI variables, which is done via the ENVIRON$ function.

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT ENVIRON$(“QUERY_STRING”)
PRINT “”

QUERY_STRING is set by the CGI gateway, accessing this page with a url like http://localhost/cgi-bin/qload.exe?bla would print:
“Hello World! bla”

This has no real practical use anymore, but it’s just interesting to try out. Also, sorry about the code blocks here being screwed up, wordpress managed to mangle them.

Sorry for the lack of updates..

I’ve been a bit busy :P , but a lot has been done since I last posted something..

1. I finished the Rhymbee Freelance client, PHP based server + Shockwave Client. All done (http://graymatter.hostkiwi.co.uk/rhbee/ <<version without graphics when server is up)

2. Did some more JS practice ( http://graymatter.hostkiwi.co.uk/jswalk/walk.htm and http://graymatter.hostkiwi.co.uk/jsfield.htm# ).

3. Created an AIML based message poster, that ‘intelligently’ replied to posts on a certain board.. (will post source later)

I’ll be posting more code snippets soon, and will have theme sorted (gonna share with scriptd) in a while.

TapShirt — What’s done

TapShirt.org now has a domain, is setup with hosting / store structure.

Newest core framework is installed on it, but we still need a layout :/. Building shirt search engine / product aggregator work is really just starting. Listing products will probably take a couple days to do, then there’s product display, shopping cart, etc. So lots of work to be done on it.

Interested in joining the small team working on it? Drop me a line at graham.stachowiak (at) gmail.com .

Very basic php server..

But it works, unlike a lot I’ve seen, I wrote up a basic client for it:

http://graymatter.hostkiwi.co.uk/php-client/

and you can register at: http://graymatter.hostkiwi.co.uk/php_framework/testsite/register.php
It checks if it’s up on the client page :p.  This was all coded between like, 2:50 this morning and now so don’t expect a ton. Might release server source later on imcedev or something..

The ego framework.

There’s a long story behind this and in the coming days, all will be explained.

But I now present to you the code of a page using the ego framework, when we get it all finished properly it will be awesome:

The internet before ego:
<html>
<head>
<title>The ugly page</title>
</head>
<body>
<h1>The Ugly Page</h1><br />
<div id="bla">This page sucks, loads links normally, and doesn't come out of the browser looking good. Why would a market-demographic like a teenager or somebody want to look at this page? Unless your a coder and it's full of awesome content, you don't.</div>
</body>
</html>

The internet after ego:
<?php
    include('ego_framework.php');
    $ego = new ego();
    $ego->__init();
?>
<html>
<head>
<title>The new hot page</title>
</head>
<body>
<?php echo $ego->WriteHeadBar(); ?>
<h1>The HOT Page</h1><br />
<div id="bla">This page doesn't suck because it used the 'Ego' framework, it looks nice and is auto stylized with the 'ego' template. And don't worry about CSS classes ego's JS system will take care of that.<a href="two.php" type="ajax">Click here</a></div>
<?php echo $ego->WriteFooterBar(); ?>
<div id="extra-footer">And here ego's JS system will automatically stylize this bit. For copyrights and shit</div>
</body>
</html>
two.php:
<div id="bla">This content will be dynamically loaded and replaced! All with a simple link</div>

It’s awesome, make pages look good and enter a network of sites. And use OpenLogin’s existing framework(<< secret) at the same time. Cool.

More news on this and it’s big parent project in a couple days. Expect blog about sushi later.

Writing a social site network.

So I create a lot of internet sites. And I know people that create a lot of internet sites. And I like it this way, I like having 100’s of sites that I visit. But the annoying thing is the globalized login system.

This has actually been in the works for a while, since somewhere near the start of Axcid. It was never fully documented as a login system and got cut out of the latest Axcid API version.

The goal? To create a network of sites. What the plan was?

  • Implement a social login system.
  • Implement a fully compatible XML login API for it, that also allowed access to some public user data.
  • Implement Facebook & Myspace integration applications, aswell as a small social network using the login system.
  • Implement an OpenID provider system, allowing you to login on OpenID sites with our details, but not the reverse.
  • A global site ‘framework’ allowing for fast creation of new sites, layout generation, site cross-integration and quick ajax frameworks.

So I’d like to hear your thoughts on this idea, as a developer, would you use a freely availible login framework? Would people be open to the idea of a site directory? Would developing this into all products be worthwhile? Leave a comment by going to the full post link or drop me a line @ anon@nati0n.org and tell me your thoughts.

Today I learned.. All about Google Maps & AJAX

http://graymatter.hostkiwi.co.uk/maps_experiment/#

Best viewed with FireFox 3, Fullscreen mode. Search does not seem to work in google chrome and I do NOT expect it to work in IE.

But anyways this was me learning the Google Maps API, GeoCoding and AJAX all in one day, plus some cool UI tricks.

F11 does the fullscreen for firefox 3 on windows btw ;) . Now let’s tear the thing apart:
I used the google maps api (http://code.google.com/apis/maps/documentation/) and tried to learn as much as possible. My own code to generate the 3 buttons used. AJAX for the search and google / my code for the ajax search (geosearch.php). That basically created and parsed calls to a geocoder which converted the search query into a latitude / longitude pair. That was then passed in my navigation function thru the XMLHTTP object and then eval’d. So my function would run and navigate it.

A pretty cool way to learn ajax and the maps api huh? I’ll give the source to anyone who is intrested but the page source tells a lot of the story :P . Great learning experience. I’m gonna go take a look at what other API’s google has :P .
EDIT:

Screenshot of the original running fullscreen: http://graymatter.hostkiwi.co.uk/supercool.png

before it had supercool stuff :P