nSun

[muxxulib] func/profilMuxxu.php

Jul 5th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.01 KB | None | 0 0
  1. <?php
  2. /*
  3.  * function profilMuxxu()
  4.  * @param (string) $appName nom de l'application
  5.  * @param (string) $appKey clé privée de l'application
  6.  * @param (int) $uid N°identifiant du profil
  7.  * @param (string) $pubkey clé publique du profil
  8.  * @return (string) HTML de la fiche Muxxu
  9.  * @return (bool) false en cas d'échec du parser
  10.  * @author nSun
  11.  * @date 2011-06-28
  12.  * <p>Retourne une chaine formatée HTML identique à l'encart (haut gauche) d'une page profil Muxxu.</p>
  13.  * <p>Nécessite la fonction func/age.php, et le fichier css/profilMuxxu.css</p>
  14.  */
  15.  
  16. require('func/age.php');
  17.  
  18. function profilMuxxu($appName,$appkey,$uid,$pubkey)
  19. {
  20.     global $XMLlog;
  21.    
  22.     //Contacte l'API de Muxxu / Récupération du flux 'user'
  23.     $url = "http://muxxu.com/app/xml?app={$appName}&xml=user&id={$uid}&key=".md5($appkey . $pubkey);
  24.     $xml = simplexml_load_file($url);
  25.  
  26.     if($xml && isset($xml['name'])) //Vérifie la validité du flux
  27.     {
  28.         //Avatar
  29.         if(isset($xml['avatar']) && trim($xml['avatar']) != null)
  30.         {
  31.             $avatar = $xml['avatar'];
  32.         }
  33.         //Avatar de ceux qui n'en ont pas
  34.         else $avatar = 'http://muxxu.com/img/design/basic/avatar.gif';
  35.        
  36.         //Age
  37.         if(isset($xml['birthday']) && $xml['birthday'] != null)
  38.         {
  39.             $muxxuAge = age($xml['birthday']);
  40.         }
  41.         //Age inconnu [?]
  42.         else $muxxuAge = '<img src="http://muxxu.com/img/pixel.gif" class="unknown"/>';
  43.  
  44.         //Sexe
  45.         if(isset($xml['male']))
  46.         {
  47.             switch($xml['male'])
  48.             {
  49.                 //Garçon
  50.                 case 'true':
  51.                 $muxxuSex = '<img src="http://muxxu.com/img/pixel.gif" class="boy"/>';
  52.                 break;
  53.  
  54.                 //Fille
  55.                 case 'false':
  56.                 $muxxuSex = '<img src="http://muxxu.com/img/pixel.gif" class="girl"/>';
  57.                 break;
  58.  
  59.                 //Sexe non-définis [?]
  60.                 default:
  61.                 $muxxuSex = '<img src="http://muxxu.com/img/pixel.gif" class="unknown"/>';
  62.             }
  63.         }
  64.         //Cas où le sexe n'aurait JAMAIS été définis pour ce profil
  65.         else $muxxuSex = '<img src="http://muxxu.com/img/pixel.gif" class="unknown"/>';
  66.  
  67.         //Pays
  68.         if(isset($xml['country']) && trim($xml['country']) != null)
  69.         {
  70.             $muxxuCountry = $xml['country'];
  71.         }
  72.         //Pays non-definis [?]
  73.         else $muxxuCountry = '<img src="http://muxxu.com/img/pixel.gif" class="unknown"/>';
  74.        
  75.         //Ville
  76.         if(isset($xml['city']) && trim($xml['city']) != null)
  77.         {
  78.             $muxxuCity = $xml['city'];
  79.         }
  80.         //Ville non-définie [?]
  81.         else $muxxuCity = '<img src="http://muxxu.com/img/pixel.gif" class="unknown"/>';
  82.        
  83.         //Message
  84.         if(isset($xml->message) && $xml->message != null)
  85.         {
  86.             $muxxuMSG = $xml->message;
  87.         }
  88.         //Aucun message
  89.         else $muxxuMSG = '';
  90.        
  91.         //Titre
  92.         if(isset($xml->title) && $xml->title != null)
  93.         {
  94.             $muxxuTitle = '<div class="usertitle"><div class="customtitle">'.$xml->title.'</div></div>';
  95.         }
  96.         //Aucun titre
  97.         else $muxxuTitle = '';
  98.        
  99.         //Contitution de la source HTML
  100.         $muxxu =
  101.  '<div id="profilMuxxu" class="profilmaincontent">'
  102. .   "<h1 class=\"hprofil\"><a href=\"http://muxxu.com/u/{$xml['name']}\">{$xml['name']}</a></h1>"
  103. .   '<div class="editinfo">'
  104. .       '<div class="profilavatar">'
  105. .           '<div class="corneravatar">'
  106. .           '</div>'
  107. .           "<img src=\"{$avatar}\" alt=\"\"/>"
  108. .       '</div>'
  109. .       '<table class="profilinfo">'
  110. .           '<tbody>'
  111. .               '<tr>'
  112. .                   '<td class="iddata">Age :</td>'
  113. .                   '<td class="idinfo">'
  114. .                       $muxxuAge  
  115. .                   '</td>'
  116. .               '</tr>'
  117. .               '<tr>'
  118. .                   '<td class="iddata">Sexe&nbsp;:</td>'
  119. .                   '<td class="idinfo">'
  120. .                       $muxxuSex
  121. .                   '</td>'
  122. .               '</tr>'
  123. .               '<tr>'
  124. .                   '<td class="iddata">Pays&nbsp;:</td>'
  125. .                   '<td class="idinfo">'
  126. .                       '<div>'
  127. .                           $muxxuCountry
  128. .                       '</div>'
  129. .                   '</td>'
  130. .               '</tr>'
  131. .               '<tr>'
  132. .                   '<td class="iddata">Ville&nbsp;:</td>'
  133. .                   '<td class="idinfo">'
  134. .                       '<div>'
  135. .                           $muxxuCity
  136. .                       '</div>'
  137. .                   '</td>'
  138. .               '</tr>'
  139. .           '</tbody>'
  140. .       '</table>'
  141. .   '</div>'
  142. .   '<div id="msgBox" class="bubble">'
  143. .       '<div id="msgContent">'
  144. .           $muxxuMSG
  145. .       '</div>'
  146. .   '</div>'
  147. .           $muxxuTitle
  148. .'</div>'; 
  149.     }
  150.     //Si le flux 'user' est invalide
  151.     else $muxxu = false;
  152.    
  153.     return $muxxu;
  154. }
  155. ?>
Advertisement
Add Comment
Please, Sign In to add comment