function test_auto_marking_sc($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale'], '/new-question/errors');
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die($msg->_('invalid-format'), 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data) || !isset($input_data['question']) || !isset($input_data['source-code']) || !is_string($input_data['source-code'])) {
            Util::output_errors_and_die($msg->_('invalid-format'), 400);
        }
        $extra = !empty($input_data['extra']) ? $input_data['extra'] : [];
        $qd = $input_data['question'];
        set_empty_if_undefined($qd['type']);
        if ($qd['type'] != 'source-code') {
            Util::output_errors_and_die('', 400);
        }
        $q = new QuestionSC($qd, Question::FROM_USER, $extra);
        $q->mark_automatically(array('source-code' => $input_data['source-code']), $log, $result);
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result);
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
function test_auto_marking($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale'], '/new-question/errors');
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die($msg->_('invalid-format'), 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data) || !isset($input_data['question']) || !isset($input_data['studentAnswer'])) {
            Util::output_errors_and_die($msg->_('invalid-format'), 400);
        }
        $extra = !empty($input_data['extra']) ? $input_data['extra'] : [];
        $qd = $input_data['question'];
        set_empty_if_undefined($qd['type']);
        if (!Validator::validate_question_type($qd['type'])) {
            Util::output_errors_and_die($msg->_('invalid-type'), 400);
        }
        switch ($qd['type']) {
            case 'short-answer':
                $q = new QuestionSA($qd, Question::FROM_USER, $extra);
                break;
            case 'essay':
                $q = new QuestionES($qd, Question::FROM_USER, $extra);
                break;
            case 'multiple-choice':
                $q = new QuestionMC($qd, Question::FROM_USER, $extra);
                break;
            case 'matching':
                $q = new QuestionMA($qd, Question::FROM_USER, $extra);
                break;
            case 'fitb-type':
                $q = new QuestionFT($qd, Question::FROM_USER, $extra);
                break;
            case 'fitb-select':
                $q = new QuestionFS($qd, Question::FROM_USER, $extra);
                break;
            case 'source-code':
                $q = new QuestionSC($qd, Question::FROM_USER, $extra);
                break;
        }
        http_response_code(200);
        header('Content-Type: application/json');
        $mark = $q->mark_automatically($input_data['studentAnswer'], $log);
        foreach ($log as $i => $line) {
            $log[$i] = $msg->_('/auto-marking/' . $line[0], $line[1]);
        }
        $log = implode('<br/>', $log);
        echo my_json_encode(array('log' => $log, 'mark' => $mark));
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
Пример #3
0
function create_session($request)
{
    $raw_input = $request->getBody();
    $content_type = explode(';', $request->type)[0];
    switch ($content_type) {
        case 'application/json':
            $input_data = json_decode($raw_input, true);
            break;
        case 'application/x-www-form-urlencoded':
            $input_data = array();
            parse_str($raw_input, $input_data);
            break;
        default:
            Util::output_errors_and_die('', 415);
    }
    if ($input_data === null) {
        Util::output_errors_and_die('', 400);
    }
    set_empty_if_undefined($input_data['username_or_email']);
    set_empty_if_undefined($input_data['password']);
    $msg = new Messages($GLOBALS['locale'], '/signin');
    try {
        $model = new Model();
        $user_data = $model->is_valid_user($input_data['username_or_email'], $input_data['password']);
        if (!$user_data) {
            Util::output_errors_and_die($msg->_('invalid-username-pw'), 403);
        }
        switch ($user_data['status']) {
            case 'pending-activation':
                Util::output_errors_and_die($msg->_('pending-activation'), 403);
                break;
            case 'pending-approval':
                Util::output_errors_and_die($msg->_('pending-approval'), 403);
                break;
            case 'banned':
                Util::output_errors_and_die($msg->_('banned'), 403);
                break;
            case 'active':
                $token = generate_token($user_data);
                $now = new DateTime('now');
                $expires_at = clone $now;
                $expires_at->add(new DateInterval('P7D'));
                $model->insert_auth_token($user_data['user_id'], $token, $now, $expires_at);
                http_response_code(201);
                $output = array('token' => $token, 'expires_at' => $expires_at->format('Y-m-d H:i:s'));
                setcookie('authToken', $token, $expires_at->getTimestamp(), '/', '', $secure = true, $httponly = true);
                header('Content-Type: application/json');
                echo my_json_encode($output);
                die;
                break;
        }
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
 public function to_sql()
 {
     $qd = parent::to_sql();
     $qd['answers'] = my_json_encode(array_map(function ($a) {
         return $a['text'];
     }, $this->answers));
     $qd['hex_ids'] = implode(',', array_keys($this->answers_by_hex_id));
     return $qd;
 }
 public function __construct($message = null, $code = 0)
 {
     if ($message) {
         $msg = new Messages($GLOBALS['locale']);
         $err = array('DATABASE-ERROR' => $msg->_('/showmsg/database-error'));
         // discard original message
         $message = my_json_encode($err);
     }
     parent::__construct($message, $code);
 }
Пример #6
0
function test_question($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale'], '/new-question/errors');
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die($msg->_('invalid-format'), 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data)) {
            Util::output_errors_and_die($msg->_('invalid-format'), 400);
        }
        set_empty_if_undefined($input_data['type']);
        if (!Validator::validate_question_type($input_data['type'])) {
            Util::output_errors_and_die($msg->_('invalid-type'), 400);
        }
        switch ($input_data['type']) {
            case 'short-answer':
                $q = new QuestionSA($input_data, Question::FROM_USER);
                break;
            case 'essay':
                $q = new QuestionES($input_data, Question::FROM_USER);
                break;
            case 'multiple-choice':
                $q = new QuestionMC($input_data, Question::FROM_USER);
                break;
            case 'matching':
                $q = new QuestionMA($input_data, Question::FROM_USER);
                break;
            case 'fitb-type':
                $q = new QuestionFT($input_data, Question::FROM_USER);
                break;
            case 'fitb-select':
                $q = new QuestionFS($input_data, Question::FROM_USER);
                break;
            case 'source-code':
                $q = new QuestionSC($input_data, Question::FROM_USER);
                break;
        }
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($q->to_auto_marking_test(true, true));
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
Пример #7
0
function my_json_encode(array $data)
{
    $s = array();
    foreach ($data as $k => $v) {
        if (is_array($v)) {
            $v = my_json_encode($v);
            $s[] = "\"{$k}\":{$v}";
        } else {
            $v = addslashes(str_replace(array("\n", "\r"), '', $v));
            $s[] = "\"{$k}\": \"{$v}\"";
        }
    }
    return '{' . implode(', ', $s) . '}';
}
Пример #8
0
 function getFilesArray($value)
 {
     $filesArray = my_json_decode($value);
     if (!is_array($filesArray) || count($filesArray) == 0) {
         if ($value == "") {
             $filesArray = array();
         } else {
             $uploadedFile = $this->upload_handler->get_file_object($value);
             if (is_null($uploadedFile)) {
                 $filesArray = array();
             } else {
                 $filesArray = array(my_json_decode(my_json_encode($uploadedFile)));
             }
         }
     }
     return $filesArray;
 }
function get_programming_languages($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $result = $model->get_programming_languages();
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result);
        die;
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
 public function createMenuAction()
 {
     //获取access_token
     $appid = C("APPID");
     $appsecret = C("APPSECRET");
     $wechatInterface = new wechatInterfaceapiLogic();
     $access_token = $wechatInterface->getAccessToken($appid, $appsecret);
     //将数组重排成树
     $MenuL = new CustomMenuLogic();
     $lists = $MenuL->getLists();
     $tree = list_to_tree($lists, 'id', 'pid', 'sub_button');
     $menus = array();
     $wechatMenu = new wechatMenuapiLogic();
     $wechatMenu->setAccessToken($access_token);
     $wechatMenu->deleteMenu();
     //将树转换成json格式的树
     $array = $wechatMenu->createJson($tree);
     //将数组转化成符合要求的json数据
     $json = my_json_encode('text', $array);
     $wechatMenu->createMenus($json);
 }
 public static function test($file_name, $extension, $source_code, $compiler_flags, $check_command, $compile_command, $run_command, $arguments, $stdin)
 {
     $file_name_with_ext = $file_name . '.' . $extension;
     if ($compile_command) {
         $flags_string = '';
         foreach ($compiler_flags as $f) {
             $flags_string .= ' ' . escapeshellarg($f);
         }
         if ($flags_string) {
             $index = mb_strpos($compile_command, ' ');
             if ($index !== false) {
                 $compile_command = substr_replace($compile_command, $flags_string, $index, 0);
             } else {
                 $compile_command .= ' ' . $flags_string;
             }
         }
     }
     $spr = new StudentProgramRunner($file_name_with_ext, $source_code, $check_command, $compile_command, $run_command);
     $stop = false;
     if ($check_command) {
         $r = $spr->check();
         $result['check'] = $r;
         if ($r === null || $r['return_value']) {
             $stop = true;
         }
     }
     if ($compile_command and !$stop) {
         $r = $spr->compile();
         $result['compile'] = $r;
         if ($r === null || $r['return_value']) {
             $stop = true;
         }
     }
     if ($run_command and !$stop) {
         $r = $spr->run($arguments, $stdin);
         $result['run'] = $r;
     }
     $spr = null;
     echo my_json_encode($result);
 }
Пример #12
0
function get_user($request, $username)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $request->query['fields'] = implode(',', ['username', 'email', 'gender', 'full_name', 'birth_date', 'created_at', 'last_logged_in_at', 'status', 'role']);
        $request->query['username'] = $username;
        $result = $model->get_users($request->query);
        if ($result['n_items'] == 0) {
            http_response_code(404);
            die;
        }
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result['items'][0]);
        die;
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
Пример #13
0
 public function delete()
 {
     $fileName = postvalue("fileName");
     $success = false;
     if (isset($_SESSION["mupload_" . $this->formStamp][$fileName])) {
         if (!$_SESSION["mupload_" . $this->formStamp][$fileName]["fromDB"]) {
             $sessionFile = $_SESSION["mupload_" . $this->formStamp][$fileName]["file"];
             $file_path = $sessionFile["name"];
             if (is_file($file_path)) {
                 $success = unlink($file_path);
             }
             if ($success && $sessionFile["thumbnail"] != "") {
                 $file = $sessionFile["thumbnail"];
                 if (is_file($file)) {
                     unlink($file);
                 }
             }
             unset($_SESSION["mupload_" . $this->formStamp][$fileName]);
         } else {
             $_SESSION["mupload_" . $this->formStamp][$fileName]["deleted"] = true;
             $success = true;
         }
     }
     header('Content-type: application/json');
     echo my_json_encode($success);
 }
Пример #14
0
 /**
  * @param String fieldValue
  * @return String
  */
 function getFieldValueCopy($fieldValue)
 {
     $this->initUploadHandler();
     $uploadFolder = $this->pageObject->pSetEdit->getUploadFolder($this->field);
     $absoluteUploadDirPath = $this->pageObject->pSetEdit->getFinalUploadFolder($this->field);
     $filesData = my_json_decode($fieldValue);
     if (!is_array($filesData) || count($filesData) == 0) {
         return $fieldValue;
     }
     foreach ($filesData as $idx => $fileData) {
         $info = $this->upload_handler->pathinfo_local($fileData["usrName"]);
         $newFieldName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $info['filename'], $info['extension']);
         runner_copy_file(getabspath($fileData["name"]), $absoluteUploadDirPath . $newFieldName);
         $filesData[$idx]["name"] = $uploadFolder . $newFieldName;
         if ($this->pageObject->pSetEdit->getCreateThumbnail($this->field)) {
             $thumbnailPrefix = $this->pageObject->pSetEdit->getStrThumbnail($this->field);
             $newThumbName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $thumbnailPrefix . $info['filename'], $info['extension']);
             runner_copy_file(getabspath($fileData["thumbnail"]), $absoluteUploadDirPath . $newThumbName);
             $filesData[$idx]["thumbnail"] = $uploadFolder . $newThumbName;
         }
     }
     return my_json_encode($filesData);
 }
Пример #15
0
 public function to_sql()
 {
     $qd = parent::to_sql();
     $qd['answers'] = my_json_encode($this->raw_answer);
     return $qd;
 }
    if ($i == 1) {
        $options["masterKeysReq"] = array();
    }
    $options["masterKeysReq"][$i] = $_REQUEST["masterkey" . $i];
    $i++;
}
//	Create $pageObject
$pageObject = ListPage::createListPage($strTableName, $options);
// Read Search parameters from the request
if (postvalue("saveSearch") && postvalue("searchName") && !is_null($pageObject->searchLogger)) {
    $searchName = postvalue("searchName");
    $searchParams = $pageObject->getSearchParamsForSaving();
    $pageObject->searchLogger->saveSearch($searchName, $searchParams);
    $pageObject->searchClauseObj->savedSearchIsRun = true;
    $_SESSION[$pageObject->sessionPrefix . '_advsearch'] = serialize($pageObject->searchClauseObj);
    echo my_json_encode($searchParams);
    exit;
}
// Delete the saved search
if (postvalue("deleteSearch") && postvalue("searchName") && !is_null($pageObject->searchLogger)) {
    $searchName = postvalue("searchName");
    $pageObject->searchLogger->deleteSearch($searchName);
    exit;
}
$gQuery->ReplaceFieldsWithDummies($pageObject->getNotListBlobFieldsIndices());
if ($mode != LIST_DETAILS) {
}
unset($_SESSION["message_add"]);
unset($_SESSION["message_edit"]);
// prepare code for build page
$pageObject->prepareForBuildPage();
Пример #17
0
             $value = db_stripslashesbinary($data[$field]);
         }
     } else {
         $cipherer = new RunnerCipherer($strTableName, $pSet);
         $row = $cipherer->DecryptFetchedArray($rs);
         if (!is_null($row)) {
             $filesArray = my_json_decode($row[$field]);
             if (!is_array($filesArray) || count($filesArray) == 0) {
                 if ($row[$field] == "") {
                     $filesArray = array();
                 } else {
                     $uploadedFile = $upload_handler->get_file_object($row[$field]);
                     if (is_null($uploadedFile)) {
                         $filesArray = array();
                     } else {
                         $filesArray = array(my_json_decode(my_json_encode($uploadedFile)));
                     }
                 }
             }
             foreach ($filesArray as $uploadedFile) {
                 if ($uploadedFile["usrName"] == $fileName) {
                     $sessionFile = $uploadedFile;
                     break;
                 }
             }
         }
     }
 }
 $iconShowed = false;
 if ($isDBFile) {
     $ftype = "";
Пример #18
0
    $pageObject->body['end'] .= "window.settings = " . my_json_encode($pageObject->jsSettings) . ";";
    $pageObject->body['end'] .= '</script>';
    $pageObject->body['end'] .= "<script language=\"JavaScript\" src=\"include/runnerJS/RunnerAll.js\"></script>\r\n";
    $pageObject->body["end"] .= "<script>" . $pageObject->PrepareJs() . "</script>";
    $xt->assignbyref("body", $pageObject->body);
    $xt->display($templatefile);
    exit;
} else {
    if ($mode == SEARCH_LOAD_CONTROL) {
        $searchControlBuilder = new PanelSearchControl($searchControllerId, $strTableName, $pageObject->searchClauseObj, $pageObject);
        $ctrlField = postvalue('ctrlField');
        $ctrlBlockArr = $searchControlBuilder->buildSearchCtrlBlockArr($id, $ctrlField, 0, '', false, true, '', '');
        // build array for encode
        $resArr = array();
        $resArr['control1'] = trim($xt->call_func($ctrlBlockArr['searchcontrol']));
        $resArr['control2'] = trim($xt->call_func($ctrlBlockArr['searchcontrol1']));
        $resArr['comboHtml'] = trim($ctrlBlockArr['searchtype']);
        $resArr['delButt'] = trim($ctrlBlockArr['delCtrlButt']);
        $resArr['delButtId'] = trim($searchControlBuilder->getDelButtonId($ctrlField, $id));
        $resArr['divInd'] = trim($id);
        $resArr['fLabel'] = GetFieldLabel(GoodFieldName($strTableName), GoodFieldName($ctrlField));
        $resArr['ctrlMap'] = $pageObject->controlsMap['controls'];
        if (postvalue('isNeedSettings') == 'true') {
            $pageObject->fillSettings();
            $resArr['settings'] = $pageObject->jsSettings;
        }
        // return JSON
        echo my_json_encode($resArr);
        exit;
    }
}
Пример #19
0
function SecurityRedirect($inlineedit)
{
    if ($inlineedit == EDIT_INLINE) {
        echo my_json_encode(array("success" => false, "message" => "The record is not editable"));
        return;
    }
    $_SESSION["MyURL"] = $_SERVER["SCRIPT_NAME"] . "?" . $_SERVER["QUERY_STRING"];
    header("Location: menu.php?message=expired");
}
Пример #20
0
function my_json_encode_unescaped_unicode($value)
{
    array_walk_recursive($value, 'json_mb_encode_numericentity');
    return runner_decode_numeric_entity(my_json_encode($value), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
}
Пример #21
0
 function create_topic($topic)
 {
     if (!Validator::validate_topic($topic)) {
         $error = $this->msg->_('/new-topic/error', array(1, 127));
         throw new Exception(my_json_encode(array('name' => $error)));
     }
     $sql = 'INSERT IGNORE INTO
           `topic`(name)
         VALUES (?);';
     $s = $this->conn->prepare($sql);
     if (!$s) {
         throw new DatabaseException($this->conn->errorInfo()[2]);
     }
     if (!$s->execute(array($topic))) {
         throw new DatabaseException($s->errorInfo()[2]);
     }
     if (!$s->rowCount()) {
         $error = $this->msg->_('/new-topic/existing', [$topic]);
         throw new ConflictException(my_json_encode(array('name' => $error)));
     }
     return $this->conn->lastInsertId();
 }
Пример #22
0
function send2weibo_via_apikey($s_email, $s_pwd, $tweet, $apikey)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://api.t.sina.com.cn/statuses/update.json");
    curl_setopt($ch, CURLOPT_USERPWD, "{$s_email}:{$s_pwd}");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "source=" . $apikey . "&status=" . urlencode($tweet));
    $rs = json_decode(curl_exec($ch), true);
    if (!empty($rs['error'])) {
        $rs['email'] = $s_email;
        //$rs['pwd'] = $s_pwd;
        $rs['tweet'] = $tweet;
        $rs['apikey'] = $apikey;
        log_data('[ERROR] 使用 API 同步新浪微博失败:' . str_replace('\\/', '/', my_json_encode($rs)));
        return false;
    }
    curl_close($ch);
    return true;
}
Пример #23
0
 public function action_send()
 {
     //Inserir tarefas no TimeSheet com data do horário comercial vigente (hoje se 5h-23h, ontem se 0h-5h)?
     $this->session = Session::instance();
     $task = new Model_Task();
     $task->batch_all($this->session->get('tsuser'));
     $this->request->headers['Content-Type'] = 'application/json';
     $this->request->response = my_json_encode(array('success' => 1, 'msg' => 'TimeSheet salvo com sucesso!'));
 }
Пример #24
0
 /**
  * Get an 'actions' block for a particular 'point'
  * @param Array data
  */
 function getActions($data)
 {
     if (!count($this->detailTablesData)) {
         return '';
     }
     global $strTableName, $useFlashChartLibrary;
     $delimiter = $useFlashChartLibrary ? '\\n' : '';
     if ($this->dashChart) {
         $masterKeysArr = array();
         foreach ($this->detailTablesData as $detailId => $detail) {
             foreach ($detail['masterKeys'] as $idx => $mk) {
                 $masterKeysArr[$detail['dDataSourceTable']] = array('masterkey' . ($idx + 1) => $data[$mk]);
             }
         }
         if (!$this->dashChartFirstPointSelected) {
             $this->dashChartFirstPointSelected = true;
             $this->detailMasterKeys = my_json_encode($masterKeysArr);
         }
         return '<actions>' . $delimiter . '<action type="call" function="Runner.updateDetailsForDashboardChart">' . $delimiter . '<arg>' . my_json_encode($masterKeysArr) . '</arg>' . $delimiter . '<arg>' . $this->pageId . '</arg>' . $delimiter . '</action>' . $delimiter . '</actions>' . $delimiter;
     } else {
         // The one detail table is allowed for a chart page only
         $detailTableData = $this->detailTablesData[0];
         $masterquery = "mastertable=" . rawurlencode($strTableName);
         foreach ($detailTableData['masterKeys'] as $idx => $mk) {
             $masterquery .= "&masterkey" . ($idx + 1) . "=" . rawurlencode($data[$mk]);
         }
         $url = runner_htmlspecialchars(GetTableLink($detailTableData['dShortTable'], $detailTableData['dType'], $masterquery));
         return '<actions>' . $delimiter . '<action type="navigateToURL" url="' . $url . '" target="_self"/>' . $delimiter . '</actions>' . $delimiter;
     }
 }
        $viewContainer->recId = $recordsCounter;
        $value = $viewContainer->showDBValue("update_uid", $data, $keylink);
        $row["update_uid_value"] = $value;
        //	npwpd_old -
        $viewContainer->recId = $recordsCounter;
        $value = $viewContainer->showDBValue("npwpd_old", $data, $keylink);
        $row["npwpd_old_value"] = $value;
        //	id_old -
        $viewContainer->recId = $recordsCounter;
        $value = $viewContainer->showDBValue("id_old", $data, $keylink);
        $row["id_old_value"] = $value;
        $rowinfo[] = $row;
        $data = $cipherer->DecryptFetchedArray($rs);
    }
    $xt->assign_loopsection("details_row", $rowinfo);
}
$returnJSON = array("success" => true);
$xt->load_template("pad_pad_customer_detailspreview.htm");
$returnJSON["body"] = $xt->fetch_loaded();
if ($mode != "inline") {
    $returnJSON["counter"] = postvalue("counter");
    $layout = GetPageLayout(GoodFieldName($strTableName), 'detailspreview');
    if ($layout) {
        $rtl = $xt->getReadingOrder() == 'RTL' ? 'RTL' : '';
        $returnJSON["style"] = "styles/" . $layout->style . "/style" . $rtl . ".css";
        $returnJSON["pageStyle"] = "pagestyles/" . $layout->name . $rtl . ".css";
        $returnJSON["layout"] = $layout->style . " page-" . $layout->name . ".css";
    }
}
echo "<textarea>" . htmlspecialchars(my_json_encode($returnJSON)) . "</textarea>";
Пример #26
0
 public function to_sql()
 {
     $qd = parent::to_sql();
     $get_text = function ($a) {
         return $a['text'];
     };
     $left = array_map($get_text, $this->left_column);
     $right = array_map($get_text, $this->right_column);
     $qd['answers'] = my_json_encode([$left, $right]);
     $qd['hex_ids'] = my_json_encode([array_keys($this->left_column_by_hex_id), array_keys($this->right_column_by_hex_id)]);
     return $qd;
 }
// add button events if exist
$pageObject->addButtonHandlers();
$pageObject->body["begin"] .= "<script type=\"text/javascript\" src=\"include/loadfirst.js\"></script>\r\n";
$pageObject->body["begin"] .= "<script>\r\n";
$pageObject->body["begin"] .= "function importMore(id)\r\n";
$pageObject->body["begin"] .= "{\r\n";
$pageObject->body["begin"] .= "\tif(\$('#importDebugInfoTable'+id).css('display')=='none')\r\n";
$pageObject->body["begin"] .= "\t\t\$('#importDebugInfoTable'+id).show();\r\n";
$pageObject->body["begin"] .= "\telse\r\n";
$pageObject->body["begin"] .= "\t\t\$('#importDebugInfoTable'+id).hide();\r\n";
$pageObject->body["begin"] .= "}\r\n";
$pageObject->body["begin"] .= "</script>\r\n";
$pageObject->body["begin"] .= "<script type=\"text/javascript\" src=\"include/lang/" . getLangFileName(mlang_getcurrentlang()) . ".js\"></script>";
$pageObject->fillSetCntrlMaps();
$pageObject->body['end'] .= '<script>';
$pageObject->body['end'] .= "window.controlsMap = " . my_json_encode($pageObject->controlsHTMLMap) . ";";
$pageObject->body['end'] .= "window.settings = " . my_json_encode($pageObject->jsSettings) . ";";
$pageObject->body['end'] .= '</script>';
$pageObject->body["end"] .= "<script language=\"JavaScript\" src=\"include/runnerJS/RunnerAll.js\"></script>\r\n";
$pageObject->addCommonJs();
$pageObject->body["end"] .= "<script>" . $pageObject->PrepareJS() . "</script>";
$xt->assignbyref("body", $pageObject->body);
$xt->assign("importfile_attrs", "id=\"file_ImportFileName" . $pageObject->id . "\" name=\"file_ImportFileName" . $pageObject->id . "\"");
$xt->assign("backtolist_attrs", "id=\"backButton" . $pageObject->id . "\"");
$xt->assign("importlink_attrs", "id=\"saveButton" . $pageObject->id . "\"");
$xt->assign("error_message", $error_message);
$xt->display("Readings_import.htm");
?>


    /**
     * Show page method
     *
     */
    function showPage($returnJson = true)
    {
        global $page_layouts;
        $layout =& $page_layouts[$this->shortTableName . '_' . $this->pageType];
        $pageSkinStyle = $layout->style . " page-" . $layout->name;
        $this->BeforeShowList();
        $this->xt->set_template($this->templatefile);
        //set bricks, which	must be shown on details preview page
        $bricksExcept = array("grid", "pagination");
        if ($this->masterPageType != PAGE_EDIT && $this->masterPageType != PAGE_ADD && $this->masterPageType != PAGE_VIEW) {
            $bricksExcept[] = "details_found";
            $bricksExcept[] = "page_of";
            $bricksExcept[] = "recordcontrols_new";
            $bricksExcept[] = "recordcontrol";
            if ($this->deleteMessage != '') {
                $bricksExcept[] = "message";
            }
        }
        if ($this->masterPageType == PAGE_EDIT || $this->masterPageType == PAGE_ADD) {
            $bricksExcept[] = "recordcontrols_new";
            $bricksExcept[] = "recordcontrol";
        }
        // if we use details inline. We don't need show the header/footer.
        $this->xt->unassign('header');
        $this->xt->unassign('footer');
        $this->xt->hideAllBricksExcept($bricksExcept);
        $this->xt->prepare_template($this->templatefile);
        $contents = $this->displayAfterLoadTempl();
        if (!$returnJson) {
            echo '<br>
				<div id="dpShowHide' . $this->id . '" class="dpDiv">
					<img id="dpMinus' . $this->id . '" class="dpImg" border="0" src="images/minus.gif" valign="middle" alt="*" />
					<a name="dt' . $this->id . '" class="dt">' . $this->strCaption . '</a>
				</div>
				<div id="detailPreview' . $this->id . '" class="' . $pageSkinStyle . ' runner-pagewrapper dpStyle">' . $contents . '</div>';
            return;
        }
        //add for details preview page skin and style
        $respArr = array();
        // add cMap, sett
        $this->fillSetCntrlMaps();
        $respArr['controlsMap'] = $this->controlsHTMLMap;
        $respArr['settings'] = $this->jsSettings;
        $respArr['html'] = $contents;
        $respArr['success'] = true;
        $respArr['id'] = $this->id;
        $respArr['idStartFrom'] = $this->flyId;
        $respArr['delRecs'] = $this->recordsDeleted;
        if ($this->deleteMessage != '') {
            $respArr['delMess'] = true;
        }
        echo my_json_encode($respArr);
    }
Пример #29
0
    }
    if (count($pageObject->includes_cssIE)) {
        $returnJSON['CSSFilesIE'] = array_unique($pageObject->includes_cssIE);
    }
    $returnJSON["additionalJS"] = $pageObject->grabAllJsFiles();
    $returnJSON['idStartFrom'] = $id + 1;
    echo my_json_encode($returnJSON);
} elseif ($inlineadd == ADD_INLINE) {
    $xt->load_template($templatefile);
    $returnJSON["html"] = array();
    foreach ($addFields as $fName) {
        $returnJSON["html"][$fName] = $xt->fetchVar(GoodFieldName($fName) . "_editcontrol");
    }
    $returnJSON["additionalJS"] = $pageObject->grabAllJsFiles();
    $returnJSON["additionalCSS"] = $pageObject->grabAllCSSFiles();
    echo my_json_encode($returnJSON);
} else {
    $xt->display($templatefile);
}
function GetAddedDataLookupQuery($pageObject, $keys, $forLookup)
{
    global $conn, $strTableName, $strOriginalTableName;
    $LookupSQL = "";
    $linkfield = "";
    $dispfield = "";
    $noBlobReplace = false;
    $lookupFieldName = "";
    if ($LookupSQL && $nLookupType != LT_QUERY) {
        $LookupSQL .= " from " . AddTableWrappers($strOriginalTableName);
    }
    $data = 0;
Пример #30
0
<?php

// $arr = $_POST; //若以$.get()方式发送数据,则要改成$_GET.或者干脆:$_REQUEST
$arr = $_REQUEST;
$result = valdate($arr);
$myjson = my_json_encode($result);
echo $myjson;
function valdate($arr)
{
    $object = new MyValidator();
    $result = "";
    // email
    if ($arr["email"] == null || $arr["email"] == "") {
        $result["status"] = false;
        $result["email"] = "没有填写";
        return $result;
    } else {
        $object->setEmail($arr["email"]);
        if ($object->email()) {
            $result["email"] = "正确";
        } else {
            $result["status"] = false;
            $result["email"] = "邮件格式错误";
            return $result;
        }
    }
    // mobile 手机
    if ($arr["mobile"] == null || $arr["mobile"] == "") {
        $result["status"] = false;
        $result["mobile"] = "没有填写";
        return $result;