Viewing file: joomlacode.php (4.23 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
# $Id$
# Expose Joomlacode Files Scraper Tool
# Copyright (C) 2010 GotGTEK. All rights reserved.
# License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Joomlacode Files Scraper</title>
<link href="joomlacode.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="main">
<?php
// http://simplehtmldom.sourceforge.net/ - X11 License (aka MIT License)
include_once('simple_html_dom.php');
// Base URL to the GForge site
$url_root = "http://joomlacode.org";
/***********************************/
// ONLY EDIT THIS LINE!!!
// For most people it will be enough with replacing
// expose with the name of your project.
// URL from root to project Files page
$url_base = "/gf/project/expose/frs/";
/***********************************/
// Captures the URL paramaters
$url_request = $_SERVER['QUERY_STRING'];
// Debug - $url_request
// echo '<p><h1><font color="orange">'.$url_request.'</font></h1></p>';
// Select request or not and builds the URL
if (!empty($url_request))
{
$url = $url_root.$url_request;
} else {
$url = $url_root.$url_base;
}
// Debug - $url
// echo '<p><h1><font color="orange"><br /><br />'.$url.'</font></h1></p>';
// Imports the page into memory
$html = file_get_html($url);
// Extracts the table containing the Files list aka "<table class="tabular">"
$table = $html->find('table[class="tabular"]', 0);
// Replaces the a href values with the correct URL
foreach($table->find('tr[class="th"] a') as $element)
{
$th_a_value = $element->href;
$element->href = $url_root.$th_a_value;
}
// Replaces the img src values with the correct URL
foreach($table->find('tr[class="l"] a[href^="/gf/project/"], tr[class="d"] a[href^="/gf/project/"]') as $element)
{
$project_a_value = $element->href;
$element->href = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$project_a_value;
}
// Replaces the a href values with the correct download URL
foreach($table->find('tr[class="l"] a[href^="/gf/download/"], tr[class="d"] a[href^="/gf/download/"]') as $element)
{
$dl_a_value = $element->href;
$element->href = $url_root.$dl_a_value;
}
// Replaces the img src values with the correct URL
foreach($table->find('img') as $element)
{
$img_value = $element->src;
$element->src = $url_root.$img_value;
$element->alt = null;
}
// Replace Download text with 'DL #'
foreach($table->find('table[class="tabular2"] tr[class="th"] th[style="text-align:left;"] table th[style="padding-right:3px;margin:0px;"]') as $element)
{
$element->innertext = 'DL #';
}
// Remove Download quickmenu
foreach($table->find('table[class="tabular2"] tr[class="th"] th[style="text-align:right;"]') as $element)
{
$element->outertext = '';
}
/*
* Replaces the a href values with the URL for this file and
* global URL for the onmouseover & onmouseout actions
*/
foreach($table->find('area') as $element)
{
$area_herf_value = $element->href;
$element->href = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$area_herf_value;
$area_onmouseover_value = $element->onmouseover;
$area_onmouseover_value_new = str_replace(".src=\"",".src=\"$url_root",$area_onmouseover_value);
$element->onmouseover = $area_onmouseover_value_new;
$area_onmouseout_value = $element->onmouseout;
$area_onmouseout_value_new = str_replace(".src=\"",".src=\"$url_root",$area_onmouseover_value);
$element->onmouseout = $area_onmouseout_value_new;
}
// Render new table
echo $table->outertext;
// Clear memory
$html->clear();
unset($html, $table);
?>
</div>
</body>
</html>
|