/** * Page handler for embeds * * @param array $page */ function embed_page_handler($page) { $params = array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array())); $container_guid = get_input('container_guid'); if ($container_guid && get_entity($container_guid)) { elgg_set_page_owner_guid($container_guid); } switch ($page[0]) { default: case 'tab': $default_tab = elgg_is_active_plugin('file') ? 'file' : 'content_items'; $embed_tab = elgg_extract(1, $page, $default_tab); $title = elgg_echo("embed:embed"); $filter = elgg_view('embed/filter', array('filter_context' => $embed_tab)); $view = "embed/tab/{$embed_tab}"; if (elgg_view_exists($view)) { $content = elgg_view($view); } else { $embed_tab = elgg_get_config('embed_tab'); if ($embed_tab instanceof \ElggMenuItem) { $view = $embed_tab->getData('view'); $options = $embed_tab->getData('options'); if ($view) { $content = elgg_view($view); } else { if ($options) { $content = elgg_view('embed/get_list', array('options' => $options)); } } } } if (empty($content)) { $content = elgg_autop(elgg_echo('embed:section:invalid')); } $params['output'] = elgg_view_layout('one_column', array('title' => $title, 'content' => $filter . $content, 'class' => 'embed-wrapper')); break; } $system_messages = system_messages(NULL, ""); if (isset($system_messages['success'])) { $params['system_messages']['success'] = $system_messages['success']; } if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; } // We do not want to serve this page via non-xhr requests if (!elgg_is_xhr()) { register_error(elgg_echo('embed:error:non_xhr_request')); return false; } echo json_encode($params); exit; }
function CheckLTIUser($user_id) { // Check that user_id is present; if not all we can do is forward // to login page if (empty($user_id)) { system_messages(elgg_echo('LTI:info:noid')); forward(); } // Is there a user with username $user_id $user = get_user_by_username($user_id); if (!empty($user->username)) { return $user; } // No such user return null; }
<?php /* * Create a new backup file */ elgg_load_library("backup_tool"); $backup_file_name = get_input("file"); if (backup_tool_restore_backup(array("file_name" => $backup_file_name))) { system_messages(elgg_echo("backup-tool:restore:success", array($filename))); } else { register_error(elgg_echo("backup-tool:restore:fail")); } forward(REFERRER);
/** * Show the edit match form */ function loadEditMatchForm() { global $db, $_pre; if (!isset($_GET['m_id'])) { system_messages(0, 'No match given'); return; } if ($_GET['m_id'] == 'none') { system_messages(0, 'Please select a match to edit'); return; } $match_id = $_GET['m_id']; settype($match_id, 'integer'); $query = "SELECT * FROM {$_pre}matches WHERE id={$match_id} ORDER BY start_time DESC"; $db->setQuery($query); if ($db->foundRows == 0) { system_messages(0, 'No such match!'); return; } $row = $db->fetch_assoc(); ?> <span class="dark10">Editing CodeZone match <?php echo "{$match_id} .::. {$row['title']}"; ?> </span><br /> <form class='admin-panel-form' name='global-conf' method='POST' action='index.php?a=su&a1=edit-match-details'> <table class='admin-panel-forms-table' cellpadding="2" cellspacing="2" border="0"> <tr><td class='form-field-label'><span class='form-field-label-text'>Match Name</span></td> <td><input type="text" name="edm-title" class="admin-panel-text-input" value="<?php echo $row['title']; ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Match duration (sec)</span></td><td><input type="text" name="edm-duration" class="admin-panel-text-input" value="<?php echo $row['duration']; ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Start date (yyyy-mm-dd)</span></td><td><input type="text" name="edm-start_date" class="admin-panel-text-input" value="<?php echo get_date($row['start_time']); ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Start time (hh:mm:ss)</span></td><td><input type="text" name="edm-start_time" class="admin-panel-text-input" value="<?php echo get_time($row['start_time']); ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Difficulty</span></td><td><input type="text" name="edm-difficulty" class="admin-panel-text-input" value="<?php echo $row['difficulty']; ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Match points</span></td><td><input type="text" name="edm-match_points" class="admin-panel-text-input" value="<?php echo $row['match_points']; ?> "/></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Ranked match</span></td><td>Yes <input type="radio" name="edm-ranked_match" value="1" <?php if ($row['match_ranked'] == 1) { echo "checked='true'"; } ?> /> No <input type="radio" name="edm-ranked_match" value="0" <?php if ($row['match_ranked'] == 0) { echo "checked='true'"; } ?> /></td></tr> <tr><td class='form-field-label'><span class='form-field-label-text'>Analysis <i>(Allowed tags are: <p>,<a>,<strong>,<i>,<br>. To highlight code blocks enclose the code in a div tag with class code_block e.g <div class="code_block"><pre>echo CONSTANT;</pre></div></i></span></td><td><textarea name="edm-analysis" class="admin-panel-textarea" style="width:400px;" rows="15" cols="45"><?php echo stripslashes($row['analysis']); ?> </textarea></td></tr> <tr><td><input type="hidden" name="adm" value="<?php echo base64_encode('su'); ?> " /><input type="hidden" name="f" value="<?php echo base64_encode('edit_match'); ?> " /><input type="hidden" name="m_id" value="<?php echo base64_encode($match_id); ?> " /></td><td><input type="submit" name="save" class="admin-panel-submit-button" value="save" /> <input type="submit" name='delete_match' class="admin-panel-submit-button" value='Delete this match?' class="admin-panel-submit-button" onclick="return confirm('WARNING: Are you sure you want to delete this match? this action cannot be reversed!!');" /></td></tr> </table> </form> <br /> <br /> <?php $query = "SELECT COUNT(*) FROM {$_pre}{$row['match_table_name']} WHERE 1"; $db->setQuery($query); $tmp_row = $db->fetch_assoc(); $st_total_registered = $tmp_row['COUNT(*)']; //Total users registered for the match $query = "SELECT * FROM {$_pre}user_match_log WHERE match_id={$row['id']} AND participated=1"; $db->setQuery($query); $st_total_participated = $db->foundRows; $query = "SELECT SUM(downloads_count) FROM {$_pre}{$row['match_table_name']} WHERE 1"; $db->setQuery($query); $tmp_row = $db->fetch_assoc(); $st_downloads = $tmp_row['SUM(downloads_count)']; $query = "SELECT SUM(submissions) FROM {$_pre}{$row['match_table_name']} WHERE 1"; $db->setQuery($query); $tmp_row = $db->fetch_assoc(); $st_submissions = $tmp_row['SUM(submissions)']; ?> <span class="navy10">Match Statistics</span> <ul> <li><span class="form-field-label-text">Total Registered Users for this match: </span><span class="green10"><?php echo $st_total_registered; ?> </span></li> <li><span class="form-field-label-text">Total Registered Users who participated: </span><span class="green10"><?php echo $st_total_participated; ?> </span></li> <li><span class="form-field-label-text">Total Registered Users who did not participate: </span><span class="green10"><?php echo $st_total_registered - $st_total_participated < 0 ? 0 : $st_total_registered - $st_total_participated; ?> </span></li> <li><span class="form-field-label-text">Total Input file downloads: </span><span class="green10"><?php echo $st_downloads; ?> </span></li> <li><span class="form-field-label-text">Total Submissions: </span><span class="green10"><?php echo $st_submissions; ?> </span></li> </ul> <button id="show_problem_st" class="admin-panel-button" value="hidden" onclick="showProblemToggle('<?php echo $row['match_table_name']; ?> ','<?php echo $row['problem_sheet']; ?> ');">Show/Hide problem sheet</button> <button class="admin-panel-button" onclick="downloadSheet('<?php echo $row['match_table_name']; ?> ','<?php echo $row['input_sheet']; ?> ','input');">Download input sheet</button> <button class="admin-panel-button" onclick="downloadSheet('<?php echo $row['match_table_name']; ?> ','<?php echo $row['answer_sheet']; ?> ','answer');">Download answer sheet</button> <div id="problem_statement_view"></div><!--render problem statement here--> <iframe id="sheet_download" src="" style="display: none;" /><!--Frame whose src is changed by JS to trigger download--> <?php }
<link type="text/css" media="screen" rel="stylesheet" href="theme/jquery.colorbox/colorbox.css" /> <script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <script src="js/jquery.countdown.min.js" type="text/javascript"></script> <script src="js/countdown.custom.js" type="text/javascript"></script> <script src="js/server.time.js" type="text/javascript"></script> <?php //Check if there's an active match if (!$arn->active_match()) { system_messages(0, "There is no active match"); return; } //Check if user logged in i.e to entice him/her to login if (!$login) { system_messages(0, "To participate in the arena, you must login"); return; } //Initialize arena validation require_once 'ajphp' . DS . 'arenaValidatorHelper.php'; $arnv = new arenaValidatorHelper(time(), $_pre, $db, $arn, $_max_submissions, $_submission_timeout); //Is this user registered...? if (!$arnv->isUserRegistered() && !$su) { system_messages(0, 'You are not registered to participate in this match'); return; } //Set participated column to 1 in user_match_log table $arn->set_participate(); /** There's an active match... Now we need to render the match arena ie. the problem statement plus the relevant ajax scripts to handle data transfer, countdown timing, scoreboard refreshes ... */ $arn->render_arena(); }
/** * Assembles and outputs a full page. * * A "page" in Elgg is determined by the current view type and * can be HTML for a browser, RSS for a feed reader, or * Javascript, PHP and a number of other formats. * * @param string $title Title * @param string $body Body * @param string $page_shell Optional page shell to use. See page/shells view directory * @param array $vars Optional vars array to pass to the page * shell. Automatically adds title, body, and sysmessages * * @return string The contents of the page * @since 1.8 */ function elgg_view_page($title, $body, $page_shell = 'default', $vars = array()) { $messages = null; if (count_messages()) { // get messages - try for errors first $messages = system_messages(NULL, "error"); if (count($messages["error"]) == 0) { // no errors so grab rest of messages $messages = system_messages(null, ""); } else { // we have errors - clear out remaining messages system_messages(null, ""); } } $vars['title'] = $title; $vars['body'] = $body; $vars['sysmessages'] = $messages; // check for deprecated view if ($page_shell == 'default' && elgg_view_exists('pageshells/pageshell')) { elgg_deprecated_notice("pageshells/pageshell is deprecated by page/{$page_shell}", 1.8); global $CONFIG; $vars['config'] = $CONFIG; $output = elgg_view('pageshells/pageshell', $vars); } else { $output = elgg_view("page/{$page_shell}", $vars); } $vars['page_shell'] = $page_shell; // Allow plugins to mod output return elgg_trigger_plugin_hook('output', 'page', $vars, $output); }
//You can add more than one receipients. $formproc->AddRecipient($email); //<<---Put your email address here //2. For better security. Get a random tring from this link: http://tinyurl.com/randstr // and put it here $formproc->SetFormRandomKey('CnRrspl1FyEylUj'); $formproc->AddFileUploadField('photo', 'jpg,jpeg,gif,png,pdf,doc,docx,rar.zip,', 5120); // Get post_max_size and upload_max_filesize $post_max_size = elgg_get_ini_setting_in_bytes('post_max_size'); $upload_max_filesize = elgg_get_ini_setting_in_bytes('upload_max_filesize'); // Determine the correct value $max_upload = $upload_max_filesize > $post_max_size ? $post_max_size : $upload_max_filesize; $upload_limit = elgg_echo('file:upload_limit', array(elgg_format_bytes($max_upload))); if (isset($_POST['submitted'])) { if ($formproc->ProcessForm()) { system_messages(elgg_echo('contactform:thankyoumsg')); forward("mod/contactform"); // forward(elgg_get_site_url()); } } ?> <script type='text/javascript' src='scripts/gen_validatorv31.js'></script> <script> $(document).ready(function (){ $("#reason").change(function() { // foo is the id of the other select box if ($(this).val() == "Autres$Other") { $("#subject").show(); }else{
<?php $messages = null; if (count_messages()) { // get messages - try for errors first $messages = system_messages(NULL, 'error'); if (count($messages['error']) == 0) { // no errors so grab rest of messages $messages = system_messages(null, ''); } else { // we have errors - clear out remaining messages system_messages(null, ''); } } $type = elgg_extract('type', $vars, 'view'); $entity = elgg_extract('entity', $vars); echo elgg_view_menu('newsletter_buttons', ['entity' => $entity, 'type' => $type, 'class' => 'newsletter-buttons', 'sort_by' => 'priority']); echo elgg_view('page/elements/messages', ['object' => $messages]); echo elgg_format_element('style', ['type' => 'text/css'], elgg_view('css/newsletter/buttons.css')); elgg_load_css('newsletter_buttons');
/** * Catch calls to forward() in ajax request and force an exit. * * Forces response is json of the following form: * <pre> * { * "current_url": "the.url.we/were/coming/from", * "forward_url": "the.url.we/were/going/to", * "system_messages": { * "messages": ["msg1", "msg2", ...], * "errors": ["err1", "err2", ...] * }, * "status": -1 //or 0 for success if there are no error messages present * } * </pre> * where "system_messages" is all message registers at the point of forwarding * * @param string $hook * @param string $type * @param string $reason * @param array $params * */ function ajax_forward_hook($hook, $type, $reason, $params) { if (elgg_is_xhr()) { //grab any data echo'd in the action $output = ob_get_clean(); //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { $params['output'] = $json; } else { $params['output'] = $output; } //Grab any system messages so we can inject them via ajax too $params['system_messages'] = system_messages(NULL, ""); if (isset($params['system_messages']['error'])) { $params['status'] = -1; } else { $params['status'] = 0; } header("Content-type: application/json"); echo json_encode($params); exit; } }
<?php /* * Do the redirect to previous trip * * Plugin: myTripsTeranga from previous version of @package ElggGroup * Author: Rosana Montes Soldado * Universidad de Granada * Licence: CC-ByNCSA * Reference: Microproyecto CEI BioTIC Ref. 11-2015 * Project coordinator: @rosanamontes * Website: http://lsi.ugr.es/rosana * Project colaborator: Antonio Moles * * Project Derivative: * TFG: Desarrollo de un sistema de gestión de paquetería para Teranga Go * Advisor: Rosana Montes * Student: Ricardo Luzón Fernández * */ $trip_guid = (int) get_input('trip_guid'); $trip = get_entity($trip_guid); system_messages(elgg_echo('mytrips:manageOrders:saved')); forward($trip->getUrl());
defined('IN_APP') or die('Restricted Access!'); ?> <?php if ($expire) { system_messages(0, "Session expired, Please login again!"); } if ($reg_pass_no) { system_messages(0, "Reg No and password did not match"); } if ($acc_active) { system_messages(2, "Please activate this account to access CodeZone"); } if ($acc_disabled) { system_messages(2, "Your account has been disabled by CodeZone. Please contact an administrator"); } if ($login_notify) { system_messages(1, "Thank you for logging in {$user_row_data['nick_name']}"); } if ($logout_notify) { system_messages(1, "You are logged out, Bye bye!"); } if ($request_expired) { system_messages(0, "Request expired, please try again!"); } if ($request_toofast) { system_messages(0, 'Request too fast, Slow down and try again!'); } ?>
<?php $schedule_action = get_input("schedule-action"); $enable_schedule = get_input("enable-schedule"); $schedule_period = get_input("schedule-period"); $schedule_delete = get_input("schedule-delete"); $backup_options = get_input("backup_options"); $ftp_enable = get_input("ftp-enable", false); $ftp = get_input("ftp", false); if (!$backup_options) { register_error(elgg_echo('backup-tool:settings:error:backup_options')); } else { elgg_set_plugin_setting('backup_options', serialize($backup_options), 'backup-tool'); if ($schedule_action == elgg_echo("backuptool:schedule:button:enable")) { $enable_schedule = true; elgg_set_plugin_setting('enable_schedule', $enable_schedule, 'backup-tool'); system_messages(elgg_echo("backup-tool:settings:success:enable")); } elseif ($schedule_action == elgg_echo("backuptool:schedule:button:disable")) { $enable_schedule = false; elgg_set_plugin_setting('enable_schedule', $enable_schedule, 'backup-tool'); system_messages(elgg_echo("backup-tool:settings:success:disable")); } else { system_messages(elgg_echo("backup-tool:settings:success")); } elgg_set_plugin_setting('schedule_period', $schedule_period, 'backup-tool'); elgg_set_plugin_setting('schedule_delete', $schedule_delete, 'backup-tool'); //save ftp settings elgg_set_plugin_setting('ftp_enable', $ftp_enable[0], 'backup-tool'); elgg_set_plugin_setting('ftp', serialize($ftp), 'backup-tool'); }
| links clicked on the frontpage | | | *----------------------------------------------------------* */ //Is in application...? defined('IN_APP') or die('Restricted access'); if ($action == 'showstory') { if (!isset($_GET['s_id'])) { system_messages(0, 'Requested story unknown'); return; } $story_id = (int) $_GET['s_id']; $query = "SELECT {$_pre}stories.*,{$_pre}users.nick_name FROM {$_pre}stories LEFT JOIN {$_pre}users ON {$_pre}stories.registration_no = {$_pre}users.registration_no WHERE {$_pre}stories.published=1 AND {$_pre}stories.id={$story_id}"; $db->setQuery($query); if ($db->foundRows < 1) { system_messages(0, 'Invalid story requested'); return; } $data = $db->fetch_assoc(); ?> <h3 class='arena-match-title'>Title:: <?php echo ucfirst($data['title']); ?> </h3> <hr class='h3-bottom-line' /> <div id="showstories"> <?php echo stripslashes(preg_replace("/<rmore>/", "", $data['content'])); //Remove the read more tag and strip any splashes echo "<p class='article_details'><span class='light1'>" . time_stamp_to_readable($data['create_time']) . "</span> .::. Author: <span class='admin_orange'>{$data['nick_name']}</span></p>"; //Get next and previous stories if any
/** * Render the arena */ function render_arena() { global $arnv, $_max_submissions; $match_details = $this->get_match_details(); //Verify if there's actually an active match if (!$match_details) { system_messages(0, "There is no active match or match over"); return; } //Compute remaining time $seconds_rem = $match_details['start_time'] + $match_details['duration'] - time(); ?> <div id="arena-applet-container"> <div id="arena-applet-left"> <?php echo "<h3 class='arena-match-title'>Problem Statement ..::.. " . strtoupper($match_details['title']) . "</h3>"; echo "<hr class='h3-bottom-line' />"; echo "<p class='arena-match-subtitle'>Maximum points: {$match_details['match_points']} .::. Difficulty: {$match_details['difficulty']} .::. Max downloads allowed: {$_max_submissions}</p>"; ?> <div id="match-rem-time" align="right"> <!--Match remaining time--> </div> <?php /**Only show the downloads link if there is remaining downloads*/ if ($arnv->downloads_over()) { echo "<h4 class='contact-link'><a class='load-iframe' title='CodeZone solution submission' href='ajphp/arenaValidator.php?a=arenaval&v=render_submission_form'>Submit solution</a></h4>"; } //Print the problem Statement $this->print_problem(); ?> </div> <div id="arena-applet-right"> <span class='arena-general'>Live Scoreboard</span> <!--Live scoreboard goes here--> <div id="live-scoreboard"></div> </div> <div id="clear"></div> </div> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({ cache:false });$(".load-iframe").colorbox({width:"60%", height:"45%", iframe:true,overlayClose:false}); var seconds=<?php echo $seconds_rem; ?> ; //Show match remaining time $(function(){ $('#match-rem-time').countdown({ layout:"<span class='timer-rem-time'>Remaining time: {hnn} {hl}, {mnn} {ml}, {snn} {sl}</span>",until:+seconds, serverSync:serverTime,onExpiry:function(){alert('Match over!');window.location.href='index.php';}}); }); }); //Code to load scoreboard every 30 seconds $('#live-scoreboard').load('ajphp/arenaValidator.php?a=arenaval&v=partial_scoreboard'); //Load it for the first time on page load setInterval(function(){ $('#live-scoreboard').load('ajphp/arenaValidator.php?a=arenaval&v=partial_scoreboard'); }, 30000); </script> <?php }
function doContentHandler($tool_provider) { LoginUser($tool_provider); system_messages('Forwarded to Group creation page'); forward(elgg_get_config('wwwroot') . '/groups/new/'); return; }
/** * Save offserver video after getting responese from YouTube * * @version 5.0 */ function izap_youtube_response() { $id = get_input('id'); $url = 'https://www.youtube.com/watch?v=' . $id; $video_data = array('url' => $url); $izap_video = new IzapVideo(); if ($izap_video->guid == 0) { $new = true; } $izap_video->videourl = $url; $izap_video->saveYouTubeVideoData($video_data); if ($izap_video->save()) { if ($new == true) { if (is_callable('elgg_create_river_item')) { elgg_create_river_item(array('view' => 'river/object/izap_video/create', 'action_type' => 'create', 'subject_guid' => elgg_get_logged_in_user_guid(), 'object_guid' => $izap_video->getGUID())); } else { add_to_river('river/object/izap_video/create', 'create', elgg_get_logged_in_user_guid(), $izap_video->getGUID()); } } elgg_clear_sticky_form('izap_videos'); system_messages(elgg_echo('izap-videos:Save:success')); forward($izap_video->getURL($izap_video->getOwnerEntity(), GLOBAL_IZAP_VIDEOS_PAGEHANDLER)); } }
/** * @param int $amount * @param string $profile * @param string $locale * @throws InvalidArgumentException * @return int */ static function generate($amount, $profile, $locale) { $amount = (int) $amount; if ($amount <= 0) { throw new InvalidArgumentException("Amount must be positive integer."); } if (!in_array($profile, data_generator::getElggProviderMethods())) { throw new InvalidArgumentException("Invalid profile provided: {$profile}"); } if (!in_array($locale, data_generator::getLocales())) { throw new InvalidArgumentException("Invalid locale provided: {$locale}"); } $totalAmount = $amount; $mt = microtime(true); $time = null; $generator = self::getGenerator($locale); $success = 0; $processed = 0; while ($amount-- > 0) { $processed++; $data = $generator->{$profile}(); try { if (is_callable(array($data, 'save'))) { if ($data->save()) { $success++; } else { if (self::is_cli()) { //clear line echo "\t\t\t\t\t\t\t\t\t\r"; echo "Fail: Error while saving\n"; $messages = system_messages(NULL, "error"); echo "Msgs: " . var_export($messages['error'], true) . "\n"; } } } else { if (self::is_cli()) { //clear line echo "\t\t\t\t\t\t\t\t\t\r"; echo "Fail: Not saveable item: " . var_export($data, true) . "\n"; } } } catch (Exception $e) { if (self::is_cli()) { //clear line echo "\t\t\t\t\t\t\t\t\t\r"; echo "Fail: " . $e->getMessage() . "\n"; } //fail silently here - just count } if (self::is_cli()) { if ($time === null || time() > $time + self::$cli_info_interval) { $time = time(); echo sprintf("%.2f%% - %d items generated, %d failures in %.2fs\r", ($totalAmount - $amount) * 100 / $totalAmount, $success, $processed - $success, microtime(true) - $mt); } } } if (self::is_cli()) { //clear line echo "\t\t\t\t\t\t\t\t\t\r"; } return $success; }
function ProvisionLTIGroup($tool_provider) { // Get status of group provisining $values = GetPluginSettings(); $groupprovision = $values['groupprovision']; $groupname = $tool_provider->context->title; // Get context_id and consumer_key for primary context $context_id = $tool_provider->context->id; $consumer_key = $tool_provider->context->consumer_instance->consumer_guid; $user_id = $tool_provider->user->getID(BasicLTI_Tool_Provider::ID_SCOPE_GLOBAL); // Check if we are dealing with an unapproved share. If so return // to consumer with suitable message if (!empty($tool_provider->user->context->share_approved) && !$tool_provider->user->context->share_approved) { $urlencode = urlencode(sprintf(elgg_echo('LTI:error:sharing'), elgg_get_config('sitename'))); forward($tool_provider->return_url . '<i_msg=' . $urlencode); return false; } // Get user $user = CheckLTIUser($user_id); $user_guid = $user->getGUID(); $_SESSION['lti_logger_id'] = $user->getGUID(); $staff = $tool_provider->user->isStaff(); // Check that groups are present and provisioning is on if (elgg_is_active_plugin('groups') && $groupprovision) { $group = CheckLTIGroup($groupname, $context_id, $consumer_key); // Only staff can create groups. if ($staff && is_null($group)) { $group = CreateLTIGroup($user, $groupname, $context_id, $consumer_key); // Ensure that the owner is instructor as simpifies matters add_entity_relationship($user_guid, 'instructor', $group->getGUID()); system_message(elgg_echo('LTI:info:newgroup')); forward($group->getURL()); } if (is_null($group)) { system_messages(elgg_echo('LTI:info:nogroup')); forward(); } $group_guid = $group->getGUID(); $_SESSION['lti_group_id'] = $group->getGUID(); // Is this user a member of the group if ($group->isMember($user)) { // If user used to be instructor but is now student remove 'instructor' relationship if ($tool_provider->user->isLearner() && check_entity_relationship($user_guid, 'instructor', $group_guid)) { remove_entity_relationship($user_guid, 'instructor', $group->getGUID()); system_messages(elgg_echo('LTI:change:downgrade')); forward($group->getURL()); } // If user is staff add instructor relationship unless they are group owner if ($staff && !check_entity_relationship($user_guid, 'instructor', $group_guid) && $user_guid != $group_guid) { add_entity_relationship($user_guid, 'instructor', $group_guid); system_messages(elgg_echo('LTI:change:upgrade')); forward($group->getURL()); } system_messages('Forwarded to Group'); forward($group->getURL()); } // If not member join $group->join($user); // If instructor but not owner give instructor relationship to group. This makes // other consumer instructors able to edit the group in Elgg if ($staff && !check_entity_relationship($user_guid, 'instructor', $group_guid)) { add_entity_relationship($user_guid, 'instructor', $group_guid); system_messages(elgg_echo('LTI:change:upgrade')); forward($group->getURL()); } system_messages('Forwarded to Group'); forward($group->getURL()); } }
| | *----------------------------------------------------------* */ //Is in application...? defined('IN_APP') or die('Restricted access'); if ($action == 'profile') { if (isset($_GET['do'])) { $do = $_GET['do']; } else { system_messages(2, 'Invalid arguments in query'); return; } $handle = ''; if (isset($_GET['nick_name'])) { $handle = $_GET['nick_name']; } //Get the profileHelper class require_once 'profileHelper.php'; $profile = new profileHelper($handle); if ($do == 'viewProfile') { $profile->view_profile(); } else { if ($do == 'updateProfile' && $login) { //Allow profile update only if user is logged in $profile->update_profile_fields(); } else { system_messages(2, 'Invalid arguments in query'); } } //print_r($profile); }
//Is the requested match valid? if ($db->foundRows < 1) { system_messages(2, 'Invalid match requested'); return; } $match_data = $db->fetch_assoc(); //Is the requested match still active? if ($match_data['start_time'] < time()) { system_messages(0, 'Match is inactive'); return; } $query = "SELECT * FROM {$_pre}{$match_data['match_table_name']} WHERE registration_no='{$registration_no}'"; $db->setQuery($query); //Is this user already registered? if ($db->foundRows > 0) { system_messages(0, 'You are already registered for this match!'); return; } //Now we can safely register this user (fun..) $query = "INSERT INTO {$_pre}{$match_data['match_table_name']} (registration_no,nick_name) VALUES ('{$registration_no}','{$nick_name}')"; $db->setQuery($query); //Update profile table that is, match_count column and add the user to user_match_log table $query = "SELECT match_count FROM " . $_pre . "profile WHERE registration_no='{$registration_no}'"; $db->setQuery($query); $data = $db->fetch_assoc(); $new_match_count = $data['match_count'] + 1; //$matches_participated=(strlen($data['matches_participated'])==0)?$match_data['id'].'---'.$match_data['title']:$data['matches_participated'].'*****'.$match_data['id'].'---'.$match_data['title']; $query = "UPDATE " . $_pre . "profile SET match_count={$new_match_count} WHERE registration_no='{$registration_no}'"; $db->setQuery($query); $query = "INSERT INTO {$_pre}user_match_log (registration_no,match_id,title,match_date,register_date) VALUES ('{$registration_no}',{$match_data['id']},'{$match_data['title']}',{$match_data['start_time']}," . time() . ")"; $db->setQuery($query);
/** * Catch calls to forward() in ajax request and force an exit. * * Forces response is json of the following form: * <pre> * { * "current_url": "the.url.we/were/coming/from", * "forward_url": "the.url.we/were/going/to", * "system_messages": { * "messages": ["msg1", "msg2", ...], * "errors": ["err1", "err2", ...] * }, * "status": -1 //or 0 for success if there are no error messages present * } * </pre> * where "system_messages" is all message registers at the point of forwarding * * @param string $hook * @param string $type * @param string $reason * @param array $params * @return void * @access private */ function ajax_forward_hook($hook, $type, $reason, $params) { if (elgg_is_xhr()) { // always pass the full structure to avoid boilerplate JS code. $params = array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array())); //grab any data echo'd in the action $output = ob_get_clean(); //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { $params['output'] = $json; } else { $params['output'] = $output; } //Grab any system messages so we can inject them via ajax too $system_messages = system_messages(NULL, ""); if (isset($system_messages['success'])) { $params['system_messages']['success'] = $system_messages['success']; } if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; } // Check the requester can accept JSON responses, if not fall back to // returning JSON in a plain-text response. Some libraries request // JSON in an invisible iframe which they then read from the iframe, // however some browsers will not accept the JSON MIME type. if (stripos($_SERVER['HTTP_ACCEPT'], 'application/json') === FALSE) { header("Content-type: text/plain"); } else { header("Content-type: application/json"); } echo json_encode($params); exit; } }
$files_array = $_FILES['image']; $entity_id = $_POST['entity_id']; $entity_field = $_POST['entity_field']; $entity = get_entity($entity_id); if (false == $entity->canEdit()) { register_error(elgg_echo('gallery_field:cant_edit')); forward(REFERRER); } $image_ids = gallery_field_image_ids_from_value($entity->{$entity_field}); $count_added = 0; for ($i = 0; $i < count($files_array['tmp_name']); $i++) { if (false == in_array($files_array['type'][$i], array("image/jpeg", "image/jpg"))) { if (strlen($files_array['type'][$i]) == 0) { register_error(elgg_echo("gallery_field:max_upload_exceed")); } else { register_error(elgg_echo("gallery_field:only_jpg")); } continue; } $file = \GalleryFieldImage::createFromFile($files_array['tmp_name'][$i], $files_array['type'][$i]); if ($file == null) { continue; } $file->entity_id = $entity_id; $file->save(); array_unshift($image_ids, $file->guid); $count_added++; } $entity->{$entity_field} = implode(",", $image_ids); system_messages(elgg_echo("gallery_field:files_uploaded") . ": " . $count_added); forward($_SERVER['HTTP_REFERER'] . "#editor_" . $entity_field);
| | *----------------------------------------------------------* */ //Is in application...? defined('IN_APP') or die('Restricted access'); if (@$action == 'activate') { $registration_no = base64_decode(@$_GET['r']); $key = @$_GET['k']; //Check if account has been previosly activated $query = "SELECT * FROM " . $_pre . "users WHERE registration_no='{$registration_no}' AND activated=1"; $db->setQuery($query); if ($db->foundRows > 0) { system_messages(2, 'Your account is already active, please use it constructively'); return; } //Check if the account is waiting activation ie activate==2 $query = "SELECT * FROM " . $_pre . "users WHERE registration_no='{$registration_no}' AND activated=2"; $db->setQuery($query); if ($db->foundRows == 0) { system_messages(0, "This account is non-existent or is already being used by somebody else, Please contact the admin if you continue experiencing this problem"); return; } //Activate account $query = "UPDATE " . $_pre . "users SET activated=1 WHERE registration_no='{$registration_no}' AND activation_key='{$key}'"; $db->setQuery($query); if ($db->affectedRows == 0) { system_messages(2, 'There is no such an account; Contact admin'); } else { system_messages(1, 'Success! Your CodeZone account is now active...'); } }
/** * @see ajax_forward_hook * @access private */ public function ajaxForwardHook($hook, $reason, $return, $params) { if (elgg_is_xhr()) { // always pass the full structure to avoid boilerplate JS code. $params = array_merge($params, array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array()))); //grab any data echo'd in the action $output = ob_get_clean(); //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { $params['output'] = $json; } else { $params['output'] = $output; } //Grab any system messages so we can inject them via ajax too $system_messages = system_messages(null, ""); if (isset($system_messages['success'])) { $params['system_messages']['success'] = $system_messages['success']; } if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; } $context = array('action' => $this->currentAction); $params = elgg_trigger_plugin_hook('output', 'ajax', $context, $params); // Check the requester can accept JSON responses, if not fall back to // returning JSON in a plain-text response. Some libraries request // JSON in an invisible iframe which they then read from the iframe, // however some browsers will not accept the JSON MIME type. $http_accept = _elgg_services()->request->server->get('HTTP_ACCEPT'); if (stripos($http_accept, 'application/json') === false) { header("Content-type: text/plain"); } else { header("Content-type: application/json"); } echo json_encode($params); exit; } }
/** * Assembles and outputs a full page. * * A "page" in Elgg is determined by the current view type and * can be HTML for a browser, RSS for a feed reader, or * Javascript, PHP and a number of other formats. * * For HTML pages, use the 'head', 'page' plugin hook for setting meta elements * and links. * * @param string $title Title * @param string $body Body * @param string $page_shell Optional page shell to use. See page/shells view directory * @param array $vars Optional vars array to pass to the page * shell. Automatically adds title, body, head, and sysmessages * * @return string The contents of the page * @since 1.8 */ function elgg_view_page($title, $body, $page_shell = 'default', $vars = array()) { $params = array(); $params['identifier'] = _elgg_services()->request->getFirstUrlSegment(); $params['segments'] = _elgg_services()->request->getUrlSegments(); array_shift($params['segments']); $page_shell = elgg_trigger_plugin_hook('shell', 'page', $params, $page_shell); $messages = null; if (count_messages()) { // get messages - try for errors first $messages = system_messages(null, "error"); if (count($messages["error"]) == 0) { // no errors so grab rest of messages $messages = system_messages(null, ""); } else { // we have errors - clear out remaining messages system_messages(null, ""); } } $vars['title'] = $title; $vars['body'] = $body; $vars['sysmessages'] = $messages; // head has keys 'title', 'metas', 'links' $head_params = _elgg_views_prepare_head($title); $vars['head'] = elgg_trigger_plugin_hook('head', 'page', $vars, $head_params); $vars = elgg_trigger_plugin_hook('output:before', 'page', null, $vars); // check for deprecated view if ($page_shell == 'default' && elgg_view_exists('pageshells/pageshell')) { elgg_deprecated_notice("pageshells/pageshell is deprecated by page/{$page_shell}", 1.8); $output = elgg_view('pageshells/pageshell', $vars); } else { $output = elgg_view("page/{$page_shell}", $vars); } $vars['page_shell'] = $page_shell; // Allow plugins to modify the output return elgg_trigger_plugin_hook('output', 'page', $vars, $output); }
if (isset($title)) { try { $izap_videos->checkTitle($title); } catch (Exception $e) { register_error($e->getMessage()); forward(REFERRER); } } if (isset($video_url)) { try { $izap_videos->checkUrl($video_url); } catch (Exception $e) { register_error($e->getMessage()); forward(REFERRER); } } $data = array('subtype' => GLOBAL_IZAP_VIDEOS_SUBTYPE, 'title' => $title, 'description' => $description, 'access_id' => (string) $access_id, 'container_guid' => $container_guid, 'tags' => string_to_tag_array($tags), 'videourl' => $video_url, 'videoprocess' => $page_url, 'youtube_cats' => $youtube_cats); if ($izap_videos->saveVideo($data, $new)) { $izap_videos->save(); //create river if new entity if ($new) { if (is_callable('elgg_create_river_item')) { elgg_create_river_item(array('view' => 'river/object/izap_video/create', 'action_type' => 'create', 'subject_guid' => elgg_get_logged_in_user_guid(), 'object_guid' => $izap_videos->getGUID())); } else { add_to_river('river/object/izap_video/create', 'create', elgg_get_logged_in_user_guid(), $izap_videos->getGUID()); } } system_messages(elgg_echo('izap-videos:Save:success')); elgg_clear_sticky_form('izap_videos'); forward($izap_videos->getURL($izap_videos->getOwnerEntity(), GLOBAL_IZAP_VIDEOS_PAGEHANDLER)); }
/** * Reset the password of a given account after a request */ function rpass_make_active() { global $db, $_pre; $registration_no = base64_decode($_GET['r']); $key = $_GET['k']; $password = base64_decode($_GET['p']); $query = "SELECT * FROM {$_pre}users WHERE registration_no='{$registration_no}' AND activation_key='{$key}'"; $db->setQuery($query); if ($db->foundRows < 1) { system_messages(2, 'Invalid account activation request!'); return; } $key = md5(time()); //Set new key $query = "UPDATE {$_pre}users SET password='******',activation_key='{$key}',activated=1 WHERE registration_no='{$registration_no}' LIMIT 1"; $db->setQuery($query); system_messages(1, 'Your password has been reset, You can now proceed to the login page', 'true'); }
/** * Render practice arena */ function render_practice_arena($m_id) { $arnv = $this->arnv; $db = $this->db; $_pre = $this->_pre; $query = "SELECT * FROM " . $_pre . "matches WHERE id={$m_id} AND (start_time+duration)<" . time() . ""; $db->setQuery($query); if ($db->foundRows == 0) { system_messages(2, 'Unable to load practice arena for the requested match'); return; } $md = $db->fetch_assoc(); //Store match details //Get data for partial static scoreboard from the match table $query = "SELECT * FROM " . $_pre . $md['match_table_name'] . " WHERE disqualified=0 ORDER BY points DESC LIMIT 10"; $db->setQuery($query); $coders = array(); while ($row = $db->fetch_assoc()) { array_push($coders, $row); } ?> <div id="arena-applet-container"> <div id="arena-applet-left"> <?php echo "<h3 class='arena-match-title'>....:Practice mode:....</h3>"; echo "<h3 class='arena-match-title'>Problem Statement ..::.. " . strtoupper($md['title']) . "</h3>"; echo "<hr class='h3-bottom-line' />"; echo "<p class='arena-match-subtitle'><i>Unlimited submissions, no source code required!</i></p>"; //Submission button echo "<h4 class='contact-link'><a class='load-iframe' title='CodeZone practice mode solution submission' href='ajphp/practiceValidator.php?a=arenaval&v=render_submission_form&m_id={$md['id']}'>Submit solution</a></h4>"; //Print the problem Statement $this->print_problem($md); ?> </div> <div id="arena-applet-right"> <span class='arena-general'>Scoreboard</span> <!--scoreboard goes here--> <div id="static-scoreboard"></div> <?php $this->static_scoreboard($coders, $md); ?> </div> <div id="clear"></div> </div> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({ cache:false }); $(".load-iframe").colorbox({width:"50%", height:"40%", iframe:true,overlayClose:false}); }); </script> <?php }
/** * Display an error on next page load. * * @see system_messages() * * @param string|array $error Error or errors to add * * @return bool */ function register_error($error) { return system_messages($error, "error"); }
/** * Catch calls to forward() in ajax request and force an exit. * * Forces response is json of the following form: * <pre> * { * "current_url": "the.url.we/were/coming/from", * "forward_url": "the.url.we/were/going/to", * "system_messages": { * "messages": ["msg1", "msg2", ...], * "errors": ["err1", "err2", ...] * }, * "status": -1 //or 0 for success if there are no error messages present * } * </pre> * where "system_messages" is all message registers at the point of forwarding * * @param string $hook * @param string $type * @param string $reason * @param array $params * */ function ajax_forward_hook($hook, $type, $reason, $params) { if (elgg_is_xhr()) { // always pass the full structure to avoid boilerplate JS code. $params = array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array())); //grab any data echo'd in the action $output = ob_get_clean(); //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { $params['output'] = $json; } else { $params['output'] = $output; } //Grab any system messages so we can inject them via ajax too $system_messages = system_messages(NULL, ""); if (isset($system_messages['success'])) { $params['system_messages']['success'] = $system_messages['success']; } if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; } header("Content-type: application/json"); echo json_encode($params); exit; } }