/** 输出预设的格式化路径 @param array $info @return string */ public function depathMode($info) { global $king; $path = str_replace('TIME', time(), $info['kpathmode']); if (false !== strpos($path, 'ID')) { //如果有ID $model = $this->infoModel($info['modelid']); $res = $king->db->getRows_one("select max(kid) from %s__{$model['modeltable']}"); $res[0] ? $path = str_replace('ID', $res[0] + 1, $path) : ($path = str_replace('ID', 1, $path)); } $date = explode(',', kc_formatdate(time(), 'Y,m,d,G,i,s,M')); $path = str_replace('yyyy', $date[0], $path); $path = str_replace('yy', substr($date[0], 2), $path); $path = str_replace('dd', $date[2], $path); $path = str_replace('hh', $date[3], $path); $path = str_replace('mm', $date[4], $path); $path = str_replace('ss', $date[5], $path); $path = str_replace('MMM', $date[6], $path); $path = str_replace('MM', $date[1], $path); while (False !== strpos($path, 'RND')) { $path = preg_replace('/RND/', kc_random(3), $path, 1); } while ($king->db->getRows_one("select kpath from %s__{$model['modeltable']} where kpath='" . $king->db->escape($path) . "';")) { $ext = kc_f_ext($path); //扩展名 $path = substr($path, 0, strlen($path) - strlen($ext) - 1) . $king->config('rewriteline') . kc_random(6) . '.' . $ext; } return $path; }
/** 返回文件类型图标对应的<icon.gif>图片位置代号 @param string $_name 文件名或路径 @return string */ function kc_f_ico($name) { switch (kc_f_ext($name)) { case 'doc': $s = 'b3'; break; case 'htm': $s = 'f3'; break; case 'html': $s = 'f3'; break; case 'js': $s = 'l3'; break; case 'css': $s = 'l3'; break; case 'mid': $s = 'k3'; break; case 'wma': $s = 'k3'; break; case 'mp3': $s = 'k3'; break; case 'pdf': $s = 'j3'; break; case 'php': $s = 'a3'; break; case 'php3': $s = 'a3'; break; case 'jpg': $s = 'd3'; break; case 'png': $s = 'i3'; break; case 'gif': $s = 'd3'; break; case 'bmp': $s = 'd3'; break; case 'swf': $s = 'h3'; break; case 'txt': $s = 'h6'; break; case 'xls': $s = 'c3'; break; case 'zip': $s = 'e3'; break; case 'rar': $s = 'e3'; break; case '7z': $s = 'e3'; break; default: $s = 'g3'; } return $s; }
function king_iframe_upfile() { global $king; $king->access('#brow_upfile'); $filetype = ''; $is = ''; $jsfun = ''; $path = ''; $info = inc_brow(); extract($info); $s = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n\t<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>\r\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . PAGE_CHARSET . "\" />\r\n\t<script type=\"text/javascript\" src=\"" . $king->config('inst') . "system/js/jquery.js\"></script>\r\n\t<style type=\"text/css\">\r\n\t\t<!--\r\n\t\t*{margin:0;padding:0;font-size:12px;}\r\n\t\tbody{background:#F2F9FD;margin-left:20px;}\r\n\t\t.k_in{width:250px;margin-left:5px;font-size:14px;}\r\n\t\tlabel{width:70px;position:absolute;overflow:hidden;display:block;float:left;\r\n\t\t\t-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\";filter:alpha(opacity=0);/*IE*/opacity:0;}\r\n\t\t.k_up{width:70px;display:block;font-size:16px;height:24px;;margin-right:-5px;}\r\n\t\tp,tr{height:25px;}\r\n\t\t.k_brow{display:block;width:60px;border:1px solid;padding:2px 0;\r\n\t\t\tborder-color:#787878 #ADADAD #5F5F5F #ADADAD;background:#F2F2F2;}\r\n\t\tp{text-indent:10px;text-align:center;display:block;height:25px;}\r\n\t\ttable{margin:0 auto;width:100%;}\r\n\t\ttd{text-align:left;position:relative;}\r\n\t\tth{text-align:left;text-indent:10px;}\r\n\t\t.submit{width:80px;margin-left:10px;}\r\n\t\t.c1{color:#3875D7;text-align:left;} /* 蓝 */\r\n\t\t.c2{color:#CF0422;text-align:left;} /* 红 */\r\n\t\t.l{text-align:left;}\r\n\t\t.sel{background:#FC0;}\r\n\t\t-->\r\n\t</style>\r\n\t</head><body>"; $s .= "<form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"manage.php?action=iframe&CMD=upfile\">"; if ($_FILES) { $ftypes = $king->getfext($filetype); $_array_filetype = explode('|', $ftypes); //扩展名转换为数组 $s .= "<p class=\"l\"><strong>" . $king->lang->get('system/common/list') . ":</strong></p>"; for ($i = 0; $i < 5; $i++) { //判断file元素是否包含了上传文件 if ($_FILES['file']['name'][$i] != '') { //判断文件扩展名 $ext = kc_f_ext($_FILES['file']['name'][$i]); //文件扩展名 if (in_array($ext, $_array_filetype)) { kc_post('isrename') == 1 ? $filename = time() . $i . '.' . $ext : ($filename = $_FILES['file']['name'][$i]); //上传操作 if (move_uploaded_file($_FILES['file']['tmp_name'][$i], ROOT . $path . iconv('UTF-8', '', $filename))) { //上传成功,并记录上传文件地址 $s .= "<p class=\"c1\">" . $king->lang->get('system/common/file') . ($i + 1) . ' : ' . $king->lang->get('system/brow/t1'); $s .= '<a href="../' . $path . $filename . '" target="_blank">[' . $king->lang->get('system/common/view') . ': ' . $filename . ']</a>'; $insert = "onClick=\"window.parent.\$('#{$id}').val('{$path}{$filename}');window.parent."; $insert .= $is ? $jsfun : "\$.kc_close()"; $insert .= "\" title=\"" . $king->lang->get('system/common/insert') . "\""; $s .= "<a href=\"javascript:;\" {$insert}>[" . $king->lang->get('system/common/insert') . ']</a></p>'; //增加插入功能 $array = array('ktitle' => kc_post("name{$i}"), 'kpath' => $path . $filename, 'ndate' => time(), 'adminid' => $king->admin['adminid'], 'ntype' => $filetype); $king->db->insert('%s_upfile', $array); } else { $s .= "<p class=\"c2\">" . $king->lang->get('system/common/file') . ($i + 1) . ' : ' . $king->lang->get('system/brow/t2') . "</p>"; } } else { $s .= "<p class=\"c2\">" . $king->lang->get('system/common/file') . ($i + 1) . ' : ' . $king->lang->get('system/brow/t3') . "</p>"; } } else { $s .= "<p class=\"c2\">" . $king->lang->get('system/common/file') . ($i + 1) . ' : ' . $king->lang->get('system/brow/t4') . "</p>"; } } $s .= "<p class=\"l\"><input type=\"button\" class=\"submit\" onClick=\"window.parent.\$('#a_brow_upfile').attr('rel','" . addslashes("{{$verbs},CMD:'brow_upfile',isopen:1,path:'{$path}',IS:1,ID:'brow_top'}") . "');window.parent.\$('#brow_upfile').remove();\" value=\"" . $king->lang->get('system/common/close') . "\"/></p>"; } else { $s .= "<table cellspacing=\"0\">"; $s .= "<tr><th>" . $king->lang->get('system/common/select') . "</th><th>" . $king->lang->get('system/upfile/title') . "</th></tr>"; for ($i = 0; $i < 5; $i++) { $s .= "<tr><td><label><input onClick=\"\$('#k_brow_{$i}').addClass('sel')\" class=\"k_up\" type=\"file\" name=\"file[]\" /></label>"; $s .= "<input id=\"k_brow_{$i}\" class=\"k_brow\" type=\"button\"value=\"" . $king->lang->get('system/common/brow') . "..\" /></td>"; $s .= "<td><input type=\"text\" class=\"k_in\" name=\"name{$i}\"/></td>"; $s .= "</tr>"; } $s .= "</table>"; $s .= "<p><input type=\"checkbox\" name=\"isrename\" id=\"isrename\" value=\"1\" checked=\"true\" /> " . $king->lang->get('system/brow/rename'); $s .= "<input type=\"submit\" class=\"submit\" value=\"" . $king->lang->get('system/common/upload') . "\"/>"; $s .= "<input type=\"button\" class=\"submit\" onClick=\"window.parent.\$('#a_brow_upfile').attr('rel','" . addslashes("{{$verbs},CMD:'brow_upfile',isopen:1,path:'{$path}',IS:1,ID:'brow_top'}") . "');window.parent.\$('#brow_upfile').remove();\" value=\"" . $king->lang->get('system/common/close') . "\"/></p>"; $s .= kc_htm_hidden($info); } $s .= "</form></body></html>"; echo $s; //成功上传后,Remove #brow_upfile }
/** 上传付款凭证 */ function king_bank() { global $king; $oid = kc_get('oid', 2, 1); if (!($rs = $king->db->getRows_one("select ono,kname,nnumber,ntotal,kfeedback,eid,nexpress,userid,nstatus from %s_orders where oid={$oid}"))) { kc_error($king->lang->get('system/error/param')); } if ($rs['userid'] > 0) { $king->Load('user'); $king->user->access(); //如果有记录用户,则做登录验证 if ($king->user->userid != $rs['userid']) { $king->portal->error($king->lang->get('system/common/error'), $king->lang->get('portal/error/cart')); } } if ((int) $rs['nstatus'] !== 2) { $king->portal->error($king->lang->get('system/common/error'), $king->lang->get('portal/error/status')); } $s = '<table class="k_table_list" cellspacing="0">'; $s .= '<caption>' . $king->lang->get('portal/cart/prodinfo') . '</caption>'; $s .= '<tr><th class="w150">' . $king->lang->get('portal/cart/youorders') . '</th><td><strong class="red">' . $rs['ono'] . '</strong></td>'; $s .= '<th>' . $king->lang->get('portal/cart/prodname') . '</th><td>' . $rs['kname'] . '</td></tr>'; $s .= '<tr><th>' . $king->lang->get('portal/cart/total') . '</th><td>' . $rs['nnumber'] . '件</td>'; $s .= '<th>' . $king->lang->get('portal/cart/alltotal') . '</th><td>' . number_format($rs['ntotal'], 2) . '</td></tr>'; $s .= '</table>'; if ($_FILES) { $ext = strtolower(kc_f_ext($_FILES['bankfile']['name'])); kc_f_md($king->config('uppath') . "/orders"); if (!in_array($ext, array('jpg', 'jpeg'))) { $s .= '<p class="k_error">' . $king->lang->get('portal/error/ext') . '</p>'; //提示文件类型不正确 $s .= '<p><a href="cart.php?action=bank&oid=' . $oid . '">' . $king->lang->get('portal/cart/reup') . '</a></p>'; } elseif (move_uploaded_file($_FILES['bankfile']['tmp_name'], ROOT . $king->config('uppath') . "/orders/{$oid}.jpg")) { $s .= '<p>' . $king->lang->get('portal/cart/upok') . '</p>'; $array = array('paymethod' => 'bank'); $king->db->update('%s_orders', $array, "oid={$oid}"); } else { $s .= '<p class="k_error">' . $king->lang->get('portal/error/upbank') . '</p>'; } } else { $s .= $king->openForm('cart.php?action=bank', null, 1); $s .= '<p>' . $king->lang->get('portal/cart/bankmemo') . '</p>'; $s .= '<p>' . $king->lang->get('portal/cart/bankmemo1') . '</p>'; $s .= $king->htmForm($king->lang->get('portal/cart/upbank'), "<input type=\"file\" name=\"bankfile\" class=\"k_in w400\" />"); $hide = array('oid' => $oid, 'MAX_FILE_SIZE' => 204800); $s .= kc_htm_hidden($hide); $s .= $king->closeForm($king->lang->get('system/common/upfile')); } $tmp = new KC_Template_class($king->config('templateorders', 'portal')); $tmp->assign('oid', $oid); $tmp->assign('title', $king->lang->get('portal/cart/upbank')); $tmp->assign('nav', $king->lang->get('portal/cart/upbank')); $tmp->assign('type', 'edit'); $tmp->assign('inside', $s); echo $tmp->output(); }
/** 编辑文本 */ function king_ajax_edit() { global $king; $king->access('webftp_edit'); $path = kc_post('path'); $ext = kc_f_ext($path); switch ($ext) { case 'html': $code = 'html'; break; case 'htm': $code = 'html'; break; case 'shtml': $code = 'html'; break; case 'shtm': $code = 'html'; break; case 'css': $code = 'css'; break; case 'js': $code = 'js'; break; case 'php': $code = 'php'; break; case 'php3': $code = 'php'; break; case 'php4': $code = 'php'; break; case 'sql': $code = 'sql'; break; case 'xml': $code = 'xml'; break; default: $code = ''; } if (isset($_POST['webftpcontent'])) { //写文件 kc_f_put_contents($path, $_POST['webftpcontent'], 1); kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/ok/save') . "</p>"); } if (!kc_f_isfile($path)) { kc_error($king->lang->get('system/error/notfile')); } $content = kc_f_get_contents($path); $js = "editAreaLoader.init({\r\n\t\t\tid: \"webftpcontent\"\r\n\t\t\t,start_highlight: " . (strlen($content) > 10240 ? 'false' : 'true') . "\r\n\t\t\t,allow_resize: \"both\"\r\n\t\t\t,allow_toggle: false\r\n\t\t\t,word_wrap: true\r\n\t\t\t,language: \"en\"\r\n\t\t\t,syntax: \"php\"\r\n\t\t});"; $s = "<textarea id=\"webftpcontent\" name=\"webftpcontent\" rows=\"15\" cols=\"80\" style=\"width:870px;height:420px\">"; $s .= htmlspecialchars($content); $s .= "</textarea>"; $but = kc_htm_a($king->lang->get('system/common/save'), "{CMD:'edit',IS:1,path:'{$path}'}"); kc_ajax($king->lang->get('system/common/edit') . ' : ' . $path, $s, $but, $js, 900, 450); }