public static function find_xml_hash($hash) { $logged_user = User::get_logged_user(); $sql = $logged_user->mysql_list_rights_filter(static::get_mysql_table(), "`" . static::get_mysql_table() . "`.`id` ASC"); $z = mysql_query($sql); while ($r = mysql_fetch_array($z)) { $obj = static::from_mysql_id($r[0]); if (!$logged_user->is_object_editable($obj)) { continue; } if ($obj->xml_hash == $hash) { return $r[0]; } } return 0; }
of the License, and not any of the later versions. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ if (!isset($ini)) { require_once '../../Ini.php'; $ini = new Ini(); } $logged_user = User::get_logged_user(); if ($logged_user == null) { echo json_encode(array("result" => -1)); exit; } if (!is_array($_POST['oid'])) { $oid = array($_POST['oid']); } else { $oid = $_POST['oid']; } foreach ($oid as $id) { $obj = $_POST['class_name']::from_mysql_id($id); if (!$logged_user->is_object_editable($obj)) { echo json_encode(array("result" => -2)); exit; }
<script type="text/javascript" src="js/lib/kendo-ui/js/kendo.web.min.js"></script> <script type="text/javascript" src="js/lib/kendo-ui/js/cultures/kendo.culture.<?php echo Language::get_kendo_culture(); ?> .min.js"></script> <script type="text/javascript"> kendo.culture("<?php echo Language::get_kendo_culture(); ?> "); </script> </head> <body> <div id="content" align="center"> <?php if (User::get_logged_user() == null) { include 'view/log_in.php'; } else { include 'view/layout.php'; } ?> </div> <div id="divProgressDialog" class="notVisible"> <div id="divProgressBar" class="fullWidth"></div> </div> <div id="divGeneralDialog" class="notVisible"></div> <div id="divAddFormDialog" class="notVisible"></div> <script> //password recovery
public function RCall($values = null, $code = null, $resume_from_last_template = false) { if (Ini::$log_server_events) { TestServer::log_debug("TestSession->RCall --- R call initiated #" . session_id()); } //resume from last template if ($resume_from_last_template) { $response = array("data" => array("HEAD" => $this->head, "HASH" => $this->hash, "TIME_LIMIT" => $this->time_limit, "HTML" => $this->HTML, "TEST_ID" => $this->Test_id, "TEST_SESSION_ID" => $this->id, "STATUS" => TestSession::TEST_SESSION_STATUS_TEMPLATE, "TEMPLATE_ID" => $this->Template_id, "LOADER_TEMPLATE_ID" => $this->loader_Template_id, "FINISHED" => 0, "EFFECT_SHOW" => $this->effect_show, "EFFECT_HIDE" => $this->effect_hide, "EFFECT_SHOW_OPTIONS" => $this->effect_show_options, "EFFECT_HIDE_OPTIONS" => $this->effect_hide_options, "LOADER_HTML" => $this->loader_HTML, "LOADER_HEAD" => $this->loader_head, "LOADER_EFFECT_SHOW" => $this->loader_effect_show, "LOADER_EFFECT_SHOW_OPTIONS" => $this->loader_effect_show_options, "LOADER_EFFECT_HIDE" => $this->loader_effect_hide, "LOADER_EFFECT_HIDE_OPTIONS" => $this->loader_effect_hide_options, "LOADER_HTML" => $this->loader_HTML, "LOADER_HEAD" => $this->loader_head, "LOADER_EFFECT_SHOW" => $this->loader_effect_show, "LOADER_EFFECT_SHOW_OPTIONS" => $this->loader_effect_show_options, "LOADER_EFFECT_HIDE" => $this->loader_effect_hide, "LOADER_EFFECT_HIDE_OPTIONS" => $this->loader_effect_hide_options)); return $response; } //R server connection $command_obj = json_encode(array("workspace_id" => $this->UserWorkspace_id, "session_id" => $this->id, "hash" => $this->hash, "values" => $values, "code" => $code, "type" => 0, "IP" => $_SERVER["REMOTE_ADDR"])); if (Ini::$log_server_events) { TestServer::log_debug("TestSession->RCall --- checking for server"); } if (TestServer::get_server_status() == TestServer::SERVER_STATUS_STOPPED) { TestServer::start_process(); TestServer::wait_until_started(); } else { if (TestServer::get_server_status() == TestServer::SERVER_STATUS_STARTING) { TestServer::wait_until_started(); } } if (Ini::$log_server_events) { TestServer::log_debug("TestSession->RCall --- server found, trying to send"); } $response = TestServer::send($command_obj); $result = json_decode(trim($response)); if (Ini::$log_server_events) { TestServer::log_debug("TestSession->RCall --- sent and recieved response"); } $status = TestSession::TEST_SESSION_STATUS_ERROR; $removed = false; $release = 0; $html = ""; $head = ""; $Template_id = 0; $debug = 0; $hash = ""; $time_limit = 0; $Test_id = 0; $finished = 0; $loader_Template_id = 0; $loader_HTML = ""; $loader_head = ""; $loader_effect_show = "none"; $loader_effect_hide = "none"; $loader_effect_show_options = ""; $loader_effect_hide_options = ""; $effect_show = "none"; $effect_hide = "none"; $effect_show_options = ""; $effect_hide_options = ""; $state = "[]"; $output = ""; $thisSession = TestSession::from_mysql_id($this->id); $return = $result->return; if ($thisSession != null) { $output = $thisSession->output; $error_output = $thisSession->error_output; $state = $thisSession->state; $status = $thisSession->status; $release = $thisSession->release; $html = $thisSession->HTML; $head = $thisSession->head; $Template_id = $thisSession->Template_id; $debug = $thisSession->debug; $hash = $thisSession->hash; $time_limit = $thisSession->time_limit; $Test_id = $thisSession->Test_id; $loader_Template_id = $thisSession->loader_Template_id; $loader_HTML = $thisSession->loader_HTML; $loader_head = $thisSession->loader_head; $loader_effect_hide = $thisSession->loader_effect_hide; $loader_effect_hide_options = $thisSession->loader_effect_hide_options; $loader_effect_show = $thisSession->loader_effect_show; $loader_effect_show_options = $thisSession->loader_effect_show_options; $effect_hide = $thisSession->effect_hide; $effect_hide_options = $thisSession->effect_hide_options; $effect_show = $thisSession->effect_show; $effect_show_options = $thisSession->effect_show_options; if ($return != 0) { $status = TestSession::TEST_SESSION_STATUS_ERROR; } if ($status == TestSession::TEST_SESSION_STATUS_WORKING && $release == 1) { $status = TestSession::TEST_SESSION_STATUS_COMPLETED; } $thisSession->status = $status; $thisSession->mysql_save(); switch ($status) { case TestSession::TEST_SESSION_STATUS_COMPLETED: if ($debug) { TestSession::unregister($thisSession->UserWorkspace_id . "-" . $thisSession->id, $thisSession->UserWorkspace_id); $removed = true; } else { $thisSession->close(); } break; case TestSession::TEST_SESSION_STATUS_ERROR: if ($debug) { TestSession::unregister($thisSession->UserWorkspace_id . "-" . $thisSession->id, $thisSession->UserWorkspace_id); $removed = true; } else { $thisSession->close(); if (Ini::$log_r_errors) { $thisSession->log_error(nl2br(htmlspecialchars($error_output, ENT_QUOTES))); } } break; case TestSession::TEST_SESSION_STATUS_TAMPERED: if ($debug) { TestSession::unregister($thisSession->UserWorkspace_id . "-" . $thisSession->id, $thisSession->UserWorkspace_id); $removed = true; } else { $thisSession->close(); } break; case TestSession::TEST_SESSION_STATUS_TEMPLATE: if ($release) { if ($debug) { TestSession::unregister($thisSession->UserWorkspace_id . "-" . $thisSession->id, $thisSession->UserWorkspace_id); $removed = true; } else { $thisSession->close(); } } break; } } else { $removed = true; } $debug_data = false; $logged_user = User::get_logged_user(); if ($logged_user != null) { $debug_data = true; } if ($release == 1 || $status == TestSession::TEST_SESSION_STATUS_COMPLETED || $status == TestSession::TEST_SESSION_STATUS_ERROR || $status == TestSession::TEST_SESSION_STATUS_TAMPERED) { $finished = 1; } $response = array("data" => array("HEAD" => $head, "HASH" => $hash, "TIME_LIMIT" => $time_limit, "HTML" => $html, "TEST_ID" => $Test_id, "TEST_SESSION_ID" => $this->id, "STATUS" => $status, "TEMPLATE_ID" => $Template_id, "FINISHED" => $finished, "LOADER_TEMPLATE_ID" => $loader_Template_id, "LOADER_HTML" => $loader_HTML, "LOADER_HEAD" => $loader_head, "LOADER_EFFECT_SHOW" => $loader_effect_show, "LOADER_EFFECT_SHOW_OPTIONS" => $loader_effect_show_options, "LOADER_EFFECT_HIDE" => $loader_effect_hide, "LOADER_EFFECT_HIDE_OPTIONS" => $loader_effect_hide_options, "EFFECT_SHOW" => $effect_show, "EFFECT_HIDE" => $effect_hide, "EFFECT_SHOW_OPTIONS" => $effect_show_options, "EFFECT_HIDE_OPTIONS" => $effect_hide_options)); if ($debug_data) { if (!is_array($response)) { $response = array(); } if ($output != null) { if (strpos(trim($output), ">") !== 0 && strpos(trim($output), "[") !== 0) { $output = "> " . trim($output); } } if ($debug) { $state = json_decode($state, true); if ($state != null) { foreach ($state as $k => $v) { $state[$k] = htmlspecialchars($v, ENT_QUOTES); } $state = json_encode($state); } else { $state = "[]"; } $response["debug"] = array("return" => $return, "output" => nl2br(htmlspecialchars($output, ENT_QUOTES)), "error_output" => nl2br(htmlspecialchars($error_output, ENT_QUOTES)), "state" => nl2br($state)); } } if (Ini::$timer_tamper_prevention && !$removed) { $sql = sprintf("UPDATE `%s` SET `time_tamper_prevention`=%d WHERE `id`=%d", TestSession::get_mysql_table(), time(), $this->id); mysql_query($sql); } return $response; }
public function RCall($code, $include_ini_code = false, $close = false, $debug_syntax = false) { $command = ""; if (!$debug_syntax) { if ($include_ini_code) { $command = $this->get_ini_RCode(); } else { $command .= $this->get_next_ini_RCode(); } } $command .= $code; if (!$debug_syntax) { $command .= $this->get_post_RCode(); } $output = array(); $return = -999; $command_obj = json_encode(array("session_id" => $this->id, "code" => $command, "close" => 0)); if (TestServer::$debug) { TestServer::log_debug("TestSession->RCall --- checking for server"); } if (!TestServer::is_running()) { TestServer::start_process(); } if (TestServer::$debug) { TestServer::log_debug("TestSession->RCall --- server found, trying to send"); } $response = TestServer::send($command_obj); $result = json_decode(trim($response)); if (TestServer::$debug) { TestServer::log_debug("TestSession->RCall --- sent and recieved response"); } $output = explode("\n", $result->output); $return = $result->return; $thisSession = null; $status = TestSession::TEST_SESSION_STATUS_ERROR; $removed = false; $release = 0; $html = ""; $head = ""; $Template_id = 0; $debug = 0; $hash = ""; $time_limit = 0; $Test_id = 0; $finished = 0; $loader_HTML = ""; $loader_head = ""; $loader_effect_show = "none"; $loader_effect_hide = "none"; $loader_effect_show_options = ""; $loader_effect_hide_options = ""; $effect_show = "none"; $effect_hide = "none"; $effect_show_options = ""; $effect_hide_options = ""; if (!$debug_syntax) { $thisSession = TestSession::from_mysql_id($this->id); if ($thisSession != null) { $status = $thisSession->status; $release = $thisSession->release; $html = $thisSession->HTML; $Template_id = $thisSession->Template_id; $debug = $thisSession->debug; $hash = $thisSession->hash; $time_limit = $thisSession->time_limit; $Test_id = $thisSession->Test_id; $loader_HTML = $thisSession->loader_HTML; $loader_head = $thisSession->loader_head; $loader_effect_hide = $thisSession->loader_effect_hide; $loader_effect_hide_options = $thisSession->loader_effect_hide_options; $loader_effect_show = $thisSession->loader_effect_show; $loader_effect_show_options = $thisSession->loader_effect_show_options; $effect_hide = $thisSession->effect_hide; $effect_hide_options = $thisSession->effect_hide_options; $effect_show = $thisSession->effect_show; $effect_show_options = $thisSession->effect_show_options; if ($return != 0) { $status = TestSession::TEST_SESSION_STATUS_ERROR; } if ($status == TestSession::TEST_SESSION_STATUS_WORKING && $release == 1 || $close) { $status = TestSession::TEST_SESSION_STATUS_COMPLETED; } $thisSession->status = $status; $thisSession->mysql_save(); switch ($status) { case TestSession::TEST_SESSION_STATUS_COMPLETED: if ($debug) { TestSession::unregister($thisSession->id); $removed = true; } else { $thisSession->serialize(); } break; case TestSession::TEST_SESSION_STATUS_ERROR: case TestSession::TEST_SESSION_STATUS_TAMPERED: if ($debug) { TestSession::unregister($thisSession->id); $removed = true; } else { $thisSession->close(); } break; case TestSession::TEST_SESSION_STATUS_TEMPLATE: if ($debug) { $html = Template::strip_html($html); if ($release) { TestSession::unregister($thisSession->id); } } else { $head = Template::from_mysql_id($Template_id)->head; if ($release) { $thisSession->serialize(); } } break; } } else { $removed = true; } } $test = Test::from_mysql_id($this->Test_id); $debug_data = false; $logged_user = User::get_logged_user(); if ($logged_user != null) { $debug_data = $logged_user->is_object_readable($test); } if ($release == 1 || $status == TestSession::TEST_SESSION_STATUS_COMPLETED || $status == TestSession::TEST_SESSION_STATUS_ERROR || $status == TestSession::TEST_SESSION_STATUS_TAMPERED) { $finished = 1; } if (!$debug_syntax) { $response = array("data" => array("HEAD" => $head, "HASH" => $hash, "TIME_LIMIT" => $time_limit, "HTML" => $html, "TEST_ID" => $Test_id, "TEST_SESSION_ID" => $this->id, "STATUS" => $status, "TEMPLATE_ID" => $Template_id, "FINISHED" => $finished, "LOADER_HTML" => $loader_HTML, "LOADER_HEAD" => $loader_head, "LOADER_EFFECT_SHOW" => $loader_effect_show, "LOADER_EFFECT_SHOW_OPTIONS" => $loader_effect_show_options, "LOADER_EFFECT_HIDE" => $loader_effect_hide, "LOADER_EFFECT_HIDE_OPTIONS" => $loader_effect_hide_options, "EFFECT_SHOW" => $effect_show, "EFFECT_HIDE" => $effect_hide, "EFFECT_SHOW_OPTIONS" => $effect_show_options, "EFFECT_HIDE_OPTIONS" => $effect_hide_options)); } if ($debug_data) { for ($i = 0; $i < count($output); $i++) { if (strpos($output[$i], "CONCERTO_DB_PASSWORD <-") !== false) { $output[$i] = "[hidden]"; } $output[$i] = htmlspecialchars($output[$i], ENT_QUOTES); } $command_lines = explode("\n", $command); for ($i = 0; $i < count($command_lines); $i++) { if (strpos($command_lines[$i], "CONCERTO_DB_PASSWORD <-") !== false) { $command_lines[$i] = "[hidden]"; } } $command = implode("\n", $command_lines); $command = htmlspecialchars($command, ENT_QUOTES); if (!is_array($response)) { $response = array(); } $response["debug"] = array("code" => $command, "return" => $return, "output" => $output); } if (Ini::$timer_tamper_prevention && !$debug_syntax && !$removed) { $sql = sprintf("UPDATE `%s` SET `time_tamper_prevention`=%d WHERE `id`=%d", TestSession::get_mysql_table(), time(), $this->id); mysql_query($sql); } return $response; }
public static function get_list() { $list = parent::get_list(); $logged_user = User::get_logged_user(); if ($logged_user != null) { if ($logged_user->superuser == 1) { return $list; } else { return array($logged_user); } } return array(); }
public function import_XML($xml, $compare = null) { $this->Sharing_id = 1; $xpath = new DOMXPath($xml); $elements = $xpath->query("/export"); foreach ($elements as $element) { if (Ini::$version != $element->getAttribute("version")) { return -5; } } if ($compare == null) { $compare = array("Template" => array(), "Table" => array(), "CustomSection" => array(), "Test" => array(), "QTIAssessmentItem" => array()); } //link templates $logged_user = User::get_logged_user(); $elements = $xpath->query("/export/Template"); foreach ($elements as $element) { $id = $element->getAttribute("id"); $hash = $element->getAttribute("xml_hash"); $compare["Template"][$id] = Template::find_xml_hash($hash); if ($compare["Template"][$id] == 0) { $obj = new Template(); $obj->Owner_id = $logged_user->id; $lid = $obj->import_XML(Template::convert_to_XML_document($element)); $compare["Template"][$id] = $lid; } } //link QTI assessment items $logged_user = User::get_logged_user(); $elements = $xpath->query("/export/QTIAssessmentItem"); foreach ($elements as $element) { $id = $element->getAttribute("id"); $hash = $element->getAttribute("xml_hash"); $compare["QTIAssessmentItem"][$id] = QTIAssessmentItem::find_xml_hash($hash); if ($compare["QTIAssessmentItem"][$id] == 0) { $obj = new QTIAssessmentItem(); $obj->Owner_id = $logged_user->id; $lid = $obj->import_XML(QTIAssessmentItem::convert_to_XML_document($element)); $compare["QTIAssessmentItem"][$id] = $lid; } } //link tables $elements = $xpath->query("/export/Table"); foreach ($elements as $element) { $id = $element->getAttribute("id"); $hash = $element->getAttribute("xml_hash"); $compare["Table"][$id] = Table::find_xml_hash($hash); if ($compare["Table"][$id] == 0) { $obj = new Table(); $obj->Owner_id = $logged_user->id; $lid = $obj->import_XML(Table::convert_to_XML_document($element)); $compare["Table"][$id] = $lid; } } //link custom sections $elements = $xpath->query("/export/CustomSection"); foreach ($elements as $element) { $id = $element->getAttribute("id"); $hash = $element->getAttribute("xml_hash"); $compare["CustomSection"][$id] = CustomSection::find_xml_hash($hash); if ($compare["CustomSection"][$id] == 0) { $obj = new CustomSection(); $obj->Owner_id = $logged_user->id; $lid = $obj->import_XML(CustomSection::convert_to_XML_document($element)); $compare["CustomSection"][$id] = $lid; } } //link tests $elements = $xpath->query("/export/Test"); for ($i = 0; $i < $elements->length - 1; $i++) { $element = $elements->item($i); $id = $element->getAttribute("id"); $hash = $element->getAttribute("xml_hash"); if (!isset($compare["Test"][$id])) { $compare["Test"][$id] = 0; } if ($compare["Test"][$id] == 0) { $obj = new Test(); $obj->Owner_id = $logged_user->id; $lid = $obj->import_XML(CustomSection::convert_to_XML_document($element), $compare); $compare["Test"][$id] = $lid; } } $elements = $xpath->query("/export/Test"); $element = $elements->item($elements->length - 1); $this->xml_hash = $element->getAttribute("xml_hash"); $element_id = $element->getAttribute("id"); if (isset($compare["Test"][$element_id]) && $compare["Test"][$element_id] != 0) { return $compare["Test"][$element_id]; } $children = $element->childNodes; foreach ($children as $child) { switch ($child->nodeName) { case "name": $this->name = $child->nodeValue; break; case "description": $this->description = $child->nodeValue; break; case "open": $this->open = $child->nodeValue; break; case "loader_Template_id": $this->loader_Template_id = $child->nodeValue == 0 ? 0 : $compare["Template"][$child->nodeValue]; break; } } $this->id = $this->mysql_save(); $post = array(); $post["sections"] = array(); $elements = $xpath->query("/export/Test[@id='" . $element_id . "']/TestSections/TestSection"); foreach ($elements as $element) { $test_section = array(); $test_section["value"] = array(); $children = $element->childNodes; foreach ($children as $child) { switch ($child->nodeName) { case "end": $test_section["end"] = $child->nodeValue; break; case "counter": $test_section["counter"] = $child->nodeValue; break; case "TestSectionType_id": $test_section["type"] = $child->nodeValue; break; case "parent_counter": $test_section["parent"] = $child->nodeValue; break; case "TestSectionValues": $ts_child_list = $child->childNodes; foreach ($ts_child_list as $ts_child) { $index = -1; $value = ""; $tsv_vars = $ts_child->childNodes; foreach ($tsv_vars as $tsv_child) { switch ($tsv_child->nodeName) { case "index": $index = $tsv_child->nodeValue; break; case "value": $value = $tsv_child->nodeValue; break; } } if ($index != -1) { $test_section["value"]["v" . $index] = $value; } } break; } } switch ($test_section["type"]) { case 2: if ($test_section["value"]["v0"] == 0) { break; } $value = 0; if (isset($compare["Template"][$test_section["value"]["v0"]])) { $value = $compare["Template"][$test_section["value"]["v0"]]; } $test_section["value"]["v0"] = $value; break; case 13: if ($test_section["value"]["v0"] == 0) { break; } $value = 0; if (isset($compare["QTIAssessmentItem"][$test_section["value"]["v0"]])) { $value = $compare["QTIAssessmentItem"][$test_section["value"]["v0"]]; } $test_section["value"]["v0"] = $value; break; case 11: if ($test_section["value"]["v0"] == 0) { break; } $value = 0; if (isset($compare["Test"][$test_section["value"]["v0"]])) { $value = $compare["Test"][$test_section["value"]["v0"]]; } $test_section["value"]["v0"] = $value; break; case 9: if ($test_section["value"]["v0"] == 0) { break; } $value = 0; if (isset($compare["CustomSection"][$test_section["value"]["v0"]])) { $value = $compare["CustomSection"][$test_section["value"]["v0"]]; } $test_section["value"]["v0"] = $value; break; case 8: if ($test_section["value"]["v3"] == 0) { break; } $value = 0; if (isset($compare["Table"][$test_section["value"]["v3"]])) { $value = $compare["Table"][$test_section["value"]["v3"]]; } $test_section["value"]["v3"] = $value; break; case 5: if ($test_section["value"]["v5"] == 0) { break; } if ($test_section["value"]["v2"] == 0) { $value = 0; if (isset($compare["Table"][$test_section["value"]["v5"]])) { $value = $compare["Table"][$test_section["value"]["v5"]]; } $test_section["value"]["v5"] = $value; } break; } if (count($test_section["value"]) == 0) { $test_section['value'] = "{}"; } array_push($post["sections"], $test_section); } $post['sections'] = json_encode($post['sections']); $post["parameters"] = array(); $elements = $xpath->query("/export/Test[@id='" . $element_id . "']/TestVariables/TestVariable"); foreach ($elements as $element) { $tv = array(); $tv["Test_id"] = $element_id; $children = $element->childNodes; $correct = true; foreach ($children as $child) { switch ($child->nodeName) { case "index": $tv["index"] = $child->nodeValue; break; case "name": $tv["name"] = $child->nodeValue; break; case "description": $tv["description"] = $child->nodeValue; break; case "type": $tv["type"] = $child->nodeValue; if ($tv["type"] != 0) { $correct = false; } break; } } if ($correct) { $tv = json_encode($tv); array_push($post['parameters'], $tv); } } $post["returns"] = array(); $elements = $xpath->query("/export/Test[@id='" . $element_id . "']/TestVariables/TestVariable"); foreach ($elements as $element) { $tv = array(); $tv["Test_id"] = $element_id; $children = $element->childNodes; $correct = true; foreach ($children as $child) { switch ($child->nodeName) { case "index": $tv["index"] = $child->nodeValue; break; case "name": $tv["name"] = $child->nodeValue; break; case "description": $tv["description"] = $child->nodeValue; break; case "type": $tv["type"] = $child->nodeValue; if ($tv["type"] != 1) { $correct = false; } break; } } if ($correct) { $tv = json_encode($tv); array_push($post['returns'], $tv); } } $post["protected"] = array(); $elements = $xpath->query("/export/Test[@id='" . $element_id . "']/TestProtectedVariables/TestProtectedVariable"); foreach ($elements as $element) { $tpv = array(); $tpv["Test_id"] = $element_id; $children = $element->childNodes; $correct = true; foreach ($children as $child) { switch ($child->nodeName) { case "name": $tpv["name"] = $child->nodeValue; break; } } $tpv = json_encode($tpv); array_push($post['protected'], $tpv); } return $this->mysql_save_from_post($post); }