function ResultadoDetalleExtendido($Resultado) { if (!$this->user || !$this->password) { $ret = generate_error("Autenticacion", "", "ResultadoDetalleExtendido"); } else { $payload = file_get_contents("php://input"); log_to_file("wsSeguimiento XMLrequest: " . $payload); log_to_file("wsSeguimiento request: " . serialize($Resultado)); $ret = get_ResultadoDetalleExtendido($Resultado->ResultadoExtendido, $this->user, $this->password); } log_to_file("wsSeguimiento response: " . serialize($ret)); return $ret; }
/** * Getting list of tables in database and putting it into $this->aTables array * @param none * @return none * @access private */ function _get_tables() { $this->_report('Selecting tables', 30); $res = @mysql_query("SELECT VERSION() as mysql_version"); if ($res) { $rowVersion = mysql_fetch_assoc($res); } // getting list of tables if (version_compare($rowVersion['mysql_version'], '5.0.1', '<')) { $result = @mysql_list_tables($this->sDBName); } else { $result = @mysql_query("SHOW FULL TABLES FROM `" . $this->sDBName . "` WHERE Table_type = 'BASE TABLE'"); } $arr_exclude_db_tables = isset($GLOBALS['exclude_db_tables']) ? (string) $GLOBALS['exclude_db_tables'] : ''; $arr_exclude_db_tables = explode(';', $arr_exclude_db_tables); $quoted_tbls = array(); foreach ($arr_exclude_db_tables as $tbl) { $tbl = preg_quote($tbl, '/'); $tbl = str_replace('\\*', '.*', $tbl); $tbl = str_replace('\\?', '?', $tbl); $quoted_tbls[] = '^' . $tbl . '$'; } $tables_exclude_pattern = implode('|', $quoted_tbls); $db_prefix = isset($_REQUEST['db_prefix']) ? $_REQUEST['db_prefix'] : ''; $include_db_tables = isset($GLOBALS['include_db_tables']) ? (string) $GLOBALS['include_db_tables'] : ''; $quoted_tbls = array(); if (!empty($include_db_tables)) { $arr_include_db_tables = explode(';', (string) $GLOBALS['include_db_tables']); foreach ($arr_include_db_tables as $tbl) { $tbl = preg_quote($tbl, '/'); $tbl = str_replace('\\*', '.*', $tbl); $tbl = str_replace('\\?', '?', $tbl); $quoted_tbls[] = '^' . $db_prefix . $tbl . '$'; } $quoted_tbls[] = '^sm_.*$'; // Magento tables with prefix "sm_" } $tables_include_pattern = implode('|', $quoted_tbls); if (!$result) { generate_error('Error selecting tables. ' . mysql_error(), $this); } else { $tables = array(); $inc_tables = 0; while ($row = @mysql_fetch_row($result)) { if (preg_match('/' . $tables_include_pattern . '/', $row[0])) { $inc_tables++; } $tables[] = $row; } foreach ($tables as $table) { if (preg_match('/' . $tables_exclude_pattern . '/', $table[0])) { continue; } if (preg_match('/' . $tables_include_pattern . '/', $table[0]) || $inc_tables == 0) { $this->aTables[] = $table[0]; } } } @mysql_free_result($result); }
die(generate_error('N: I/O error', -1)); } if (!isset($_POST['id']) || !is_numeric($_POST['id'])) { die(generate_error('N: Invalid ID', -2)); } $cache_file = CACHE_DIR . (substr(CACHE_DIR, -1) === '/' ? '' : '/') . $_POST['id'] . '.json'; if (file_exists($cache_file)) { if (time() - filemtime($cache_file) > CACHE_AGE) { unlink($cache_file); } else { die(file_get_contents($cache_file)); } } $ce = curl_init(API_ENDPOINT . $_POST['id']); curl_setopt($ce, CURLOPT_HEADER, false); curl_setopt($ce, CURLOPT_RETURNTRANSFER, true); // To let this work on platforms with broken SSL CAs (do not enable in production) // curl_setopt ($ce, CURLOPT_SSL_VERIFYPEER, false); $out = curl_exec($ce); curl_close($ce); if (!$out) { // don't cache empty responses, may be temporary errors die(generate_error('N: Bad response', -3)); } file_put_contents($cache_file, $out); chmod($cache_file, CACHE_FILE_PERMS); echo $out; function generate_error($msg, $code) { return json_encode(['errors' => [['message' => $msg, 'code' => $code]]]); }
} $info = $this->network->get_user_follows($desired_user_id); if (!$info) { if (!isset($_GET['suppress_response_codes'])) { header('HTTP/1.1 500 Internal Server Error'); } else { echo generate_error($api_session->format, 'Server error (Stage 1).', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } $followers = array_keys($info->followers); if (!count($followers)) { if (!isset($_GET['suppress_response_codes'])) { header('HTTP/1.1 304 Not Modified'); } else { echo generate_error($api_session->format, 'No followers found.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } $num_rows = count($followers); $twitter_data = new TwitterData($api_session->format, $api_session->callback, $desired_user_id, TRUE); $answer = $twitter_data->data_header(); $answer .= $twitter_data->data_section('id_list', FALSE, FALSE, TRUE, ' type="array"'); $answer .= $twitter_data->data_section('ids'); foreach ($followers as $user_id) { $check = $num_rows - 1 > 0 ? true : false; $answer .= $twitter_data->data_field('id', $user_id, $check); $num_rows--; } $answer .= $twitter_data->data_section('ids', FALSE, TRUE); $answer .= $twitter_data->data_section('id_list', FALSE, TRUE, TRUE);
} else { echo generate_error($format, 'API is disabled', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } setlocale(LC_TIME, 'en_US'); global $user; if ($user->is_logged) { $user->logout(); } $user->is_logged = false; $user->id = false; $user->info->is_network_admin = 0; $uri = $this->param('more'); $api_session->resource = isset($uri[0]) ? $uri[0] : 'invalid'; $api_session->resource_option = isset($uri[1]) ? $uri[1] : false; unset($uri); if (!is_valid_data_format($api_session->format)) { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid data format requested.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 304 Not Modified'); } else { echo generate_error($api_session->format, 'Not implemented feature. Contact our support team for more information.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit;
unset($u, $obj); } } if (!$api_session->oauth_status && !$api_session->bauth_status) { if (!isset($_GET['suppress_response_codes'])) { header('HTTP/1.1 401 Unauthorized'); } else { echo generate_error($api_session->format, 'OAuth otorization problem:' . $api_session->oauth_error, $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } if (empty($search_string) || strlen($search_string) > 140) { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 403 Forbidden'); } else { echo generate_error($api_session->format, 'Invalid string parameter.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } $in_sql = array(); if (FALSE !== $until_id && FALSE !== $since_id) { $in_sql[] = 'p.id BETWEEN ' . $since_id . ' AND ' . $until_id; } elseif (FALSE !== $until_id) { $in_sql[] = 'p.id<=' . $until_id; } elseif (FALSE !== $since_id) { $in_sql[] = 'p.id>=' . $since_id; } $in_sql[] = 'user_id<>0'; if (!$user->info->is_network_admin) { $api_session->not_in_groups = array(); $api_session->not_in_groups = not_in_groups();
echo $answer; exit; } elseif ($api_session->resource == 'daily') { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid feature requested.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } elseif ($api_session->resource == 'weekly') { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid feature requested.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } elseif ($api_session->resource == 'location') { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid feature requested.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } elseif ($api_session->resource == 'available') { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid feature requested.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; }
} else { $callback = FALSE; } setlocale(LC_TIME, 'en_US'); $uri = $this->param('more'); if (!is_valid_data_format($format)) { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($format, 'Invalid data format requested.', $_SERVER['REQUEST_URI'], $callback); } exit; } elseif ($uri[0] == 'test') { switch ($format) { case 'json': echo '"ok": true'; break; case 'rss': case 'atom': case 'xml': echo '<ok>true</ok>'; break; } exit; } if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 304 Not Modified'); } else { echo generate_error($format, 'Invalid resource request', $_SERVER['REQUEST_URI'], $callback); } exit;
<?php require_once $C->INCPATH . 'helpers/func_api.php'; $format = $this->param('format'); $uri = $this->param('more'); if (!isset($uri[0])) { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($format, 'Invalid resource address requested.', $_SERVER['REQUEST_URI']); } } elseif ($uri[0] == 'home') { header('HTTP/1.1 400 Bad Request'); } if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($format, 'Invalid resource address requested.', $_SERVER['REQUEST_URI']); } exit;
if (isset($dir) && $dir != "./") { $parent = dirname($dir); print "<a class='home' href='gallery.php?dir=$parent/'>Назад</a><br>"; print_tree($dir . "*"); } else { print_tree("./*"); } ?> </div> </div> <div id="content"> <?php if (strnatcasecmp($error, 1) == 0) { generate_error($error_messages['not_exist_dir'] . " или " . $error_messages['wrong_perm']); } else { generate_error($error); } print_images("./*"); if (isset($dir)) { ?> <table cellspacing="5"> <?php print_images($dir); ?> </table> <?php } ?> </div> <div id="footer">© <a href="mailto:rainxforum@gmail.com">Ekaterina Khurtina</a></div> </body> </html>
} exit; } } elseif ($api_session->resource == 'all_groups') { if ($_SERVER['REQUEST_METHOD'] != 'GET') { if (!isset($_REQUEST['suppress_response_codes'])) { header('HTTP/1.1 400 Bad Request'); } else { echo generate_error($api_session->format, 'Invalid request method.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } elseif (!$api_session->oauth_status && !$api_session->bauth_status) { if (!isset($_POST['suppress_response_codes'])) { header('HTTP/1.1 401 Unauthorized'); } else { echo generate_error($api_session->format, 'OAuth otorization problem: ' . $api_session->oauth_error, $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } $res = $this->db2->query('SELECT id, groupname FROM groups WHERE is_public=1'); $num_rows = $this->db2->num_rows($res); $twitter_data = new TwitterData($api_session->format, $api_session->callback, -1, TRUE); $answer = $twitter_data->data_header(); $answer .= $twitter_data->data_section('groups', FALSE, FALSE, TRUE, ' type="array"'); while ($obj = $this->db2->fetch_object($res)) { $answer .= $twitter_data->data_section('group'); $answer .= $twitter_data->data_field('id', $obj->id); $answer .= $twitter_data->data_field('name', $obj->groupname, FALSE); $answer .= $twitter_data->data_section('group', FALSE, TRUE); $answer .= $api_session->format == 'json' && $num_rows - 1 > 0 ? ',' : ''; $num_rows--;
/** * Creating a structure definition of a table * @param sting table name for creating stucture * @return none * @access public */ function _generate_structure($tblname) { //!!! Retrieve general information!!! $this->_report('Generating structure for ' . $tblname, 30); $result = @mysql_query("DESCRIBE `{$tblname}`", $this->rLink); if (!$result) { $this->_connect(); $this->_report('Generating structure for ' . $tblname, 30); $result = @mysql_query("DESCRIBE `{$tblname}`", $this->rLink); if (!$result) { generate_error('Can`t get main strucutre from ' . $tblname . '. ' . mysql_error($this->rLink), $this); } } $result = mysql_query("SHOW CREATE TABLE `{$tblname}`", $this->rLink); $aRow = mysql_fetch_array($result); $sOutput = "#\r\n### TABLE STRUCTURE FOR `{$tblname}`###\r\n#\n\n"; if ($this->bDeleteBefore) { $sOutput .= "DROP TABLE IF EXISTS `{$tblname}`;\r\n"; } $sOutput .= $aRow[1] . "; \r\n"; $this->_write_to_output($sOutput); }
function get_ResultadoDetalleExtendido($ResultadoExtendido, $user, $passwd) { global $CFG, $USER, $DB; set_time_limit(0); try { // Seek rcontent data $rcontent = $DB->get_record('rcontent', array('id' => $ResultadoExtendido->idContenidoLMS)); if (!$rcontent) { return generate_error("InvalidIdContenidoLMS", $ResultadoExtendido->idContenidoLMS, "ResultadoDetalleExtendido"); } // Search book $book = rcommon_book::get($rcontent->bookid); if (!$book) { return generate_error("LibroInvalido", $rcontent->bookid, "ResultadoDetalleExtendido"); } //MARSUPIAL ********** AFEGIT -> Validating activity, unit and content in case of forzarGuardar = 1 //06/02/2014 . @naseq if (isForzarGuardar($ResultadoExtendido)) { $real_rcontent = get_real_rcontent($ResultadoExtendido, $rcontent, $book->id); if ($real_rcontent) { $rcontent = $real_rcontent; $ResultadoExtendido->idContenidoLMS = $real_rcontent->id; log_to_file('ForzarGuardar changed idContenidoLMS to ' . $ResultadoExtendido->idContenidoLMS); } } //*********** FI $cm = get_coursemodule_from_instance('rcontent', $rcontent->id, $rcontent->course); if (!rcommon_book::check_auth($book->id, $user, $passwd)) { return generate_error("Autenticacion", "", "ResultadoDetalleExtendido", $cm->id); } if ($CFG->center != $ResultadoExtendido->idCentro) { return generate_error("CentroInvalido", get_string('center', 'rcontent') . ": {$CFG->center} - {$ResultadoExtendido->idCentro}", "ResultadoDetalleExtendido", $cm->id); } // Valid mandatory if (!isset($ResultadoExtendido->idUsuario) || !isset($ResultadoExtendido->idContenidoLMS) || !valid_result_details($ResultadoExtendido)) { return generate_error("ValoresObligatorios", "", "ResultadoDetalleExtendido", $cm->id); } if (!valid_status_result($ResultadoExtendido)) { return generate_error("EstadoInvalido", "", "ResultadoDetalleExtendido", $cm->id); } if ($rcontent->course == SITEID) { if (!$DB->record_exists('user', array('id' => $ResultadoExtendido->idUsuario))) { return generate_error("UsrNoExisteEnCurso", get_string('user') . ": {$ResultadoExtendido->idUsuario} - " . get_string('course') . ": {$rcontent->course}", "ResultadoDetalleExtendido", $cm->id); } } else { if (!valid_user($ResultadoExtendido->idUsuario, $rcontent->course)) { return generate_error("UsrNoExisteEnCurso", get_string('user') . ": {$ResultadoExtendido->idUsuario} - " . get_string('course') . ": {$rcontent->course}", "ResultadoDetalleExtendido", $cm->id); } $contextmodule = context_module::instance($cm->id); if (!has_capability('mod/rcontent:savetrack', $contextmodule, $ResultadoExtendido->idUsuario)) { return generate_error("SinPermisosGuardarSeguimiento", get_string('user') . ": {$ResultadoExtendido->idUsuario}", "ResultadoDetalleExtendido", $cm->id); } } $unidad = valid_unit($ResultadoExtendido, $book, $rcontent->unitid); if (!$unidad) { return generate_error("UnidadInvalida", $ResultadoExtendido->idUnidad, "ResultadoDetalleExtendido"); } $unidadid = isset($unidad->id) ? $unidad->id : 0; $actividad = valid_activity($ResultadoExtendido, $book, $rcontent->activityid, $unidadid); if (!$actividad) { return generate_error("ActividadInvalida", $ResultadoExtendido->idActividad, "ResultadoDetalleExtendido"); } $actividadid = isset($actividad->id) ? $actividad->id : 0; // Prepare to insert/modify rcontent_grade $instance = new stdClass(); $instance->userid = $ResultadoExtendido->idUsuario; $instance->rcontentid = $ResultadoExtendido->idContenidoLMS; $instance->unitid = $unidadid; $instance->activityid = $actividadid; $instance->sumweights = isset($ResultadoExtendido->SumaPesos) ? $ResultadoExtendido->SumaPesos : 100; $instance->timemodified = time(); if (!empty($ResultadoExtendido->Resultado)) { require_once "{$CFG->dirroot}/mod/rcontent/lib.php"; $dat_result = $ResultadoExtendido->Resultado; $status = isset($dat_result->Estado) ? $dat_result->Estado : "FINALIZADO"; $instance->status = TiposEstado::Tipos($status); $instance->comments = isset($dat_result->Observaciones) ? $dat_result->Observaciones : ""; $instance->mingrade = isset($dat_result->MinCalificacion) ? $dat_result->MinCalificacion : 0; $instance->maxgrade = isset($dat_result->MaxCalificacion) ? $dat_result->MaxCalificacion : 100; $instance->attempt = isset($dat_result->Intentos) ? $dat_result->Intentos : 1; $instance->maxattempts = isset($dat_result->MaxIntentos) ? $dat_result->MaxIntentos : 1; if (isset($dat_result->Calificacion)) { $instance->grade = $dat_result->Calificacion; } if (isset($dat_result->FechaHoraInicio)) { $instance->starttime = $dat_result->FechaHoraInicio; } if (isset($dat_result->Duracion)) { $instance->totaltime = $dat_result->Duracion; } if (isset($dat_result->MaxDuracion)) { $instance->maxtotaltime = $dat_result->MaxDuracion; } if (isset($dat_result->URLVerResultados)) { $instance->urlviewresults = $dat_result->URLVerResultados; } $select = array('userid' => $instance->userid, 'rcontentid' => $instance->rcontentid, 'unitid' => $instance->unitid, 'activityid' => $instance->activityid, 'attempt' => $instance->attempt); if (!($rcont_gradeid = $DB->get_field('rcontent_grades', 'id', $select))) { $instance->timecreated = $instance->timemodified; $rcont_gradeid = $DB->insert_record('rcontent_grades', $instance); } else { $instance->id = $rcont_gradeid; $DB->update_record('rcontent_grades', $instance); } rcontent_update_grades($rcontent, $USER->id); if (!$rcont_gradeid) { return generate_error("GuardarGrades", "", "ResultadoDetalleExtendido", $cm->id); } } // Save details if (isset($ResultadoExtendido->Detalles)) { $detalles = $ResultadoExtendido->Detalles; if (is_array($detalles)) { $detalles = array_shift($detalles); } } if (isset($detalles) && isset($detalles->DetalleResultado)) { $detalles_resultado = $detalles->DetalleResultado; if (!is_array($detalles_resultado)) { $detalles_resultado = array($detalles_resultado); } foreach ($detalles_resultado as $detalle) { $instance = new stdClass(); $instance->userid = $ResultadoExtendido->idUsuario; $instance->rcontentid = $ResultadoExtendido->idContenidoLMS; $instance->unitid = $unidadid; $instance->activityid = $actividadid; $instance->timemodified = time(); $instance->mingrade = isset($detalle->MinCalificacion) ? $detalle->MinCalificacion : 0; $instance->maxgrade = isset($detalle->MaxCalificacion) ? $detalle->MaxCalificacion : 100; $instance->attempt = isset($detalle->Intentos) ? $detalle->Intentos : 1; $instance->maxattempts = isset($detalle->MaxIntentos) ? $detalle->MaxIntentos : 1; $instance->typeid = isset($detalle->IdTipoDetalle) ? strtoupper($detalle->IdTipoDetalle) : 'PREGUNTA'; $instance->weight = isset($detalle->Peso) ? $detalle->Peso : 1; if (isset($detalle->Calificacion)) { $instance->grade = $detalle->Calificacion; } if (isset($detalle->FechaHoraInicio)) { $instance->starttime = $detalle->FechaHoraInicio; } if (isset($detalle->Duracion)) { $instance->totaltime = $detalle->Duracion; } if (isset($detalle->MaxDuracion)) { $instance->maxtotaltime = $detalle->MaxDuracion; } if (isset($detalle->IdDetalle)) { $instance->code = $detalle->IdDetalle; } if (isset($detalle->Descripcion)) { $instance->description = $detalle->Descripcion; } if (isset($detalle->URLVerResultados)) { $instance->urlviewresults = $detalle->URLVerResultados; } $select = array('userid' => $instance->userid, 'rcontentid' => $instance->rcontentid, 'unitid' => $instance->unitid, 'activityid' => $instance->activityid, 'code' => $instance->code, 'attempt' => $instance->attempt); if (!($rcont_gradeid = $DB->get_field('rcontent_grades_details', 'id', $select))) { $instance->timecreated = $instance->timemodified; $rcont_gradeid = $DB->insert_record('rcontent_grades_details', $instance); } else { $instance->id = $rcont_gradeid; $DB->update_record('rcontent_grades_details', $instance); } if (!$rcont_gradeid) { return generate_error("GuardarGradesDetail", "", "ResultadoDetalleExtendido", $cm->id); } } } } catch (Exception $e) { return generate_error($e->getMessage(), "", "ResultadoDetalleExtendido", $cm->id); } $ret2 = new ResultadoDetalleExtendidoResponse(); $ret2->setOK(); return $ret2; }