/** * Simple function to send an email on failure of MySQL commands * @param string $subject * @param string $body * @param array $trace * @return boolean */ function sql_mailman($subject, $body, $trace) { ob_start(); dump($trace); $trace = ob_get_contents(); ob_end_clean(); global $MYSQL_OPTS; $to = DEBUG_EMAIL; $from = "noreply@{$MYSQL_OPTS['domain_name']}"; $params = "-f" . $from; $headers = "From: MySQL Debug <" . $from . ">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"MIME-BOUNDARY\"\r\n"; $message = "\r\n"; $message .= "--MIME-BOUNDARY\r\n"; $message .= "Content-type: text/html; charset=US-ASCII\r\n"; $message .= "\r\n"; $message .= "<HTML>\r\n" . "<HEAD>\r\n" . "<STYLE TYPE='text/css'>\r\n" . "#SQL, #SQL TD, #SQL TH { font-family: Tahoma, Helvetica, sans-serif; font-size: 10pt; color: #000000; }\r\n" . "#SQL { border: 1px solid #000000 }\r\n" . "#SQL TD { border: 1px solid #000000 }\r\n" . "#SQL TH { background: #000000; color: #FFFFFF }\r\n" . "</STYLE>\r\n" . "</HEAD>\r\n" . "<BODY BGCOLOR=WHITE>\r\n" . "{$body}\r\n" . "</BODY>\r\n" . "</HTML>\r\n"; $message .= "\r\n"; $message .= "--MIME-BOUNDARY\r\n"; $message .= "Content-Type: text/html;\n" . " name=\"backtrace.html\"\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n" . chunk_split(base64_encode($trace)) . "\r\n\r\n" . "--MIME-BOUNDARY--"; ob_start(); $ok = mail($to, $subject, $message, $headers, $params); $buffer = ob_get_contents(); ob_clean(); return $ok ? true : false; }
function index() { $user = new UserViewModel(); $list = $user->select(); dump($list); //$this->display(); }
public function barbersUpdate() { $this->checkroute(); if (IS_POST) { $data = M('barber')->find(1); $data['name'] = I('post.name'); $data['expert'] = I('post.major'); $data['details'] = I('post.message'); M('order_type')->where('fk_bid=' . $data['bid'])->delete(); $items = I('post.item'); $costs = I('post.cost'); for ($i = 0; $i < count($items); $i++) { $orders[] = array('fk_bid' => $data['bid'], 'type_name' => $items[$i], 'cost' => $costs[$i], 'insert_time' => time()); } dump(I('post.')); dump(M('order_type')->addAll($orders)); /*if(M('barber')->save($data)&&M('order_type')->addAll($orders)) $this->success('修改成功!','barbers'); else $this->error('修改失败,请重试!','barbersUpdate?id='.$data['bid']);*/ } else { $barberinfo = M('barber')->find(I('get.id')); $this->assign('barberinfo', $barberinfo); $data = M('order_type')->where("fk_bid=" . $barberinfo['bid'])->select(); $this->assign('data', $data); //dump($data); $this->display('barbers_done'); } }
public function login() { if ($_POST) { $user = M('auth_user')->where($_POST)->select(); dump($user); if ($user) { $timeout = 30; // 3600 * 24 * 2 setcookie("username", $_POST['name'], time() + $timeout); setcookie("password", $_POST['password'], time() + $timeout); $_SESSION['user'] = $user; } else { echo "invalid username or password !"; die; } $returnUrl = $_SESSION['returnUrl']; $_SESSION['returnUrl'] = null; if ($returnUrl) { $this->redirect($returnUrl); } else { $this->redirect("/"); } die; } $this->display(); }
/** * 公共函数 * @package config * @copyright Copyright (c) 2014-2030 Wangkeyun-com Inc.(http://www.wangkeyun.com) * @license http://www.wangkeyun.com * @link http://www.wangkeyun.com * @author wangkeyun-com Team */ function p($arr, $Charset = 'utf-8') { if (!empty($Charset)) { header("Content-Type: text/html; charset={$Charset}"); } dump($arr, 1, '<pre>', 0); }
/** * Funcao que eh chamada apos o login * * @param Event $objEvent */ public function onLogged(Event $objEvent) { dump('Efutuar o log do usuario logado'); dump($objEvent); dump($objEvent->getTarget()); dump($objEvent->getParams()); }
public function start_order() { header("Content-Type:text/html; charset=utf-8"); $d = I("post."); if ($d['menu_id'] == '' || $d['menu_id' == '0']) { $this->error("请正确订餐", U('/Home/StartOrder/Index')); } $menu = M('menu'); $d['order_name'] = session('name'); $d['order_user'] = session('username'); $m_info = $menu->field('food_name,food_price')->where('id=' . $d['menu_id'])->find(); dump($m_info); $shop = M('shop'); $s_info = $shop->field('shopname')->where('id=' . $d['shop_id'])->find(); $d['order_res'] = $s_info['shopname']; $d['order_food'] = $m_info['food_name']; $d['order_time'] = time(); //通过order_food和order_res,查询food_price $menu = M('menu'); //$order_price = $menu->where("food_name = '$data[order_food]' AND food_res = '$data[order_res]'")->field('food_price')->find(); $d['order_price'] = $m_info['food_price']; //添加新的订单信息 $this->assign('order_info', $d); session('order', $d); $this->display('sure'); }
public function excute() { $aliyunQueue = new Queue_Model_MNS(); $aliyunQueue->setQueue('notifications'); switch ($_REQUEST['action']) { case 'send': $message = $_REQUEST['message']; $message = $message ? $message : "Jesse"; $result = $aliyunQueue->sendMessage($message); break; case 'get': $result = $aliyunQueue->receiveMessage(); if ($_REQUEST['del']) { $delResult = $aliyunQueue->delMessage($result['ReceiptHandle']); dump($delResult); } break; case 'info': $result = $aliyunQueue->getQueueInfo(); break; case 'del': $result = $aliyunQueue->delMessage($_REQUEST['receipt_handle']); break; } dump($result); }
/** * Default form handler */ public function process() { /** @var ArrayHash $values */ $values = $this->values; try { $this->onBeforeProcess($this, $values); if (isset($values->id)) { $this->onBeforeUpdate($this, $values); $arr = (array) $values; unset($arr['id']); $row = $this->selection->wherePrimary($values->id)->fetch(); $row->update($arr); $this->onAfterUpdate($row, $this, $values); } else { $this->onBeforeInsert($this, $values); $row = $this->selection->insert($values); $this->onAfterInsert($row, $this, $values); } $this->onAfterProcess($row, $this, $values); } catch (\PDOException $e) { $this->addError($e->getMessage()); dump($e); Debugger::log($e); } }
/** * Captura todas as exceções não tratadas do sistema. * * @param Exception $e */ function throwNewExceptionFromAnywhere($e) { $setup = BraghimSistemas::getInstance(); // Tenta carregar a tela de erro do MODULO. try { $setup->mvc = $setup->resolve($setup->mvc->moduleName, 'error', 'error'); } catch (Exception $ex) { // Tenta carregar a tela de erro // padrao do framework. try { $setup->mvc = $setup->resolve('ModuleError', 'error', 'error', __DIR__ . DIRECTORY_SEPARATOR . 'library'); } catch (Exception $ex2) { if (function_exists('createSystemLog')) { createSystemLog($e); } echo "Exception sem possibilidade de tratamento."; dump($e); } } $setup->mvc->exception = $e; // Ultima tentativa de dar certo, // se chegar aqui e der erro então // o projeto esta configurado incorretamente. try { $setup->run(); } catch (Exception $ex3) { if (function_exists('createSystemLog')) { createSystemLog($e); } echo "Exception sem possibilidade de tratamento."; dump($ex3); } }
/** * @Route("/register", name="security_register") * @Method("POST") */ public function registerAction(Request $request) { $em = $this->getDoctrine()->getManager(); $request = Request::createFromGlobals(); $email = $request->request->get('email'); $password = $request->request->get('password'); $ico = trim($request->request->get('ico')); $user = new User(); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword($password, $user->getSalt())); $user->setEmail($email); $user->setIco($ico); $backgroundImages = ['animal', 'corn', 'farming', 'chicken']; shuffle($backgroundImages); $user->setBackgroundImage($backgroundImages[0]); $profileImages = ['animal', 'corn', 'farming', 'chicken']; shuffle($profileImages); $user->setProfileImage($profileImages[0]); $em->persist($user); $em->flush(); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->get('security.token_storage')->setToken($token); //rabbit MQ $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest'); $channel = $connection->channel(); $channel->queue_declare('ico_queue', false, false, false, false); $json = json_encode(["userId" => $user->getId(), "ico" => $ico]); $msg = new AMQPMessage($json); $channel->basic_publish($msg, '', 'ico_queue'); dump(" [x] Sent '{$ico}'\n"); $channel->close(); $connection->close(); return $this->redirect($this->generateUrl('main_overview')); }
function run() { // 设置默认错误级别, 测试环境,尽量显示所有错误 if (Config::get('show_error')) { ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); } else { ini_set('display_errors', 'Off'); error_reporting(0); } // echo 'Application.php'; // var_dump(microtime(1) - $_SERVER['REQUEST_TIME_FLOAT']); dump("SERVER内容", $_SERVER); // dump($_SERVER); // dump((($sdir = dirname($_SERVER['SCRIPT_NAME'])) == '/' || $sdir == '\\') ? '' : $sdir); // run_info(1); // try // { // // $x = 1 / 0; // throw new CommonException("Application.php 发生了错误!"); // } // catch (CommonException $e) // { // echo $e; // } // \wlog("test", "Application.php"); // run_info(); // \show_404(); // show_success("Application.php"); show_error("Application.php"); }
public function red() { $userinfo = M('Userinfo'); $list = $User->where($userinfo['infoid'] == 0)->select(); $this->assign('list', $list); dump($list); }
public function checkverify() { $code = $_GET['code']; $verify = new \Think\Verify(); $result = $verify->check($code); dump($result); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $orfo = $this->request->get('orfo'); $url = $this->request->get('url'); $comment = $this->request->get('comment', false); $author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname'); $form = $this->getForm('orfo'); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $data = $form->parse($this->request, $is_submitted); $data['date'] = date('Y-m-d H:i:s'); $errors = $form->validate($this, $data); dump($errors); if (!$errors) { $this->model->addComplaints($data); $messenger = cmsCore::getController('messages'); $messenger->addRecipient(1); $notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true)); $messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add'); } cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess')); } $data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment); return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data)); }
public function WX_request($url, $data = null) { $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 if ($data != null) { curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包 } curl_setopt($curl, CURLOPT_TIMEOUT, 300); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $info = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { echo 'Errno:' . curl_getinfo($curl); //捕抓异常 dump(curl_getinfo($curl)); } return $info; }
function dump_highlight($var, $depth = null) { $out = dump($var); $out = highlight_string("<?php\n" . $out, true); $out = preg_replace('@<\\?php<br />@s', '', $out, 1); return $out; }
public function match() { if (!$this->configuration->isCliServer()) { return null; } dump(self::class); }
private function adminMenUrl($type, $id) { /*if(substr($type,0,1) != '_'){ $ }*/ //var_dump($type); $menu_date = M('menu' . $type)->where(['menu_id' => $id])->find(); if (empty($menu_date)) { return 'javascript:void(0);'; } //$MType = if (strpos($type, 'other')) { $url = U(C('admin_module') . '/' . C('admin_url_c') . '/adminMenUrlDir', ['mvc_dir' => $menu_date['dir'], 'mvc_file' => $menu_date['file'], 'mvc_var' => $menu_date['var']]); //'adminMenUrlDir/'.$menu_date['dir'].'/'.$menu_date['file']; } else { if (strpos($type, 'mvc')) { $menu_default = C('mvc_module_default'); $url = U(C('admin_module') . '/' . C('admin_url_c') . '/adminMenUrlMvc', ['mvc_model' => $menu_date['mvc_model'], 'mvc_module_default' => $menu_default[$menu_date['mvc_model']], 'mvc_c' => $menu_date['controller'], 'mvc_m' => $menu_date['model'], 'mvc_v' => $menu_date['view'], 'mvc_var' => $menu_date['var']]); //'./index.php/'.C('ADMIN_MODULE').'/'.C('ADMIN_URL_C').'/adminMenUrlMvc/dir/'.$ } } dump(strpos($type, 'mvc')); dump($url); return $url; }
function Index() { echo '【DB类测试】<br />'; $db = DB::getInstance(); echo '1.查询 Cache 表 k 值为 plugins 的记录(单条)<br />记录信息:'; dump($db->table('cache')->field(array('k', 'v'))->where(array('k' => 'plugins'))->find()); echo '生成的SQL:' . $db->getLastSql() . '<br /><br />'; echo '2.查询 sign_log 表的全部记录并统计签到经验(多条)<br />记录信息:'; dump($db->table('sign_log')->field(array('SUM(exp)' => 'exp'))->group('uid')->select()); echo '生成的SQL:' . $db->getLastSql() . '<br /><br />'; echo '3.在 Cache 表插入一条记录<br />'; $data = array('k' => 'test', 'v' => 'test'); $flag = $db->table('cache')->insert($data); echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />'; echo '4.在 Cache 表更新 k 值为 plugins 的记录<br />'; $data['v'] = "testnow"; $flag = $db->table('cache')->where(array('k' => 'test'))->update($data); echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />'; echo '5.在 Cache 表删除 k 值为 plugins 的记录<br />'; $flag = $db->table('cache')->where(array('k' => 'test'))->delete(); echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />'; echo '6.在 sign_log 表查询 uid 值为 4 且 date 值为 20140517 的签到记录<br />'; dump($db->table(array('sign_log' => 'l'))->join(array('_table' => 'my_tieba', '_as' => 't', '_on' => 't.tid = l.tid', '_type' => 'LEFT JOIN'))->where(array('l.uid' => '4', 'l.date' => '20140517'))->order('l.uid DESC')->select()); echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />'; echo '用时' . (microtime(true) - START_TIME) * 1000 . '毫秒<br /><br />'; echo '【GET测试】<br />GET值:'; dump($_GET); }
public function add() { if (I("flag")) { $Group = D("Group"); if ($Group->create()) { $_POST['rules'] = implode(',', I('rules')); $g = $Group->add($_POST); //菜单的添加 if ($g) { $this->ajaxReturn(1); } else { $this->ajaxReturn(0); } } else { $this->ajaxReturn($Group->getError()); } } else { $menu = D('menu'); $data = $menu->field("id,pid,name")->select(); $pid = 0; $treeList = makeTree($pid, $data); dump($treeList); $tree = treeOutput($treeList); $this->assign("tree", $tree); $this->display(); } }
function insertRole($data) { $connection = connect(); $role = new Role(); echo dump($data); $role->setRole(mysqli_real_escape_string($connection, $data['role'])); $role->setDescription(mysqli_real_escape_string($connection, $data['description'])); $query = "insert into role ("; $query .= " role,description "; $query .= ") values( "; $query .= " '{$role->getRole()}','{$role->getDescription()}'"; $query .= ")"; $result = mysqli_query($connection, $query); if ($result) { // echo dump($result); $query = "select id from role where role = '{$role->getRole()}' LIMIT 1"; $result = mysqli_query($connection, $query); confirm_query($result); $row = mysqli_fetch_assoc($result); colse_connection($connection); //echo dump($row['id']); return $row['id']; } colse_connection($connection); return null; }
public function hproseAct() { vendor('Hprose.HproseHttpClient'); $client = new \HproseHttpClient('http://localhost:8500/Api/HproseTest'); $result = $client->test(); dump($result); }
public function zhangadd() { //写入章节表 $zhang = D('Zhang'); $info = $zhang->create(); if ($info) { // 获取章节ID $zh_id = $zhang->add(); dump($info); } else { $this->error($zhang->getError()); } // 写入小节表 $xiaojie = D('Zizhang'); $xi_data['xi_name'] = $_POST['xi_name']; $xi_data['zh_id'] = $zh_id; $xi_data['add_time'] = time(); $xi_id = $xiaojie->add($xi_data); // 上传视频 $setting = C('UPLOAD_SITEIMG_QINIU'); $Upload = new \Think\Upload($setting); $info = $Upload->upload($_FILES); $a = $info['video']['url']; $b = "yanqingju.qiniudn.com"; $str = str_replace($b, "7xo3l8.com1.z0.glb.clouddn.com", $a); // 写入视频表 $video = D('Video'); $vi_data['name'] = $str; $vi_data['zz_id'] = $xi_id; $vi_id = $video->add($vi_data); // 更新小节表视频ID $xiaojie->where('id=' . $xi_id)->setField('video_id', $vi_id); $this->redirect('index'); }
public function actionIndex() { $path = \Yii::$app->basePath . '/../'; exec("svn update " . $path); $e = system("svn status -v " . $path); dump($e); }
function users($args) { dump('Seeding users'); $count = !empty($args['count']) ? $args['count'] : 2; $faker = new Users(); $faker->seed($count); }
public function index(){ //导入PHPExcel类库,因为PHPExcel没有用命名空间,只能inport导入 import("Org.Util.PHPExcel"); //要导入的xls文件,位于根目录下的Public文件夹 $filename="./Public/1.xls"; //创建PHPExcel对象,注意,不能少了\ $PHPExcel=new \PHPExcel(); //如果excel文件后缀名为.xls,导入这个类 import("Org.Util.PHPExcel.Reader.Excel5"); //如果excel文件后缀名为.xlsx,导入这下类 //import("Org.Util.PHPExcel.Reader.Excel2007"); //$PHPReader=new \PHPExcel_Reader_Excel2007(); $PHPReader=new \PHPExcel_Reader_Excel5(); //载入文件 $PHPExcel=$PHPReader->load($filename); //获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推 $currentSheet=$PHPExcel->getSheet(0); //获取总列数 $allColumn=$currentSheet->getHighestColumn(); //获取总行数 $allRow=$currentSheet->getHighestRow(); //循环获取表中的数据,$currentRow表示当前行,从哪行开始读取数据,索引值从0开始 for($currentRow=1;$currentRow<=$allRow;$currentRow++){ //从哪列开始,A表示第一列 for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){ //数据坐标 $address=$currentColumn.$currentRow; //读取到的数据,保存到数组$arr中 $arr[$currentRow][$currentColumn]=$currentSheet->getCell($address)->getValue(); } } dump($arr); }
public function query($query) { //$cache = Ajde_Db_Cache::getInstance(); $log = ['query' => $query]; $start = microtime(true); //if (!$cache->has($query)) { try { $result = parent::query($query); } catch (Exception $e) { if (config('app.debug') === true) { if (isset($this->queryString)) { dump($this->queryString); } dump('Go to ' . config('app.rootUrl') . '?install=1 to install DB'); throw new Ajde_Db_Exception($e->getMessage()); } else { Ajde_Exception_Log::logException($e); die('DB connection problem. <a href="?install=1">Install database?</a>'); } } //$cache->set($query, serialize($result)); // $log['cache'] = false; //} else { // $result = $cache->get($query); // $log['cache'] = true; //} $time = microtime(true) - $start; $log['time'] = round($time * 1000, 0); self::$log[] = $log; return $result; }
/** * Get all available icons list * @param array $img_ext - possible extensions of files in scanned directory * @param array $skip - files to skip * @return array */ public function get($img_ext = array('gif'), array $skip = array('unknown.gif', 'recycle.bin.empty.gif', 'recycle.bin.full.gif')) { if (is_string($img_ext)) { $img_ext = [$img_ext]; } elseif (!is_array($img_ext)) { dump('Supply a list of possible extensions for icons.'); } if (isset(self::$data[$this->dir])) { $data = self::$data[$this->dir]; } else { $data = []; $img_ext = array_flip($img_ext); foreach (array_diff(scandir($this->dir), ['.', '..']) as $f) { $exts = explode('.', $f); if (!isset($img_ext[array_pop($exts)])) { continue; } foreach ($exts as $v) { $data[$v] = $f; } } self::$data[$this->dir] = $data; } return $skip ? array_diff($data, $skip) : $data; }
function ut_main() { $pattern = <<<_MSG_ {gender_of_host, select, female {{num_guests, plural, offset:1 =0 {{host} does not give a party.} =1 {{host} invites {guest} to her party.} =2 {{host} invites {guest} and one other person to her party.} other {{host} invites {guest} as one of the # people invited to her party.}}} male {{num_guests, plural, offset:1 =0 {{host} does not give a party.} =1 {{host} invites {guest} to his party.} =2 {{host} invites {guest} and one other person to his party.} other {{host} invites {guest} as one of the # people invited to his party.}}} other {{num_guests, plural, offset:1 =0 {{host} does not give a party.} =1 {{host} invites {guest} to their party.} =2 {{host} invites {guest} and one other person to their party.} other {{host} invites {guest} as one of the # people invited to their party.}}}} _MSG_; $args = array(array('gender_of_host' => 'female', 'num_guests' => 0, 'host' => 'Alice', 'guest' => 'Bob'), array('gender_of_host' => 'male', 'num_guests' => 1, 'host' => 'Alice', 'guest' => 'Bob'), array('gender_of_host' => 'none', 'num_guests' => 2, 'host' => 'Alice', 'guest' => 'Bob'), array('gender_of_host' => 'female', 'num_guests' => 27, 'host' => 'Alice', 'guest' => 'Bob')); $str_res = ''; $fmt = ut_msgfmt_create('en_US', $pattern); if (!$fmt) { $str_res .= dump(intl_get_error_message()) . "\n"; return $str_res; } foreach ($args as $arg) { $str_res .= dump(ut_msgfmt_format($fmt, $arg)) . "\n"; $str_res .= dump(ut_msgfmt_format_message('en_US', $pattern, $arg)) . "\n"; } return $str_res; }