','>',$html); return $html; } function removetags($s) { $tag=substr($s,0,1)=='<'; $S=''; while ($s<>'') { $z=substr($s,0,1); $s=substr($s,1,999999); if ($z=='<') $tag=true; if ($z=='>') { $tag=false; continue; } if (!$tag) $S.=$z; } return $S; } function xtract0($h,$e) { $p=strpos($h,$e); $x=substr($h,0,$p); return $x; } function xtract($h,$s,$e,$trace=false) { $p=strpos($h,$s); if (!$p) { $S=xlat($s); if ($trace) echo " z $S @ $p "; return ""; } if ($trace) echo " s @ $p "; $x=substr($h,$p+strlen($s),9999999); $p=strpos($x,$e); if ($trace) echo " e @ $p "; $x=substr($x,0,$p); return $x; } function numerics($n) { $N=''; for ($i=0; $i='0' && substr($n,$i,1)<='9') $N.=substr($n,$i,1); return $N; } function dollars($n) { $N=''; for ($i=0; $i='0' && substr($n,$i,1)<='9') $N.=substr($n,$i,1); } return $N; } function Categories($catid='cat',$selected) { $CATS=array( 'Advertising and Marketing', 'Arts and Entertainment', 'Automotive', 'Business', 'Business to Business', 'Computers and Electronics', 'Construction', 'Cultural and Heritage', 'Educational', 'Employment', 'Family and Community', 'Financial', 'Food and Dining', 'Health and Medical', 'Home and Garden', 'Hospitality', 'Internet and Websites', 'Legal', 'Manufacturing', 'Municipal', 'Non-Profit', 'Outdoor Services', 'Personal Care and Services', 'Real Estate', 'Retail and Shopping', 'Sports and Recreation', 'Travel and Transportation', 'Utility', 'Weddings and Events'); $echo=""; return $echo; } function LoadInfo($session) { $q="select UserID,Name,PhotoURL,Location from SH_Players where SessionID='$session'"; $result=mysql_query($q); $nrows = mysql_num_rows($result); if ($nrows<>0) { $row = mysql_fetch_array($result); // getting first record in case cheating with multiple twitter id's $_SESSION['userid']=$row['UserID']; $_SESSION['name']=$row['Name']; $_SESSION['photourl']=$row['PhotoURL']; $_SESSION['location']=$row['Location']; return true; } return false; } function BackFromTwitter() { global $ip,$consumer_key,$consumer_secret; $sessionid=session_id(); if ($sessionid=='') $sessionid=rand(11111111,99999999); // in case of Apple fake the session id $oauth_token = @$_GET['oauth_token']; // if we have an openauth token we are logged in if ($oauth_token <> '') { $twitterObj = new EpiTwitter($consumer_key, $consumer_secret); $twitterObj->setToken($_GET['oauth_token']); $token = $twitterObj->getAccessToken(); $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret); $_SESSION['ot'] = $token->oauth_token; $_SESSION['ots'] = $token->oauth_token_secret; $_SESSION['twitterobj'] = $twitterObj; $twitterInfo= $twitterObj->get_accountVerify_credentials(); $twitterInfo->response; $_SESSION['twitterinfo'] = $twitterInfo; $username = $twitterInfo->screen_name; $name = ucfirst($twitterInfo->name); $pic=$twitterInfo->profile_image_url; $location=$twitterInfo->location; $name=mysql_real_escape_string($name); $location=mysql_real_escape_string($location); $now=time(); // print_r($twitterInfo); // best to call remote telcontests.com to update database $q="select PRKey,Active from SH_Players where UserID='$username'"; $result=mysql_query($q); $nrows = mysql_num_rows($result); if ($nrows==0) { $v=rand(10000000,99999999); $name=mysql_real_escape_string($name); $q="insert into SH_Players (UserID,Email,Active,Name,PhotoURL,SocialConnector,Location,SessionID) values ('$username','NOEMAIL-$username','Y','$name','$pic','TW','$location','$sessionid')"; $result = mysql_query($q); if ($result) { $prkey=mysql_insert_id(); mymail($_AdminEmail,$_AdminEmail,"Discover Aurora Twitter Login","$username $name $prkey "); } else { echo mysql_error($result); } } else { $row = mysql_fetch_array($result); $prkey=$row['PRKey']; $q="update SH_Players set Last_IP='$ip',Last_Login=$now,Location='$location',UserID='$username',Active='Y',Name='$name',PhotoURL='$pic',SocialConnector='TW',SessionID='$sessionid' where PRKey=$prkey"; $result = mysql_query($q); } } return $sessionid; } function LoginWithTwitterButton($redirectscript,$prefix='Login with Twitter:',$suffix='') { $_SESSION['TwitterCaller']=$redirectscript; // which script to go back to $_SESSION['twitterid']=''; // not logged in yet echo "$prefix "; global $consumer_key, $consumer_secret,$game; $twitterObj = new EpiTwitter($consumer_key, $consumer_secret); $signinurl = $twitterObj->getAuthorizationUrl(); echo ""; echo " $suffix"; } function showTwitterID() { if (@$_SESSION['twitterid']<>'') echo "[ @ ".$_SESSION['twitterid']." ]   [ Logout ]
"; } function IP() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } // determine base domain name function basetel($tel) { $basetel=str_replace('.tel ','',"$tel "); //echo " $tel - $basetel "; // mark-kolb.corporate.kprobe.tel - mark-kolb.corporate.kprobe $p=strrpos($basetel,'.'); if ($p) $basetel=substr($basetel,$p+1); return "$basetel.tel"; } // proxy email because gmail has banned us at telmasters function mymail($to, $from, $subject, $message) { $p=$to; //set POST variables $url = 'http://mytel.me/emailproxy.php'; $fields = array( 't'=>urlencode($to), 'f'=>urlencode($from), 's'=>urlencode($subject), 'm'=>urlencode($message), ); //url-ify the data for the POST $fields_string=''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); return; } function getRealIP() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } function Login() { $un=clean(@$_POST['un']); $pw=clean(@$_POST['pw']); $q="select id,email,BadLoginAttempts,LoginOnlyFromIP,IdentityCredits,IdentityEmail,IdentityTermsURL,IdentityPayID from users where (user_name='$un' or email='$un') and lbx_password='$pw' and is_active=1 and BadLoginAttempts<5"; $result = mysql_query($q); $nvrows = mysql_num_rows($result); if ($nvrows==1) { $row = mysql_fetch_array($result); if ($row['BadLoginAttempts']>4) { return "Sorry, this account is temporarily suspended. Please contact support @ telmasters.com to release your account."; } $userid=$row['id']; $email=$row['email']; $_SESSION['username']=$un; $_SESSION['email']=$email; $_SESSION['userid']=$userid; $_SESSION['ownerid']=$userid; $_SESSION['credits']=$row['IdentityCredits']; $_SESSION['idemail']=$row['IdentityEmail']; $_SESSION['terms']=$row['IdentityTermsURL']; $_SESSION['payid']=$row['IdentityPayID']; $loginfromip=$row['LoginOnlyFromIP']; $_SESSION['deferred_message']=trim("Ownership confirmed for $userid ($email)").'.'; $ip=getRealIP(); $now=time(); $q="update users set BadLoginAttempts=0,last_Ip_Address='$ip',last_login=$now where id=$userid"; $result = mysql_query($q); //tLog("Successful OWNER Login $ip,$username,$userid. $q"); return ''; } return "Sorry, login failed."; } function clean($t) { $t=str_replace('{','',$t); $t=str_replace('}','',$t); $t=str_replace('<','',$t); $t=str_replace('>','',$t); $t=str_replace("'","`",$t); return(trim($t)); } function curler($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // RETURN THE CONTENTS OF THE CALL $r = curl_exec($ch); return $r; } function mm($to, $from, $subject, $message) { $headers = "From: $from\r\n"; $headers .= "Reply-To: $to\r\n"; $headers .= "Return-Path: $from\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "$message"; //$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: $from <$from>\r\nTo: $to <$to>\r\nReply-To: $from <$from>\r\nX-Priority: 1\r\nX-MSMail-Priority: High\r\n X-Mailer: mytel.me"; mail($to, $subject, $message, $headers); } function ContactByEmail() { // grab the data from the confirmation email $em=@$_POST['em']; $message=$_POST['message']; $valid=eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $em); if ($em=='') $valid=false; if (!$valid) include "contact.php"; else { mymail($em,"info@telidentity.com","TelIdentity.com inquiry",$message); mymail($em,"info@kprobe.com","TelIdentity.com inquiry COPY",$message); echo "

Your message has been sent."; } } function getDirectoryList ($directory) { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($directory); // open directory and walk through the filenames while ($file = readdir($handler)) { // if file isnt this directory or its parent, add it to the results if ($file != "." && $file != "..") { $results[] = $file; } } // tidy up: close the handler closedir($handler); // done! return $results; } ?>