|
|
@@ -49,8 +49,25 @@ class HomeController extends AbstractController
|
|
|
$text = $form->get('text')->getData();
|
|
|
$mentions = array();
|
|
|
$hashtags = array();
|
|
|
+ $dp = array();
|
|
|
+ $dh = array();
|
|
|
+ $urls = array();
|
|
|
preg_match_all("~@([a-zA-Z0-9_]*)~", $text, $mentions);
|
|
|
preg_match_all("~#([a-zA-Z0-9_]*)~", $text, $hashtags);
|
|
|
+ preg_match_all("!DP %(.+)(?:\s|$)!U", $text, $dp);
|
|
|
+ preg_match_all("!DH %(.+)(?:\s|$)!U", $text, $dh);
|
|
|
+ preg_match_all("~[a-z]+://\S+~", $text, $urls);
|
|
|
+ for($i = 0; $i < sizeof($urls[0]); $i++) {
|
|
|
+ $url = $urls[0][$i];
|
|
|
+ $urls[1][$i] = "<a href='$url'>$url</a>";
|
|
|
+ $u = explode("/", $urls[0][$i]);
|
|
|
+ $formatted_url = "";
|
|
|
+ foreach ($u as $u_part) {
|
|
|
+ $formatted_url .= $u_part . "\/";
|
|
|
+ }
|
|
|
+ $urls[0][$i] = "~[a-z]+://\S+~";
|
|
|
+ }
|
|
|
+ $text = preg_replace($urls[0], $urls[1], $text);
|
|
|
for($i=0; $i < sizeof($mentions[0]); $i++) {
|
|
|
$user = $repository_profile->findOneBy(array('username' => $mentions[1][$i]));
|
|
|
if ($user) {
|
|
|
@@ -74,6 +91,50 @@ class HomeController extends AbstractController
|
|
|
$hashtags[0][$i] = "~" . $hashtags[0][$i] . "~";
|
|
|
$em->persist($hashtag);
|
|
|
}
|
|
|
+ for($i=0; $i < sizeof($dp[0]); $i++) {
|
|
|
+ $ch = curl_init("https://richie.u-strasbg.fr/~virgile/sf4/public/index.php/cours/diablo/");
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ $json_response = json_decode($response, true);
|
|
|
+ $battletag = $json_response["battleTag"];
|
|
|
+ if (str_replace("-", "#", $dp[1][$i]) == $battletag) {
|
|
|
+ $parangon = $json_response["paragonLevel"];
|
|
|
+ $parangon_season = $json_response["paragonLevelSeason"];
|
|
|
+ $kills = $json_response["kills"]["monsters"];
|
|
|
+ $kills_elites = $json_response["kills"]["elites"];
|
|
|
+ $profile_name = $dp[1][$i];
|
|
|
+ $dp[1][$i] = "<a href='#' data-toggle='popover' data-original-title='$profile_name' data-content='Parangon : $parangon ; Parangon saisonnier : $parangon_season ; Nombre de tués : $kills ; Nombre d élites tués : $kills_elites'>$profile_name</a>";
|
|
|
+ $dp[0][$i] = "~" . $dp[0][$i] . "~";
|
|
|
+ $text = preg_replace($dp[0], $dp[1], $text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for($i=0; $i < sizeof($dh[0]); $i++) {
|
|
|
+ $values = explode("/", $dh[1][$i]);
|
|
|
+ $ch = curl_init("https://richie.u-strasbg.fr/~virgile/sf4/public/index.php/cours/diablo/");
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ $json_response = json_decode($response, true);
|
|
|
+ $battletag = $json_response["battleTag"];
|
|
|
+ $found_hero = null;
|
|
|
+ if (str_replace("-", "#", $values[0]) == $battletag) {
|
|
|
+ foreach ($json_response["heroes"] as $hero) {
|
|
|
+ if ($hero["name"] == $values[1]) {
|
|
|
+ $found_hero = $hero;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($found_hero) {
|
|
|
+ $hero_name = $found_hero["name"];
|
|
|
+ $hero_class = $found_hero["class"];
|
|
|
+ $hero_level = $found_hero["level"];
|
|
|
+ $dh[1][$i] = "<a href='#' data-toggle='popover' data-original-title='$hero_name' data-content='Classe : $hero_class Niveau : $hero_level'>$hero_name</a>";
|
|
|
+ $dh[0][$i] = "~" . $dh[0][$i] . "~";
|
|
|
+ $text = preg_replace($dh[0], $dh[1], $text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
$text = preg_replace($mentions[0], $mentions[1], $text);
|
|
|
$message->setText(preg_replace($hashtags[0], $hashtags[1], $text));
|
|
|
$message->setSender($profile);
|