Advertisement
icorrelate

DestinedPL

Aug 20th, 2017
1,572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. <?php
  2.  
  3. $name = "";
  4. function secure($str){
  5.     return strip_tags(trim(htmlspecialchars($str)));
  6. }
  7.  
  8. function ProcessName($name = ""){
  9.  
  10.     $count = 0;
  11.     $strlen = strlen( $name );
  12.     for( $i = 0; $i <= $strlen; $i++ ) {
  13.         $char = substr( $name, $i, 1 );
  14.  
  15.         $count += toNumber($char);
  16.     }
  17.     return $count % 10;
  18. }
  19.  
  20. function toNumber($dest)
  21. {
  22.     if ($dest)
  23.         return ord(strtolower($dest)) - 96;
  24.     else
  25.         return 0;
  26. }
  27.  
  28. function getProgrammingLanguage($id){
  29.     $servername = "localhost";
  30.     $username = "root";
  31.     $password = "";
  32.     $dbname = "dbproglang";
  33.     try
  34.     {
  35.         $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  36.         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  37.     }
  38.     catch(PDOException $e)
  39.     {
  40.         echo "Connection failed: " . $e->getMessage();
  41.     }
  42.  
  43.     $stmt = $conn->prepare("SELECT `plid`, `plname`, `pldescription`,`image` FROM `tblproglang` WHERE `plid`=:id");
  44.     $stmt->bindParam(':id',$id);
  45.     $stmt->execute();
  46.     $row = $stmt->fetch();
  47.  
  48.     return $arrayName = array(
  49.         'plname' => $row['plname'],
  50.         'pldescription' => $row['pldescription'],
  51.         'image' => $row['image']);
  52.  
  53. }
  54.  
  55. if(!isset($_GET['name'])){
  56.     echo "Name not set;";
  57. }else{
  58.     $name = secure(strtolower($_GET['name']));
  59.     $arr = getProgrammingLanguage(ProcessName($name));
  60.    
  61.  
  62.     echo "Your name is: ".secure($_GET['name'])."<br><br>";
  63.     echo "Your Destined PL is: ".$arr['plname'],"<br><br>";
  64.     echo "<img src='http://".$_SERVER['SERVER_NAME']."/pl/".$arr['image']."' alt='".$arr['plname']."'><br><br>";
  65.     echo "Description <br>".$arr['pldescription'];
  66.  
  67. }
  68.  
  69.  
  70.  
  71. /*
  72. Change the Meta Data
  73. og:image
  74. og:title
  75. og:description
  76.  
  77. For Fb to scrape the title, desc and image/
  78. */
  79.  
  80.  
  81. //HTACCESS Rewrite Rule
  82. /*
  83. RewriteEngine On
  84. RewriteRule ^calculate?$ calculate.php
  85. RewriteRule ^calculate/?$ calculate.php
  86. RewriteRule ^calculate/([a-zA-Z]+) calculate.php?name=$1
  87.  
  88. */
  89.  
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement