function replaceTex($pathOfTexFile, $studentId) { // mysql connection info $conHost = "127.0.0.1"; // connect ip $conUsername = "******"; $conPassword = "******"; $conDatabase = "formatPaper"; $conView = "VassignmentBook"; $conQuery = "SELECT * FROM {$conView} WHERE studentId = '{$studentId}';"; // connect mysql $con = mysql_connect($conHost, $conUsername, $conPassword); if (!$con) { die('Could not connect: ' . mysql_error()); } // echo $conQuery; // 检查查询语句 // query database mysql_select_db($conDatabase, $con); $result = mysql_query("SET NAMES 'UTF8'"); $result = mysql_query($conQuery, $con); $infoarr = mysql_fetch_array($result); mysql_close($con); $fstr = file_get_contents($pathOfTexFile); foreach ($infoarr as $key => $value) { if ($value) { $value = str_replace(" ", " ", $value); $value = analysis(html_entity_decode($value)); } $fstr = str_replace("!{$key}-!", html_entity_decode($value), $fstr); } if ($infoarr['subjectName']) { $cuttitle = cut($infoarr['subjectName']); $fstr = str_replace($infoarr['subjectName'], $cuttitle, $fstr); } $fstr = str_replace("\\block{" . $infoarr['topicType'] . "}", "\\blockC{" . $infoarr['topicType'] . "}", $fstr); $fstr = preg_replace("/\\!(\\w+)\\-!/", "", $fstr); //$newadd = str_replace("template", $studentId, $pathOfTexFile); $newadd = str_replace("template", getStuId($studentId), $pathOfTexFile); //echo $newadd ."<br/>\n"; // 这里的路径为执行该函数的 php 所在路径决定 $fstr = str_replace("\r\n", "\n", $fstr); file_put_contents($newadd, $fstr); }
$nQsid = $_POST["qsid"]; $g_nqsid = $nQsid; $g_arrData = array(); foreach ($master as $ip => $jf) { if (!array_key_exists($jf, $g_arrData)) { $g_arrData[$jf] = array(); } if ($nTime == 0) { $key = $ip; } else { $key = $ip . "_" . $nTime; } $msg = $redis->get($key); if ($msg != NULL) { $xmlMsg = simplexml_load_string($msg); $ip_arr = analysis($xmlMsg); if (sizeof($ip_arr) > 0) { $g_arrData[$jf][$ip] = $ip_arr; } } } //print_r($g_arrData); print_r('(' . json_encode($g_arrData) . ')'); function analysis($xmlMsg) { global $g_nqsid; $arr = array(); $delayMessage = $xmlMsg->delayMessage; foreach ($delayMessage->children() as $isp => $SummaryMsg) { $nIndex = 0; foreach ($SummaryMsg->children() as $item => $value) {
} else { // POST フォームからPOSTによって要求された場合 $word = $_POST['word']; } //セッションスタート session_start(); //認証OKなら if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) { header('Location: ./clearsessions.php'); } else { TOATool::create_oauth($_SESSION['access_token']['oauth_token'], $_SESSION['access_token']['oauth_token_secret']); } //処理開始時間を保持 $start_time = time(); //分析処理 $res = analysis($word); //処理終了時間を保持 $complete_time = time(); //経過時間を表示 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> \r\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>いるかの一般意志予報 | 一般意志2.0 実現システム α版</title> "; ?> <link rel="stylesheet" type="text/css" href="./js/jquery.jqplot.min.css" /> <!--[if IE]><script language="javascript" type="text/javascript" src="./js/excanvas.min.js"></script><![endif]--> <script language="javascript" type="text/javascript" src="./js/jquery.min.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.jqplot.min.js"></script> <script language="javascript" type="text/javascript" src="./js/plugins/jqplot.dateAxisRenderer.min.js"></script> <style type="text/css"> img {border-width: 0}
function transPreToCNF($prerequisites) { $stack = analysis($prerequisites); return $stack[0]; }
} } switch ($mood_type) { case 1: $amazing++; break; case 2: $very_good++; break; case 3: $good++; break; case 4: $usual++; break; case 5: $bad++; break; case 6: $very_bad++; break; case 7: $fuck_dog++; break; } } } echo "\n <div class='col-md-12'>\n <div id='analysis-moves'>\n <div style='margin-left: 10%'>\n <h3>你总共走了 <strong style='color: white'>{$total_steps}</strong> 步,平均每天走了 <strong style='color: white'>{$avg_steps}</strong> 步</h3>\n </div>\n </div>\n <div id='analysis-sleeps'>\n <div style='margin-left: 10%'>\n <h3>你总共睡了 <strong style='color: white'>{$total_sleeps}</strong> 小时,平均每天睡了 <strong style='color: white'>{$avg_sleep}</strong> 小时</h3>\n </div>\n </div>\n <div id='analysis-workouts'>\n <div style='margin-left: 10%'>\n <h3>你总共跑了 <strong style='color: white'>{$total_run}</strong> 公里,平均每天跑了 <strong style='color: white'>{$avg_run} </strong> 公里</h3>\n </div>\n </div>\n <div id='analysis-meals'>\n <div style='margin-left: 10%'>\n <h4>共摄入 <strong style='color: white'>{$total_fat}</strong> 克脂肪</h4>\n <h4>共摄入 <strong style='color: white'>{$total_protein}</strong> 毫克蛋白质</h4>\n <h4>共摄入 <strong style='color: white'>{$total_calcium}</strong> 毫克钙</h4>\n <h4>共摄入 <strong style='color: white'>{$total_carbohydrate}</strong> 毫克碳水化合物</h4>\n <h4>共摄入 <strong style='color: white'>{$total_sugar}</strong> 毫克糖</h4>\n <h4>共摄入 <strong style='color: white'>{$total_cholesterol}</strong> 毫克胆固醇</h4>\n <h4>共摄入 <strong style='color: white'>{$total_vitamin_c}</strong> 毫克维他命C</h4>\n <h4>共摄入 <strong style='color: white'>{$total_vitamin_a}</strong> 毫克维他命A</h4>\n\n </div>\n </div>\n <div id='analysis-mood'>\n <div style='margin-left: 10%'>\n <h3>心情状况为</h3>\n <h4>“Amazing好” <strong style='color: white'>{$amazing}</strong> 次</h4>\n <h4>“非常好” <strong style='color: white'>{$very_good}</strong> 次</h4>\n <h4>“好” <strong style='color: white'>{$good}</strong> 次</h4>\n <h4>“一般” <strong style='color: white'>{$usual}</strong> 次</h4>\n <h4>“坏” <strong style='color: white'>{$bad}</strong> 次</h4>\n <h4>“非常坏” <strong style='color: white'>{$very_bad}</strong> 次</h4>\n <h4>“槽糕透了” <strong style='color: white'>{$fuck_dog}</strong> 次</h4>\n </div>\n </div>\n </div>\n "; } analysis();
$any[$key]['time'] = array($time); } else { $any[$key]['amount']++; $any[$key]['time'][] = $time; } break; } } } $handle = fopen("dootapc.access.2015052611.log", "r"); if (!$handle) { echo "fopen error\n"; exit; } while (($buffer = fgets($handle)) !== FALSE) { analysis($buffer); } fclose($handle); $result = array(); foreach ($any as $name => $info) { $totalTime = 0; $totalAmount = $info['amount']; echo "name:" . $name . " total_amount:" . $totalAmount; $levelOne = $levelTwo = $levelThree = $levelFour = array('amount' => 0, 'total_time' => 0); foreach ($info['time'] as $time) { $totalTime += $time; $level = 0; if ($time > 0 && $time <= 0.1) { $levelOne['amount']++; $levelOne['total_time'] += $time; } elseif ($time > 0.1 && $time <= 0.5) {
<?php //$con=mysql_connect("localhost:3306","root","5656123ljx"); //if(!$con){ // die('Could not connect: ' . mysql_error()); //} //mysql_select_db("capstone",$con); //$sql="select prerequisites from Course WHERE cid='"."CHM325L"."'"; // //$result=mysql_query($sql); //$row=mysql_fetch_array($result); //$prerequisites=$row[0]; $prerequisites = $_POST["prerequisites"]; //echo $prerequisites; if ($prerequisites != null) { echo printStack(analysis($prerequisites)); } function analysis($prerequisites) { $array = explode(" ", $prerequisites); //print_r($array); $stack = array(); $i = 0; do { if ($array[$i] == "(") { array_push($stack, "("); } else { if ($array[$i] == "∧" || $array[$i] == "∨") { array_push($stack, $array[$i]); } else { if ($array[$i] == ")") {