1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8function wikiplugin_myspace_info()
9{
10	return [
11		'name' => tra('MySpace'),
12		'documentation' => 'PluginMySpace',
13		'description' => tra('Display a MySpace Flash mp3 playlist'),
14		'prefs' => [ 'wikiplugin_myspace' ],
15		'iconname' => 'music',
16		'introduced' => 3,
17		'params' => [
18			'page' => [
19				'required' => true,
20				'name' => tra('MySpace Page'),
21				'description' => tra('MySpace page name.'),
22				'since' => '3.0',
23				'default' => '',
24				'filter' => 'text',
25			]
26		]
27	];
28}
29
30function wikiplugin_myspace($data, $params)
31{
32
33	extract($params, EXTR_SKIP);
34
35	if (! isset($page)) {
36		return "error page parameter requested";
37	}
38	$ch = curl_init("http://www.myspace.com/$page");
39	//$ch = curl_init("http://www.google.com/");
40	//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
41	 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
42	$data = curl_exec($ch);
43	curl_close($ch);
44	if (! $data) {
45		return "pas d'chance";
46	}
47
48	$a = stripos($data, '<OBJECT id="mp3player" ');
49	$data = substr($data, $a);
50	$a = stripos($data, '</OBJECT>');
51	$data = substr($data, 0, $a + strlen('</OBJECT>'));
52
53	$data = str_replace("\n", " ", $data);
54	$data = str_replace("\r", " ", $data);
55
56	return $data;
57}
58