Whoops! There was an error.
core \ exception \ moodle_exception
No guests here! core\exception\moodle_exception thrown with message "No guests here!" Stacktrace: #10 core\exception\moodle_exception in /var/www/html/lib/filelib.php:377 #9 file_get_unused_draft_itemid in /var/www/html/lib/form/filepicker.php:138 #8 MoodleQuickForm_filepicker:toHtml in /var/www/html/lib/pear/HTML/QuickForm/Renderer/Tableless.php:192 #7 HTML_QuickForm_Renderer_Tableless:renderElement in /var/www/html/lib/formslib.php:3503 #6 MoodleQuickForm_Renderer:renderElement in /var/www/html/lib/pear/HTML/QuickForm/element.php:432 #5 HTML_QuickForm_element:accept in /var/www/html/lib/pear/HTML/QuickForm.php:1644 #4 HTML_QuickForm:accept in /var/www/html/lib/formslib.php:2130 #3 MoodleQuickForm:accept in /var/www/html/lib/pear/HTML/QuickForm.php:1687 #2 HTML_QuickForm:toHtml in /var/www/html/lib/pear/HTML/Common.php:445 #1 HTML_Common:display in /var/www/html/lib/formslib.php:1048 #0 moodleform:display in /var/www/html/local/ipemcpd/upload_evidence.php:324
Stack frames (11)
10
core\exception\moodle_exception
/lib/filelib.php377
9
file_get_unused_draft_itemid
/lib/form/filepicker.php138
8
MoodleQuickForm_filepicker toHtml
/lib/pear/HTML/QuickForm/Renderer/Tableless.php192
7
HTML_QuickForm_Renderer_Tableless renderElement
/lib/formslib.php3503
6
MoodleQuickForm_Renderer renderElement
/lib/pear/HTML/QuickForm/element.php432
5
HTML_QuickForm_element accept
/lib/pear/HTML/QuickForm.php1644
4
HTML_QuickForm accept
/lib/formslib.php2130
3
MoodleQuickForm accept
/lib/pear/HTML/QuickForm.php1687
2
HTML_QuickForm toHtml
/lib/pear/HTML/Common.php445
1
HTML_Common display
/lib/formslib.php1048
0
moodleform display
/local/ipemcpd/upload_evidence.php324
/var/www/html/lib/filelib.php
    }
 
    return $data;
}
 
/**
 * Generate a draft itemid
 *
 * @category files
 * @global moodle_database $DB
 * @global stdClass $USER
 * @return int a random but available draft itemid that can be used to create a new draft
 * file area.
 */
function file_get_unused_draft_itemid() {
    global $DB, $USER;
 
    if (isguestuser() or !isloggedin()) {
        // guests and not-logged-in users can not be allowed to upload anything!!!!!!
        throw new \moodle_exception('noguest');
    }
 
    $contextid = context_user::instance($USER->id)->id;
 
    $fs = get_file_storage();
    $draftitemid = rand(1, 999999999);
    while ($files = $fs->get_area_files($contextid, 'user', 'draft', $draftitemid)) {
        $draftitemid = rand(1, 999999999);
    }
 
    return $draftitemid;
}
 
/**
 * Initialise a draft file area from a real one by copying the files. A draft
 * area will be created if one does not already exist. Normally you should
 * get $draftitemid by calling file_get_submitted_draft_itemid('elementname');
 *
 * @category files
 * @global stdClass $CFG
/var/www/html/lib/form/filepicker.php
            return 'default';
        }
    }
 
    /**
     * Returns HTML for filepicker form element.
     *
     * @return string
     */
    function toHtml() {
        global $CFG, $COURSE, $USER, $PAGE, $OUTPUT;
        $id     = $this->_attributes['id'];
        $elname = $this->_attributes['name'];
 
        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        }
        if (!$draftitemid = (int)$this->getValue()) {
            // no existing area info provided - let's use fresh new draft area
            $draftitemid = file_get_unused_draft_itemid();
            $this->setValue($draftitemid);
        }
 
        if ($COURSE->id == SITEID) {
            $context = context_system::instance();
        } else {
            $context = context_course::instance($COURSE->id);
        }
 
        $client_id = uniqid();
 
        $args = new stdClass();
        // need these three to filter repositories list
        $args->accepted_types = $this->_options['accepted_types']?$this->_options['accepted_types']:'*';
        $args->return_types = $this->_options['return_types'];
        $args->itemid = $draftitemid;
        $args->maxbytes = $this->_options['maxbytes'];
        $args->context = $PAGE->context;
        $args->buttonname = $elname.'choose';
        $args->elementid = $id;
/var/www/html/lib/pear/HTML/QuickForm/Renderer/Tableless.php
    function renderElement(&$element, $required, $error)
    {
        // if the element name indicates the end of a fieldset, close the fieldset
        if (   in_array($element->getName(), $this->_stopFieldsetElements)
            && $this->_fieldsetsOpen > 0
           ) {
            $this->_html .= $this->_closeFieldsetTemplate;
            $this->_fieldsetsOpen--;
        }
        // if no fieldset was opened, we need to open a hidden one here to get
        // XHTML validity
        if ($this->_fieldsetsOpen === 0) {
            $this->_html .= $this->_openHiddenFieldsetTemplate;
            $this->_fieldsetsOpen++;
        }
        if (!$this->_inGroup) {
            $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error);
            // the following lines (until the "elseif") were changed / added
            // compared to the default renderer
            $element_html = $element->toHtml();
            if (!is_null($element->getAttribute('id'))) {
                $id = $element->getAttribute('id');
            } else {
                $id = $element->getName();
            }
            if (!empty($id) and !is_a($element, 'MoodleQuickForm_group') and !is_a($element, 'HTML_QuickForm_static')) { // moodle hack
                $html = str_replace('<label', '<label for="' . $id . '"', $html);
                $element_html = preg_replace('#name="' . $id . '#',
                                             'id="' . $id . '" name="' . $id . '',
                                             $element_html,
                                             1);
            }
            $this->_html .= str_replace('{element}', $element_html, $html);
        } elseif (!empty($this->_groupElementTemplate)) {
            $html = str_replace('{label}', $element->getLabel(), $this->_groupElementTemplate);
            if ($required) {
                $html = str_replace('<!-- BEGIN required -->', '', $html);
                $html = str_replace('<!-- END required -->', '', $html);
            } else {
                $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html);
/var/www/html/lib/formslib.php
            }
        } else {
            if ($this->_inGroup) {
                $this->_groupElementTemplate = $html;
            }
        }
        if (($this->_inGroup) and !empty($this->_groupElementTemplate)) {
            $this->_groupElementTemplate = $html;
        } else if (!isset($this->_templates[$element->getName()])) {
            $this->_templates[$element->getName()] = $html;
        }
 
        // Check if the element should be displayed in the sticky footer.
        if ($element->getName() && ($this->_stickyfooterelement == $element->getName())) {
            $stickyfooter = new core\output\sticky_footer($html);
            $html = $OUTPUT->render($stickyfooter);
        }
 
        if (!$fromtemplate) {
            parent::renderElement($element, $required, $error);
        } else {
            if (in_array($element->getName(), $this->_stopFieldsetElements) && $this->_fieldsetsOpen > 0) {
                $this->_html .= $this->_closeFieldsetTemplate;
                $this->_fieldsetsOpen--;
            }
            $this->_html .= $html;
        }
    }
 
    /**
     * Called when visiting a form, after processing all form elements
     * Adds required note, form attributes, validation javascript and form content.
     *
     * @global moodle_page $PAGE
     * @param MoodleQuickForm $form Passed by reference
     */
    function finishForm(&$form){
        global $PAGE;
        if ($form->isFrozen()){
            $this->_hiddenHtml = '';
/var/www/html/lib/pear/HTML/QuickForm/element.php
                $this->setValue($arg);
        }
        return true;
    } // end func onQuickFormEvent
 
    // }}}
    // {{{ accept()
 
   /**
    * Accepts a renderer
    *
    * @param object     An HTML_QuickForm_Renderer object
    * @param bool       Whether an element is required
    * @param string     An error message associated with an element
    * @access public
    * @return void 
    */
    function accept(&$renderer, $required=false, $error=null)
    {
        $renderer->renderElement($this, $required, $error);
    } // end func accept
 
    // }}}
    // {{{ _generateId()
 
   /**
    * Automatically generates and assigns an 'id' attribute for the element.
    * 
    * Currently used to ensure that labels work on radio buttons and
    * checkboxes. Per idea of Alexander Radivanovich.
    *
    * @access private
    * @return void 
    */
    function _generateId() {
        if ($this->getAttribute('id')) {
            return;
        }
 
        $id = $this->getName() ?? '';
/var/www/html/lib/pear/HTML/QuickForm.php
    // }}}
    // {{{ accept()
 
   /**
    * Accepts a renderer
    *
    * @param object     An HTML_QuickForm_Renderer object
    * @since 3.0
    * @access public
    * @return void
    */
    function accept(&$renderer)
    {
        $renderer->startForm($this);
        foreach (array_keys($this->_elements) as $key) {
            $element =& $this->_elements[$key];
            $elementName = $element->getName();
            $required    = ($this->isElementRequired($elementName) && !$element->isFrozen());
            $error       = $this->getElementError($elementName);
            $element->accept($renderer, $required, $error);
        }
        $renderer->finishForm($this);
    } // end func accept
 
    // }}}
    // {{{ defaultRenderer()
 
   /**
    * Returns a reference to default renderer object
    *
    * @access public
    * @since 3.0
    * @return object a default renderer object
    */
    function &defaultRenderer()
    {
        if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) {
            include_once('HTML/QuickForm/Renderer/Default.php');
            $GLOBALS['_HTML_QuickForm_default_renderer'] = new HTML_QuickForm_Renderer_Default(); //Moodle: PHP 5.3 compatibility
        }
/var/www/html/lib/formslib.php
                    }
                } else if ($anyrequiredorerror && (empty($headername) || $this->is_shown($headername))) {
                    // If any error or required field are present within the header, we need to expand it.
                    $this->setExpanded($headername, true, true);
                } else if (!isset($this->_collapsibleElements[$headername])) {
                    // Define element as collapsed by default.
                    $this->setExpanded($headername, false);
                }
            }
 
            // Pass the array to renderer object.
            $renderer->setCollapsibleElements($this->_collapsibleElements);
        }
 
        $this->accept_set_nonvisible_elements($renderer);
 
        if (method_exists($renderer, 'set_sticky_footer') && !empty($this->_stickyfooterelement)) {
            $renderer->set_sticky_footer($this->_stickyfooterelement);
        }
        parent::accept($renderer);
    }
 
    /**
     * Checking non-visible elements to set when accepting a renderer.
     * @param HTML_QuickForm_Renderer $renderer
     */
    private function accept_set_nonvisible_elements($renderer) {
        if (!method_exists($renderer, 'set_nonvisible_elements') || $this->_disableShortforms) {
            return;
        }
        $nonvisibles = [];
        foreach (array_keys($this->_elements) as $index) {
            $element =& $this->_elements[$index];
            if ($element->getType() != 'header') {
                continue;
            }
            $headername = $element->getName();
            if (!$this->is_shown($headername)) {
                $nonvisibles[] = $headername;
            }
/var/www/html/lib/pear/HTML/QuickForm.php
    // }}}
    // {{{ toHtml ()
 
    /**
     * Returns an HTML version of the form
     *
     * @param string $in_data (optional) Any extra data to insert right
     *               before form is rendered.  Useful when using templates.
     *
     * @return   string     Html version of the form
     * @since     1.0
     * @access   public
     */
    function toHtml ($in_data = null)
    {
        if (!is_null($in_data)) {
            $this->addElement('html', $in_data);
        }
        $renderer =& $this->defaultRenderer();
        $this->accept($renderer);
        return $renderer->toHtml();
    } // end func toHtml
 
    // }}}
    // {{{ getValidationScript()
 
    /**
     * Returns the client side validation script
     *
     * @since     2.0
     * @access    public
     * @return    string    Javascript to perform validation, empty string if no 'client' rules were added
     */
    function getValidationScript()
    {
        if (empty($this->_rules) || empty($this->_attributes['onsubmit'])) {
            return '';
        }
 
        include_once('HTML/QuickForm/RuleRegistry.php');
/var/www/html/lib/pear/HTML/Common.php
    /**
     * Abstract method.  Must be extended to return the objects HTML
     *
     * @access    public
     * @return    string
     * @abstract
     */
    function toHtml()
    {
        return '';
    } // end func toHtml
 
    /**
     * Displays the HTML to the screen
     *
     * @access    public
     */
    function display()
    {
        print $this->toHtml();
    } // end func display
 
} // end class HTML_Common
?>
 
/var/www/html/lib/formslib.php
            return $file->get_content();
 
        } else if (isset($_FILES[$elname])) {
            return file_get_contents($_FILES[$elname]['tmp_name']);
        }
 
        return false;
    }
 
    /**
     * Print html form.
     */
    function display() {
        //finalize the form definition if not yet done
        if (!$this->_definition_finalized) {
            $this->_definition_finalized = true;
            $this->definition_after_data();
        }
 
        $this->_form->display();
    }
 
    /**
     * Renders the html form (same as display, but returns the result).
     *
     * Note that you can only output this rendered result once per page, as
     * it contains IDs which must be unique.
     *
     * @return string HTML code for the form
     */
    public function render() {
        ob_start();
        $this->display();
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }
 
    /**
     * Form definition. Abstract method - always override!
/var/www/html/local/ipemcpd/upload_evidence.php
                foreach ($errors as $error) {
                    echo html_writer::tag('li', $error);
                }
                echo html_writer::end_tag('ul');
                echo html_writer::end_div();
            }
 
            if ($success > 0) {
                echo html_writer::div(
                    html_writer::link(new moodle_url('/local/ipemcpd/index.php'),
                        get_string('viewevidence', 'local_ipemcpd'),
                        ['class' => 'btn btn-primary']),
                    'mt-3'
                );
            }
        }
    }
}
 
$form->display();
 
echo $OUTPUT->footer();
 

Environment & details:

empty
empty
empty
empty
Key Value
USER stdClass Object ( [id] => 1 [auth] => manual [confirmed] => 1 [policyagreed] => 0 [deleted] => 0 [suspended] => 0 [mnethostid] => 1 [username] => guest [idnumber] => [firstname] => Guest user [lastname] => [email] => root@localhost [emailstop] => 0 [phone1] => [phone2] => [institution] => [department] => [address] => [city] => [country] => [lang] => en [calendartype] => gregorian [theme] => [timezone] => 99 [firstaccess] => 0 [lastaccess] => 0 [lastlogin] => 0 [currentlogin] => 0 [lastip] => [secret] => [picture] => 0 [descriptionformat] => 1 [mailformat] => 1 [maildigest] => 0 [maildisplay] => 2 [autosubscribe] => 1 [trackforums] => 0 [timecreated] => 0 [timemodified] => 1731422767 [trustbitmask] => 0 [imagealt] => [lastnamephonetic] => [firstnamephonetic] => [middlename] => [alternatename] => [moodlenetprofile] => [lastcourseaccess] => Array ( ) [currentcourseaccess] => Array ( ) [profile] => Array ( ) [sesskey] => Y4t4NtqBGw [preference] => Array ( ) [autologinguest] => 1 [access] => Array ( [ra] => Array ( [/1] => Array ( [6] => 6 ) ) [time] => 1778827823 [rsw] => Array ( ) ) [enrol] => Array ( [enrolled] => Array ( ) [tempguest] => Array ( ) ) )
SESSION stdClass Object ( [isnewsessioncookie] => 1 [lang] => en [calendarshoweventtype] => 15 [cachestore_session] => Array ( [default_session-core/calendar_categories] => Array ( [__lastaccess__u1_166ssnhvdut8jp62r4eedf9vts] => Array ( [0] => 1778827823 [1] => 1778827823 ) [u1_166ssnhvdut8jp62r4eedf9vts_lastinvalidation-54d720d11ece57b555859017bb76dfb4] => Array ( [0] => 1778827823.5244-6a06c22f8009a1.02027805 [1] => 1778827823 ) [u1_166ssnhvdut8jp62r4eedf9vts_site-54d720d11ece57b555859017bb76dfb4] => Array ( [0] => Array ( ) [1] => 1778827823 ) ) [default_session-core/navigation_cache] => Array ( [__lastaccess__u1_166ssnhvdut8jp62r4eedf9vts] => Array ( [0] => 1778827823 [1] => 1778827823 ) ) [default_session-core/coursecat] => Array ( [__lastaccess__u1_166ssnhvdut8jp62r4eedf9vts] => Array ( [0] => 1778827823 [1] => 1778827823 ) [u1_166ssnhvdut8jp62r4eedf9vts_fd62dd52135191ed900a38df44e7b347c6219dbc] => Array ( [0] => 1778827823.5244-6a06c22f8009a1.02027805 [1] => 1778827823 ) [u1_166ssnhvdut8jp62r4eedf9vts_8f4f29333501a57b81fcd293acb1153dbfd4c22d] => Array ( [0] => Array ( ) [1] => 1778827823 ) [u1_166ssnhvdut8jp62r4eedf9vts_4bbd71334e8f7d0af868c7243d676be7b5ef9a71] => Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 10 [9] => 12 [10] => 13 [11] => 14 [12] => 15 [13] => 24 [14] => 25 [15] => 26 [16] => 27 [17] => 28 [18] => 29 [19] => 30 [20] => 31 [21] => 32 ) [1] => 1778827823 ) ) ) )
Key Value
HTTPS on
SSL_TLS_SNI lewsdevbox.adaptivle.co.uk
HTTP_ACCEPT */*
HTTP_USER_AGENT Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT_ENCODING gzip, br, zstd, deflate
HTTP_HOST lewsdevbox.adaptivle.co.uk
PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
SERVER_SIGNATURE <address>Apache/2.4.52 (Ubuntu) Server at lewsdevbox.adaptivle.co.uk Port 443</address>
SERVER_SOFTWARE Apache/2.4.52 (Ubuntu)
SERVER_NAME lewsdevbox.adaptivle.co.uk
SERVER_ADDR 139.59.168.8
SERVER_PORT 443
REMOTE_ADDR 216.73.217.0
DOCUMENT_ROOT /var/www/html
REQUEST_SCHEME https
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT /var/www/html
SERVER_ADMIN webmaster@localhost
SCRIPT_FILENAME /var/www/html/local/ipemcpd/upload_evidence.php
REMOTE_PORT 44686
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING
REQUEST_URI /local/ipemcpd/upload_evidence.php
SCRIPT_NAME /local/ipemcpd/upload_evidence.php
PHP_SELF /local/ipemcpd/upload_evidence.php
REQUEST_TIME_FLOAT 1778827821.7736
REQUEST_TIME 1778827821
empty
0. Whoops\Handler\PrettyPageHandler
1. Whoops\Handler\CallbackHandler