De script
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
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
<?php
/**
* @author Eris First setup
* @license GPL 2.0 or newer
* @date 02-02-2007
* Description: Recives a wikiping from a wiki and put it into a database.
* Written for PHPnieuws.nl
*
* Due leak of ability to test a lot with different wiki's
* I can't tell any thing about the support of other wiki's
* Script is written for WikkaWiki (http://www.wikkawiki.org)
*/
error_reporting(0);
//Connect towards the database
if($link = mysql_connect('localhost','root',''))
{
if(!mysql_select_db('test',$link))
{
$link = false;
}
}
if(!$link)
{
$error = 'Unable to connect towards the database';
}
//define the data array;
$data = array();
//strip any non supported tags
$allowed_keys = array('tag','url','wiki','author','authorpage','history');
if(!empty($HTTP_RAW_POST_DATA))
{
//we could not use SimpleXML due no support for PHP 4
$xml_praser = xml_parser_create();
//tell the vars to the xml phrasers
xml_parse_into_struct($xml_praser,$HTTP_RAW_POST_DATA,$xml_keys,$xml_index);
xml_parser_free($xml_praser);
foreach($xml_index['MEMBER'] as $key)
{
if($xml_keys[$key]['type'] == 'open')
{
if(in_array($xml_keys[$key + 1]['value'],$allowed_keys))
{
//don't ask me why but this seems to be working
$data[$xml_keys[$key + 1]['value']] = $xml_keys[$key + 3]['value'];
}
}
}
if(!empty($data))
{
//put data into database
if($link)
{
$sql = 'insert into wikiping set';
//create sql QUERY
foreach($data as $label => $value)
{
$sql.= ' '.$label.'="'.mysql_real_escape_string($value,$link).'",';
}
//add a date
$sql.= ' date_received = now()';
//send to database
if(!mysql_query($sql,$link))
{
$error = 'Error during insert into database';
}
}
else
{
$error = 'No valid data availble';
}
}
}
else
{
$error = 'No Raw post data availble';
}
if (isset($error))
{
echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
echo "<response>\n";
echo "<error>1</error>\n";
echo "<message>$error</message>\n";
echo "</response>";
}
else
{
echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
echo "<response>\n";
echo "<error>0</error>\n";
echo "</response>";
}
?>
/**
* @author Eris First setup
* @license GPL 2.0 or newer
* @date 02-02-2007
* Description: Recives a wikiping from a wiki and put it into a database.
* Written for PHPnieuws.nl
*
* Due leak of ability to test a lot with different wiki's
* I can't tell any thing about the support of other wiki's
* Script is written for WikkaWiki (http://www.wikkawiki.org)
*/
error_reporting(0);
//Connect towards the database
if($link = mysql_connect('localhost','root',''))
{
if(!mysql_select_db('test',$link))
{
$link = false;
}
}
if(!$link)
{
$error = 'Unable to connect towards the database';
}
//define the data array;
$data = array();
//strip any non supported tags
$allowed_keys = array('tag','url','wiki','author','authorpage','history');
if(!empty($HTTP_RAW_POST_DATA))
{
//we could not use SimpleXML due no support for PHP 4
$xml_praser = xml_parser_create();
//tell the vars to the xml phrasers
xml_parse_into_struct($xml_praser,$HTTP_RAW_POST_DATA,$xml_keys,$xml_index);
xml_parser_free($xml_praser);
foreach($xml_index['MEMBER'] as $key)
{
if($xml_keys[$key]['type'] == 'open')
{
if(in_array($xml_keys[$key + 1]['value'],$allowed_keys))
{
//don't ask me why but this seems to be working
$data[$xml_keys[$key + 1]['value']] = $xml_keys[$key + 3]['value'];
}
}
}
if(!empty($data))
{
//put data into database
if($link)
{
$sql = 'insert into wikiping set';
//create sql QUERY
foreach($data as $label => $value)
{
$sql.= ' '.$label.'="'.mysql_real_escape_string($value,$link).'",';
}
//add a date
$sql.= ' date_received = now()';
//send to database
if(!mysql_query($sql,$link))
{
$error = 'Error during insert into database';
}
}
else
{
$error = 'No valid data availble';
}
}
}
else
{
$error = 'No Raw post data availble';
}
if (isset($error))
{
echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
echo "<response>\n";
echo "<error>1</error>\n";
echo "<message>$error</message>\n";
echo "</response>";
}
else
{
echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
echo "<response>\n";
echo "<error>0</error>\n";
echo "</response>";
}
?>
« vorige pagina | volgende pagina »
Inhoudsopgave
- Wiki ping
- Wat is een wikiping
- XML bestand
- De script
- Uitleg van de PHP code
- Uitlezen
- Tabel Structuur
- Ondersteuning van wiki's
- Waarom zo uitgebreid