[chora] Search Function in chora (double login need help)

Christiaan DeRuiter cdr00 at earthlink.net
Fri Apr 18 12:25:15 PDT 2003


We've a serious need for people to find a file based on filename or part of=
 it.
Due to the fact that nobody could show me a tool that can do this and luxor=
 is not ready for cvs yet, I created a little hack
to do this.
There are only two issue's that needs to be resolved with this.
1. you need to login twice.
2. It only works for one user due to the fact that the session specifics ar=
e not passed thru.

Any thoughts on this ??

With this I=E2=80=99m including the code.
OK I know I=E2=80=99m not a programmer but for a scripter, I would say it w=
orks!!

=20

CVS.PHP


59          /* This is where our HACK could come */
    60          ?>
    61          <table>
    62          <form method=3D"post" action=3D"/horde/chora/search_vcs.php=
">
    63          <tr class =3D item1><td>File Name</td><td>
    64                  <input type=3D"text"  name=3D"fname"></td>
    65          <td>File Name Contains</td><td>
    66                  <input type=3D"text"  name=3D"fuzzy"></td><td>
    67                  <input type=3D"submit" value=3D"Submit Search" >
    68          </td></tr></form>
    69          </table>
    70          <?php

=20

search_cvs.php
=20
The substr 26 strips away the first part of the path to my vcs repository a=
nd of course -2 strips the vcs extension.

<?php
define('CHORA_BASE', dirname(__FILE__));
require_once CHORA_BASE . '/lib/base.php';
require_once HORDE_BASE . '/config/mime_mapping.php';
require_once HORDE_BASE . '/config/mime_drivers.php';
require_once HORDE_BASE . '/lib/MIME/Magic.php';
require_once HORDE_BASE . '/lib/MIME/Viewer.php';
require_once CHORA_BASE . '/config/mime_drivers.php';

if (@is_dir($fullname)) {
    /* checkError() is the error trapping function. */
    checkError($dir =3D $CVS->queryDir($where));
    $atticFlags =3D $acts['sa'] ? CVSLIB_ATTIC_SHOW : CVSLIB_ATTIC_HIDE;
    checkError($dir->browseDir(CVSLIB_LOG_QUICK, $atticFlags));
    $dir->applySort($acts['sbt'], $acts['ord']);
    checkError($dirList =3D& $dir->queryDirList());
    checkError($fileList =3D $dir->queryFileList($atticFlags));

    /* Decide what title to display */
    if ($where =3D=3D '') {
        $title =3D $conf['options']['introTitle'];
    } else {
        $title =3D sprintf(_("CVS Directory of /%s"), Text::htmlallspaces($=
where));
    }
    if ($acts['sa']) {
        $extraLink=3D'<a href=3D"' . Chora::url('cvs', $where, array('sa' =
=3D> 0)) . '">' . _("Hide Deleted Files") .
'</a>';
    } else {
        $extraLink=3D'<a href=3D"' . Chora::url('cvs', $where, array('sa' =
=3D> 1)) . '">' . _("Show Deleted Files") .
'</a>';
    }
    $js_onLoad =3D null;
    require CHORA_TEMPLATES . '/common-header.inc';
    require CHORA_BASE . '/menu.php';
    require CHORA_TEMPLATES . '/headerbar.inc';
    $dirrow =3D 0;
        $fnamesrch =3D $HTTP_POST_VARS["fname"];
        //$fuzzysrch =3D $HTTP_POST_VARS["fuzzy"];
        if ( $fnamesrch ){
                exec("find /repository/fs001/vc-data -name $fnamesrch,v -pr=
int", $TempFile);
                $itemnr =3D "item0";
                print "<table>";
                print "<tr class =3Dsmallheader>";
                print "<td align=3Dleft><h4>Searching on</h4></td><td><h5> =
$fnamesrch</h5>";
                print "</td></tr>";
                foreach ($TempFile as $currFile) {
                        $currFile =3D substr($currFile,26,-2);
                        //print "<tr class =3D $itemnr><td colspan =3D 2><a=
 href=3D\"https://doubt.ovid.com/horde/chora/cvs.php/$currFile?login=3D1\">=
";
                        print "<tr class =3D $itemnr><td colspan =3D 2><a h=
ref=3D\"https://doubt.ovid.com/horde/chora/
cvs.php/$currFile\">";
                        print "$currFile";
                        print "</a>";
                        print "</td></tr>";
                        if ( "$itemnr" =3D=3D "item0" ){
                                $itemnr =3D "item1";
                        } else {
                                $itemnr =3D "item0";
                        }
                }
        }
        print "</table>";
        $fuzzysrch =3D $HTTP_POST_VARS["fuzzy"];
        if ( $fuzzysrch ){
                exec("find /repository/fs001/vc-data -name *$fuzzysrch*,v -=
print", $TempFile2);
                $itemnr =3D "item0";
                print "<table>";
                print "<tr class =3Dsmallheader>";
                print "<td align=3Dleft><h4>Searching on</h4></td><td><h5> =
$fuzzysrch</h5>";
                print "</td></tr>";
                foreach ($TempFile2 as $currFile2) {
                        $currFile2 =3D substr($currFile2,26,-2);
                        //print "<tr class =3D $itemnr><td colspan =3D 2><a=
 href=3D\"https://doubt.ovid.com/horde/chor
a/cvs.php/$currFile2?login=3D1\">";
                        print "<tr class =3D $itemnr><td colspan =3D 2><a h=
ref=3D\"https://doubt.ovid.com/horde/chora/
cvs.php/$currFile2\">";
                        print "$currFile2";
                        print "</a>";
                        print "</td></tr>";
                        if ( "$itemnr" =3D=3D "item0" ){
                                $itemnr =3D "item1";
                        } else {
                                $itemnr =3D "item0";
                        }
                }
        }
    print "</table>";
}

=20



Thanks,

Chris.=20




More information about the chora mailing list