Ejemplo n.º 1
0
/**
* Create a task as docu page
*
* @ingroup pages
*/
function taskNewDocu()
{
    $foo = array('task_category' => TCATEGORY_DOCU, 'show_folder_as_documentation' => 1);
    addRequestVars($foo);
    TaskNew();
    exit;
}
Ejemplo n.º 2
0
/**
* Filter get and post-vars
*
* - We don't not distinguish security between post-,get- and cookie-vars
*   because any of them can be easily forged. We create a joined assoc array
*   and filter for too long variables and html-tags. Additional security-checks
*   should be done later in db- and field-classes.
*
* - passed parames should always be accessed like;
*
*    $f_person_name= get('person_name');
*
* - You CAN NOT access $_GET, $_POST and $_COOKIE-vars directly (because they are cleared)!
* - for additional information see std/common.inc
*/
function filterGlobalArrays()
{
    ### clean global namespace from register globals ###
    if (@ini_get('register_globals')) {
        foreach ($_REQUEST as $key => $value) {
            unset($GLOBALS[$key]);
        }
    }
    clearRequestVars();
    addRequestVars($_GET);
    addRequestVars($_POST);
    addRequestVars($_COOKIE);
    $_COOKIE = $_GET = $_POST = array();
}
Ejemplo n.º 3
0
/**
* change current task-list-view (tree, list, grouped, etc.) @ingroup pages
*/
function changeBlockGrouping()
{
    global $PH;
    $block_id = get('block_id');
    $page_id = get('page_id');
    $grouping = get('grouping');
    if (!$block_id || !$grouping) {
        $PH->abortWarning("ChangeBlockGrouping() missed parameters", ERROR_BUG);
    }
    $id = "blockstyle_" . $page_id . "_" . $block_id . "_grouping";
    setcookie($id, $grouping, time() + 60 * 60 * 24 * 30, '', '', 0);
    ### keep for current page ###
    $ref = array($id => $grouping);
    addRequestVars($ref);
    ### return to from-page ###
    if (!$PH->showFromPage()) {
        $PH->show('home');
    }
}
Ejemplo n.º 4
0
 public function show($id = NULL, $params = NULL, $fn_argument = NULL)
 {
     global $auth;
     ### echo debug output ###
     if (isset($auth->cur_user)) {
         $user_name = $auth->cur_user->name;
     } else {
         $user_name = '__not_logged_in__';
     }
     $crawler = Auth::isCrawler() ? 'crawler' : '';
     log_message($user_name . '@' . getServerVar('REMOTE_ADDR', true) . " -> {$id} " . getServerVar('REQUEST_URI') . "  (" . getServerVar('HTTP_USER_AGENT') . ") {$crawler}", LOG_MESSAGE_DEBUG);
     if (!$id) {
         $this->show('home');
         exit;
     } else {
         if ($id != asAlphaNumeric($id)) {
             new FeedbackWarning("Ignored invalid page '" . asCleanString($id) . "'");
             $this->show('home');
             exit;
         } else {
             if (!isset($this->hash[$id])) {
                 trigger_error('try to show undefined page-id ' . $id, E_USER_WARNING);
                 $this->show('error');
                 return;
             }
         }
     }
     $handle = $this->hash[$id];
     ### not authenticated ###
     if (!isset($auth) || !$auth->cur_user) {
         if (!$handle->valid_for_anonymous) {
             new FeedbackWarning("As an anonymous user you have not enough rights to view page '{$id}'");
             $this->show('loginForm');
             exit;
         }
     }
     ### check sufficient user-rights ###
     if ($handle->rights_required && !($handle->rights_required & $auth->cur_user->user_rights)) {
         $this->abortWarning("insufficient rights");
     }
     ### hide modification pages from guests ###
     /**
      * Note: for some reason, this interfers with unit testing. Using the user agent for this
      * check here is extremely dirty, because it can be faked from attackers. This will not lead
      * to a result, because it switches the database for unit testing, though.
      */
     if (getServerVar('HTTP_USER_AGENT') != 'streber_unit_tester') {
         if (isset($auth) && $auth->isAnonymousUser() && !$handle->valid_for_anonymous && ($handle->type == 'form' || $handle->type == 'subm' || $handle->type == 'func')) {
             $this->abortWarning("insufficient rights");
         }
     }
     require_once $handle->req;
     #--- set page-handler-curpage ---
     $keep_cur_page_id = $this->cur_page_id;
     # show() might be called again, so we have to keep the page_id
     $this->cur_page_id = $id;
     $keep_cur_page = $this->cur_page;
     $this->cur_page = $handle;
     ### submit ###
     if ($handle->type = 'subm') {
         $tmp = get('from');
         if ($tmp) {
             $this->cur_page_md5 = $tmp;
         }
     }
     #--- set params ---
     if ($params) {
         #            global $vars;
         #            foreach($params as $key=>$value) {
         #                $vars[$key]=$value;
         #            }
         #            $vars['go']=$id;
         $params['go'] = $id;
         addRequestVars($params);
     }
     #--- avoid endless traps ---
     if (count($this->recursions) > MAX_PAGE_RECURSIONS) {
         trigger_error("maximum page recursions reached! (" . implode(",", $this->recursions) . ")", E_USER_ERROR);
         return;
     }
     $this->recursions[] = $id;
     #--- use id as function-name ----
     if (function_exists($id)) {
         if ($fn_argument) {
             $id($fn_argument);
             # pass additional paramenter (eg. non-db-objects to xxxNew()-functions)
         } else {
             $id();
         }
     } else {
         $this->abortWarning("page-call to undefined functions '{$id}'", ERROR_FATAL);
     }
     $this->cur_page_id = $keep_cur_page_id;
     $this->cur_page = $keep_cur_page;
 }
/**
* Submit data of a newly registered person @ingroup pages
*/
function personRegisterSubmit()
{
    global $PH;
    global $auth;
    ### cancel ? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    $person = new Person(array('id' => 0));
    $person->user_rights = RIGHT_PERSON_EDIT_SELF;
    ### person category ###
    $pcategory = get('pcategory');
    if ($pcategory != NULL) {
        if ($pcategory == -1) {
            $person->category = PCATEGORY_STAFF;
        } else {
            if ($pcategory == -2) {
                $person->category = PCATEGORY_CONTACT;
            } else {
                $person->category = $pcategory;
            }
        }
    }
    $flag_ok = true;
    # update valid?
    # retrieve all possible values from post-data
    # NOTE:
    # - this could be an security-issue.
    # - TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($person->fields as $f) {
        $name = $f->name;
        $f->parseForm($person);
    }
    $person->can_login = 1;
    $period = get('person_notification_period');
    ### turn off ###
    if ($period === 0 || $period === "0") {
        $person->settings &= USER_SETTING_NOTIFICATIONS ^ RIGHT_ALL;
        $person->notification_period = 0;
    } else {
        $person->settings |= USER_SETTING_NOTIFICATIONS;
        $person->notification_period = $period;
        if ($person->can_login && !$person->personal_email && !$person->office_email) {
            $flag_ok = false;
            $person->fields['office_email']->required = true;
            $person->fields['personal_email']->required = true;
            new FeedbackWarning(__("Sending notifactions requires an email-address."));
        }
    }
    if (get('person_html_mail')) {
        $person->settings |= USER_SETTING_HTML_MAIL;
    } else {
        $person->settings &= USER_SETTING_HTML_MAIL ^ RIGHT_ALL;
    }
    $zone = get('person_time_zone');
    if ($zone != NULL && $person->time_zone != 1.0 * $zone) {
        $person->time_zone = 1.0 * $zone;
        if ($zone == TIME_OFFSET_AUTO) {
            new FeedbackMessage(__("Using auto detection of time zone requires this user to relogin."));
        } else {
            $person->time_offset = $zone * 60.0 * 60.0;
            if ($person->id == $auth->cur_user->id) {
                $auth->cur_user->time_offset = $zone * 60.0 * 60.0;
            }
        }
    }
    $theme = get('person_theme');
    if ($theme != NULL) {
        $person->theme = $theme;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->theme = $theme;
        }
    }
    $language = get('person_language');
    global $g_languages;
    if (isset($g_languages[$language])) {
        $person->language = $language;
        ### update immediately / without page-reload ####
        if ($person->id == $auth->cur_user->id) {
            $auth->cur_user->language = $language;
            setLang($language);
        }
    }
    if (!$person->name) {
        new FeedbackWarning(__("Login-accounts require a full name."));
        $person->fields['name']->required = true;
        $person->fields['name']->invalid = true;
        $flag_ok = false;
    }
    if (!$person->office_email) {
        new FeedbackWarning(__("Please enter an e-mail address."));
        $person->fields['office_email']->required = true;
        $person->fields['office_email']->invalid = true;
        $flag_ok = false;
    }
    $t_nickname = get('person_nickname');
    if (!$person->nickname) {
        new FeedbackWarning(__("Login-accounts require a unique nickname"));
        $person->fields['nickname']->required = true;
        $person->fields['nickname']->invalid = true;
        $flag_ok = false;
    }
    ### check if changed nickname is unique
    if ($person->can_login || $person->nickname != "") {
        /**
         * \todo actually this should be mb_strtolower, but this is not installed by default
         */
        if ($person->nickname != strtolower($person->nickname)) {
            new FeedbackMessage(__("Nickname has been converted to lowercase"));
            $person->nickname = strtolower($person->nickname);
        }
        if ($p2 = Person::getByNickname($t_nickname)) {
            # another person with this nick?
            if ($p2->id != $person->id) {
                new FeedbackWarning(__("Nickname has to be unique"));
                $person->fields['nickname']->required = true;
                $flag_ok = false;
            }
        }
    }
    ### password entered? ###
    $t_password1 = get('person_password1');
    $t_password2 = get('person_password2');
    $flag_password_ok = true;
    if (($t_password1 || $t_password2) && $t_password1 != "__dont_change__") {
        ### check if password match ###
        if ($t_password1 !== $t_password2) {
            new FeedbackWarning(__("Passwords do not match"));
            $person->fields['password']->required = true;
            $flag_ok = false;
            $flag_password_ok = false;
            $person->cookie_string = $auth->cur_user->calcCookieString();
        }
    }
    ### check if password is good enough ###
    $password_length = strlen($t_password1);
    $password_count_numbers = strlen(preg_replace('/[\\d]/', '', $t_password1));
    $password_count_special = strlen(preg_replace('/[\\w]/', '', $t_password1));
    $password_value = -7 + $password_length + $password_count_numbers * 2 + $password_count_special * 4;
    if ($password_value < confGet('CHECK_PASSWORD_LEVEL')) {
        new FeedbackWarning(__("Password is too weak (please add numbers, special chars or length)"));
        $flag_ok = false;
        $flag_password_ok = false;
    }
    if ($flag_password_ok) {
        $person->password = md5($t_password1);
    }
    if (!validateFormCaptcha()) {
        new FeedbackWarning(__("Please copy the text from the image."));
        $flag_ok = false;
    }
    ### repeat form if invalid data ###
    if (!$flag_ok) {
        $PH->show('personRegister', NULL, $person);
        exit;
    }
    /**
     * store indentifier-string for login from notification & reminder - mails
     */
    $person->identifier = $person->calcIdentifierString();
    ### insert new object ###
    if ($person->settings & USER_SETTING_NOTIFICATIONS && $person->can_login) {
        $person->settings |= USER_SETTING_SEND_ACTIVATION;
        new FeedbackHint(sprintf(__("A notification / activation  will be mailed to <b>%s</b> when you log out."), $person->name) . " " . sprintf(__("Read more about %s."), $PH->getWikiLink('notifications')));
    }
    $person->notification_last = getGMTString(time() - $person->notification_period * 60 * 60 * 24 - 1);
    $person->cookie_string = $person->calcCookieString();
    if ($person->insert()) {
        new FeedbackHint(__("Thank you for registration! After your request has been approved by a moderator, you will can an email."));
        ### link to a company ###
        if ($c_id = get('company')) {
            require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
            if ($c = Company::getVisibleById($c_id)) {
                require_once confGet('DIR_STREBER') . 'db/class_employment.inc.php';
                $e = new Employment(array('id' => 0, 'person' => $person->id, 'company' => $c->id));
                $e->insert();
            }
        }
        ## assigne to project ##
        require_once confGet('DIR_STREBER') . 'db/class_projectperson.inc.php';
        $prj_num = confGet('REGISTER_NEW_USERS_TO_PROJECT');
        global $g_user_profile_names;
        if (isset($prj_num)) {
            if ($prj_num != -1) {
                if ($p = Project::getVisibleById($prj_num)) {
                    $prj_person = new ProjectPerson(array('person' => $person->id, 'project' => $p->id, 'name' => $g_user_profile_names[$person->profile]));
                    $prj_person->insert();
                }
            }
        }
        new FeedbackMessage(sprintf(__('Person %s created'), $person->getLink()));
        ### automatically login ###
        $foo = array('login_name' => $person->nickname, 'login_password_md5' => $person->password);
        addRequestVars($foo);
        $PH->show('loginFormSubmit', array());
        exit;
    } else {
        new FeedbackError(__("Could not insert object"));
    }
    ### display fromPage ####
    if (!$PH->showFromPage()) {
        $PH->show('home', array());
    }
}
Ejemplo n.º 6
0
/**
* Search of a work @ingroup pages
*/
function search()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "lists/list_searchresults.inc.php";
    /**
     * note: Default search uses boolean mode. This leads to the problem that a lot of search requests
     * fail, because they include stop words.
     */
    $mysql_default_stopwords = array("a" => 1, "able" => 1, "about" => 1, "above" => 1, "according" => 1, "accordingly" => 1, "across" => 1, "actually" => 1, "after" => 1, "afterwards" => 1, "again" => 1, "against" => 1, "ain't" => 1, "all" => 1, "allow" => 1, "allows" => 1, "almost" => 1, "alone" => 1, "along" => 1, "already" => 1, "also" => 1, "although" => 1, "always" => 1, "am" => 1, "among" => 1, "amongst" => 1, "an" => 1, "and" => 1, "another" => 1, "any" => 1, "anybody" => 1, "anyhow" => 1, "anyone" => 1, "anything" => 1, "anyway" => 1, "anyways" => 1, "anywhere" => 1, "apart" => 1, "appear" => 1, "appreciate" => 1, "appropriate" => 1, "are" => 1, "aren't" => 1, "around" => 1, "as" => 1, "aside" => 1, "ask" => 1, "asking" => 1, "associated" => 1, "at" => 1, "available" => 1, "away" => 1, "awfully" => 1, "be" => 1, "became" => 1, "because" => 1, "become" => 1, "becomes" => 1, "becoming" => 1, "been" => 1, "before" => 1, "beforehand" => 1, "behind" => 1, "being" => 1, "believe" => 1, "below" => 1, "beside" => 1, "besides" => 1, "best" => 1, "better" => 1, "between" => 1, "beyond" => 1, "both" => 1, "brief" => 1, "but" => 1, "by" => 1, "c'mon" => 1, "c's" => 1, "came" => 1, "can" => 1, "can't" => 1, "cannot" => 1, "cant" => 1, "cause" => 1, "causes" => 1, "certain" => 1, "certainly" => 1, "changes" => 1, "clearly" => 1, "co" => 1, "com" => 1, "come" => 1, "comes" => 1, "concerning" => 1, "consequently" => 1, "consider" => 1, "considering" => 1, "contain" => 1, "containing" => 1, "contains" => 1, "corresponding" => 1, "could" => 1, "couldn't" => 1, "course" => 1, "currently" => 1, "definitely" => 1, "described" => 1, "despite" => 1, "did" => 1, "didn't" => 1, "different" => 1, "do" => 1, "does" => 1, "doesn't" => 1, "doing" => 1, "don't" => 1, "done" => 1, "down" => 1, "downwards" => 1, "during" => 1, "each" => 1, "edu" => 1, "eg" => 1, "eight" => 1, "either" => 1, "else" => 1, "elsewhere" => 1, "enough" => 1, "entirely" => 1, "especially" => 1, "et" => 1, "etc" => 1, "even" => 1, "ever" => 1, "every" => 1, "everybody" => 1, "everyone" => 1, "everything" => 1, "everywhere" => 1, "ex" => 1, "exactly" => 1, "example" => 1, "except" => 1, "far" => 1, "few" => 1, "fifth" => 1, "first" => 1, "five" => 1, "followed" => 1, "following" => 1, "follows" => 1, "for" => 1, "former" => 1, "formerly" => 1, "forth" => 1, "four" => 1, "from" => 1, "further" => 1, "furthermore" => 1, "get" => 1, "gets" => 1, "getting" => 1, "given" => 1, "gives" => 1, "go" => 1, "goes" => 1, "going" => 1, "gone" => 1, "got" => 1, "gotten" => 1, "greetings" => 1, "had" => 1, "hadn't" => 1, "happens" => 1, "hardly" => 1, "has" => 1, "hasn't" => 1, "have" => 1, "haven't" => 1, "having" => 1, "he" => 1, "he's" => 1, "hello" => 1, "help" => 1, "hence" => 1, "her" => 1, "here" => 1, "here's" => 1, "hereafter" => 1, "hereby" => 1, "herein" => 1, "hereupon" => 1, "hers" => 1, "herself" => 1, "hi" => 1, "him" => 1, "himself" => 1, "his" => 1, "hither" => 1, "hopefully" => 1, "how" => 1, "howbeit" => 1, "however" => 1, "i'd" => 1, "i'll" => 1, "i'm" => 1, "i've" => 1, "ie" => 1, "if" => 1, "ignored" => 1, "immediate" => 1, "in" => 1, "inasmuch" => 1, "inc" => 1, "indeed" => 1, "indicate" => 1, "indicated" => 1, "indicates" => 1, "inner" => 1, "insofar" => 1, "instead" => 1, "into" => 1, "inward" => 1, "is" => 1, "isn't" => 1, "it" => 1, "it'd" => 1, "it'll" => 1, "it's" => 1, "its" => 1, "itself" => 1, "just" => 1, "keep" => 1, "keeps" => 1, "kept" => 1, "know" => 1, "knows" => 1, "known" => 1, "last" => 1, "lately" => 1, "later" => 1, "latter" => 1, "latterly" => 1, "least" => 1, "less" => 1, "lest" => 1, "let" => 1, "let's" => 1, "like" => 1, "liked" => 1, "likely" => 1, "little" => 1, "look" => 1, "looking" => 1, "looks" => 1, "ltd" => 1, "mainly" => 1, "many" => 1, "may" => 1, "maybe" => 1, "me" => 1, "mean" => 1, "meanwhile" => 1, "merely" => 1, "might" => 1, "more" => 1, "moreover" => 1, "most" => 1, "mostly" => 1, "much" => 1, "must" => 1, "my" => 1, "myself" => 1, "name" => 1, "namely" => 1, "nd" => 1, "near" => 1, "nearly" => 1, "necessary" => 1, "need" => 1, "needs" => 1, "neither" => 1, "never" => 1, "nevertheless" => 1, "new" => 1, "next" => 1, "nine" => 1, "no" => 1, "nobody" => 1, "non" => 1, "none" => 1, "noone" => 1, "nor" => 1, "normally" => 1, "not" => 1, "nothing" => 1, "novel" => 1, "now" => 1, "nowhere" => 1, "obviously" => 1, "of" => 1, "off" => 1, "often" => 1, "oh" => 1, "ok" => 1, "okay" => 1, "old" => 1, "on" => 1, "once" => 1, "one" => 1, "ones" => 1, "only" => 1, "onto" => 1, "or" => 1, "other" => 1, "others" => 1, "otherwise" => 1, "ought" => 1, "our" => 1, "ours" => 1, "ourselves" => 1, "out" => 1, "outside" => 1, "over" => 1, "overall" => 1, "own" => 1, "particular" => 1, "particularly" => 1, "per" => 1, "perhaps" => 1, "placed" => 1, "please" => 1, "plus" => 1, "possible" => 1, "presumably" => 1, "probably" => 1, "provides" => 1, "que" => 1, "quite" => 1, "qv" => 1, "rather" => 1, "rd" => 1, "re" => 1, "really" => 1, "reasonably" => 1, "regarding" => 1, "regardless" => 1, "regards" => 1, "relatively" => 1, "respectively" => 1, "right" => 1, "said" => 1, "same" => 1, "saw" => 1, "say" => 1, "saying" => 1, "says" => 1, "second" => 1, "secondly" => 1, "see" => 1, "seeing" => 1, "seem" => 1, "seemed" => 1, "seeming" => 1, "seems" => 1, "seen" => 1, "self" => 1, "selves" => 1, "sensible" => 1, "sent" => 1, "serious" => 1, "seriously" => 1, "seven" => 1, "several" => 1, "shall" => 1, "she" => 1, "should" => 1, "shouldn't" => 1, "since" => 1, "six" => 1, "so" => 1, "some" => 1, "somebody" => 1, "somehow" => 1, "someone" => 1, "something" => 1, "sometime" => 1, "sometimes" => 1, "somewhat" => 1, "somewhere" => 1, "soon" => 1, "sorry" => 1, "specified" => 1, "specify" => 1, "specifying" => 1, "still" => 1, "sub" => 1, "such" => 1, "sup" => 1, "sure" => 1, "t's" => 1, "take" => 1, "taken" => 1, "tell" => 1, "tends" => 1, "th" => 1, "than" => 1, "thank" => 1, "thanks" => 1, "thanx" => 1, "that" => 1, "that's" => 1, "thats" => 1, "the" => 1, "their" => 1, "theirs" => 1, "them" => 1, "themselves" => 1, "then" => 1, "thence" => 1, "there" => 1, "there's" => 1, "thereafter" => 1, "thereby" => 1, "therefore" => 1, "therein" => 1, "theres" => 1, "thereupon" => 1, "these" => 1, "they" => 1, "they'd" => 1, "they'll" => 1, "they're" => 1, "they've" => 1, "think" => 1, "third" => 1, "this" => 1, "thorough" => 1, "thoroughly" => 1, "those" => 1, "though" => 1, "three" => 1, "through" => 1, "throughout" => 1, "thru" => 1, "thus" => 1, "to" => 1, "together" => 1, "too" => 1, "took" => 1, "toward" => 1, "towards" => 1, "tried" => 1, "tries" => 1, "truly" => 1, "try" => 1, "trying" => 1, "twice" => 1, "two" => 1, "un" => 1, "under" => 1, "unfortunately" => 1, "unless" => 1, "unlikely" => 1, "until" => 1, "unto" => 1, "up" => 1, "upon" => 1, "us" => 1, "use" => 1, "used" => 1, "useful" => 1, "uses" => 1, "using" => 1, "usually" => 1, "value" => 1, "various" => 1, "very" => 1, "via" => 1, "viz" => 1, "vs" => 1, "want" => 1, "wants" => 1, "was" => 1, "wasn't" => 1, "way" => 1, "we" => 1, "we'd" => 1, "we'll" => 1, "we're" => 1, "we've" => 1, "welcome" => 1, "well" => 1, "went" => 1, "were" => 1, "weren't" => 1, "what" => 1, "what's" => 1, "whatever" => 1, "when" => 1, "whence" => 1, "whenever" => 1, "where" => 1, "where's" => 1, "whereafter" => 1, "whereas" => 1, "whereby" => 1, "wherein" => 1, "whereupon" => 1, "wherever" => 1, "whether" => 1, "which" => 1, "while" => 1, "whither" => 1, "who" => 1, "who's" => 1, "whoever" => 1, "whole" => 1, "whom" => 1, "whose" => 1, "why" => 1, "will" => 1, "willing" => 1, "wish" => 1, "with" => 1, "within" => 1, "without" => 1, "won't" => 1, "wonder" => 1, "would" => 1, "would" => 1, "wouldn't" => 1, "yes" => 1, "yet" => 1, "you" => 1, "you'd" => 1, "you'll" => 1, "you're" => 1, "you've" => 1, "your" => 1, "yours" => 1, "yourself" => 1, "yourselves" => 1, "zero" => 1);
    $search_query = get('search_query');
    if (!$search_query) {
        $PH->abortWarning("Nothing entered...");
    }
    /**
     * additionally remove slashes and ? because we are gonny using this in a regex
     */
    $search_query = asMatchString($search_query);
    ### direct id -jumps
    if ($search_query && intval($search_query) == $search_query) {
        $id = intval($search_query);
        require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
        ### visibile item?
        if ($item = DBProjectItem::getVisibleById($id)) {
            switch ($item->type) {
                case ITEM_TASK:
                    $PH->show('taskView', array('tsk' => $id));
                    exit;
                case ITEM_PROJECT:
                    $PH->show('projView', array('prj' => $id));
                    exit;
                case ITEM_COMPANY:
                    $PH->show('companyView', array('company' => $id));
                    exit;
                case ITEM_COMMENT:
                    $PH->show('commentView', array('comment' => $id));
                    exit;
                case ITEM_FILE:
                    $PH->show('fileView', array('file' => $id));
                    exit;
                case ITEM_COMPANY:
                    $PH->show('companyView', array('company' => $id));
                    exit;
                default:
                    new FeedbackMessage(__('cannot jump to this item type'));
            }
        }
    }
    $a = array('q' => $search_query);
    addRequestVars($a);
    $flag_jump = false;
    if (preg_match("/(.*)!\$/", $search_query, $matches)) {
        $flag_jump = true;
        $search_query = $matches[1];
    }
    $found_stop_words = array();
    $found_ok_words = array();
    /**
     * adjust query with more than one word...
     * e.g. "admi task" -> "+admi* +task"
     */
    $search_query = asSearchQuery($search_query);
    if (count($ar = explode(' ', $search_query)) > 1) {
        $search_query = '';
        $sep = '+';
        foreach ($ar as $a) {
            #$a = preg_replace("/[\t (),\*+:\\_\"'.=]/","",$a);
            if (!$a || strlen($a) < 3) {
                continue;
            } else {
                if (isset($mysql_default_stopwords[$a])) {
                    $found_stop_words[] = $a;
                } else {
                    $search_query .= $sep . $a;
                    $sep = "* +";
                    $found_ok_words[] = $a;
                }
            }
        }
    } else {
        if (isset($mysql_default_stopwords[$search_query])) {
            $found_stop_words[] = $search_query;
        } else {
            if ($search_query) {
                $found_ok_words[] = $search_query;
            }
        }
    }
    if ($found_stop_words) {
        new FeedbackHint(sprintf(__("Due to the implementation of MySQL following words cannot be searched and have been ignored: %s"), join($found_stop_words, ', ')));
    }
    if (!$found_ok_words) {
        new FeedbackWarning(__("Sorry, but there is nothing left to search."));
        $results = array();
    } else {
        if ($results = SearchResult::getForQuery($search_query)) {
            usort($results, array("SearchResult", "cmp"));
            $results = array_reverse($results);
        }
    }
    if ($flag_jump) {
        if (count($results) && isset($results[0]->jump_params)) {
            new FeedbackMessage(sprintf(__('jumped to best of %s search results'), count($results)));
            $PH->show($results[0]->jump_id, $results[0]->jump_params);
            exit;
        }
    } else {
        if (!$found_stop_words) {
            new FeedbackHint(__('Add an ! to your search request to jump to the best result.'));
        }
    }
    $page = new Page();
    #$page->tabs['search']=  array('target'=>"index.php?go=error",     'title'=>"Error", 'bg'=>"error");
    $PH->defineFromHandle(array('search_query' => $search_query));
    $page->cur_tab = 'search';
    $page->options[] = new NaviOption(array('target_id' => 'search'));
    if (count($results)) {
        $page->title = sprintf(__("%s search results for `%s`"), count($results), $search_query . "*");
    } else {
        $page->title = sprintf(__("No search results for `%s`"), $search_query . "*");
    }
    $page->type = __("Searching");
    echo new PageHeader();
    echo new PageContentOpen();
    if (!count($results)) {
        echo "<p>" . __("Sorry. Could not find anything.") . "</p>";
        echo "<p>" . __("Due to limitations of MySQL fulltext search, searching will not work for...<br>- words with 3 or less characters<br>- Lists with less than 3 entries<br>- words containing special charaters") . "</p>";
    } else {
        $list = new ListBlock_searchresults();
        $list->print_automatic($results);
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 7
0
if (function_exists('mysql_connect')) {
    $g_supported_db_types[] = 'mysql';
}
if (function_exists('mysqli_connect')) {
    $g_supported_db_types[] = 'mysqli';
}
require_once dirname(__FILE__) . "/../std/common.inc.php";
#require_once(dirname(__FILE__)."/../std/errorhandler.inc.php");
require_once dirname(__FILE__) . "/../conf/defines.inc.php";
require_once dirname(__FILE__) . "/../conf/conf.inc.php";
require_once dirname(__FILE__) . "/install_forms.inc.php";
print_InstallationHTMLOpen();
clearRequestVars();
addRequestVars($_GET);
addRequestVars($_POST);
addRequestVars($_COOKIE);
if (!get('install_step')) {
    step_01_checkEvironment();
} else {
    step_02_form_submit();
}
print_InstallationHTMLClose();
exit;
/**
* STEP WELCOME TO INSTALLATION
*/
function step_01_checkEvironment()
{
    global $g_supported_db_types;
    $flag_errors = false;
    echo "<h1>Welcome to installing streber " . confGet('STREBER_VERSION') . "</h1>";