public function mysql_save() { $prev = UserShare::from_mysql_id($this->id); if ($this->id != 0 && $prev != null) { if ($this->UserWorkspace_id != $prev->UserWorkspace_id || $this->invitee_id != $prev->invitee_id) { $shares = UserShare::from_property(array("UserWorkspace_id" => $prev->UserWorkspace_id, "invitee_id" => $prev->invitee_id)); $ws = $prev->get_UserWorkspace(); if ($ws != null && count($shares) <= 1) { $ws->revoke_privileges_db_user($prev->invitee_id); } } } $ws = UserWorkspace::from_mysql_id($this->UserWorkspace_id); if ($ws != null) { $ws->grant_privileges_db_user($this->invitee_id); } parent::mysql_save(); }
function get_returns($sid, $hash, $pass, $wid) { if (!authorize_WS($pass)) { return -1; } $workspace = UserWorkspace::from_mysql_id($wid); if ($workspace != null) { mysql_select_db($workspace->db_name); } $session = TestSession::from_property(array("id" => $sid, "hash" => $hash), false); if ($session == null) { return false; } $return = TestSessionReturn::from_property(array("TestSession_id" => $sid)); $result = array(); foreach ($return as $ret) { $result[$ret->name] = $ret->value; } return json_encode($result); }
public static function forward($tid, $sid, $hash, $values, $btn_name, $debug, $time, $wid = null, $resume_from_last_template = false, $code = null) { $workspace = UserWorkspace::from_mysql_id($wid); if ($workspace != null) { mysql_select_db($workspace->db_name); } else { return false; } if (is_string($values)) { $values = json_decode($values, true); } $session = null; $result = array(); if ($wid != null && $sid != null && $hash != null) { $session = TestSession::authorized_session($wid, $sid, $hash); if ($session != null) { if ($btn_name != null) { if ($values != null) { $values["LAST_PRESSED_BUTTON_NAME"] = $btn_name; } } if (Ini::$timer_tamper_prevention && $session->time_limit > 0 && $time - $session->time_tamper_prevention - Ini::$timer_tamper_prevention_tolerance > $session->time_limit) { if ($session->debug == 1) { TestSession::unregister($session->UserWorkspace_id . "-" . $session->id, $session->UserWorkspace_id); } else { $session->close(); } $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => 0, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1)); if ($session->debug == 1) { $result["debug"] = array("return" => 0, "output" => "", "state" => "[]"); } } else { $result = $session->RCall($values, $code, $resume_from_last_template); } } else { $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => 0, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1), "debug" => array("return" => 0, "output" => "", "state" => "[]")); } } else { if ($wid != null && $tid != null) { if ($debug == 1) { $debug = true; } else { $debug = false; } $test = Test::from_mysql_id($tid); if ($test->type != 2) { $session = TestSession::start_new($wid, $tid, $debug); } if ($values == null) { $values = array(); } if ($test != null && $test->type != 2) { $values = $test->verified_input_values($values); } else { $result = array("data" => array("HASH" => $hash, "TIME_LIMIT" => 0, "HTML" => "", "TEST_ID" => $tid, "TEST_SESSION_ID" => $sid, "STATUS" => TestSession::TEST_SESSION_STATUS_TAMPERED, "TEMPLATE_ID" => 0, "HEAD" => "", "FINISHED" => 1), "debug" => array("return" => 0, "output" => "", "state" => "[]")); return $result; } $result = $result = $session->RCall($values, $code, $resume_from_last_template); } } return $result; }
<td><span class="tooltip spanIcon ui-icon ui-icon-help" title="<?php echo Language::string(680); ?> "></span></td> <td class="fullWidth"> <div class="horizontalMargin"> <select id = "selectUserWorkspaceShareDialog" class = "fullWidth ui-widget-content ui-corner-all"> <option value = "0"><<?php echo Language::string(650); ?> ></option> <?php $sql = sprintf("SELECT * FROM `%s`.`%s` WHERE `owner_id`='%s' ORDER BY `name` ASC", Ini::$db_master_name, UserWorkspace::get_mysql_table(), $owner->id); $z = mysql_query($sql); while ($r = mysql_fetch_array($z)) { $ws = UserWorkspace::from_mysql_result($r); $ignore = false; if (!$ignore) { ?> <option value="<?php echo $ws->id; ?> " name="<?php echo $ws->name; ?> " <?php echo array_key_exists("current_workspace_id", $_POST) && $_POST['current_workspace_id'] == $ws->id ? "selected" : ""; ?> ><?php echo $ws->get_formatted_name(); ?>
echo Language::string(443); ?> </button> <button class="btnUpload" onclick="<?php echo $class_name; ?> .uiUpload(<?php echo $oid; ?> )"><?php echo Language::string(383); ?> </button> <?php } $ws = UserWorkspace::from_property(array("db_name" => User::get_current_db()), false); $ws_id = 0; if ($ws != null) { $ws_id = $ws->id; } ?> <button class="btnRunTest" onclick="window.open('<?php echo Ini::$path_external . "?wid=" . $ws_id . "&tid=" . $obj->id; ?> ', '_blank')"><?php echo Language::string(362); ?> </button> </div> <?php }
<div id="divTestContainer"> <div align="center" style="color: red; font-weight: bold;"><noscript>Your browser does not support JavaScript!</noscript></div> <br/> <div align="center"><img src="cms/css/img/logo.png" /> v<?php echo Ini::$version; ?> </div> <div align="center"> <div style="display: table;"> <fieldset class="ui-widget-content"> <legend>available tests</legend> <select id="selectTest" class="ui-widget-content" onchange="Concerto.selectTest()"> <option value="0"><none selected></option> <?php $query = array(); $sql = sprintf("SELECT `id`,`db_name` FROM `%s`.`%s`", Ini::$db_master_name, UserWorkspace::get_mysql_table()); $z = mysql_query($sql); while ($r = mysql_fetch_array($z)) { $sql = sprintf("(SELECT `id`,%s as `wid`,`name` FROM `%s`.`%s` WHERE `type`=1)", $r['id'], $r['db_name'], Test::get_mysql_table()); array_push($query, $sql); } $query = implode(" UNION ", $query) . " ORDER BY `name` ASC"; $z = mysql_query($query); while ($r = mysql_fetch_array($z)) { ?> <option value="<?php echo $r['id']; ?> " workspace="<?php echo $r["wid"]; ?>
} //vars $name = "concerto.table.query"; $db = User::get_current_db(); if (array_key_exists("db", $_POST)) { $workspace_id = $_POST['db']; } $table_name = ""; if (array_key_exists("table_name", $_POST)) { $table_name = $_POST['table_name']; } $type = "SELECT"; if (array_key_exists("type", $_POST)) { $type = $_POST['type']; } $ws = UserWorkspace::from_property(array("db_name" => $db), false); TestSession::change_db($ws->id); $table = Table::from_property(array("name" => $table_name), false); $table_columns = array(); if ($table != null) { $table_columns = $table->get_columns(); } $select_section = array(array("v" => 0, "w0" => "*", "c" => "*")); $select_section = json_encode($select_section); if (array_key_exists('select_section', $_POST)) { $select_section = $_POST['select_section']; } $select_section = json_decode($select_section); if (array_key_exists("select_section_add", $_POST) && $_POST['select_section_add'] == 1) { array_push($select_section, json_decode(json_encode(array("v" => 0, "w0" => "*", "c" => "*")))); }
public function mysql_save_from_post($post) { $is_new = $this->id == 0; if (array_key_exists("superuser", $post)) { $logged_user = User::get_logged_user(); if ($logged_user == null || $logged_user->superuser == 0) { $post['superuser'] = 0; } } $post['oid'] = parent::mysql_save_from_post($post); $obj = User::from_mysql_id($post['oid']); if ($post['modify_password'] == 1) { $obj->password = $obj->calculate_password_hash($post['password_hash']); $obj->mysql_save(); } if (array_key_exists("deleteShare", $post)) { $rows = json_decode($post["deleteShare"]); foreach ($rows as $row) { $share = UserShare::from_mysql_id($row); if ($share != null) { $share->mysql_delete(); } } } if (array_key_exists("updateShare", $post)) { $rows = json_decode($post["updateShare"], true); foreach ($rows as $row) { if ($row["id"] != 0) { $share = UserShare::from_mysql_id($row['id']); $share->invitee_id = $row['invitee_id']; $share->UserWorkspace_id = $row['workspace_id']; $share->mysql_save(); } else { $share = new UserShare(); $share->invitee_id = $row['invitee_id']; $share->UserWorkspace_id = $row['workspace_id']; $share->mysql_save(); } } } if ($is_new) { $ws = new UserWorkspace(); $ws->owner_id = $post['oid']; $ws->main = 1; $ws->name = "main"; $ws->mysql_save(); } else { if (array_key_exists("deleteWorkspace", $post)) { $rows = json_decode($post["deleteWorkspace"]); foreach ($rows as $row) { $ws = UserWorkspace::from_mysql_id($row); if ($ws != null) { $ws->mysql_delete(); } } } if (array_key_exists("updateWorkspace", $post)) { $rows = json_decode($post["updateWorkspace"], true); foreach ($rows as $row) { if ($row["id"] != 0) { $ws = UserWorkspace::from_mysql_id($row['id']); $ws->name = $row['name']; $ws->owner_id = $this->id; $ws->mysql_save(); } else { $ws = new UserWorkspace(); $ws->name = $row['name']; $ws->owner_id = $this->id; $ws->mysql_save(); } } } } return $post['oid']; }
public function get_UserWorkspace() { return UserWorkspace::from_mysql_id($this->UserWorkspace_id); }