function wiki_parser_attached_files_ewiki($line)
{
    global $WS;
    $begin = strpos($line, 'internal://');
    while ($begin !== false) {
        for ($i = $begin; $i < strlen($line) and $line[$i] !== ' '; $i++) {
        }
        $end = $i;
        $file = substr($line, $begin + 11, $end - ($begin + 11));
        $internal = '<a href="' . wiki_upload_url($file, $WS) . '">' . $file . '</a>';
        $line = str_replace('internal://' . $file, $internal, $line);
        $begin = strpos($line, 'internal://', $end);
    }
    return $line;
}
function wiki_sintax_create_internal_link_bis(&$linktext)
{
    global $WS, $USER, $itinerary;
    $WS->member->id = $USER->id;
    if ($WS->dfwiki->studentmode == '0') {
        $WS->member->id = '0';
    }
    $res = '';
    //separate type link from link text
    $parts = explode(":", $linktext);
    if (count($parts) == 1) {
        $linktype = 'internal';
        $linkname = $parts[0];
    } else {
        $linktype = $parts[0];
        $linkname = $parts[1];
    }
    switch ($linktype) {
        case 'internal':
            //normal internal links
            //separate linktext into pagename and text
            $parts = explode("|", $linkname);
            if (count($parts) == 1) {
                $linkpage = $parts[0];
                $linktext = $parts[0];
            } else {
                $linkpage = $parts[0];
                $linktext = $parts[1];
            }
            $cleanpagename = clean_filename($linkpage);
            if (isset($itinerary)) {
                if (!wiki_page_exists($WS, $linkpage)) {
                    $res = '<b><u>' . $linktext . '</u></b><a target="popup" href="' . $linkpage . '.html">?</a>';
                } else {
                    $res = '<a href="' . $cleanpagename . '.html">' . $linkpage . '</a>';
                }
            } else {
                if (wiki_page_exists($WS, $linkpage)) {
                    //if the page already exists
                    $res = '<a href="' . $cleanpagename . '.html">' . $linktext . '</a>';
                } else {
                    //to create the page
                    $res = '<b><u>' . $linktext . '</u></b><a href="' . $linkpage . '.html">?</a>';
                }
            }
            //save link into log
            if (!isset($WS->parser_logs['internal'])) {
                $WS->parser_logs['internal'] = array();
            }
            if (!in_array($linkpage, $WS->parser_logs['internal'])) {
                $WS->parser_logs['internal'][] = $linkpage;
            }
            break;
        case 'user':
            $res = wiki_get_user_info($linkname, 25);
            break;
        case 'attach':
            wiki_upload_config($WS);
            $res = '[' . wiki_upload_url($linkname, $WS) . ' ' . $linkname . ']';
            break;
        default:
            //error
    }
    return $res;
}