diff --git a/css/style.css b/css/style.css index a082ed58cbff3d15d9f2ddad3fcc774487f1fd86..c9022237ba993c05860a5d5fd77041f4c6a03f7e 100644 --- a/css/style.css +++ b/css/style.css @@ -248,7 +248,7 @@ button.submit:hover { } .bg2 { - background: url(../images/1.jpg)no-repeat center; + background: url(../images/1.jpg)repeat center; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; @@ -268,7 +268,7 @@ button.submit:hover { .bg1, .bg2 { min-height: 50vw; - height: 700px; + /*height: 700px;*/ } /*-- text Slider --*/ @@ -1427,7 +1427,7 @@ input.img { input.img + label { border: 3px dotted transparent; display: inline-block; - opacity: .7; + opacity: .7; } input.img:checked + label { border-color: red; @@ -1438,11 +1438,11 @@ input.img:checked + label { /* AJOUT DE KEVIN : PAGE ACCUEIL */ #suggestionButtons { - width: 400px; - margin:auto; - display: flex; - align-items: center; - justify-content: flex-start; + width: 400px; + margin:auto; + display: flex; + align-items: center; + justify-content: flex-start; flex-direction: column; } @@ -1495,4 +1495,4 @@ input.img:checked + label { -/* -- //Responsive code -- */ \ No newline at end of file +/* -- //Responsive code -- */ diff --git a/facto.php b/facto.php index eb3871220e9c974e5b2afd49982c3aa53f6b7854..1ec6330459860d100b365ed9ff107e02f019c852 100644 --- a/facto.php +++ b/facto.php @@ -17,7 +17,7 @@ function head(){ } </script> <!--// Meta tag Keywords --> - + <!-- go to user_page--> <script> function tz(){ @@ -61,7 +61,7 @@ function header2($where){ <nav class="navbar navbar-expand-lg navbar-light py-4"> <div class="container"> <h1 style="margin: auto"> - <a class="navbar-brand" href="'.$where.'"> + <a class="navbar-brand" href="../page_welcome/index.php"> <!-- <i class="fas fa-utensils"></i> --> <img width="50" height="50" src="../images/ll.png" alt="logo"> Know Your Influencer @@ -76,36 +76,35 @@ function header2($where){ <ul class="navbar-nav mx-auto text-center"> <li class="nav-item active"> - <a class="nav-link" href="'.$where.'">Home + <a class="nav-link" href="../page_welcome/index.php">Home <span class="sr-only">(current)</span> </a> </li> - <li class="nav-item"> - <a class="nav-link scroll" href="#semaine">Influencer</a> - </li> + <li class="nav-item">'; + if (isset($_SESSION['username'])) + echo '<a class="nav-link" href="../page_user/user.php">My influencers</a>'; + else + echo '<a class="nav-link scroll" href="../page_user/user.php"></a>'; + echo' + </li> </ul> <div class="forms-w3ls-agilesm text-center mt-lg-0 mt-4"> <ul> - <li class="login-list-w3ls d-inline border-right pr-3 mr-3">'; - if (!($_SESSION['username'])) + <li class="login-list-w3ls d-inline pr-3 mr-3">'; + if (!isset($_SESSION['username'])) echo '<a id="modal_trigger" href="#modal" class="text-white">Login | Register</a>'; else { - echo '<span style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif"><a href="userpage.php" style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif">'.$_SESSION['username'] .'</a> | <a href="logout.php" style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif">Log out</a></span>'; + echo '<span style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif"><a href="../page_welcome/userpage.php" style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif">'.$_SESSION['username'] .'</a> | <a href="../page_welcome/logout.php" style="color: #fff; letter-spacing: 2px; font-size: 15px; padding: 0.5em 0; font-family: "Source Sans Pro", sans-serif">Log out</a></span>'; } echo ' </li> </ul> </div> - - <div>'; - if ($_SESSION['username']) - echo '<button onclick="tz()">user</button>'; - - echo ' + <div> </div> - - + + </div> </div> </nav> @@ -146,11 +145,11 @@ function header2($where){ <!-- Username & Password Login form --> <div class="user_login"> - <form action="login.php" method="post"> + <form action="../page_welcome/login.php" method="post"> <label>Username</label> <input type="text" name="username"/> <br /> - + <input type="hidden" name="back" value="'.$_SERVER["REQUEST_URI"].'"/> <label>Password</label> <input type="password" name="password"/> <br /> @@ -171,7 +170,7 @@ function header2($where){ <!-- Register Form --> <div class="user_register"> - <form action="register.php" method="post"> + <form action="../page_welcome/register.php" method="post"> <!-- <label>First name</label> <input type="text" name="firstname" /> <br /> diff --git a/graphs/graphFunctions.php b/graphs/graphFunctions.php new file mode 100644 index 0000000000000000000000000000000000000000..c2e603da1b43ec59dbadf10b018c9554020e6db3 --- /dev/null +++ b/graphs/graphFunctions.php @@ -0,0 +1,108 @@ +<?php +/* Include the `fusioncharts.php` file that contains functions to embed the charts. */ +include("fusioncharts-suite-xt/integrations/php/fusioncharts-wrapper/fusioncharts.php"); +require_once('../API_Twitter/userInfosFunctions.php'); +/** + * Must have included the JS + */ +function lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $data, $width, $height) { + // Chart Configuration stored in Associative Array + $arrChartConfig = array( + "chart" => array( + "caption" => $caption, + //"subCaption" => "In MMbbl = One Million barrels", + "xAxisName" => $xAxisName, + "yAxisName" => $yAxisName, + "lineThickness" => "2", + "theme" => "fusion" + ) + ); + + // An array of hash objects which stores data + $arrChartData = []; + + $mean = 0; + + $count = count($data); + for ($i=0; $i<$count; $i++) { + $arrChartData[] = [ + 'label' => $i, + 'value' => $data[$i] + ]; + $mean += $data[$i]; + } + $mean = round($mean/$count, 2); + + // An array which stores trend-lines + $arrTrendLines = []; + $arrTrendLines[] = [ + "line" => [ + [ + "startvalue" => $mean, + "color" => "#1aaf5d", + "displayvalue" => "Mean = ".$mean, + "valueOnRight" => "1", + "thickness" => "2" + ] + ] + ]; + + $arrChartConfig["data"] = $arrChartData; + $arrChartConfig["trendLines"] = $arrTrendLines; + + // JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. + $jsonEncodedData = json_encode($arrChartConfig); + + // chart object + $Chart = new FusionCharts("line", $caption , $width, $height, $chartName, "json", $jsonEncodedData); + + // Render the chart + $Chart->render(); + echo '<center> <div id="'.$chartName.'">Chart will render here!</div> </center>'; +} + +function diagramme($favt){ + echo ' + <script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script> + <script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script> + <script type="text/javascript"> + FusionCharts.ready(function(){ + var fusioncharts = new FusionCharts({ + type: "bar2d", + renderAt: "diagtwitter", + width: "500", + height: "400", + dataFormat: "json", + dataSource: { + "chart": { + "theme": "fusion", + "caption": "Les meilleurs favoris", + "subCaption": "Twitter", + "yAxisName": "Nombre de followers", + "numberPrefix": "$", + "alignCaptionWithCanvas": "0" + }, + + "data": [' ; + for( $i=0 ; $i < count($favt)-2 ; $i++){ + $name = getUserScreenName($favt[$i]); + $followers = getUserNbFollowers($favt[$i]); + echo ' { + "label": "'.$name.'", + "value": "'.$followers.'" + },'; + } + + $name = getUserScreenName($favt[count($favt)-1]); + $followers = getUserNbFollowers($favt[count($favt)-1]); + echo '{ + "label": "'.$name.'", + "value": "'.$followers.'" + }] + } + })}); + fusioncharts.render(); + </script>' ; +} + +?> diff --git a/graphs/test.php b/graphs/test.php index 78e9469e4a8699d03623ce84cb8a4498c7f501ce..bcfc9a88b45e358c018babb88cfe785fbaa422f7 100644 --- a/graphs/test.php +++ b/graphs/test.php @@ -5,8 +5,62 @@ require_once('../API_Twitter/tweetInfosFunctions.php'); ?> +<html> +<head> +<title>My first chart using FusionCharts Suite XT</title> +<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script> +<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script> +<script type="text/javascript"> + FusionCharts.ready(function(){ + var fusioncharts = new FusionCharts({ + type: 'bar2d', + renderAt: 'chart-container', + width: '500', + height: '400', + dataFormat: 'json', + dataSource: { + "chart": { + "theme": "fusion", + "caption": "Top 5 Stores by Sales", + "subCaption": "Last month", + "yAxisName": "Sales (In USD)", + "numberPrefix": "$", + "alignCaptionWithCanvas": "0" + }, + + "data": [{ + "label": "Bakersfield Central", + "value": "880000" + }, + { + "label": "Garden Groove harbour", + "value": "730000" + }, + { + "label": "Los Angeles Topanga", + "value": "590000" + }, + { + "label": "Compton-Rancho Dom", + "value": "520000" + }, + { + "label": "Daly City Serramonte", + "value": "330000" + } + ] + } +}); + fusioncharts.render(); + }); +</script> +</head> +<body> + <div id="chart-container">FusionCharts XT will load here!</div> +</body> +</html> - +<!-- <html> <head> @@ -43,7 +97,7 @@ require_once('../API_Twitter/tweetInfosFunctions.php'); $count = count($likes); for ($i=0; $i<$count; $i++) { $arrChartData[] = [ - 'label' => $i, + 'label' => $i, 'value' => $likes[$i] ]; $likeMoyen += $likes[$i]; @@ -61,7 +115,7 @@ require_once('../API_Twitter/tweetInfosFunctions.php'); "valueOnRight" => "1", "thickness" => "2" ] - ] + ] ]; $arrChartConfig["data"] = $arrChartData; @@ -81,4 +135,6 @@ require_once('../API_Twitter/tweetInfosFunctions.php'); <div id="chart-container">Chart will render here!</div> </center> </body> -</html> \ No newline at end of file +</html> + +--> diff --git a/images/3.png b/images/3.png deleted file mode 100644 index 4564a922e6ca05a85b75f1047f7e94006dff7726..0000000000000000000000000000000000000000 Binary files a/images/3.png and /dev/null differ diff --git a/images/a1.jpg b/images/a1.jpg deleted file mode 100644 index 247ff849d42ff371d5d75535a8c650386b05f82b..0000000000000000000000000000000000000000 Binary files a/images/a1.jpg and /dev/null differ diff --git a/images/a2.jpg b/images/a2.jpg deleted file mode 100644 index 929f9f1b7bcc6cd52effe8b04ec7e8e75967af7a..0000000000000000000000000000000000000000 Binary files a/images/a2.jpg and /dev/null differ diff --git a/images/bg1.jpg b/images/bg1.jpg deleted file mode 100644 index 9b26c3867dbe42746a768eb3681d5c81dbfa2c83..0000000000000000000000000000000000000000 Binary files a/images/bg1.jpg and /dev/null differ diff --git a/images/bg3.jpg b/images/bg3.jpg deleted file mode 100644 index 84a4c70ad1722d023f139286222552aa8af0d89e..0000000000000000000000000000000000000000 Binary files a/images/bg3.jpg and /dev/null differ diff --git a/images/bg5.jpg b/images/bg5.jpg deleted file mode 100644 index 8221b36a986dfe3fe814aac244572229ccf4ac0b..0000000000000000000000000000000000000000 Binary files a/images/bg5.jpg and /dev/null differ diff --git a/images/g1.jpg b/images/g1.jpg deleted file mode 100644 index b726e549a83e668d1581a8fa508fccb88d811c28..0000000000000000000000000000000000000000 Binary files a/images/g1.jpg and /dev/null differ diff --git a/images/g2.jpg b/images/g2.jpg deleted file mode 100644 index ddf553361dfa3cd543a5bee58a027456263f2755..0000000000000000000000000000000000000000 Binary files a/images/g2.jpg and /dev/null differ diff --git a/images/g3.jpg b/images/g3.jpg deleted file mode 100644 index d9d4959956f452dfeb4e0cb891f81ad20f1f13c7..0000000000000000000000000000000000000000 Binary files a/images/g3.jpg and /dev/null differ diff --git a/images/g4.jpg b/images/g4.jpg deleted file mode 100644 index a69632df3807dce2881c0b4fe95fa75698605490..0000000000000000000000000000000000000000 Binary files a/images/g4.jpg and /dev/null differ diff --git a/images/g5.jpg b/images/g5.jpg deleted file mode 100644 index 30001a04505146353fa53516a7ff66f0768a06ed..0000000000000000000000000000000000000000 Binary files a/images/g5.jpg and /dev/null differ diff --git a/images/g6.jpg b/images/g6.jpg deleted file mode 100644 index d9686e3d37b725ac6aaef3f68c6445a396a05561..0000000000000000000000000000000000000000 Binary files a/images/g6.jpg and /dev/null differ diff --git a/images/g7.jpg b/images/g7.jpg deleted file mode 100644 index 0f597e1536c24d46db2127fbd582a9d2c66c0c3f..0000000000000000000000000000000000000000 Binary files a/images/g7.jpg and /dev/null differ diff --git a/images/g8.jpg b/images/g8.jpg deleted file mode 100644 index 667551a19846f2c5ac176cde2446e73bac4dc26d..0000000000000000000000000000000000000000 Binary files a/images/g8.jpg and /dev/null differ diff --git a/images/middle.jpg b/images/middle.jpg deleted file mode 100644 index e8fc4e5cccefdf8af9ccca4d6017ede57360a88d..0000000000000000000000000000000000000000 Binary files a/images/middle.jpg and /dev/null differ diff --git a/page_profile/profil.css b/page_profile/profil.css index eef143f4007cc3ed3bb7d6d3cd59fc05e1053006..0617a8e68e6035c32e59dd2cbdc79e7902decd9c 100644 --- a/page_profile/profil.css +++ b/page_profile/profil.css @@ -3,10 +3,6 @@ body { margin:0; } -nav.navbar { - border-bottom: 2px solid rgba(132, 132, 132, 0.53); - background: rgba(140, 140, 140, 0.63); -} div a:link{ color:#99c1ff; @@ -16,7 +12,6 @@ div a:link{ padding: 115px 10px 10px; text-align: left; height: 547px; - background: url(../images/2.jpg); } #photoprofil{ @@ -46,6 +41,7 @@ div a:link{ height:60px; border:0; margin-bottom: 10px; + z-index: 2; } #divindex div{ @@ -117,7 +113,6 @@ a:link { #stats{ padding: 10px 20px; text-align:center; - background: url(../images/1.jpg)repeat; } .flex{ diff --git a/page_profile/profil.php b/page_profile/profil.php index a92ea2c782713a58309773ace409c36ac3f571f8..43541ce85d175d5a2f7e03851c1c34c400f2895a 100644 --- a/page_profile/profil.php +++ b/page_profile/profil.php @@ -3,6 +3,8 @@ require_once('../API_Twitter/userInfosFunctions.php'); require_once('../API_Twitter/tweetInfosFunctions.php'); require_once('../youtube-api/userInfos.php'); require_once('../facto.php'); +require_once('../graphs/graphFunctions.php'); + session_start(); if (isset($_POST['username'])) { @@ -41,13 +43,15 @@ $youtube_fav = $_SESSION['youtube']; ?> <!DOCTYPE html> +<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/fusioncharts.js"></script> +<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/themes/fusioncharts.theme.fusion.js"></script> + <html lang="zxx"> <?php head(); ?> -<body> - -<?php header2('../page_welcome/index.php'); ?> +<body class="bg2"> +<?php header2($_SERVER['REQUEST_URI']); ?> <div id='profile'> @@ -66,12 +70,12 @@ $youtube_fav = $_SESSION['youtube']; elseif ($socialNetwork === "Youtube") { echo getChannelProfileImage($id); } - ?>' alt='profile_image' style="width:100px;height:100px;"/> + ?>' alt='profile_image' style="width:100px;height:100px;border-radius:50px"/> <br/> <br/> <?php if (!$_SESSION['username']){ - echo '<a id="modal_trigger" href="#modal" class="text-white">Login to add to favorites</a>'; + echo '<div>Login to add to favorites</div>'; } elseif ( in_array($id, $twitter_fav) || in_array($id, $youtube_fav) ){ echo '<button style="margin-left:10px">Subscribed</button>'; @@ -93,13 +97,13 @@ $youtube_fav = $_SESSION['youtube']; ?> </div> <br/><br/> - <div class='flexspace' style="padding:30px 40px 0px;border-left:1px solid;width:100%;background-image: linear-gradient(to bottom right, #919df9, #93eeff);border-radius:50px"> + <div class='flexspace' style="margin-top:90px;margin-bottom:90px;padding:30px 40px 0px;border:1px solid;border-color: red;width:100%;background: white;border-radius:50px"> <div><?php echo $socialNetwork; ?> Username <br/> <h5><?php if ($socialNetwork === "Twitter") { - echo getUserScreenName($id); + echo '<a href="https://twitter.com/'.getUserScreenName($id).'" target="_blank" style="color:black">'.getUserScreenName($id).'</a>'; } elseif ($socialNetwork === "Youtube") { - echo getChannelUsername($id); + echo '<a href="https://www.youtube.com/channel/'.$id.'" target="_blank" style="color:black">'.getChannelUsername($id).'</a>';; } ?> @@ -124,175 +128,183 @@ $youtube_fav = $_SESSION['youtube']; echo "Number of videos <br/> <h5>".number_format(getChannelVideoCount($id), 0, ".", " ").'<br/> <h5></h5> </div>'; echo "<div>Number of total views <br/> <h5>".number_format(getChannelViewCount($id), 0, ".", " "); } - ?> + ?> <br/> <h5></h5> </div> + </br><br/> + </div> </div> </div> <div id='divindex' class='flex center sticky'> <div class='center orange' style='border-left:1px solid;'> - <a href='#a'> Evolution of Tweets likes </a> - </div> - <div class='center green'> - <a href='#b'> Evolution of Tweets Retweets</a> + <?php + if ($socialNetwork === "Twitter") { + echo "<a href='#a'> Evolution of Tweets likes </a>"; + echo "</div>"; + echo "<div class='center green'>"; + echo "<a href='#b'> Evolution of Tweets Retweets</a>"; + } + elseif ($socialNetwork === "Youtube") { + echo "<a href='#a'> Evolution of Views of recent videos</a>"; + echo "</div>"; + echo "<div>"; + echo "<a href='#b'> Evolution of Likes of recent videos</a>"; + echo "</div>"; + echo "<div>"; + echo "<a href='#c'> Evolution of Dislikes of recent videos</a>"; + } + ?> </div> </div> <div id='stats'> - <div id='a'><br/><br/><span class="title_graphs">Evolution of Tweets Likes</span><br/><br/> - -<?php -/* Include the `fusioncharts.php` file that contains functions to embed the charts. */ -include("../graphs/fusioncharts-suite-xt/integrations/php/fusioncharts-wrapper/fusioncharts.php"); -require_once('../API_Twitter/tweetInfosFunctions.php'); -?> -<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/fusioncharts.js"></script> -<script type="text/javascript" src="../graphs/fusioncharts-suite-xt/js/themes/fusioncharts.theme.fusion.js"></script> - <?php - // Nombre de tweets - $count = 50; - - // Chart Configuration stored in Associative Array - $arrChartConfig = array( - "chart" => array( - "caption" => "Evolution of likes : Last ".$count." tweets", - //"subCaption" => "In MMbbl = One Million barrels", - "xAxisName" => "Tweet (from most recent to oldest)", - "yAxisName" => "Likes", - "lineThickness" => "2", - "theme" => "fusion" - ) - ); - - // An array of hash objects which stores data - $arrChartData = []; - - $likes = getNbLikesOfUserByScreenName(getUserScreenName($id), $count); - - $likeMoyen = 0; - - $count = count($likes); - for ($i=0; $i<$count; $i++) { - $arrChartData[] = [ - 'label' => $i, - 'value' => $likes[$i] - ]; - $likeMoyen += $likes[$i]; - } - $likeMoyen = round($likeMoyen/$count, 2); - - // An array which stores trend-lines - $arrTrendLines = []; - $arrTrendLines[] = [ - "line" => [ - [ - "startvalue" => $likeMoyen, - "color" => "#1aaf5d", - "displayvalue" => "Like moyen = ".$likeMoyen, - "valueOnRight" => "1", - "thickness" => "2" - ] - ] - ]; - - $arrChartConfig["data"] = $arrChartData; - $arrChartConfig["trendLines"] = $arrTrendLines; - - // JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. - $jsonEncodedData = json_encode($arrChartConfig); - - // chart object - $Chart = new FusionCharts("line", "MyFirstChart" , "700", "400", "chart-container", "json", $jsonEncodedData); - - // Render the chart - $Chart->render(); - ?> - <center> - <div id="chart-container">Chart will render here!</div> - </center> - - - - - </br><br/></div> - <div id='b'><br/><br/><span class="title_graphs">Evolution of Tweets Retweets</span><br/><br/> + <div id='a'><br/><br/><span class="title_graphs"> + <?php + if ($socialNetwork === "Twitter") { + echo "Evolution of Tweets Likes"; + } + elseif ($socialNetwork === "Youtube") { + echo "Evolution of Views of recent videos"; + } + ?> + </span><br/><br/> + <?php + if ($socialNetwork === "Twitter") { + // Nombre de tweets + $count = 50; + + $chartName = "chart1"; + $caption = "Evolution of likes : Last ".$count." tweets"; + $xAxisName = "Tweet (from most recent to oldest)"; + $yAxisName = "Likes"; + + $likes = getNbLikesOfUserByScreenName(getUserScreenName($id), $count); + + lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $likes, 700, 400); + } + elseif ($socialNetwork === "Youtube") { + $count = 10; + + $chartName = "chart3"; + $caption = "Evolution of views : Last ".$count." videos"; + $xAxisName = "Video (from most recent to oldest)"; + $yAxisName = "Number of Views"; + + $views = getviewCountOfRecentVideo($id, $count); + + lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $views, 700, 400); + } + ?> + </br><br/> + </div> + <div id='b'><br/><br/><span class="title_graphs"> + <?php + if ($socialNetwork === "Twitter") { + echo "Evolution of Tweets Retweets"; + } + elseif ($socialNetwork === "Youtube") { + echo "Evolution of Likes of recent videos"; + } + ?> + </span><br/><br/> + <?php + if ($socialNetwork === "Twitter") { + // Nombre de tweets + $count = 50; + + $chartName = "chart2"; + $caption = "Evolution of retweets : Last ".$count." tweets"; + $xAxisName = "Tweet (from most recent to oldest)"; + $yAxisName = "Retweets"; + + $retweets = getNbRetweetsOfUserByScreenName(getUserScreenName($id), $count); + lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $retweets, 700, 400); + } + elseif ($socialNetwork === "Youtube") { + $count = 10; + + $chartName = "chart4"; + $caption = "Evolution of likes : Last ".$count." videos"; + $xAxisName = "Video (from most recent to oldest)"; + $yAxisName = "Number of Likes"; + + $likes = getLikeCountOfRecentVideo($id, $count); + + lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $likes, 700, 400); + } + ?> + </br><br/> + </div> + <div id='c'><br/><br/><span class="title_graphs"> <?php - // Nombre de tweets - $count = 50; - - // Chart Configuration stored in Associative Array - $arrChartConfig = array( - "chart" => array( - "caption" => "Evolution of retweets : Last ".$count." tweets", - //"subCaption" => "In MMbbl = One Million barrels", - "xAxisName" => "Tweet (from most recent to oldest)", - "yAxisName" => "Retweets", - "lineThickness" => "2", - "theme" => "fusion" - ) - ); - - // An array of hash objects which stores data - $arrChartData = []; - - $retweets = getNbRetweetsOfUserByScreenName(getUserScreenName($id), $count); - - $retweetMoyen = 0; - - $count = count($retweets); - for ($i=0; $i<$count; $i++) { - $arrChartData[] = [ - 'label' => $i, - 'value' => $retweets[$i] - ]; - $retweetMoyen += $retweets[$i]; - } - $retweetMoyen = round($retweetMoyen/$count, 2); - - // An array which stores trend-lines - $arrTrendLines = []; - $arrTrendLines[] = [ - "line" => [ - [ - "startvalue" => $retweetMoyen, - "color" => "#1aaf5d", - "displayvalue" => "retweet moyen = ".$retweetMoyen, - "valueOnRight" => "1", - "thickness" => "2" - ] - ] - ]; - - $arrChartConfig["data"] = $arrChartData; - $arrChartConfig["trendLines"] = $arrTrendLines; - - // JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. - $jsonEncodedData = json_encode($arrChartConfig); - - // chart object - $Chart = new FusionCharts("line", "MyFirstChart2" , "700", "400", "chart-container2", "json", $jsonEncodedData); - - // Render the chart - $Chart->render(); - ?> - <center> - <div id="chart-container2">Chart will render here!</div> - </center> - - </br><br/></div> - </div> + if ($socialNetwork === "Twitter") { + echo ""; + } + elseif ($socialNetwork === "Youtube") { + echo "Evolution of Dislikes of recent videos"; + } + ?> + </span><br/><br/> + <?php + if ($socialNetwork === "Twitter") { + echo ""; + } + elseif ($socialNetwork === "Youtube") { + $count = 10; -</div> + $chartName = "chart5"; + $caption = "Evolution of dislikes : Last ".$count." videos"; + $xAxisName = "Video (from most recent to oldest)"; + $yAxisName = "Number of Dislikes"; + + $dislikes = getDislikeCountOfRecentVideo($id, $count); + + lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $dislikes, 700, 400); + } + ?> + </br><br/> + </div> + <!-- <div id='d'><br/><br/><span class="title_graphs"> + <?php + // if ($socialNetwork === "Twitter") { + // echo ""; + // } + // elseif ($socialNetwork === "Youtube") { + // echo "Evolution of views of most popular videos"; + // } + ?> + </span><br/><br/> + <?php + // if ($socialNetwork === "Twitter") { + // echo ""; + // } + // elseif ($socialNetwork === "Youtube") { + // $count = 10; + + // $chartName = "chart6"; + // $caption = "Evolution of views : ".$count." most popular videos"; + // $xAxisName = "Video (from most recent to oldest)"; + // $yAxisName = "Number of Views"; + + // $videosID = getCountTopVideos($id, $count); + // $views = []; + // for ($i = 0; $i < $count; $i++) { + // $views[] = getVideoViewCountById($videosID[$i]); + // } + + // lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $views, 700, 400); + // } + ?> + </br><br/> + </div> --> + </div> -<!-- Js files --> -<!-- JavaScript --> -<script src="../page_welcome/js/jquery-2.2.3.min.js"></script> -<!-- Default-JavaScript-File --> +</div> <!-- banner slider --> -<script src="../page_welcome/js/responsiveslides.min.js"></script> +<script src="../js/responsiveslides.min.js"></script> <script> // You can also use "$(window).load(function() {" $(function () { @@ -334,25 +346,25 @@ require_once('../API_Twitter/tweetInfosFunctions.php'); </script> <!-- //password-script --> +<script src="../js/login.js"></script> <!-- gallery light box --> -<script src="../page_welcome/js/smoothbox.jquery2.js"></script> +<script src="../js/smoothbox.jquery2.js"></script> <!-- //gallery light box --> <!-- smooth scrolling --> -<script src="../page_welcome/js/SmoothScroll.min.js"></script> +<script src="../js/SmoothScroll.min.js"></script> <!-- //smooth scrolling --> <!-- move-top --> -<script src="../page_welcome/js/move-top.js"></script> +<script src="../js/move-top.js"></script> <!-- easing --> -<script src="../page_welcome/js/easing.js"></script> +<script src="../js/easing.js"></script> <!-- necessary snippets for few javascript files --> -<script src="../page_welcome/js/snacks.js"></script> +<script src="../js/snacks.js"></script> -<script src="../page_welcome/js/bootstrap.js"></script> +<script src="../js/bootstrap.js"></script> <!-- Necessary-JavaScript-File-For-Bootstrap --> <!-- //Js files --> - </body> </html> diff --git a/page_user/css/style.css b/page_user/css/style.css index 1ba30c8747376f90e24f748de8f350863275c7e8..78990306d7cea01dc96794de1bd343df1b1be9d5 100644 --- a/page_user/css/style.css +++ b/page_user/css/style.css @@ -268,7 +268,7 @@ button.submit:hover { .bg1, .bg2 { min-height: 50vw; - height: 700px; + /*height: 700px;*/ } /*-- text Slider --*/ diff --git a/page_user/user.php b/page_user/user.php index da7d1be07e386824d02c1f4f0c1ac78bc3df0f02..c4169e227c555822767af120f211786206530d22 100644 --- a/page_user/user.php +++ b/page_user/user.php @@ -1,12 +1,18 @@ <?php require_once('../facto.php'); require_once('../API_Twitter/userInfosFunctions.php'); +require_once('../youtube-api/userInfos.php'); +require_once('../graphs/graphFunctions.php'); session_start(); + +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); ?> <!DOCTYPE html> -<html lang="zxx"> +<html> <?php head(); ?> @@ -23,12 +29,9 @@ session_start(); <div class="slider-info bg1"> <div class="w3l-overlay"> <div class="banner-text text-center container"> - <table width="400" class="hovertable" align="center" style='text-align:center;background: white' border='1'> - <tr style="background: #3fcbfe;"><th>image</th><th>twitter</th></tr> - <?php - session_start(); + <?php // initializing variables $username = $_SESSION['username']; @@ -51,18 +54,152 @@ session_start(); $fav = mysqli_fetch_assoc($result); $favt = unserialize($fav['twitter']); + $favyy = "SELECT youtube FROM favorites WHERE userid='$userid'"; + $result = mysqli_query($db, $favyy); + $favyy = mysqli_fetch_assoc($result); + $favy = unserialize($favyy['youtube']); + + + ?> + +<div style="display: flex;justify-content: space-between;"> + + <?php echo '<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script> +<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script> +<script type="text/javascript"> + FusionCharts.ready(function(){ + var fusioncharts = new FusionCharts({ + type: "bar2d", + renderAt: "diagtwitter", + width: "500", + height: "400", + dataFormat: "json", + dataSource: { + "chart": { + "theme": "fusion", + "caption": "Followers of your fav", + "subCaption": "", + "yAxisName": "Followers", + "numberPrefix": "", + "alignCaptionWithCanvas": "0" + }, + + "data": ['; + + for( $i=0 ; $i < min(10,count($favt)-1) ; $i++){ + $name = getUserScreenName($favt[$i]); + $followers = getUserNbFollowers($favt[$i]); + echo ' { + "label": "'.$name.'", + "value": "'.$followers.'" + },'; + } + + $name = getUserScreenName($favt[count($favt)-1]); + $followers = getUserNbFollowers($favt[count($favt)-1]); + echo '{ + "label": "'.$name.'", + "value": "'.$followers.'" + } + ] + } +}); + fusioncharts.render(); + }); +</script>'; +?> + <div id="diagtwitter">Le diagramme twitter s affiche ici ! + </div> + + +<?php echo ' +<script type="text/javascript"> + FusionCharts.ready(function(){ + var fusioncharts = new FusionCharts({ + type: "bar2d", + renderAt: "diagy", + width: "500", + height: "400", + dataFormat: "json", + dataSource: { + "chart": { + "theme": "fusion", + "caption": "Number of suscribers of your fav", + "subCaption": "", + "yAxisName": "Suscribers", + "numberPrefix": "", + "alignCaptionWithCanvas": "0" + }, + + "data": ['; + + for( $i=0 ; $i < min(10,count($favy)-1) ; $i++){ + $name = getChannelUsername($favy[$i]); + $followers = getChannelNbFollowers($favy[$i]); + echo ' { + "label": "'.$name.'", + "value": "'.$followers.'" + },'; + } + + + $name = getChannelUsername($favy[count($favy)-1]); + $followers = getChannelNbFollowers($favy[count($favy)-1]); + echo '{ + "label": "'.$name.'", + "value": "'.$followers.'" + } + ] + } +}); + fusioncharts.render(); + }); +</script>'; +?> + <div id="diagy">Le diagramme youtube s affiche ici ! + </div></div> + <br><br><br> +<div style="display: flex;"> + <table width="400" class="hovertable" align="center" style='text-align:center;background: white' border='1'> + <tr style="background: #3fcbfe;"><th></th><th>twitter</th></tr> + + <?php $datarow = count($favt); for($i=0;$i<$datarow;$i++){ + $twitter = getUserScreenName($favt[$i]); $id = $favt[$i]; $image = getUserProfileImage($id); - echo "<tr onclick='showId(this.id)' id=\"$id\" style=\"background: #d4e3e5;\" onmouseover=\"this.style.backgroundColor='#ffff66';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\"><td><img src='$image'></td><td>$twitter</td></tr>"; + echo "<tr onclick='showIdt(this.id)' id=\"$id\" style=\"background: #d4e3e5;\" onmouseover=\"this.style.backgroundColor='#ffff66';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\"><td><img src='$image'></td><td>$twitter</td></tr>"; } + + ?> </table> + + <table width="400" class="hovertable" align="center" style='text-align:center;background: white' border='1'> + <tr style="background: #3fcbfe;"><th></th><th>youtube</th></tr> + + <?php + + + $datarow = count($favy); + for($i=0;$i<$datarow;$i++){ + + $youtube = getChannelUsername($favy[$i]); + $id = $favy[$i]; + $image = getChannelProfileImage($id); + echo "<tr onclick='showIdy(this.id)' id=\"$id\" style=\"background: #d4e3e5;\" onmouseover=\"this.style.backgroundColor='#ffff66';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\"><td><img src='$image' style='height: 80px;'></td><td>$youtube</td></tr>"; + } + + + ?> + </table> + </div> + </div> <div id="suggestionButtons"> @@ -80,11 +217,16 @@ session_start(); <!-- Default-JavaScript-File --> <script type="text/javascript"> - function showId(id){ + function showIdt(id){ location.href="../page_profile/profil.php?id="+id+"&sn=Twitter"; } + function showIdy(id){ + location.href="../page_profile/profil.php?id="+id+"&sn=Youtube"; + + } + </script> <!-- banner slider --> diff --git a/page_welcome/index.php b/page_welcome/index.php index 87d4d04f286a8dc5658b0d3914b399c85655372b..91444f92284c8767f7bb676e1cce1544753f533d 100644 --- a/page_welcome/index.php +++ b/page_welcome/index.php @@ -7,7 +7,6 @@ require_once('../API_Twitter/requestsFunctions.php'); require_once('../js/recherche.js'); require_once('../facto.php'); -require_once('index.js'); session_start(); ?> @@ -19,7 +18,7 @@ session_start(); ?> <body> - <?php header2('index.php'); + <?php header2($_SERVER['REQUEST_URI']); ?> <div class="callbacks_container"> @@ -58,7 +57,7 @@ session_start(); </datalist> - + </div> </div> @@ -76,18 +75,6 @@ session_start(); </div> <!-- //banner --> - - <!-- semaine --> - <div class="w3ls-middle pt-5" id="semaine"> - <div class="container py-xl-5 py-lg-3"> - <h3 class="title text-center text-dark mb-sm-5 mb-4"> - <br><br> - <span>influence de la semaine</span> </h3> - - </div> - </div> - <!-- //semaine --> - <!-- Js files --> <!-- JavaScript --> diff --git a/page_welcome/login.php b/page_welcome/login.php index b9a0873af64a0fbcd134bbf65cb2b1f420ab94da..99344fbfc0114fd444217f2c689b1797cbe1b8ca 100644 --- a/page_welcome/login.php +++ b/page_welcome/login.php @@ -15,6 +15,7 @@ if (mysqli_connect_errno()) { // REGISTER USER if (isset($_POST['login'])) { // receive all input values from the form + $back = $_POST['back']; $username = $_POST['username']; $password = $_POST['password']; @@ -42,7 +43,7 @@ if ($user && count($errors) == 0) { // if user exists $_SESSION['success'] = "You are now logged in"; $_SESSION['twitter'] = unserialize($favorites['twitter']); $_SESSION['youtube'] = unserialize($favorites['youtube']); - header('location: index.php'); + header('Location:'.$back); } // if user doesn't exist elseif (!$user){ diff --git a/page_welcome/logout.php b/page_welcome/logout.php index d2b9c137cdaeeaee1aa3e712819a1e1ece3969b1..54828812bd9f4a755aea35ae6cad36c0d97bbfb3 100644 --- a/page_welcome/logout.php +++ b/page_welcome/logout.php @@ -1,5 +1,5 @@ <?php session_start(); -$_SESSION['username'] = ""; +session_destroy(); header('location: index.php'); ?> diff --git a/page_welcome/register.php b/page_welcome/register.php index dda3227c2e63341991ad2f8e1c1b59ce3127af11..b059ae20334f7373248325bb8df16311b4c87d08 100644 --- a/page_welcome/register.php +++ b/page_welcome/register.php @@ -47,6 +47,7 @@ if (isset($_POST['register'])) { } $empty_array = array(); // Finally, register user if there are no errors in the form + echo $errors[0]; if (count($errors) == 0) { $password = md5($password_1);//encrypt the password before saving in the database diff --git a/users.sql b/users.sql new file mode 100644 index 0000000000000000000000000000000000000000..f1abe919fe76f788c2cfdb21df07fec55a87dfa7 --- /dev/null +++ b/users.sql @@ -0,0 +1,68 @@ +-- phpMyAdmin SQL Dump +-- version 4.7.0 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost:3306 +-- Generation Time: Nov 14, 2018 at 11:16 PM +-- Server version: 5.6.34-log +-- PHP Version: 7.2.1 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `data` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `id` int(6) NOT NULL, + `username` varchar(30) NOT NULL, + `email` varchar(50) DEFAULT NULL, + `password` varchar(50) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`id`, `username`, `email`, `password`) VALUES +(1, 'clementveyssiere', 'test@test.com', '098f6bcd4621d373cade4e832627b4f6'), +(2, 'nvuser', 'aaa@aaaaaaaaaa.com', 'ab70186fc55f75e31b182fc4e4788533'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `users` +-- +ALTER TABLE `users` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `users` +-- +ALTER TABLE `users` + MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/youtube-api/userInfos.php b/youtube-api/userInfos.php index ae19651b88eb1767ab0df0695b7f59cbf402ea16..f0beb1300572d7239e7161469581ec28c47435ce 100644 --- a/youtube-api/userInfos.php +++ b/youtube-api/userInfos.php @@ -5,13 +5,12 @@ * Date: 2018/11/18 * Time: 16:16 */ -require '../vendor/autoload.php'; +include '../vendor/autoload.php'; $setting = array( 'key' => 'AIzaSyAg1Jz2Zxlna4sLJTE8BNpQlN2vSETqcHA' ); - function searchByKey($keyword){ global $setting; $youtube = new Madcoda\Youtube\Youtube($setting); @@ -62,3 +61,135 @@ function getChannelViewCount($id) { return intval($res->statistics->viewCount); } +function getVideoInfoById($id){ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $res = $youtube->getVideoInfo($id); + + return $res; +} + +/** + * Search Get the name of the a video by ID + * @param Id + * @return the Name of a video + */ +function getVideoNameById($id){ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $res = $youtube->getVideoInfo($id)->snippet->title; + + return $res; +} + +/** + * Search Get the Icon of the a video by ID + * @param Id + * @return the Icon of a video + */ +function getVideoIconById($id){ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $res = $youtube->getVideoInfo($id)->snippet->thumbnails->default->url; + return $res; +} + +/** + * Search Get the ViewCount of the a video by ID + * @param Id + * @return the viewCount of a video + */ +function getVideoViewCountById($id){ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $res = $youtube->getVideoInfo($id)->statistics->viewCount; + + return $res; +} + + +/** + * Search Get the most popular count videos's id in a channel by channelID + * @param $channelId + * @param $count + * @return an array including the id of the most populare count videos + */ +function getCountTopVideos($channelId,$count) +{ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $vid = $youtube->searchChannelVideos('',$channelId,$count, "viewCount"); + + + $CountList = array(); + for($i=0;$i<$count ; $i++) + { + $CountList[$i] = getVideoInfoById($vid[$i]->id->videoId)->id; + } + return $CountList; +} + +/** + * Get the viewcount of the recent count videos by channelID + * @param $channelId + * @param $count + */ +function getviewCountOfRecentVideo($channelId,$count) +{ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $vid = $youtube->searchChannelVideos('',$channelId,$count,"date"); + + $ViewCountList = array(); + for($i=0; $i<$count ; $i++) + { + $id = $vid[$i]->id->videoId; + $ViewCountList[$i] = getVideoInfoById($id)->statistics->viewCount; + } + return $ViewCountList; +} + +/** + * Get the Likecount of the recent count videos by channelID + * @param $channelId + * @param $count + */ +function getDislikeCountOfRecentVideo($channelId,$count) +{ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $vid = $youtube->searchChannelVideos('',$channelId,$count); + + $CountList = array(); + for($i=0;$i<$count ; $i++) + { + $CountList[$i] = (getVideoInfoById($vid[$i]->id->videoId))->statistics->dislikeCount; + } + return $CountList; +} + +/** + * Search Get the DisLikecount of the recent count videos by channelID + * @param $channelId + * @param $count + */ +function getLikeCountOfRecentVideo($channelId,$count) +{ + global $setting; + $youtube = new Madcoda\Youtube\Youtube($setting); + $vid = $youtube->searchChannelVideos('',$channelId,$count); + + + $CountList = array(); + for($i=0;$i<$count ; $i++) + { + $CountList[$i] = (getVideoInfoById($vid[$i]->id->videoId))->statistics->likeCount; + } + return $CountList; +} + + +//print_r(getCountTopVideos("UCWeg2Pkate69NFdBeuRFTAw", 10)); + + +