-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetmecard.php
59 lines (53 loc) · 2 KB
/
getmecard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* getmecard.php - convert structured http query string to mecard code
*
* @copyright Geekwright, LLC http://geekwright.com
* @license GNU General Public License (GPL)
* @since 1.2
* @author Richard Griffith [email protected]
* @package qr
* @version $Id$
*
**/
include '../../mainfile.php';
//include(XOOPS_ROOT_PATH."/header.php");
$dir = basename( dirname( __FILE__ ) ) ;
$limit_referer = $xoopsModuleConfig['limit_referer'];
if($limit_referer) $check=$GLOBALS['xoopsSecurity']->checkReferer();
else $check=true;
if ($check) {
$mecardtags=explode("|","N|SOUND|TEL|TEL-AV|EMAIL|NOTE|BDAY|ADR|URL|NICKNAME");
$card='';
$have_name=false;
for($i=0; $i<sizeof($mecardtags); $i++) {
$value='';
if(!empty($_REQUEST[$mecardtags[$i]])) $value=$_REQUEST[$mecardtags[$i]];
if(!empty($_REQUEST[strtolower($mecardtags[$i])])) $value=$_REQUEST[strtolower($mecardtags[$i])];
if(!empty($value)) {
if($mecardtags[$i]=='N') $have_name=true;
$card.=formatMecard($mecardtags[$i],$value);
}
}
if(!empty($card) && $have_name) { // we must have name for most scanners to accept a MECARD
$card = 'MECARD:'.$card.';';
$_GET['d']=$card;
$_GET['e']=$xoopsModuleConfig['ec_level'];
unset($_GET['s'],$_GET['v'],$_GET['t'],$_GET['n'],$_GET['m'],$_GET['p'],$_GET['o']);
include_once(XOOPS_ROOT_PATH.'/modules/'.$dir.'/swetake/php/qr_img.php');
}
}
function formatMecard($tag,$value) {
$carditem='';
$value=mb_decode_numericentity($value, array(0x0, 0x2FFFF, 0, 0xFFFF), 'UTF-8');
//$value=str_replace("'","'",$value); // this is so names like O'Brian will work. Must be a better way.
// escape according to docomo docs
$value=str_replace("\\","\\\\",$value);
$value=str_replace(":","\\:",$value);
$value=str_replace(";","\\;",$value);
if($tag=='N' || $tag=='ADR' || $tag=='KANA') $value=str_replace(",","\\,",$value);
if(!empty($value)) $carditem=$tag.':'.$value.';';
return $carditem;
}
//include(XOOPS_ROOT_PATH."/footer.php");
?>