Archive:ServerHardwareAuction/ebay.php
From London Hackspace Wiki
(Created page with "PHP script for generating HTML for auctions form a table of server listings, dumping it here for safe keeping. <pre> <?php $data = file_get_contents( dirname( __FILE__ ) . '/eb...") |
m (JasperWallace moved page Project:ServerHardwareAuction/ebay.php to Archive:ServerHardwareAuction/ebay.php without leaving a redirect: olde) |
Latest revision as of 13:22, 8 October 2014
PHP script for generating HTML for auctions form a table of server listings, dumping it here for safe keeping.
<?php $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 <ul> <li>{$server[2]}U {$server[3]} {$server[4]} GHz Server, {$server[5]}GB RAM</li> <li>{$server[7]} {$server[6]} disk slots</li> $raid </ul> $cables <p>{$server[13]}</p> HTML; $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="http://shop.ebay.co.uk/londonhackspace/m.html" class="external free" rel="nofollow">http://shop.ebay.co.uk/londonhackspace/m.html</a> </p> <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. </p> <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. </p> HTML; $page = $abstract . $hinfo . $about; file_put_contents( dirname( __FILE__ ) . '/ebay/' . $id . '.html', $page ); }