function convertip($ip) { global $_G, $_SC; $return = ''; if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/", $ip)) { $iparray = explode('.', $ip); if ($iparray[0] == 10 || $iparray[0] == 127 || $iparray[0] == 192 && $iparray[1] == 168 || $iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31)) { $return = '- LAN'; } elseif ($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) { $return = '- Invalid IP Address'; } else { $tinyipfile = B_ROOT . './data/ipdata/tinyipdata.dat'; $fullipfile = B_ROOT . './data/ipdata/wry.dat'; if (@file_exists($tinyipfile)) { $return = biconv(convertip_tiny($ip, $tinyipfile), 'GBK', $_G['charset']); } elseif (@file_exists($fullipfile)) { $return = biconv(convertip_full($ip, $fullipfile), 'GBK', $_G['charset']); } } } return $return; }
function hotel() { if (!$token) { $token = TOKEN; } $token = htmlspecialchars($token); $this->hotels_order_model = M('hotels_order'); $where = 'token=\'' . $token . '\' AND printed=0'; //$count = $this->hotels_order_model->count($where); $orders = $this->hotels_order_model->get_one($where, $data = '*', $order = 'time ASC'); $now = time(); if ($orders) { $thisOrder = $orders; $sort = M('hotels_house_sort')->get_one(array('id' => $thisOrder['sid']), '*'); $thisCompany = M('company')->get_one(array('token' => $token, 'id' => $thisOrder['cid'])); $thisOrder['houseName'] = biconv($sort['name']); $str = "订单编号:" . $thisOrder['id'] . "\r\n"; $str .= "姓名:" . biconv($thisOrder['name']) . "\r\n"; $str .= "电话:" . $thisOrder['tel'] . "\r\n"; $str .= "入住时间:" . date('Y-m-d', strtotime($thisOrder['startdate'])) . "\r\n"; $str .= "退房时间:" . date('Y-m-d', strtotime($thisOrder['enddate'])) . "\r\n"; $days = (strtotime($thisOrder['enddate']) - strtotime($thisOrder['startdate'])) / 86400; $str .= "入住天数:" . $days . "天\r\n"; $str .= "下单时间:" . date('Y-m-d H:i:s', $thisOrder['time']) . "\r\n"; $str .= "打印时间:" . date('Y-m-d H:i:s', $now) . "\r\n"; $str .= "\r\n--------------------------------\r\n"; $str .= "房间类型: " . $thisOrder['houseName'] . "\r\n"; $str .= "房间数:" . $thisOrder['nums'] . "\r\n"; $str .= "普通单价:" . $sort['price'] . "\r\n"; $str .= "会员单价:" . $sort['vprice'] . "\r\n"; $str .= "\r\n--------------------------------\r\n"; $str .= "合计:" . $thisOrder['price'] . "元\r\n"; $str .= " 谢谢惠顾,欢迎下次光临\r\n\r\n"; $str .= " " . biconv($thisCompany['name']) . "\r\n"; $this->hotels_order_model->update(array('printed' => 1), array('id' => $thisOrder['id'])); echo "CMD=01\tFLAG=0\tMESSAGE=success\tDATETIME=" . date('YmdHis', $now) . "\tORDERCOUNT=" . $count . "\tORDERID=" . $thisOrder['id'] . "\tPRINT=" . nl2br($str); } else { echo "CMD=01\tFLAG=1\tMESSAGE=no order now " . $token . "\tDATETIME=" . date('YmdHis', time()) . "\r\n"; } }
} $feedurl = ''; $maxupload = $_G['setting']['attach']['filesize'] > 0 ? $_G['setting']['attach']['filesize'] : 10240000; echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t\t\t<parameter>\n\t\t\t\t<allowsExtend>\n\t\t\t\t\t<extend depict=\"{$depict}\">{$attachextensions}</extend>\n\t\t\t\t</allowsExtend>\n\t\t\t<language>{$xmllang}</language>\n\t\t\t<config>\n\t\t\t\t<userid>{$_G['uid']}</userid>\n\t\t\t\t<shopid>{$thisshopid}</shopid>\n\t\t\t\t<hash>{$swfhash}</hash>\n\t\t\t\t<maxupload>{$maxupload}</maxupload>\n\t\t\t\t<uploadurl>{$uploadurl}</uploadurl>\n\t\t\t\t<feedurl></feedurl>\n\t\t\t\t<albumurl>{$albumurl}</albumurl>\n\t\t\t</config>\n\t\t\t<albums>"; if ($_GET['ineditor']) { echo "\t<album id=\"0\">{$slang['album_default']}</album>"; //編輯器上傳只列出默認相冊,返回相冊id -1 } else { if (pkperm('isadmin')) { $wheresql = " WHERE itemid='{$_GET['albumid']}'"; } else { $wheresql = " WHERE itemid='{$_GET['albumid']}' AND shopid='{$_G['myshopid']}'"; } if ($_GET['albumid'] > 0) { $subject = DB::result_first('SELECT subject FROM ' . tname('albumitems') . $wheresql); $subject = biconv($subject, $_G['charset'], 'UTF-8'); if (!empty($subject)) { echo "<album id=\"{$_GET['albumid']}\">{$subject}</album>"; } } } echo "\n\t\t\t</albums>\n\t\t\t<categories><category id=\"1\">cat</category></categories>\n\t\t</parameter>"; } elseif ($_GET['op'] == 'upload' && $_POST['Upload'] == 'Submit Query') { $_POST['uid'] = intval($_POST['uid']); $_POST['albumid'] = intval($_POST['albumid']); $albumimg = ''; $swfhash = md5(swfhash() . $_POST['uid']); if (!$_FILES['Filedata']['error'] && $_POST['hash'] == $swfhash) { $_G['uid'] = intval($_POST['uid']); $query = DB::query('SELECT * FROM ' . tname('members') . ' WHERE uid=\'' . $_G['uid'] . '\' LIMIT 1'); $_G['member'] = DB::fetch($query);
if (!$relatedid && $itemid != $resultlist['itemid']) { $i++; echo "<option value=\"{$relatedtype}@{$resultlist['itemid']}\" " . ($i == 1 ? 'selected="selected"' : '') . ">{$resultlist['subject']}</option>\n"; } } else { $i++; echo "<option value=\"{$relatedtype}@{$resultlist['itemid']}\" " . ($i == 1 ? 'selected="selected"' : '') . ">{$resultlist['subject']}</option>\n"; } } if ($i == 0) { echo '<script type="text/javascript" charset="' . $_G['charset'] . '">alert(\'' . lang('noresult_content') . '\')</script>'; } } elseif ($_GET['opt'] == 'previewconsume') { $id = intval($_GET['id']); $shopid = intval($_GET['shopid']); $coupon_title = trim($_GET['coupon_title']); $brief = trim($_GET['brief']); $exception = trim($_GET['exception']); $shopinfo = DB::fetch(DB::query("SELECT subject, address, tel FROM " . tname('shopitems') . " WHERE itemid='{$shopid}'")); $coupon_title = biconv($coupon_title, 'UTF-8', $_G['charset']); $brief = biconv($brief, 'UTF-8', $_G['charset']); $exception = biconv($exception, 'UTF-8', $_G['charset']); $createimgarr = array('preview' => 1, 'id' => $id, 'coupon_title' => $coupon_title, 'dealer_name' => $shopinfo['subject'], 'begin_date' => $_GET['begin_date'], 'end_date' => $_GET['end_date'], 'brief' => $brief, 'exception' => $exception, 'address' => $shopinfo['address'], 'hotline' => $shopinfo['tel']); require_once B_ROOT . './source/adminfunc/tool.func.php'; if ($consumeimgpath = image_text($createimgarr)) { echo '<img width="750px" height="466px" src="' . getattachurl($consumeimgpath) . '?time=' . $_G['timestamp'] . '">'; } } else { //其他情況 echo "<option value=\"0\" selected=\"selected\">" . lang('please_select') . "</option>\n"; }
function image_text($arr) { global $_G, $_SGLOBAL; //for 55bbs foreach ($arr as $key => $value) { ${$key} = $value; } // Create the image $im = imagecreatefromjpeg("static/image/consume/{$id}.jpg"); // Create some colors if ($id == 1) { $color = imagecolorallocate($im, 111, 78, 0); $color1 = imagecolorallocate($im, 120, 87, 4); $color2 = imagecolorallocate($im, 120, 87, 4); } elseif ($id == 2) { $color = imagecolorallocate($im, 111, 78, 0); $color1 = imagecolorallocate($im, 111, 78, 0); $color2 = imagecolorallocate($im, 92, 63, 4); } elseif ($id == 3) { $color = imagecolorallocate($im, 24, 66, 90); $color1 = imagecolorallocate($im, 51, 51, 51); $color2 = imagecolorallocate($im, 88, 68, 7); } elseif ($id == 4) { $color = imagecolorallocate($im, 47, 89, 5); $color1 = imagecolorallocate($im, 51, 51, 51); $color2 = imagecolorallocate($im, 82, 59, 0); } elseif ($id == 5) { $color = imagecolorallocate($im, 128, 32, 90); $color1 = imagecolorallocate($im, 51, 51, 51); $color2 = imagecolorallocate($im, 91, 63, 13); } // The text to draw $title = base64_encode($coupon_title); $consume_to = lang('consume_to'); $dealer_name = biconv($dealer_name, $_G['charset'], 'UTF-8'); $coupon_title = biconv($coupon_title, $_G['charset'], 'UTF-8'); $begin_date = biconv($begin_date, $_G['charset'], 'UTF-8'); $end_date = biconv($end_date, $_G['charset'], 'UTF-8'); $date = $begin_date . $end_date; $consume_to = biconv($consume_to, $_G['charset'], 'UTF-8'); $brief = biconv($brief, $_G['charset'], 'UTF-8'); $exception = biconv($exception, $_G['charset'], 'UTF-8'); $text6 = biconv(lang('consume_55note'), $_G['charset'], 'UTF-8'); $address = biconv($address, $_G['charset'], 'UTF-8'); $hotline = biconv($hotline, $_G['charset'], 'UTF-8'); $date = $begin_date . $consume_to . $end_date; // Replace path by your own font path $font = 'static/image/fonts/' . $_G['setting']['fontpath']; // Add the text imagettftext($im, 23, 0, 220, 120, $color1, $font, $dealer_name); imagettftext($im, 18, 0, 160, 167, $color1, $font, $coupon_title); imagettftext($im, 9, 0, 565, 35, $color2, $font, $date); change_row($im, 10, 0, 158, 218, $brief, $color, $font, 38); change_row($im, 10, 0, 144, 320, $exception, $color, $font, 39); change_row($im, 10, 0, 144, 372, $address, $color, $font, 39); imagettftext($im, 10, 0, 144, 406, $color, $font, $hotline); // Using imagepng() results in clearer text compared with imagejpeg() $dirpath = loadClass('attach')->getattachdir(); if (!empty($dirpath)) { $dirpath .= '/'; } if ($preview == 1) { $filemain = $_G['uid']; } else { $_SGLOBAL['_num'] = empty($_SGLOBAL['_num']) ? 0 : intval($_SGLOBAL['_num']); $_SGLOBAL['_num']++; $filemain = $_G['uid'] . '_' . sgmdate($_G['timestamp'], 'YmdHis') . $_SGLOBAL['_num'] . random(4); } $consumeimgpath = $dirpath . $filemain . '.jpg'; $status = imagejpeg($im, A_DIR . '/' . $consumeimgpath, 80); imagedestroy($im); if ($status) { if ($preview != 1) { $filesize = filesize(A_DIR . '/' . $consumeimgpath); $hash = getmodelhash($mid, $itemid); $width = !empty($subjectimagewidth) ? $subjectimagewidth : 100; $height = !empty($subjectimageheight) ? $subjectimageheight : 100; $thumbarr = array($width, $height); $thumbpath = loadClass('image')->makethumb($consumeimgpath, $thumbarr); $insertsqlarr = array('isavailable' => 1, 'type' => 'model', 'itemid' => $itemid, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp'], 'filename' => 'consume_' . $id . '.jpg', 'subject' => 'subjectimage', 'attachtype' => 'jpg', 'isimage' => 1, 'size' => $filesize, 'filepath' => $consumeimgpath, 'thumbpath' => $thumbpath, 'hash' => $hash); inserttable('attachments', $insertsqlarr); } return $consumeimgpath; } else { return false; } }
function attach_upload($varname = 'Filedata', $multi = 0) { global $_G, $_FILES, $_POST, $_SGLOBAL, $_SC; $attachdir = A_DIR; $attacharray = $path_parts = array(); $imageexists = 0; //static $imgext = array('jpg', 'jpeg'); $attach = $_FILES[$varname]; if (empty($attach)) { return 0; } $attach_saved = false; $attach['uid'] = $_G['uid']; $filename = saddslashes($attach['name']); $attach['title'] = saddslashes(trim(strip_tags(rawurldecode($_POST['title'])))); $path_parts = pathinfo($filename); $attach['ext'] = strtolower($path_parts['extension']); //if(!($attach['ext'] == 'jpg' && ($attach['type']=='image/jpeg' || $attach['type']=='application/octet-stream'))) { // return false; //} // 文件大小檢測 if (!$this->check_attach_size($attach['size'])) { @unlink($attach['tmp_name']); return -1; } $attach['isimage'] = 1; $attach['thumb'] = 0; $attach['name'] = htmlspecialchars($attach['name'], ENT_QUOTES); $attach['name'] = biconv($attach['name'], 'UTF-8', $_G['charset']); $attach['title'] = biconv($attach['title'], 'UTF-8', $_G['charset']); if (bstrlen($attach['name']) > 45) { $attach['name'] = 'abbr_' . md5($attach['name']) . '.' . $attach['ext']; } if (!is_dir($attachdir . '/photo')) { @mkdir($attachdir . '/photo', 0777); @fclose(fopen($attachdir . '/photo/index.htm', 'w')); } $attach_subdir = 'photo/month_' . date('ym'); $attach_dir = $attachdir . '/' . $attach_subdir; if (!is_dir($attach_dir)) { @mkdir($attach_dir, 0777); @fclose(fopen($attach_dir . '/index.htm', 'w')); } $attach['attachment'] = $attach_subdir . '/'; $attach['attachment'] .= date('ymdHi') . substr(md5($filename . microtime() . random(6)), 8, 16) . '.' . $attach['ext']; $target = $attachdir . '/' . $attach['attachment']; if (@copy($attach['tmp_name'], $target) || function_exists('move_uploaded_file') && @move_uploaded_file($attach['tmp_name'], $target)) { @unlink($attach['tmp_name']); $attach_saved = true; } if (!$attach_saved && @is_readable($attach['tmp_name'])) { @($fp = fopen($attach['tmp_name'], 'rb')); @flock($fp, 2); @($attachedfile = fread($fp, $attach['size'])); @fclose($fp); @($fp = fopen($target, 'wb')); @flock($fp, 2); if (@fwrite($fp, $attachedfile)) { @unlink($attach['tmp_name']); $attach_saved = true; } @fclose($fp); } if ($attach_saved) { @chmod($target, 0644); $width = $height = $type = 0; $attach['thumb'] = $attach['attachment']; //$attach['thumb'] = loadClass('image')->makethumb($target, array(320, 240), substr($target, 0, -4).'.thumb.jpg'); } else { return 8; } $attacharray = $attach; return !empty($attacharray) ? $attacharray : false; }