* 定义 Ajax 类 * * @link http://www.yucmedia.com/ * @copyright Copyright (c) 2011-2012 宇初网络技术有限公司 {@link http://www.yucmedia.com/} * @version $Id: ajax.php 1186 2012-07-25 02:29:24Z zhanghui $ * @author Administrator * @author $Author: zhanghui $ * $Date: 2012-07-25 10:29:24 +0800 (周三, 2012-07-25) $ * @package Ajax */ define('P_IS_ACCESS', TRUE); require './_base.php'; class Ajax extends YPrepose implements YIAction { public function __construct() { parent::__construct(); } /** * 获取校验结果 * @return type */ public function run() { $ret = Verify::getVerifyResult(); $back_result = array('code' => Verify::getCode(), 'result' => Verify::getResult(), 'details' => Verify::getDetails()); echo 'yuc_site_config.ajaxresult=' . json_encode($back_result); } } YAccess::run('Ajax');
{ $ret = array(); $ret['width'] = $this->getValueInRange('width', 160, 320, 245); $ret['height'] = $this->getValueInRange('height', 90, 180, 185); $ret['fontsize'] = $this->getValueInRange('fontsize', 30, 60, 30); return $ret; } /** * 获取值的确定值 为了安全着想 * @param type $key * @param type $default * @param type $max * @param type $min * @return type */ private function getValueInRange($key, $default, $max, $min) { $value = $this->_context->get($key, $default); if ($value > $max) { return $max; } else { if ($value < $min) { return $min; } else { return $value; } } } } YAccess::run('Image');
YLog::Write('请求:' . YApp::getConfig('YUC_SERVICE_NAME') . YApp::getConfig('YUC_REQUEST_PATH') . ';返回状态 :' . $client->getStatus() . ';POST请求返回的数据:' . $client->getContent(), YLog::DEBUG); $ret_back = json_decode($client->getContent(), TRUE); if (!is_array($ret_back)) { YucMonitor::report("REPORT_0004", $client->getContent()); } return array('status' => $client->getStatus(), 'content' => $ret_back); } /** * 加载 Js文件 * @param $js * @return string|type */ private function loadJs($js) { $js_code_temp = ''; $key = md5('__compress_js__' . $js); $js_cache_code = F($key); if ($js_cache_code === FALSE) { $js_arr = explode('|', $js); foreach ($js_arr as $js) { $file = M_PRO_DIR . '/Media/Js/' . str_replace("_", "/", $js); $js_code_temp .= file_get_contents($file); } $js_cache_code = $js_code_temp; F($key, $js_cache_code); } return $js_cache_code; } } YAccess::run('Load');
<?php /** * 定义 index 类 * @link http://www.yucmedia.com/ * @copyright Copyright (c) 2011-2012 宇初网络技术有限公司 {@link http://www.yucmedia.com/} * @version $Id:$ * @author Administrator * @author $Author: $ * $Date: 2012-07-10 09:46:31 +0800 (周二, 2012-07-10) $ * @package index */ define('P_IS_ACCESS', TRUE); require './_base.php'; class Index extends YPrepose implements YIAction { public function run() { $rndCodeStr = implode(',', YucMath::getCheckCode(5, 2)); $code = urlencode(base64_encode(YucCrypt::encrypt($rndCodeStr, YucMath::erypt_key()))); $c_id = YucMath::getMultiSerialId(2, 10); $plugin_path = dirname($this->_context->baseDir()); $imgsrc = YucServer::getServerUrl() . "{$plugin_path}/image.php?I_S={$c_id}&mass={$code}"; $renderid = $this->_context->get('renderid', ''); echo "yuc_site_config.{$renderid}=" . json_encode(array('imgsrc' => $imgsrc, 'mass' => $code, "result" => array("code" => 0, 'details' => ''))); } } YAccess::run('Index');