cyrilleinvalides/choupas/www/admin/trash/sharer.php

191 lines
3.5 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$func = include('auth.php');
function title_to_url ( $title ) {
$title = trim($title);
$title = preg_replace('!\s++!', '-', $title);
$title = preg_replace('!é|è!', 'e', $title);
$title = preg_replace('!à!', 'a', $title);
$title = preg_replace('!â!', 'a', $title);
$title = preg_replace('!\'!', '-', $title);
$title = preg_replace('!\"!', '-', $title);
$title = preg_replace('!\!', '-', $title);
return $title;
}
$service = Provider::get('etpa')->getChild('Model', $_GET['type'])->Service->crud;
$item = $service->read(array(
'id' => $_GET['id']
));
$item = $item[0];
$service->update(array(
'id' => $_GET['id'],
'shared' => $item['shared'] . ',' . $_GET['provider']
));
if ( $_GET['type'] === 'anciens' || $_GET['type'] === 'grandsPrix' ) {
$data = array(
'title' => $item['prenom'] . ' ' . $item['nom'],
'text' => $item['imageAlt'],
'image' => $item['image'],
'url' => 'http://www.etpa.com/rencontres.html#' . $item['id']
);
} else {
if ( $item['texteBreve'] )
$text = $item['texteBreve'];
elseif ( $item['texte1'] )
$text = $item['texte1'];
elseif ( $item['texteVideo1'] )
$text = $item['texteVideo1'];
$data = array(
'title' => $item['titre'],
'text' => $text,
'image' => $item['image1'],
'url' => 'http://www.etpa.com/' . ( $item['url'] ?: sprintf('actualites/%1$s/%2$s.html', title_to_url($item['formation']), title_to_url($item['titre'])) ),
);
}
if ( $_GET['provider'] === 'tw' ) {
$data = array(
'status' => mb_substr($data['title'] . ' ' . $data['url'] . ' ' . $data['text'], 0, 140),
'media' => array($data['image']),
);
$x = ETPA::getTwitter(array(
'oauth_token' => '1208806574-ctvNYr9mbktVAXumVIqswkbR2w5A6vaBth2yZOc',
'oauth_token_secret' => 'zQ5A8X3oPxCKaCYxa9ZQ8R08cBxLi6lhWDLuvKEaQ',
));
$a = $x->post('http://api.twitter.com/1.1/statuses/update.json', $data);
//~ header('Location: ' . $_GET['next']);
} elseif ( $_GET['provider'] === 'fb' ) {
$ipesaaId = '379468185438957';
$fb = ETPA::getFacebook();
//~ try {
if ( !( $user = $fb->getUser() ) ) {
header('Location: ' . $fb->getLoginUrl(array(
'scope' => 'offline_access, manage_pages, publish_stream'
)));
die();
}
$ipesaaToken = '';
$accounts = $fb->api('/me/accounts/');
foreach ( $accounts['data'] as $page )
if ( $page['id'] == $ipesaaId )
$ipesaaToken = $page['access_token'];
if ( !$ipesaaToken ) {
echo TemplateSystem::get('main')->load('pages/error.html')->render(array(
'message' => 'Impossible de trouver la fanpage ESMA, vous devez vous connecter avec le compte administrateur de la page ESMA!',
'link' => '<a href="' . $fb->getLogoutUrl() . '">cliquer ici pour vous deconnecter et continuer</a>'
));
die();
}
$fb->setAccessToken($ipesaaToken);
$data = array(
'uid' => $ipesaaId,
'name' => $data['title'],
'caption' => $data['text'],
'picture' => $data['image'],
'link' => $data['url'],
);
$fb->api('/' . $ipesaaId . '/feed?privacy={"value":"EVERYONE"}', 'POST', $data);
header('Location: ' . $_SERVER['HTTP_REFERER'] . '&fb=1');
die();
} elseif ( $_GET['provider'] === 'pin' ) {
$data['image'] = urlencode($data['image']);
$data['url'] = urlencode($data['url']);
$data['text'] = urlencode($data['text']);
die(header("Location: http://pinterest.com/pin/create/button/?url={$data['url']}&media={$data['image']}&description={$data['text']}"));
}
die(header('Location: ' . $_SERVER['HTTP_REFERER']));
?>