Exemplo n.º 1
0
function draw_server($name, $stats, $dumb = false)
{
    $name = preprocess($name);
    $tag = "";
    $text = "";
    if ($stats === null) {
        if ($dumb) {
            $tag = "class=\"box borderedtinybox\"";
        } else {
            $tag = "class=\"box borderedbox\"";
        }
    } else {
        if (!$dumb) {
            $tag = "class=\"box smallbox\" ";
            $sent = intval($stats['tx']);
            $received = intval($stats['rx']);
            $loss = 100 - $received * 100.0 / $sent;
            $min = $stats['min'];
            $avg = $stats['avg'];
            $max = $stats['max'];
            $text = "<br />{$loss}%/{$min}/{$avg}/{$max}";
        } else {
            $tag = "class=\"box tinybox\" ";
        }
        $tag .= ' style="background-color: ' . gradient(intval($stats['loss'])) . '"';
    }
    echo "\t<div {$tag}>{$name}{$text}</div>\n";
}
function process($form_data)
{
    $a = session_id();
    include "connect.php";
    $conn = init($_SESSION["permission_type"]);
    include "Helper.php";
    //pretty_print_array($form_data);
    $processed_form_data = preprocess($form_data);
    $builder = new GetQueryBuilder();
    $coolresult = $builder->generateSQL($processed_form_data);
    $returnedData = "";
    //print_r($coolresult);
    $returnedData = $conn->query($coolresult["data"][0]);
    //echo ($coolresult["data"][0]);
    $coolresult["data"] = "";
    if ($conn->error) {
        if ($coolresult["error"] == "") {
            $coolresult["error"] = $conn->error;
        }
    } else {
        $coolresult["error"] = "";
        $coolresult["data"] = $returnedData->fetch_all(MYSQLI_ASSOC);
    }
    echo json_encode($coolresult);
}
Exemplo n.º 3
0
function render($tplName, $tplItem)
{
    global $smarty;
    global $smartyConf;
    CSmarty::clearError();
    // 这里,$data有三种数据格式,第一种是我定义的最原始的数据格式,第二种是有的同学在display里面进行了细分,加了extData,第三种是平台的数据格式
    // 所以,在这里先进行一次处理
    // $data = preprocess(CJSON::decode(file_get_contents($tplItem['data'])));
    $data = preprocess(json_decode(file_get_contents($tplItem['data']), TRUE));
    $result = $smarty->do_render($data, $tplName);
    // 有错误发生
    $errors = CSmarty::getError();
    if (count($errors) > 0) {
        return $errors[0];
    }
    return $result;
}
Exemplo n.º 4
0
<?php

/*
PHP Unit Tes framework

Author: Mathias Beke
Url: http://denbeke.be
Date: March 2014
*/
require_once dirname(__FILE__) . '/unit-test.php';
require_once dirname(__FILE__) . '/preprocess.php';
$t = new \UnitTest\UnitTest();
preprocess();
foreach (glob(dirname(__FILE__) . '/tests/preprocessed/*.php') as $file) {
    require_once $file;
}
$t->run();
include dirname(__FILE__) . '/theme/header.php';
$t->write();
include dirname(__FILE__) . '/theme/footer.php';
Exemplo n.º 5
0
<?php

// This code assumes $itemID is set to that of
// the item that was just rated.
// Get all of the user's rating pairs
ini_set("max_execution_time", 0);
$connection = mysql_connect($host = "localhost", $username = "******", $password = "");
mysql_select_db("glassesshop");
mysql_query("delete from dev");
$pair_result = mysql_query("select userID, itemID from rating");
$count = 1;
$count_sum = mysql_num_rows($pair_result);
while ($pair_row = mysql_fetch_array($pair_result)) {
    preprocess($pair_row["userID"], $pair_row["itemID"]);
    echo $count * 100 / $count_sum . "%<br />";
    $count++;
    ob_flush();
    flush();
}
function preprocess($userID, $itemID)
{
    $sql = "SELECT DISTINCT r.itemID, r2.ratingValue - r.ratingValue as rating_difference\r\n\t            FROM rating r, rating r2\r\n\t            WHERE r.userID='" . $userID . "' AND \r\n\t                    r2.itemID='" . $itemID . "' AND \r\n\t                    r2.userID='" . $userID . "'";
    $db_result = mysql_query($sql);
    $num_rows = mysql_num_rows($db_result);
    //For every one of the user's rating pairs,
    //update the dev table
    while ($row = mysql_fetch_assoc($db_result)) {
        $other_itemID = $row["itemID"];
        $rating_difference = $row["rating_difference"];
        //if the pair ($itemID, $other_itemID) is already in the dev table
        //then we want to update 2 rows.
Exemplo n.º 6
0
Arquivo: edit.php Projeto: kawf/kawf
    $preview = 1;
}
if ($_REQUEST['imgpreview']) {
    $imgpreview = 1;
}
if (!isset($_POST['message'])) {
    /* hit "edit" link, prefill postform (step 1) */
    $preview = 1;
    /* Synthesize state based on the state of the existing message. */
    $offtopic = $msg['state'] == 'OffTopic';
    $expose_email = !empty($msg['email']);
    $send_email = is_msg_etracked($msg);
    $track_thread = is_msg_tracked($msg);
} else {
    /* form submitted via edit (step 2) */
    preprocess($nmsg, $_POST);
    $offtopic = isset($_POST['OffTopic']);
    $expose_email = isset($_POST['ExposeEmail']);
    $send_email = isset($_POST['EmailFollowup']);
    /* automatically track thread if user requested email notification */
    $track_thread = isset($_POST['TrackThread']) || $send_email;
}
if (!isset($forum['option']['PostEdit'])) {
    $tpl->set_var(array("edit_locked" => "", "error" => "", "preview" => "", "form" => "", "accept" => ""));
    print generate_page('Edit Message Denied', $tpl->parse("CONTENT", "disabled"));
    exit;
}
$tpl->set_var("disabled", "");
$thread = get_thread($msg['tid']);
if (isset($thread['flag']['Locked']) && !$user->capable($forum['fid'], 'Lock')) {
    $tpl->set_var(array("error" => "", "preview" => "", "form" => "", "accept" => ""));
Exemplo n.º 7
0
 public function g($page = "all")
 {
     if (!file_exists(APPPATH . '/views/forms/form_' . $page . '.php')) {
         // Whoops, we don't have a page for that!
         show_404();
     }
     if (!session()) {
         redirect("index.php/users/login");
     }
     $data['title'] = "Form - " . $page;
     if ($_POST) {
         $data = preprocess($_POST);
         $check_result = check_forms($data);
         $data = escapedata($data);
         if ($check_result["passed"]) {
             $form_id = $this->form->createFormInfo();
             $eu_info = array('username' => '', 'title' => '', 'organization' => '', 'pawprint' => '', 'empiid' => '', 'address' => '', 'phone_num' => '', 'request_status' => '', 'student_worker' => '', 'if_cur_staff' => '', 'ref_name' => '', 'ref_pos' => '', 'ref_pawprint' => '', 'ref_empiid' => '', 'ferpa_score' => '', 'academic_career' => '', 'access_type' => '');
             foreach ($data as $key => $value) {
                 if (in_array($key, array_keys($eu_info))) {
                     $eu_info[$key] = $value;
                 }
             }
             $eu_info['form_id'] = $form_id;
             $this->form->insertPrepareForm($eu_info);
             //GET FORM_ID
             if (is_numeric($data['access_type2'])) {
                 // case '2':
                 $eu_info = array('basic_inquiry' => '', 'advanced_inquiry' => '', '3Cs' => '', 'advisor_update' => '', 'department_SOC_update' => '', 'service_indicators' => '', 'student_group_view' => '', 'view_study_list' => '', 'registrar_enrollment' => '', 'advisor_student_center' => '', 'class_permission' => '', 'class_permission_view' => '', 'class_roster' => '', 'block_enrollment' => '', 'report_manager' => '', 'self_service_advisor' => '', 'fiscal_officer' => '', 'academic_advising_profile' => '');
                 foreach ($eu_info as $key => $value) {
                     $eu_info[$key] = 0;
                 }
                 foreach ($data as $key => $value) {
                     if (in_array($key, array_keys($eu_info))) {
                         $eu_info[$key] = (int) $value;
                     }
                 }
                 $eu_info['form_id'] = $form_id;
                 $this->form->insertStudentRecordsAccess($eu_info);
             }
             if (is_numeric($data['access_type3'])) {
                 $eu_info = array('act' => '', 'lelts' => '', 'ged' => '', 'sat' => '', 'lsat' => '', 'millers' => '', 'gre' => '', 'mcat' => '', 'rpax' => '', 'gmat' => '', 'ap' => '', 'pla-mu' => '', 'tofel' => '', 'clep' => '', 'base' => '');
                 foreach ($eu_info as $key => $value) {
                     $eu_info[$key] = 0;
                 }
                 foreach ($data as $key => $value) {
                     if (in_array($key, array_keys($eu_info))) {
                         $eu_info[$key] = $value;
                     }
                 }
                 $eu_info['form_id'] = $form_id;
                 $this->form->insertAdmissionsAccess($eu_info);
             }
             if (is_numeric($data['access_type4'])) {
                 $eu_info = array('general_inquiry' => 0, 'cash_group_post' => 0);
                 foreach ($data as $key => $value) {
                     if (in_array($key, array_keys($eu_info))) {
                         $eu_info[$key] = $value;
                     }
                 }
                 $eu_info['form_id'] = $form_id;
                 $this->form->insertStudentFinancialsAccess($eu_info);
             }
             if (is_numeric($data['access_type5'])) {
                 $eu_info = array('fa_cash' => 0, 'fa_non_financial_aid_stuff' => 0);
                 foreach ($data as $key => $value) {
                     if (in_array($key, array_keys($eu_info))) {
                         $eu_info[$key] = $value;
                     }
                 }
                 $eu_info['form_id'] = $form_id;
                 $this->form->insertStudentFinancialAidAccess($eu_info);
             }
             if (is_numeric($data['access_type6'])) {
                 $eu_info = array('immunization_view' => '', 'transfer_credit_admission' => '', 'relationships' => '', 'student_groups' => '', 'accommodate' => '', 'support_staff' => '', 'advance_standing_report' => '');
                 foreach ($eu_info as $key => $value) {
                     $eu_info[$key] = 0;
                 }
                 foreach ($data as $key => $value) {
                     if (in_array($key, array_keys($eu_info))) {
                         $eu_info[$key] = $value;
                     }
                 }
                 $eu_info['form_id'] = $form_id;
                 $this->form->insertReservedAccess($eu_info);
             }
             redirect("index.php/users/home");
         } else {
             //      $test['data'] = $data;
             // $this->load->view("forms/test", $test);
             // return;
             $data = $_POST;
             $data['format_error'] = $check_result['error'];
             $this->load->view("templates/header", $data);
             $this->load->view("forms/form_" . $page, $data);
             $this->load->view("templates/footer", $data);
             return;
         }
     }
     $data = $this->form->getAutoFill($_SESSION['pawprint']);
     $pawprint = $_SESSION['pawprint'];
     $ids = $this->form->getIdByPawprint($pawprint);
     // print_r(var_dump($ids));
     //$ids = array(0~)
     $result = array();
     $i = 0;
     foreach ($ids as $value) {
         $result[$i] = $this->form->getFormById($value);
         $i++;
     }
     //$result[0]->array of five array
     $data["result"] = $result;
     $this->load->view("templates/header", $data);
     $this->load->view("forms/form_" . $page, $data);
     $this->load->view("templates/footer", $data);
 }