示例#1
0
function index_all()
{
    global $mysql_table_prefix;
    $result = mysql_query("select url, spider_depth, required, disallowed, can_leave_domain from " . $mysql_table_prefix . "sites");
    echo mysql_error();
    while ($row = mysql_fetch_row($result)) {
        $url = $row[0];
        $depth = $row[1];
        $include = $row[2];
        $not_include = $row[3];
        $can_leave_domain = $row[4];
        if ($can_leave_domain == '') {
            $can_leave_domain = 0;
        }
        if ($depth == -1) {
            $soption = 'full';
        } else {
            $soption = 'level';
        }
        index_site($url, 1, $depth, $soption, $include, $not_include, $can_leave_domain);
    }
}
示例#2
0
            } else {
                $soption = 'level';
            }
        }
        if ($clear == 1) {
            clean_resource($result, '01');
        }
    }
    if (!isset($in)) {
        $in = "";
    }
    if (!isset($out)) {
        $out = "";
    }
    $started = time();
    index_site($url, $reindex, $maxlevel, $soption, $in, $out, $can_leave, $use_robot, $use_nofollow, $cl, $all, $use_pref);
    $ended = time();
    $consumed = $ended - $started;
    printConsumedReport('consumed', $cl, '0', $consumed);
    printStandardReport('ReindexFinish', $command_line, '0');
}
printStandardReport('quit', $command_line, '0');
if ($email_log) {
    $indexed = $all == 1 ? 'ALL' : $url;
    $log_report = "";
    if ($log_handle) {
        $log_report = "Log saved into {$log_file}";
    }
    mail($admin_email, "Sphider indexing report", "Sphider has finished indexing {$indexed} at " . date("y-m-d H:i:s") . ". " . $log_report);
}
if ($log_handle) {
function index_suspended()
{
    global $db_con, $mysql_table_prefix, $command_line, $debug, $use_robot, $use_nofollow, $no_log, $clear, $started, $cl;
    $started = time();
    $reindex = 0;
    printStandardReport('SuspendedStart', $command_line, $no_log);
    //  get ID and URL of all sites
    $sql_query = "SELECT site_id, url from " . $mysql_table_prefix . "sites ORDER by url";
    $result1 = $db_con->query($sql_query);
    if ($debug && $db_con->errno) {
        $err_row = __LINE__ - 2;
        printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
        if (__FUNCTION__) {
            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
        } else {
            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
        }
        printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
        printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
        echo "<p> {$sql_query} </p>";
        exit;
    }
    while ($row1 = $result1->fetch_array(MYSQLI_NUM)) {
        $url = $row1[1];
        $site_id = $row1[0];
        //  check whether this site is pending
        $sql_query = "SELECT site_id from " . $mysql_table_prefix . "pending where site_id ={$site_id}";
        $result2 = $db_con->query($sql_query);
        $row2 = $result2->fetch_array(MYSQLI_ASSOC);
        //  if pending, continue indexing this URL
        if ($row2['site_id'] == $site_id) {
            //  fetch all important data of this site
            $sql_query = "SELECT url, spider_depth, required, disallowed, can_leave_domain, use_prefcharset from " . $mysql_table_prefix . "sites where url='{$url}'";
            $result = $db_con->query($sql_query);
            if ($row = $result->fetch_array(MYSQLI_NUM)) {
                $maxlevel = $row[1];
                $in = $row[2];
                $out = $row[3];
                $domaincb = $row[4];
                $use_prefcharset = $row[5];
                if ($domaincb == '') {
                    $domaincb = 0;
                }
                if ($maxlevel == -1) {
                    $soption = 'full';
                } else {
                    $soption = 'level';
                }
            }
            if ($clear == 1) {
                clean_resource($result, '21');
            }
            if (!isset($in)) {
                $in = "";
            }
            if (!isset($out)) {
                $out = "";
            }
            //  now indnex the rest of this site
            index_site($url, $reindex, $maxlevel, $soption, $in, $out, $domaincb, $use_robot, $use_nofollow, $cl, $all, $use_prefcharset);
        }
    }
    if ($clear == 1) {
        clean_resource($result, '20');
    }
    $ended = time();
    $consumed = $ended - $started;
    printConsumedReport('consumed', $cl, '0', $consumed);
    printStandardReport('SuspendedFinish', $command_line, '0');
    create_footer();
}
示例#4
0
文件: spider.php 项目: pwh/scrutiny
function index_new()
{
    global $command_line, $use_robot;
    $reindex == 0;
    //include "admin_header.php";
    printStandardReport('NewStart', $command_line);
    $result = mysql_query("select url, indexdate, spider_depth, required, disallowed, can_leave_domain from " . TABLE_PREFIX . "sites");
    if (DEBUG > '0') {
        echo mysql_error();
    }
    while ($row = mysql_fetch_row($result)) {
        $url = $row[0];
        $indexdate = $row[1];
        $depth = $row[2];
        $include = $row[3];
        $not_include = $row[4];
        $can_leave_domain = $row[5];
        if ($can_leave_domain == '') {
            $can_leave_domain = 0;
        }
        if ($depth == -1) {
            $soption = 'full';
        } else {
            $soption = 'level';
        }
        if ($indexdate == '') {
            index_site($url, 1, $depth, $soption, $include, $not_include, $can_leave_domain, $use_robot);
        }
    }
    clean_resource($result);
    printStandardReport('NewFinish', $command_line);
    create_footer();
}
     fclose($fp);
 }
 if (!$site_url) {
     //  enter here to re-index all sites
     index_all();
 } else {
     //  enter here foe site specific re-index
     $reindex = '1';
     $cl = '0';
     $all = '0';
     if ($maxlevel == -1) {
         $soption = 'full';
     } else {
         $soption = 'level';
     }
     index_site($site_url, $reindex, $maxlevel, $soption, $include, $not_include, $can_leave_domain, $use_robot, $use_nofollow, $cl, $all, $use_prefcharset);
 }
 $auto_ended = time();
 $auto_consumed = $auto_ended - $started;
 //  calculated time for last re-index procedure
 $wait = $interval - $auto_consumed;
 //  calculate rest of index interval
 if ($wait <= 0) {
     //  if interval is too short
     $update = "aborted" . time() . "";
     $fp = fopen($logfile, "a");
     //  add 'aborted' to the end of the auto-indexer log file
     if (is_readable($logfile)) {
         fwrite($fp, $update);
         fclose($fp);
     }
示例#6
0
function admin($pageid, $userid)
{
    if (isset($_GET['doaction']) && $_GET['doaction'] == 'getsuggestions' && isset($_GET['forwhat'])) {
        if (strlen($_GET['forwhat']) >= 3) {
            echo getSuggestions($_GET['forwhat']);
            disconnect();
            exit;
        }
    }
    global $urlRequestRoot, $templateFolder, $cmsFolder, $ICONS;
    if (isset($_GET['indexsite'])) {
        global $sourceFolder;
        require "{$sourceFolder}/modules/search/admin/spider.php";
        if ($_GET['indexsite'] == 1) {
            $serveruri = isset($_SERVER['ORIG_SCRIPT_NAME']) ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME'];
            $uri = substr($serveruri, 0, stripos($serveruri, "index.php"));
            $site = "http://" . $_SERVER['HTTP_HOST'] . $uri . "home/";
            index_site($site, 0, -1, 'full', "", "+\n&", 0);
            displayinfo("Index for site created");
        } else {
            index_all();
        }
    }
    $result = mysql_fetch_array(mysql_query("SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute` = 'reindex_frequency'"));
    if ($result != NULL) {
        $threshold = $result['value'];
    } else {
        $threshold = 30;
    }
    $result = mysql_fetch_array(mysql_query("SELECT to_days(CURRENT_TIMESTAMP)-to_days(`indexdate`) AS 'diff' FROM `sites` WHERE `url` LIKE '%home%'"));
    if ($result == NULL) {
        displayinfo("It seems the site doesn't have index for the search to work. Click <a href='./+admin&indexsite=1'>here</a> to index the site.");
    } else {
        if ($result['diff'] > $threshold) {
            displayinfo("Your site index was created {$result['diff']} days before. Click <a href='./+admin&indexsite=2'>here</a> to reindex your site.");
        }
    }
    $quicklinks = <<<ADMINPAGE
\t<fieldset>
\t<legend>{$ICONS['Website Administration']['small']}Website Administration</legend>
\t<a name='quicklinks'></a>
\t<table class="iconspanel">
\t<tr>
\t<td><a href="./+admin&subaction=global"><div>{$ICONS['Global Settings']['large']}<br/>Global Settings</div></a></td>\t
\t<td><a href="./+admin&subaction=template"><div>{$ICONS['Templates Management']['large']}<br/>Templates Management</div></a></td>
\t<td><a href="./+admin&subaction=module"><div>{$ICONS['Modules Management']['large']}<br/>Module Management</div></a></td>
\t<td><a href="./+admin&subaction=widgets"><div>{$ICONS['Widgets']['large']}<br/>Widgets Management</div></a></td>
\t</tr>
\t<tr>
\t<td><a href="./+admin&subaction=icon"><div>{$ICONS['Icons']['large']}<br/>Icons Management</div></a></td>
\t<td><a href="./+admin&subaction=email"><div>{$ICONS['Email Registrants']['large']}<br/>Email Registrants</div></a></td>
\t<td><a href="./+admin&subaction=editgroups"><div>{$ICONS['User Groups']['large']}<br/>Group Management</div></a></td>
\t<td><a href="./+admin&subaction=expert"><div>{$ICONS['Site Maintenance']['large']}<br/>Site Maintenance</div></a></td>
\t</tr>
\t<tr>
\t
\t<td colspan=2><a href="./+admin&subaction=useradmin"><div>{$ICONS['User Management']['large']}<br/>User Management</div></a></td>
\t<td colspan=2><a href="./+admin&subaction=editprofileform"><div>{$ICONS['User Profile']['large']}<br/>User Profiles</div></a></td>
\t</tr>

\t</table>
\t</fieldset>
ADMINPAGE;
    if (isset($_GET['subaction'])) {
        require_once "email.lib.php";
        if ($_GET['subaction'] == "email") {
            return displayEmail() . $quicklinks;
        } else {
            if ($_GET['subaction'] == "openemail") {
                return displayEmail(escape($_GET['name'])) . $quicklinks;
            } else {
                if ($_GET['subaction'] == "emailsend") {
                    sendEmail();
                    return displayEmail(escape($_POST['emailtemplates'])) . $quicklinks;
                } else {
                    if ($_GET['subaction'] == "emailsave") {
                        saveEmail();
                        return displayEmail(escape($_POST['emailtemplates'])) . $quicklinks;
                    }
                }
            }
        }
    }
    if (isset($_GET['subaction']) && ($_GET['subaction'] == 'module' || $_GET['subaction'] == 'template')) {
        $type = escape($_GET['subaction']);
        if ($type == 'module') {
            displaywarning("Module Installation/Uninstallation has the potential to completely bring down the CMS, so Install only modules from trusted source");
        }
        require_once "module.lib.php";
        require_once "template.lib.php";
        $type = ucfirst($type);
        $function = "handle{$type}Management";
        $op = $function();
        if ($op != "") {
            return $op . $quicklinks;
        }
        return managementForm($type) . $quicklinks;
    }
    global $sourceFolder;
    if (!isset($_GET['subaction']) && !isset($_GET['subsubaction'])) {
        return $quicklinks;
    }
    require_once "users.lib.php";
    $op = "";
    $ophead = "";
    $str = "";
    if (isset($_GET['subaction']) || isset($_GET['subsubaction']) || isset($_GET['id']) || isset($_GET['movePermId']) || isset($_GET['module'])) {
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'global' && isset($_POST['update_global_settings'])) {
            updateGlobalSettings();
        } else {
            if (isset($_GET['subaction']) && $_GET['subaction'] == 'global' && isset($_GET['del_black'])) {
                delete_blacklist();
            } else {
                if (isset($_GET['subaction']) && $_GET['subaction'] == 'useradmin') {
                    $op .= handleUserMgmt();
                    $ophead = "{$ICONS['User Management']['small']}User Management";
                } else {
                    if (isset($_GET['subaction']) && $_GET['subaction'] == 'widgets') {
                        $op .= handleWidgetAdmin($pageid);
                        $ophead = "{$ICONS['Widgets']['small']}Widgets Management";
                    } else {
                        if (isset($_GET['subaction']) && $_GET['subaction'] == 'icon') {
                            require_once "iconmanagement.lib.php";
                            $res = handleIconManagement();
                            if (isset($_GET['iconURL'])) {
                                return $res;
                            }
                            $op .= $res;
                            $ophead = "{$ICONS['Icons']['small']}Icons Management";
                        } else {
                            if (isset($_GET['subaction']) && $_GET['subaction'] == 'editgroups') {
                                require_once "permission.lib.php";
                                $pagepath = array();
                                parseUrlDereferenced($pageid, $pagepath);
                                $virtue = '';
                                $maxPriorityGroup = getMaxPriorityGroup($pagepath, $userid, array_reverse(getGroupIds($userid)), $virtue);
                                $modifiableGroups = getModifiableGroups($userid, $maxPriorityGroup);
                                $op .= groupManagementForm($userid, $modifiableGroups, $pagepath);
                                $ophead = "{$ICONS['Group Management']['small']}Group Management";
                            } else {
                                if (isset($_GET['subaction']) && $_GET['subaction'] == 'reloadtemplates') {
                                    $op .= reloadTemplates();
                                    $ophead = "{$ICONS['Templates Management']['small']}Reloading Templates";
                                } else {
                                    if (isset($_GET['subaction']) && $_GET['subaction'] == 'reloadmodules') {
                                        $op .= reloadModules();
                                        $ophead = "{$ICONS['Modules Management']['small']}Reloading Modules";
                                    } else {
                                        if (isset($_GET['subaction']) && $_GET['subaction'] == 'checkPerm') {
                                            $op .= admin_checkFunctionPerms();
                                            $ophead = "{$ICONS['Access Permissions']['small']}Checking Permissions Consistency";
                                        } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'checkAdminUser') {
                                            $op .= admin_checkAdminUser();
                                            $ophead = "Checking Administrator User";
                                        } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'checkAdminPerms') {
                                            $op .= admin_checkAdminPerms();
                                            $ophead = "Checking Administrator Permissions";
                                        } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'changePermRank') {
                                            $op .= admin_changePermRank();
                                            $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank";
                                        } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'editprofileform' || isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'editprofileform') {
                                            $op .= admin_editProfileForm();
                                            $ophead = "{$ICONS['User Profile']['small']}Edit User Profile Form";
                                        } elseif (isset($_GET['id'])) {
                                            $op .= admin_userAdmin();
                                        } elseif (isset($_GET['movePermId'])) {
                                            $op .= admin_changePermRank();
                                            $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank";
                                        } elseif (isset($_GET['module'])) {
                                            $op .= admin_changePermRank(escape($_GET['module']));
                                            $ophead = "{$ICONS['Access Permissions']['small']}Changing Permissions Rank for module '" . escape($_GET['module']) . "'";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($op != "") {
        $op = "<fieldset><legend>{$ophead}</legend>{$op}</fieldset>";
    }
    if (isset($_GET['subaction']) && $_GET['subaction'] == 'global') {
        $str .= globalSettingsForm();
    } else {
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'editgroups') {
            //do nothing so that "expert only" doesn't comes up
        } else {
            if (isset($_GET['subaction']) && $_GET['subaction'] == 'useradmin') {
                $op .= userManagementForm();
            } else {
                if (isset($_GET['subaction']) && $_GET['subaction'] == 'expert') {
                    $str .= "<fieldset><legend>{$ICONS['Site Maintenance']['small']}Experts Only</legend>";
                    $str .= '<a href="./+admin&subaction=checkPerm">Check Permission List</a><br />';
                    $str .= '<a href="./+admin&subaction=checkAdminUser">Check Admin User</a><br />';
                    $str .= '<a href="./+admin&subaction=checkAdminPerms">Check Admin Perms</a><br />';
                    $str .= '<a href="./+admin&subaction=changePermRank">Change Perm Ranks</a><br />';
                    $str .= '<a href="./+admin&subaction=reloadtemplates">Reload Templates</a><br />';
                    $str .= '<a href="./+admin&subaction=reloadmodules">Reload Modules</a><br />';
                    $str .= '<a href="./+admin&indexsite=2">Reindex Site for Searching</a></br/></fieldset>';
                }
            }
        }
    }
    return $str . $op . $quicklinks;
}
function index_all()
{
    global $db;
    $result = $db->query("select url, spider_depth, required, disallowed, can_leave_domain from " . TABLE_PREFIX . "sites");
    echo sql_errorstring(__FILE__, __LINE__);
    while ($row = $result->fetch()) {
        $url = $row[0];
        $depth = $row[1];
        $include = $row[2];
        $not_include = $row[3];
        $can_leave_domain = $row[4];
        if ($can_leave_domain == '') {
            $can_leave_domain = 0;
        }
        if ($depth == -1) {
            $soption = 'full';
        } else {
            $soption = 'level';
        }
        index_site($url, 1, $depth, $soption, $include, $not_include, $can_leave_domain);
    }
}