Guest User

PROFILE

a guest
Mar 23rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.41 KB | None | 0 0
  1. <?php
  2.  /*=======================================================================*\
  3.  | phpSpring - The Formspring Clone Project [version 1.0] [build 1.5.2]   |
  4.  | ====================================================================== |
  5.  | Copyright (c) 2012, Leo 'Met0do' - http://www.met0do.org               |
  6.  | For more stuffs and data, http://www.met0do.org - [email protected]       |
  7.  | ====================================================================== |
  8.  | This program is free software: you can redistribute it and/or modify   |
  9.  | it under the terms of the GNU General Public License as published by   |
  10.  | the Free Software Foundation, either version 3 of the License, or      |
  11.  | (at your option) any later version.                                    |
  12.  | ====================================================================== |
  13.  | This program is distributed in the hope that it will be useful,        |
  14.  | but WITHOUT ANY WARRANTY; without even the implied warranty of         |
  15.  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           |
  16.  | GNU General Public License for more details.                           |
  17.  \*=======================================================================*/
  18.  
  19.   /* requeriments */
  20.   require_once 'met0do.org.php';
  21.  
  22.   /* receiving data */
  23.   $userProfile = filterText(ucfirst(strtolower($_GET["user"])));
  24.  
  25.   /* special functions only to this page */
  26.   function getQuestionComments($questionID){
  27.       return mysql_num_rows(mysql_query('select * from comments where question_id = "'.$questionID.'" and alive = "1" ORDER BY id'));
  28.   }
  29.    function followersCount($userr){
  30.       return mysql_num_rows(mysql_query('select * from users_friends where friend = "'.$userr.'"'));
  31.   }
  32.    function friendsCount($userr){
  33.       return mysql_num_rows(mysql_query('select * from users_friends where username = "'.$userr.'"'));
  34.   }
  35.   function followIt($userr){
  36.     return mysql_num_rows(mysql_query("select * from users_friends where friend = '".$userr."' AND username = '".$_SESSION["username"]."'"));
  37.     }
  38.  
  39.   /* security - check if user is real */
  40.   if(getUserInfo(NULL, $userProfile, true) != false){
  41.       $pageExhibition = true;
  42.       $pageTitle = getUserInfo("name", $userProfile).' ('.$userProfile.')';
  43.       $pageTheme = getUserInfo("theme", $userProfile);
  44.       $pageUserExists = true;
  45.   } else {
  46.       $pageExhibition = false;
  47.       $pageTitle = 'User Not Found';
  48.       $pageTheme = getUserInfo("theme", $_SESSION["id"]);
  49.       $pageUserExists = false;
  50.   }
  51.  
  52.   /* header stuff */
  53.   getPageHeader($pageTitle);
  54.  
  55.   /* css stuff */
  56.   getPageCssStyle("profile", $pageTheme, $pageUserExists);
  57.  
  58.   /* js stuff */
  59.   echo('<script type="text/javascript" src="js/prototype.js"></script>
  60.  <script type="text/javascript" src="js/scriptaculous.js"></script>
  61.  <script type="text/javascript" src="js/site.js"></script>
  62.  <script type="text/javascript" src="js/search.js"></script>
  63.  <script type="text/javascript" src="js/settings.js"></script>
  64.  <script type="text/javascript" src="js/inbox.js"></script>
  65.  <script type="text/javascript" src="js/profile.js"></script>
  66.  <script type="text/javascript" src="js/color_picker.js"></script>');
  67.  
  68.   /* menus stuff */
  69.   getPageMenus(NULL, "profile");
  70.  
  71.   /* exhibition of the page if user exists */
  72.   if($pageExhibition) { ?>
  73.    <div id="content">
  74.     <noscript><div class="error"><b>ERROR:</b> JavaScript is not enabled. You must enable JavaScript to use the application.</div></noscript>
  75.     <div id="top">
  76.       <div id="ask">
  77.       <?php if(getUserInfo("spam_prevention", $userProfile) == 1 && !$_SESSION["online"]) { ?>
  78.       <p class="message" style="margin-top:28px">
  79.       You'll have to login before asking <?php echo getUserInfo("name", $userProfile); ?> a question. <a href="account/signup" target="_blank">Click here</a> to get started in 60 seconds.        </p>
  80.       </div>
  81.       <?php } else { ?>
  82.         <h3><?php echo getUserInfo("what_ask", $userProfile); ?></h3>
  83.         <form method="post" id="askForm" onsubmit="ask('<?php echo $userProfile; ?>'); return false;">
  84.         <textarea rows="4" cols="40" name="question" id="question"></textarea><br />
  85.         <?php if($_SESSION["online"]) { ?>
  86.           <input type="radio" name="anonymous" id="anonymous0" value="0" checked="checked" />
  87.           <label for="anonymous0">Include Your User Info</label>&nbsp;
  88.           <?php if(getUserInfo("spam_prevention", $userProfile) != 1) { ?>
  89.           <input type="radio" name="anonymous" id="anonymous1" value="1" />
  90.           <label for="anonymous1">Ask Anonymously</label>
  91.           <?php } ?>
  92.           <?php } else { ?>
  93.           <input type="radio" name="anonymous" id="anonymous1" value="1" checked="checked" />
  94.           <label for="anonymous1">Ask Anonymously</label>
  95.           <?php } ?>
  96.           <br />
  97.           <input type="button" id="sendButton" value="Send" onclick="ask('<?php echo $userProfile; ?>')" class="button" />
  98.           <img id="sendIndicator" src="images/indicator.gif" alt="." class="indicator" style="display:none" />
  99.         </form>
  100.         <div id="success" style="display:none">
  101.           <h3>Thanks</h3>
  102.           <p>Your question has been sent to <?php echo $userProfile; ?> successfully. Want to <a href="javascript://" onclick="askAgain()">ask another?</a></p>
  103.         </div>
  104.       </div>
  105.       <?php } ?>
  106.       <div id="profile">
  107.         <div id="profileInfo">
  108.           <div id="profileUser" class="noprofile">
  109.             <div id="profilePhoto">
  110.               <img src="http://<?php echo SITE_DOMAIN; ?>/images/uploads/<?php echo getUserInfo("photo", $userProfile); ?>" alt="lulz" width="75" />
  111.             </div>    
  112.           </div>
  113.           <strong><?php echo getUserInfo("name", $userProfile); ?></strong><br />
  114.           <?php echo getUserInfo("location", $userProfile); ?><br />
  115.           <a href="<?php echo getUserInfo("website", $userProfile); ?>" target="_blank" rel="nofollow"><?php echo getUserInfo("website", $userProfile); ?></a><br />
  116.         </div>
  117.         <div class="clear"></div>
  118.         <p><?php echo getUserInfo("bio", $userProfile); ?>
  119.         </p>    
  120.  <div class="attention"><center><br>Amigos e Fãs<br>
  121.         <b><a href="followers/<?php echo $userProfile; ?>">Meus Seguidores (<?php echo followersCount($userProfile); ?>)</a> </b>/ <b><a href="friends/<?php echo $userProfile; ?>">Estou Seguindo (<?php echo friendsCount($userProfile); ?>)</a></b><br><br></center></div>
  122.        
  123.     <p></p>
  124.     <?php if($_SESSION["online"] && $_SESSION["username"] != $userProfile) {
  125.     if(followIt($userProfile) == 0){
  126.     ?>
  127.     <a class="buttoned" href="friends/follow/<?php echo $userProfile; ?>"><span><font color="white">Seguir</font></span></a>
  128.     <?php }
  129.     elseif(followIt($userProfile) == 1){
  130.     ?>
  131.     <a class="removebuttoned" href="friends/remove/<?php echo $userProfile; ?>"><span><font color="white">Deixar de seguir</font></span></a>
  132.     <?php }
  133.    
  134.     } ?>
  135.     </div>
  136.         </div>
  137.       <div class="clear"></div>
  138.      
  139.     <div id="questions">
  140.     <?php
  141.     /* get and show all questions answered */
  142.     $getAnsweredQuestions = mysql_query('select * from questions where to_user = "'.$userProfile.'" and status = "1" and alive = "1" ORDER BY unixtime DESC');
  143.     if(mysql_num_rows($getAnsweredQuestions) == 0){
  144.         echo '<p>'.getUserInfo("name", $userProfile).' hasn\'t answered any questions yet.</p>';
  145.     } else {
  146.         $html .= '<div id="questionsanswered">';
  147.         $html .= '<h2>Questions Answered</h2>';
  148.         $html .= '</div>';
  149.         if($_SESSION["online"] || getUserInfo("spam_prevention_2", $userProfile) != 1){
  150.         while($getAQD = mysql_fetch_assoc($getAnsweredQuestions)){
  151.             if($getAQD["anonymous"] == 1){ $askedBy = "Anonymous"; } else { $askedBy = '<a href="http://'.SITE_DOMAIN.'/'.$getAQD["from_user"].'">'.$getAQD["from_user"].'</a>'; }
  152.             $html .= '<div class="question" id="question'.$getAQD["id"].'">';
  153.             $html .= '<h4>'.html_entity_decode($getAQD["question"]).'</h4>';
  154.             $html .= '<p>'.html_entity_decode($getAQD["answer"]).'</p>';
  155.             $html .= '<p>';
  156.             $html .= '<span id="questionInfo">';
  157.             $html .= 'Asked on '.$getAQD["date"].' by '.$askedBy.' - ';
  158.             $html .= '<a href="http://'.SITE_DOMAIN.'/'.$userProfile.'/q/'.$getAQD["id"].'" class="questionLink">View Question ('.getQuestionComments($getAQD["id"]).' Comments)</a>&nbsp;&nbsp;';
  159.             $html .= '</span>';
  160.             if($userProfile == $_SESSION["username"]){
  161.                 $html .= '<a href="#" onclick="removeResponse('.$getAQD["id"].'); return false;" class="removeResponseLink" style="display:none">Delete Your Response</a>';
  162.                 $html .= '<img id="removeResponse'.$getAQD["id"].'Indicator" src="images/indicator.gif" alt="." class="indicator" style="display:none;">';
  163.             }
  164.             $html .= '</p>';
  165.             $html .= '</div>';
  166.         }
  167.         $html .= '<span class="questionCount">'.$userProfile.' has answered '.mysql_num_rows($getAnsweredQuestions).' questions to date....</span>';
  168.         echo($html);
  169.     }
  170.         else{ ?>
  171.         <div id="questionsanswered">
  172.         <h2>Questions Answered</h2>
  173.         </div>
  174.     Para ver as respostas, <a href="account/login">logue-se</a> ou <a href="account/signup">crie uma conta</a>.
  175.     <?php }} ?>
  176.     </div>
  177.   </div>
  178. </div>
  179. <?php /* exhibition of the page if user exists */ } elseif(!$pageExhibition) {  ?>
  180. <div id="content">    <noscript><div class="error"><b>ERROR:</b> JavaScript is not enabled. You must enable JavaScript to use the application.</div></noscript>    
  181. <h1>User Not Found</h1>
  182. <p>The requested user does not exist, <a href="">click here</a> to visit the home page.</p>
  183. </div></div>
  184. <?php } getPageFooter(); ?>
Advertisement
Add Comment
Please, Sign In to add comment