flickr-imageripperajax
Gesponsorde koppelingen
PHP script bestanden
index.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Flickr <-> Kliksafe Cracker</title>
<script type="text/javascript" src="ajax-functions.js"></script>
<link rel="stylesheet" type="text/css" href="flickrstyle.css" />
</head>
<body>
<div id="hiddencontent" style="display:none"></div>
<div id="loading">
Bezig met laden...<br />
<img src="images/loading.gif" alt="loading" />
</div>
<div id="header">
<div><span style="color:#0063dc">Flick</span>r<sup style="font-size:12px">™</sup> ImageRipper</div>
<div style="font-size:20px;color:#aa0020">Kliksafe cracked</div>
<form method="post" action="javascript:getFlickrImages()">
<input type="text" id="searchinput" onfocus="this.style.backgroundColor='#fbf'" onblur="this.style.backgroundColor='#fff'" />
<input type="submit" id="searchsubmit" value="Zoek Flickr" style="width:200px;" />
</form>
</div>
<div id="content">
<div style="font-size:20px;margin-top:15%;color:#888;">
Typ een zoekopdracht!
</div>
</div>
<div id="navcontainer"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Flickr <-> Kliksafe Cracker</title>
<script type="text/javascript" src="ajax-functions.js"></script>
<link rel="stylesheet" type="text/css" href="flickrstyle.css" />
</head>
<body>
<div id="hiddencontent" style="display:none"></div>
<div id="loading">
Bezig met laden...<br />
<img src="images/loading.gif" alt="loading" />
</div>
<div id="header">
<div><span style="color:#0063dc">Flick</span>r<sup style="font-size:12px">™</sup> ImageRipper</div>
<div style="font-size:20px;color:#aa0020">Kliksafe cracked</div>
<form method="post" action="javascript:getFlickrImages()">
<input type="text" id="searchinput" onfocus="this.style.backgroundColor='#fbf'" onblur="this.style.backgroundColor='#fff'" />
<input type="submit" id="searchsubmit" value="Zoek Flickr" style="width:200px;" />
</form>
</div>
<div id="content">
<div style="font-size:20px;margin-top:15%;color:#888;">
Typ een zoekopdracht!
</div>
</div>
<div id="navcontainer"></div>
</body>
</html>
javascriptfile: ajax-functions.js
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function Ajax(){
var xmlHttp;
this.createXMLHttpRequest = function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
this.startAjaxRequest = function startAjaxRequest(url,data,functie) {
actie = functie
show_hide_elem('loading','show')
this.createXMLHttpRequest();
xmlHttp.onreadystatechange = this.handleStateChange;
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(data);
}
this.handleStateChange = function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
eval(actie)
show_hide_elem('loading','hide')
}
else{
alert('Er is een fout opgetreden: (' + xmlHttp.status + ') ' + xmlHttp.responseText)
}
}
}
}
function toggle_element(elementid){
var toggleelement = document.getElementById(elementid)
if(toggleelement.style.display == 'none' || toggleelement.style.display == ''){
toggleelement.style.display = 'block'
}
else if(toggleelement.style.display == 'block'){
toggleelement.style.display = 'none'
}
}
function show_hide_elem(elementid,s_h){
var toggleelement = document.getElementById(elementid)
var show_hide = s_h
if(show_hide == 'show'){
if(toggleelement.style.display == 'none' || toggleelement.style.display == ''){
toggleelement.style.display = 'block'
}
}
else if(show_hide == 'hide'){
if(toggleelement.style.display == 'block'){
toggleelement.style.display = 'none'
}
}
}
function getFlickrImages(flickrnav){
var submitknop = document.getElementById('searchsubmit')
submitknop.disabled = true
submitknop.value = 'Bezig met zoeken...'
var container = document.getElementById('content')
if(container.childNodes.length > 0){
for(i=0;container.childNodes.length;i++){
container.removeChild(container.firstChild)
}
}
var navcontainer = document.getElementById('navcontainer')
if(navcontainer.childNodes.length > 0){
for(i=0;navcontainer.childNodes.length;i++){
navcontainer.removeChild(navcontainer.firstChild)
}
}
var searchvalue = document.getElementById('searchinput').value
var parsedsearchvalue = searchvalue.replace(' ','+')
if(flickrnav == null){
var flickrpage = 'http://68.142.214.24/search/?q=' + parsedsearchvalue
}
else{
var flickrpage = 'http://68.142.214.24' + flickrnav
}
var info = 'flickrpage=' + flickrpage
var ajax_ding = new Ajax();
ajax_ding.startAjaxRequest('ajax-actions.php?action=get_images',info,'getFlickrImages_action(xmlHttp.responseText)')
}
function getFlickrImages_action(xmltekst){
var submitknop = document.getElementById('searchsubmit')
submitknop.disabled = false
submitknop.value = 'Zoek Flickr'
var tempsplit = xmltekst.split('[datadivide]')
var urls = tempsplit[0]
var urlarray = urls.split('[urldivide]')
for(i=0;i<=urlarray.length - 2;i++){
var contentelem = document.getElementById('content')
var newimage = contentelem.appendChild(document.createElement('img'))
var parsedurl = urlarray[i].replace('http://farm1.static.flickr.com','http://68.142.213.135')
newimage.src = parsedurl
}
var nextlinksrc = tempsplit[1]
if(nextlinksrc != ''){
var navcontainer = document.getElementById('navcontainer')
var newnextlink = navcontainer.appendChild(document.createElement('a'))
newnextlink.href= '#'
newnextlink.onclick = function(){getFlickrImages(nextlinksrc)}
newnextlink.appendChild(document.createTextNode('Volgende'))
}
}
var xmlHttp;
this.createXMLHttpRequest = function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
this.startAjaxRequest = function startAjaxRequest(url,data,functie) {
actie = functie
show_hide_elem('loading','show')
this.createXMLHttpRequest();
xmlHttp.onreadystatechange = this.handleStateChange;
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(data);
}
this.handleStateChange = function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
eval(actie)
show_hide_elem('loading','hide')
}
else{
alert('Er is een fout opgetreden: (' + xmlHttp.status + ') ' + xmlHttp.responseText)
}
}
}
}
function toggle_element(elementid){
var toggleelement = document.getElementById(elementid)
if(toggleelement.style.display == 'none' || toggleelement.style.display == ''){
toggleelement.style.display = 'block'
}
else if(toggleelement.style.display == 'block'){
toggleelement.style.display = 'none'
}
}
function show_hide_elem(elementid,s_h){
var toggleelement = document.getElementById(elementid)
var show_hide = s_h
if(show_hide == 'show'){
if(toggleelement.style.display == 'none' || toggleelement.style.display == ''){
toggleelement.style.display = 'block'
}
}
else if(show_hide == 'hide'){
if(toggleelement.style.display == 'block'){
toggleelement.style.display = 'none'
}
}
}
function getFlickrImages(flickrnav){
var submitknop = document.getElementById('searchsubmit')
submitknop.disabled = true
submitknop.value = 'Bezig met zoeken...'
var container = document.getElementById('content')
if(container.childNodes.length > 0){
for(i=0;container.childNodes.length;i++){
container.removeChild(container.firstChild)
}
}
var navcontainer = document.getElementById('navcontainer')
if(navcontainer.childNodes.length > 0){
for(i=0;navcontainer.childNodes.length;i++){
navcontainer.removeChild(navcontainer.firstChild)
}
}
var searchvalue = document.getElementById('searchinput').value
var parsedsearchvalue = searchvalue.replace(' ','+')
if(flickrnav == null){
var flickrpage = 'http://68.142.214.24/search/?q=' + parsedsearchvalue
}
else{
var flickrpage = 'http://68.142.214.24' + flickrnav
}
var info = 'flickrpage=' + flickrpage
var ajax_ding = new Ajax();
ajax_ding.startAjaxRequest('ajax-actions.php?action=get_images',info,'getFlickrImages_action(xmlHttp.responseText)')
}
function getFlickrImages_action(xmltekst){
var submitknop = document.getElementById('searchsubmit')
submitknop.disabled = false
submitknop.value = 'Zoek Flickr'
var tempsplit = xmltekst.split('[datadivide]')
var urls = tempsplit[0]
var urlarray = urls.split('[urldivide]')
for(i=0;i<=urlarray.length - 2;i++){
var contentelem = document.getElementById('content')
var newimage = contentelem.appendChild(document.createElement('img'))
var parsedurl = urlarray[i].replace('http://farm1.static.flickr.com','http://68.142.213.135')
newimage.src = parsedurl
}
var nextlinksrc = tempsplit[1]
if(nextlinksrc != ''){
var navcontainer = document.getElementById('navcontainer')
var newnextlink = navcontainer.appendChild(document.createElement('a'))
newnextlink.href= '#'
newnextlink.onclick = function(){getFlickrImages(nextlinksrc)}
newnextlink.appendChild(document.createTextNode('Volgende'))
}
}
php server pagina: ajax-actions.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
switch($_GET['action']){
case 'get_images':
$url = $_POST['flickrpage'].'&page='.$_POST['page'].'&m=text';
$tekst = file_get_contents($url);
$doc = new DOMDocument();
$doc->loadHTML($tekst);
$doc->saveHTML();
$tds = $doc->getElementsByTagName('td');
foreach ($tds as $param) {
$class = $param -> getAttribute('class');
if($class == 'DetailPic'){
$imgs = $param -> getElementsByTagName('img');
foreach ($imgs as $plaatje) {
$imgurl = $plaatje -> getAttribute('src');
echo $imgurl.'[urldivide]';
}
}
}
echo '[datadivide]';
//haal volgende-pagina URL op
$divs = $doc->getElementsByTagName('div');
foreach ($divs as $div) {
$nextclass = $div -> getAttribute('class');
if($nextclass == 'Paginator'){
$links = $div -> getElementsByTagName('a');
foreach ($links as $link) {
$linkclass = $link -> getAttribute('class');
if($linkclass == 'Next'){
echo $link -> getAttribute('href');
}
}
}
}
break;
}
?>
switch($_GET['action']){
case 'get_images':
$url = $_POST['flickrpage'].'&page='.$_POST['page'].'&m=text';
$tekst = file_get_contents($url);
$doc = new DOMDocument();
$doc->loadHTML($tekst);
$doc->saveHTML();
$tds = $doc->getElementsByTagName('td');
foreach ($tds as $param) {
$class = $param -> getAttribute('class');
if($class == 'DetailPic'){
$imgs = $param -> getElementsByTagName('img');
foreach ($imgs as $plaatje) {
$imgurl = $plaatje -> getAttribute('src');
echo $imgurl.'[urldivide]';
}
}
}
echo '[datadivide]';
//haal volgende-pagina URL op
$divs = $doc->getElementsByTagName('div');
foreach ($divs as $div) {
$nextclass = $div -> getAttribute('class');
if($nextclass == 'Paginator'){
$links = $div -> getElementsByTagName('a');
foreach ($links as $link) {
$linkclass = $link -> getAttribute('class');
if($linkclass == 'Next'){
echo $link -> getAttribute('href');
}
}
}
}
break;
}
?>