get_key("task", "get"));
if($task and !empty($task)) {
$this->$task();
}
else {
session_destroy();
$this->show_form();
}
}
private function show_form() {
global $smarty, $db, $getpost_mgr;
$this->output("grabber_form.tpl");
}
private function process_main_urls() {
global $db;
foreach($this->main_urls as $key => $main_url) {
echo "Read Base Uri: " . $main_url['site_url'] . "
";
$this->open_url_entry_base($main_url['site_url']);
unset($this->main_urls[$key]);
$this->do_ajax("do");
}
$this->post_status();
shuffle($this->check_links);
return "do_sub";
}
private function do_index() {
global $db, $getpost_mgr;
$this->checked_links = $_SESSION['checked_links'];
$this->check_links = $_SESSION['check_links'];
$this->main_urls = $_SESSION['main_urls'];
$this->invalid_links = $_SESSION['invalid_links'];
$this->passed_links = $_SESSION['passed_links'];
$this->external_links = $_SESSION['external_links'];
$this->page_gen = microtime(true);
$work_id = $getpost_mgr->get_key("work","get");
$this->main_urls = $_SESSION['main_urls'];
$this->checked_links = $_SESSION['checked_links'];
switch($work_id) {
case 'start':
$action = $this->getting_url_list();
$this->do_ajax($action);
break;
case 'do':
$this->process_main_urls();
$this->do_ajax("do_sub");
break;
case 'do_sub':
$action = $this->process_sub_pages();
$this->post_status();
$this->do_ajax($action);
break;
case 'restart':
break;
default:
break;
}
/*if($work_id != 0) {
$last_url = $_SESSION['last'];
$this->checked_links = $_SESSION['checked_links'];
$this->check_links = $_SESSION['check_links'];
$parsed = parse_url($last_url);
if($parsed['scheme'] == "javascript") {
var_dump($this->check_links);
die();
if(is_array($this->check_links)) {
foreach($this->check_links as $item) {
if(!in_array($item, $this->checked_links)) {
$last_url = $item;
}
}
}
}
$this->open_url_entry($last_url);
}
else {
unset($_SESSION['checked_links']);
unset($_SESSION['check_links']);
foreach($this->main_urls as $key => $row) {
$this->open_url_entry($row['site_url']);
}
}
*/
}
private function getting_url_list() {
global $db;
echo "
' . count($result) . " Base Links Found
";
$this->main_urls = $result;
return "do";
}
else {
echo ']*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
$var = preg_match_all("/$regexp/siU",$content, $links, PREG_SET_ORDER);
die("/$regexp/siU");
//var_dump($base_uri_array);
$meta = $this->getMetaData($base_url, $content);
if(is_array($meta)) {
$this->update_entry($base_url, $content, $meta, $action);
foreach($links as $key => $link) {
try {
extract($this->check_link($base_url, $link[2]));
$this->add_link($url, $is_external, $is_passed, 1);
}
catch(Exception $e) {
switch ($e->getCode()) {
case 3:
$this->add_link($link[2], 1, 1, 0);
break;
case 4:
break;
}
}
}
$this->checked_links[] = $base_url;
}
else {
$this->checked_links[] = $base_url;
$this->add_link($base_url, 1, 1, 0);
}
}
private function process_sub_pages() {
global $db;
if(count($this->check_links) != 0) {
$i = 0;
foreach($this->check_links as $key => $item) {
if(!@in_array($item, $this->checked_links)) {
if(!@in_array($item, $this->passed_links)) {
$parsed = parse_url($item);
if($parsed['scheme'] != "javascript") {
echo "Read Subpageuri: " . $item;
$ret = $this->open_url_entry($item);
if($ret == "do_sub") {
echo ' Checked!
';
}
else {
echo ' Passed!
';
}
if($i >= 10) {
return "do_sub";
}
$i++;
}
else {
$this->invalid_links[] = $item;
}
}
}
}
session_destroy();
return "do";
}
else {
$this->post_status();
return "do";
}
}
private function post_status() {
echo "
" . count($this->check_links). " internal Links found!
";
echo " " . count($this->external_links). " external Links found!
";
echo " " . count($this->invalid_links). " invalid Links!
";
echo " " . count($this->passed_links). " Links passed!
";
echo "" . count($this->checked_links). " Links checked!
";
echo "Last Link in internal links: " . @end($this->check_links). "
";
echo " Last Link in external links: " . @end($this->external_links). "
";
echo " Last Link in invalid links: " . @end($this->invalid_links). "
";
echo " Last Link in Passed links: " . @end($this->passed_links). "
";
echo " Last Link in checked links: " . @end($this->checked_links). "
";
echo "
List external Links
";
if(is_array($this->external_links)) {
foreach($this->external_links as $ex_url) {
echo "
>" . $ex_url . "
";
}
}
echo "
";
}
private function do_ajax($action, $last_url ='') {
$_SESSION['last'] = $last_url;
$_SESSION['checked_links'] = $this->checked_links;
$_SESSION['check_links'] = $this->check_links;
$_SESSION['main_urls'] = $this->main_urls;
$_SESSION['invalid_links'] = $this->invalid_links;
$_SESSION['passed_links'] = $this->passed_links;
$_SESSION['external_links'] = $this->external_links;
$time = $stop-$this->page_gen;
switch($action) {
case "do":
if(count($this->main_urls) >= 1) {
echo "|" .$action;
exit;
}
break;
case "start":
echo "|" .$action;
exit;
break;
default:
echo "|" .$action;
exit;
}
//echo $time . " Sekunden läuft das sript schon
";
}
function output($file) {
global $smarty;
$smarty->display($file);
}
}
?>