function paul_sync_log($message, $level = -1, $append = FALSE)
{
    if (defined("PAUL_SYNC_LOGLEVEL") && $level <= PAUL_SYNC_LOGLEVEL) {
        if ($append) {
            logging::append_log(LOG_PAULSYNC, $message);
            try {
                if (defined("LOG_PAULSYNC_LAST")) {
                    logging::append_log(LOG_PAULSYNC_LAST, $message);
                }
            } catch (Exception $ex) {
                /*ignore*/
            }
        } else {
            logging::write_log(LOG_PAULSYNC, $message);
            try {
                if (defined("LOG_PAULSYNC_LAST")) {
                    logging::write_log(LOG_PAULSYNC_LAST, $message);
                }
            } catch (Exception $ex) {
                /*ignore*/
            }
        }
    }
}
Esempio n. 2
0
 } else {
     $password = "";
 }
 if (isset($values["message"])) {
     $message = $values["message"];
 } else {
     $message = "";
 }
 if (!$already_member_and_exclusive) {
     if (defined("LOG_DEBUGLOG")) {
         logging::write_log(LOG_DEBUGLOG, "group_subscribe\t" . $user->get_name() . " joins " . $steam_group->get_identifier());
     }
     logging::start_timer("join_group");
     $result = $group->subscribe($password, $message);
     if (defined("LOG_DEBUGLOG")) {
         logging::append_log(LOG_DEBUGLOG, " runtime=" . logging::print_timer("join_group"));
     }
     if ($result["succeeds"]) {
         $_SESSION['confirmation'] = $result['confirmation'];
         // uncache menu so that course/group appears:
         $cache = get_cache_function($user->get_name());
         $cache->drop("lms_steam::user_get_profile", $user->get_name());
         $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
         if (!$group->is_member($user)) {
             $backlink = PATH_URL . 'desktop/';
         }
         header('Location: ' . $backlink);
     } else {
         $portal->set_problem_description($result["problem"], $result["hint"]);
     }
 } else {
Esempio n. 3
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
         throw new \Exception("Environment unknown.");
     }
     $koala_env = \koala_object::get_koala_object($env);
     if (isset($_SERVER["HTTP_REFERER"])) {
         $http_referer = $_SERVER["HTTP_REFERER"];
     } else {
         $http_referer = "";
     }
     $backlink = empty($_POST["values"]["backlink"]) ? $http_referer : $_POST["values"]["backlink"];
     $max_file_size = parse_filesize(ini_get('upload_max_filesize'));
     $max_post_size = parse_filesize(ini_get('post_max_size'));
     if ($max_post_size > 0 && $max_post_size < $max_file_size) {
         $max_file_size = $max_post_size;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = isset($_POST["values"]) ? $_POST["values"] : array();
         $problems = "";
         $hints = "";
         if (empty($_FILES) || !empty($_FILES["material"]["error"]) && $_FILES["material"]["error"] > 0) {
             if (!empty($_FILES) && empty($_FILES["material"]["name"])) {
                 $problems = gettext("No file chosen.") . " ";
                 $hints = gettext("Please choose a local file to upload.") . " ";
             } else {
                 $problems = gettext("Could not upload document.") . " ";
                 $hints = str_replace(array("%SIZE", "%TIME"), array(readable_filesize($max_file_size), (string) ini_get('max_execution_time')), gettext("Maybe your document exceeded the allowed file size (max. %SIZE) or the upload might have taken too long (max. %TIME seconds).")) . " ";
             }
         }
         if (empty($problems)) {
             $content = file_get_contents($_FILES["material"]["tmp_name"]);
             /*
             ob_start();
             readfile( $_FILES["material"]["tmp_name"] );
             $content = ob_get_contents();
             ob_end_clean();
             */
             if (defined("LOG_DEBUGLOG")) {
                 $time1 = microtime(TRUE);
                 \logging::write_log(LOG_DEBUGLOG, "upload" . " \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $_FILES["material"]["name"] . " \t" . filesize($_FILES["material"]["tmp_name"]) . " Bytes \t... ");
             }
             $filename = str_replace(array("\\", "'"), array("", ""), $_FILES["material"]["name"]);
             $new_material = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $filename, $content, $_FILES["material"]["type"], FALSE);
             if (defined("LOG_DEBUGLOG")) {
                 \logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms");
             }
             //  Disabled for Testing issues
             // upload($new_material->get_content_id(), $content);
             if (isset($values["dsc"])) {
                 $new_material->set_attribute("OBJ_DESC", $values["dsc"]);
             }
             $new_material->move($env);
             $_SESSION["confirmation"] = str_replace("%DOCUMENT", h($filename), gettext("'%DOCUMENT' has been uploaded."));
             header("Location: " . $backlink);
             exit;
         } else {
             $frameResponseObject->setProblemDescription($problems);
             $frameResponseObject->setProblemSolution($hints);
             //$portal->set_problem_description( $problems, $hints );
         }
     }
     $content = \Wiki::getInstance()->loadTemplate("upload.template.html");
     //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES );
     //$content->loadTemplateFile( "upload.template.html" );
     $content->setVariable("LABEL_UPLOAD", gettext("Upload"));
     $content->setVariable("LABEL_FILE", gettext("Local file"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $content->setVariable("BACK_LINK", $backlink);
     $content->setVariable("FORM_ACTION", PATH_URL . "wiki/upload/" . (isset($_GET["env"]) ? "?env=" . $_GET["env"] : ""));
     if ($max_file_size > 0) {
         $content->setVariable("MAX_FILE_SIZE_INPUT", "<input type='hidden' name='MAX_FILE_SIZE' value='" . (string) $max_file_size . "'/>");
         $content->setVariable("MAX_FILE_SIZE_INFO", "<br />" . str_replace("%SIZE", readable_filesize($max_file_size), gettext("The maximum allowed file size is %SIZE.")));
     }
     $link_path = $koala_env->get_link_path();
     if (!is_array($link_path)) {
         $link_path = array();
     }
     $link_path[] = array("name" => gettext("Upload document"));
     if (!WIKI_FULL_HEADLINE) {
         $tmp_array = array();
         $elem_last = array_pop($link_path);
         $elem_first = array_pop($link_path);
         $tmp_array[] = $elem_first;
         $tmp_array[] = $elem_last;
         $link_path = $tmp_array;
     }
     //$portal->set_page_main( $link_path, $content->get() );
     //$portal->set_page_main( str_replace( "%ENV", $env->get_name(), gettext( "New upload in '%ENV'" ) ), $content->get() );
     //$portal->set_page_title( gettext( "Upload document" ) );
     //$portal->show_html();
     $frameResponseObject->setHeadline($link_path);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 4
0
    if (empty($problems)) {
        $content = file_get_contents($_FILES["material"]["tmp_name"]);
        /*
        								ob_start();
        								readfile( $_FILES["material"]["tmp_name"] );
        								$content = ob_get_contents();
        								ob_end_clean();
        */
        if (defined("LOG_DEBUGLOG")) {
            $time1 = microtime(TRUE);
            logging::write_log(LOG_DEBUGLOG, "upload" . " \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $_FILES["material"]["name"] . " \t" . filesize($_FILES["material"]["tmp_name"]) . " Bytes \t... ");
        }
        $filename = str_replace(array("\\", "'"), array("", ""), $_FILES["material"]["name"]);
        $new_material = steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $filename, $content, $_FILES["material"]["type"], FALSE);
        if (defined("LOG_DEBUGLOG")) {
            logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms");
        }
        //  Disabled for Testing issues
        // upload($new_material->get_content_id(), $content);
        if (isset($values["dsc"])) {
            $new_material->set_attribute("OBJ_DESC", $values["dsc"]);
        }
        $new_material->move($env);
        $_SESSION["confirmation"] = str_replace("%DOCUMENT", h($filename), gettext("'%DOCUMENT' has been uploaded."));
        header("Location: " . $backlink);
        exit;
    } else {
        $portal->set_problem_description($problems, $hints);
    }
}
$content = new HTML_TEMPLATE_IT(PATH_TEMPLATES);
Esempio n. 5
0
        $cache->drop("lms_steam::user_get_groups", $user->get_name(), FALSE);
        $cache->drop("lms_steam::user_get_profile", $user->get_name());
        $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
        $cache = get_cache_function($group->get_id());
        $cache->drop("lms_steam::group_get_members", $group->get_id());
        $_SESSION["confirmation"] = $short_confirmation;
        if (defined("LOG_DEBUGLOG")) {
            logging::append_log(LOG_DEBUGLOG, " runtime=" . logging::print_timer("leave_group"));
        }
        header("Location: " . $values["return_to"]);
        exit;
    } else {
        throw new Exception("Cannot delete membership.");
    }
    if (defined("LOG_DEBUGLOG")) {
        logging::append_log(LOG_DEBUGLOG, "failed. runtime=" . logging::print_timer("leave_group"));
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "groups_cancel_membership.template.html");
$content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
$content->setVariable("LABEL_RETURN", gettext("back"));
if ($group instanceof koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
    if (empty($_SESSION['confirmation'])) {
        // don't warn if we came here on successful membership cancel...
        if ($group instanceof koala_group_course) {
            $portal->set_problem_description(gettext("You are not member of this course."));
        } else {
            $portal->set_problem_description(gettext("You are not member of this group."));
        }
    }
Esempio n. 6
0
 static function write_log($pFile, $pMessage)
 {
     $time = date("d.m.y G:i:s", time());
     $entry = "\n" . $time . "\t" . $pMessage;
     logging::append_log($pFile, $entry);
 }
Esempio n. 7
0
 public function search_user_posts($messageboard_id, $user_name)
 {
     if (defined("LOG_DEBUGLOG")) {
         $time1 = microtime(TRUE);
         logging::write_log(LOG_DEBUGLOG, "lms_forum::search_user_posts(" . $messageboard_id . ", " . $user_name . ") \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $messageboard_id . " \t... ");
     }
     if (!($search_mod = $GLOBALS["STEAM"]->get_module("package:searchsupport"))) {
         throw new Exception("sTeam 'package:searchsupport' not installed.");
     }
     $messageboard = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $messageboard_id, CLASS_MESSAGEBOARD);
     $user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $user_name);
     $search_results = $GLOBALS["STEAM"]->predefined_command($search_mod, "search_user_posts", array($messageboard, $user), 0);
     $result = lms_forum::get_discussions($messageboard->get_id(), $search_results);
     if (defined("LOG_DEBUGLOG")) {
         logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms \t" . count($result));
     }
     return $result;
 }
Esempio n. 8
0
function get_document_data($login, $password, $identifier, $identifier_type, $width = false, $height = false)
{
    $STEAM = new steam_connector(STEAM_SERVER, STEAM_PORT, $login, $password);
    if ($identifier_type === "name") {
        $document = $STEAM->predefined_command($STEAM->get_module("icons"), "get_icon_by_name", array((string) $identifier), 0);
    } else {
        if ($identifier_type === "id") {
            $document = steam_factory::get_object($STEAM->get_id(), (int) $identifier);
        }
    }
    // If user is not logged in, open login dialog. If user is logged in
    // and not guest, then display "Access denied" message.
    if (!$document->check_access_read($STEAM->get_current_steam_user())) {
        if ($login == 'guest') {
            throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
        } else {
            throw new Exception("Access denied.", E_USER_RIGHTS);
        }
    }
    if (!is_object($document)) {
        return array("content" => array());
    }
    // array is considered to be an error
    $document->get_attributes(array("OBJ_NAME", "DOC_MIME_TYPE", "DOC_LAST_MODIFIED"), TRUE);
    if (!$width && !$height) {
        //$tnr_content = $document->get_content(TRUE);  // workaround: get data from sTeam webinterface
        $tnr_contentsize = $document->get_content_size(TRUE);
    } else {
        $tnr_imagecontent = $document->get_thumbnail_data($width, $height, 0, TRUE);
    }
    $result = $STEAM->buffer_flush();
    if (isset($tnr_imagecontent)) {
        // handle thumbnail data
        $data["mimetype"] = $result[$tnr_imagecontent]["mimetype"];
        $data["lastmodified"] = $result[$tnr_imagecontent]["timestamp"];
        $data["name"] = $result[$tnr_imagecontent]["name"];
        $data["content"] = $result[$tnr_imagecontent]["content"];
        $data["contentsize"] = $result[$tnr_imagecontent]["contentsize"];
    } else {
        if ($identifier_type === "id") {
            $data["mimetype"] = $document->get_attribute("DOC_MIME_TYPE");
            $data["lastmodified"] = $document->get_attribute("DOC_LAST_MODIFIED");
            $data["name"] = $document->get_name();
            $data["contentsize"] = $result[$tnr_contentsize];
            //$data["content"]     = $result[$tnr_content];  // workaround: get data from sTeam webinterface
            // workaround: get content from sTeam webinterface, because
            //$data["content"] = $document->get_content();
            //   results in *huge* memory overheads (a 15 MB download fails with 60 MB scrip memory limit!
            if (defined("LOG_DEBUGLOG")) {
                $time1 = microtime(TRUE);
                logging::write_log(LOG_DEBUGLOG, "get_document::get_document_data(" . $login . ", *****" . ", " . $identifier . ", " . $identifier_type . ", false, false)\t " . $login . " \t" . $identifier . " \t" . $document->get_name() . " \t" . $data["contentsize"] . " Bytes \t... ");
            }
            $https_port = (int) $STEAM->get_config_value("https_port");
            if ($https_port == 443 || $https_port == 0) {
                $https_port = "";
            } else {
                $https_port = ":" . (string) $https_port;
            }
            $ch = curl_init("https://" . STEAM_SERVER . $https_port . "/scripts/get.pike?object=" . $identifier);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
            curl_setopt($ch, CURLOPT_USERPWD, $login . ":" . $password);
            $data["content"] = curl_exec($ch);
            curl_close($ch);
            if (defined("LOG_DEBUGLOG")) {
                logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms");
            }
        } else {
            $data = array("content" => array());
            // array is considered an error
        }
    }
    return $data;
}
Esempio n. 9
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $group_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $user = \lms_steam::get_current_user();
     //TODO: Was soll dieses $em hier??
     //$em = \lms_steam::get_extensionmanager();
     if (!($steam_group = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group_id))) {
         include "bad_link.php";
         exit;
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception("Is not a group: " . $_GET["id"]);
     }
     $group = \koala_object::get_koala_object($steam_group);
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         $values = $_POST["values"];
         if (defined("LOG_DEBUGLOG")) {
             \logging::write_log(LOG_DEBUGLOG, "group_cancel\t" . $user->get_name() . " leaves " . $steam_group->get_identifier());
         }
         \logging::start_timer("leave_group");
         if ($group->remove_member($user)) {
             $group_name = $group->get_display_name();
             $short_confirmation = str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated."));
             $confirmation = str_replace("%NAME", $user->get_full_name(), gettext("Dear %NAME,")) . "\n\n" . $short_confirmation . "\n\n" . gettext("Your koaLA Team");
             \lms_steam::mail($user, "\"" . PLATFORM_NAME . " System\"<no_reply@" . STEAM_SERVER . ">", PLATFORM_NAME . ": " . str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated")), $confirmation);
             $cache = get_cache_function($user->get_name());
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $user->get_name());
             $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
             $_SESSION["confirmation"] = $short_confirmation;
             if (defined("LOG_DEBUGLOG")) {
                 \logging::append_log(LOG_DEBUGLOG, " runtime=" . \logging::print_timer("leave_group"));
             }
             header("Location: " . $values["return_to"]);
             exit;
         } else {
             throw new \Exception("Cannot delete membership.");
         }
         if (defined("LOG_DEBUGLOG")) {
             \logging::append_log(LOG_DEBUGLOG, "failed. runtime=" . \logging::print_timer("leave_group"));
         }
     }
     $content = \Group::getInstance()->loadTemplate("groups_cancel_membership.template.html");
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
         if (empty($_SESSION['confirmation'])) {
             // don't warn if we came here on successful membership cancel...
             if ($group instanceof \koala_group_course) {
                 $portal->set_problem_description(gettext("You are not member of this course."));
             } else {
                 $portal->set_problem_description(gettext("You are not member of this group."));
             }
         }
     } else {
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             if (empty($_SESSION['confirmation'])) {
                 // don't warn if we came here on successful membership cancel...
                 if ($group instanceof \koala_group_course) {
                     $portal->set_problem_description(gettext("You are not member of this course."));
                 } else {
                     $portal->set_problem_description(gettext("You are not member of this group."));
                 }
             }
         } else {
             $redirect = $_SERVER["HTTP_REFERER"];
             if ($group instanceof \koala_group_default && !$group->is_public()) {
                 $redirect = PATH_URL . "user/" . \lms_steam::get_current_user()->get_name() . "/groups/";
             }
             $content->setVariable("DELETE_BACK_LINK", $redirect);
             $content->setVariable("FORM_ACTION", PATH_URL . "group/cancelGroup/\t" . $group_id);
             $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure?"));
             $content->setVariable("INFO_CANCEL_MEMBERSHIP", str_replace("%NAME", $group->get_display_name(), gettext("You are going to cancel your membership in <b>'%NAME'</b>.")));
             $content->setVariable("BUTTON_SUBMIT", "<input type=\"submit\" name=\"values[delete]\"  value=\"" . gettext("Yes, cancel my membership") . "\"/>");
         }
     }
     /*
     $portal->set_page_main(
     								"",
     								$content->get(),
     								""
     								);
     $portal->show_html();
     */
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }