PageRenderTime 204ms CodeModel.GetById 70ms app.highlight 6ms RepoModel.GetById 70ms app.codeStats 0ms

/imapMailChecker/1_internetbaukasten_de_pagefiller.php

https://github.com/dimon36/projekt_1
PHP | 68 lines | 42 code | 9 blank | 17 comment | 4 complexity | 8b9fa96c2b6c433821ffae64e2dca215 MD5 | raw file
 1<?
 2//receive info about item
 3$db = new edb($db_data);
 4$dataFromBD = $db->line("select * from `saved_accounts` order by `id` desc limit 1");
 5$hostArr = parse_url('http://'.$dataFromBD['url']); 
 6$hostMain = $hostArr['host'];
 7
 8//API POST - query to receive article data
 9$article = new Curl;
10$response = $article->post('http://link.gutes-lernen.com/xml/request.php', array('req_id' => '0000', 'pass' => 'ad6cd7f8413b9b6bc0baaddf62d0ce59', 'get_domain' => 'false', 'dom_purl' => $hostMain, 'get_link' => 'false'));
11$articleBody = $response->body;
12$xml = json_decode(json_encode((array) simplexml_load_string($articleBody)), 1);
13//Formatting the Text
14$formattedText = '<h1>'.$xml['element']['head1'].'</h1>';
15$i=0;
16foreach ($xml['element']['head3'] as $head3) {
17	if (is_string($head3) == true)
18		$formattedText .= '<h3>'.$head3.'</h3>';
19	$text = $xml['element']['text'][$i];
20	if (is_string($text) == true)
21		$formattedText .= '<p>'.$text.'</p>';
22	$i++;	
23}
24
25$PageEdit = new Curl;
26
27//login to site
28$PageEdit-> post('http://www.internetbaukasten.de/index.php', array('aktion' => 'login', 'login' => $dataFromBD['Benutzername'], 'passwd' => $dataFromBD['Passwort']));
29
30//query to create new pages with subpage title text
31$response = $PageEdit->get('http://www.internetbaukasten.de/index.php?view=standalone_seiten_ajax');
32$pageToEdit = str_get_html($response->body);
33$ol = $pageToEdit->find("#seitenlisten_container", 0)->find("ol", 0);
34//find last id of page to send id
35$lastchild = $ol -> lastchild() -> id;
36preg_match_all("/list_(.*)/",$lastchild,$ok_id);
37$PageEdit-> post('http://www.internetbaukasten.de/index.php', array('back2where' => 'standalone_seiten_ajax', 'aktion' => 'seite_neu', 'seiten_id' => $ok_id[1][0], 'seiten_typ_id' => '1', 'titel' => $xml['element']['subpage_title'], 'sitetitle_o' => '', 'filename' => '', 'innav_o' => '0', 'secure' => '' , 'seitenkeywords' => '' , 'variante' => '0'));
38// receive id to new block
39$response = $PageEdit->get('http://www.internetbaukasten.de/index.php?view=bearbeiten');
40$pageToEdit = str_get_html($response->body);
41//receive last age link
42$id_site_link = $pageToEdit->find("#ibk_nav_ul", 0) -> lastchild() -> find('a', 0) -> href;
43//get the page to edit
44$response = $PageEdit->get('http://www.internetbaukasten.de/'.$id_site_link);
45$pageToEdit = str_get_html($response->body);
46$new_block = $pageToEdit -> find('.ibk_editiable_new', 0)->id;
47preg_match_all("/ibk_block_id_(.*)_elemente_id_11/",$new_block,$new_block_id);
48// create new block
49$PageEdit -> get('http://www.internetbaukasten.de/index.php?aktion=new_sub_block&block_id='.$new_block_id[1][0].'&elemente_id=1');
50$PageEdit -> get('http://www.internetbaukasten.de/index.php?aktion=set_block_typ&blockkombination_id=49');
51$PageEdit -> post('http://www.internetbaukasten.de/index.php', array('aktion' => 'edit_block_data', 'ta' => $formattedText));
52//update order
53//$orderArray = array();
54//foreach ($ol ->find('li') as $li) {
55//	$orderArray['list['.$li -> id.']'] = 'root';
56//}
57//$PageEdit-> post('http://www.internetbaukasten.de/index.php?aktion=seiten_update_order', $orderArray);
58	
59//export to the web
60$response = $PageEdit->get('http://www.internetbaukasten.de/index.php?view=export_web');
61$pageToEdit = str_get_html($response->body);
62$exportServerId = $pageToEdit -> find('#gratis_form', 0)->find('[checked=checked]', 0)->value;
63$PageEdit->post("http://www.internetbaukasten.de/index.php", array('exportServerId' => $exportServerId, 'aktion' => 'export_start', 'privateServer' => '0', 'domainweiterleitung' => '0'));
64$PageEdit->get('http://www.internetbaukasten.de/index.php?aktion=export_do');
65
66
67
68