Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = "";
- function secure($str){
- return strip_tags(trim(htmlspecialchars($str)));
- }
- function ProcessName($name = ""){
- $count = 0;
- $strlen = strlen( $name );
- for( $i = 0; $i <= $strlen; $i++ ) {
- $char = substr( $name, $i, 1 );
- $count += toNumber($char);
- }
- return $count % 10;
- }
- function toNumber($dest)
- {
- if ($dest)
- return ord(strtolower($dest)) - 96;
- else
- return 0;
- }
- function getProgrammingLanguage($id){
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "dbproglang";
- try
- {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- $stmt = $conn->prepare("SELECT `plid`, `plname`, `pldescription`,`image` FROM `tblproglang` WHERE `plid`=:id");
- $stmt->bindParam(':id',$id);
- $stmt->execute();
- $row = $stmt->fetch();
- return $arrayName = array(
- 'plname' => $row['plname'],
- 'pldescription' => $row['pldescription'],
- 'image' => $row['image']);
- }
- if(!isset($_GET['name'])){
- echo "Name not set;";
- }else{
- $name = secure(strtolower($_GET['name']));
- $arr = getProgrammingLanguage(ProcessName($name));
- echo "Your name is: ".secure($_GET['name'])."<br><br>";
- echo "Your Destined PL is: ".$arr['plname'],"<br><br>";
- echo "<img src='http://".$_SERVER['SERVER_NAME']."/pl/".$arr['image']."' alt='".$arr['plname']."'><br><br>";
- echo "Description <br>".$arr['pldescription'];
- }
- /*
- Change the Meta Data
- og:image
- og:title
- og:description
- For Fb to scrape the title, desc and image/
- */
- //HTACCESS Rewrite Rule
- /*
- RewriteEngine On
- RewriteRule ^calculate?$ calculate.php
- RewriteRule ^calculate/?$ calculate.php
- RewriteRule ^calculate/([a-zA-Z]+) calculate.php?name=$1
- */
- ?>
Add Comment
Please, Sign In to add comment