From London Hackspace Wiki
Jump to navigation Jump to search

PHP script for generating HTML for auctions form a table of server listings, dumping it here for safe keeping.


$data = file_get_contents( dirname( __FILE__ ) . '/ebay.txt' );
$data = explode( "\n|-\n", $data );

foreach( $data as $server ) {
	$server = explode( "\n| ", $server );
	$server[0] = substr( $server[0], 2 );

	$id = substr( $server[0], strpos( $server[0], ' ' ) + 3, 2 );

	$url = substr( $server[1], 1, strpos( $server[1], ' ' ) - 1 );

	if( $server[8] === 'y' ) {
		$raid = "<li>{$server[11]} RAID";
		if( $server[9] === 'y' ) {
			$raid .= ' w/ Battery';
		$raid .= '</li>';
	} else {
		$raid = '';

	if( $server[10] === 'n' ) {
		$cables = '<p><strong>Please note this server is missing its internal cables.</strong></p>';
	} else {
		$cables = '';

	$abstract = <<<HTML
	<li>{$server[2]}U {$server[3]} {$server[4]} GHz Server, {$server[5]}GB RAM</li>
	<li>{$server[7]} {$server[6]} disk slots</li>

	$hinfo = file_get_contents( $url . 'ebay-summary.html' );

	$about = <<<HTML
<h2>About the London Hackspace</h2>
<p>The London Hackspace is a non-profit hackerspace in central London: a community-run workshop where people come to share tools and knowledge. We have a 1,300 square foot space in Shoreditch, just a stone's throw from Hoxton station. It's open to our members 24 hours a day, and we hold regular free events which are open to the public.
</p><p>We were donated a large amount of hardware by a local Internet company. We hope to use the proceeds of this sale to improve our space.

</p><p>Please see our full listings of items here: <a href="" class="external free" rel="nofollow"></a>
<h2><span class="mw-headline" id="Item_collection"> Item collection </span></h2>
<p>All items can to be collected from our workshop in Shoreditch (East London), near Hoxton station.  This is outside the congestion charge zone and has a 30-minute loading bay. Collection is preferred in the evenings, but any time of day can be arranged on request. We require that items be collected within 7 days of the end of the auction, if they aren't your payment will be returned (excluding fees) and we will re-list the item. 
</p><p>Post code: E2 8HD
</p><p>We can send these by courier, but this will take 3-4 working days as we buy packaging as needed.
<h2><span class="mw-headline" id="Payment"> Payment </span></h2>

<p>Payment is possible by PayPal (although we require payment within 4 working days of winning the item), or by cash when collecting the item.

	$page = $abstract . $hinfo . $about;

	file_put_contents( dirname( __FILE__ ) . '/ebay/' . $id . '.html', $page );