function search($chaine, $cle = false, $from = 0) { global $snippets, $template, $config; if ($cle == false) { $query = 'search=' . $chaine; } else { $query = 'tag=' . $chaine; } $chaine = str_replace(' ', '+', $chaine); $chaine = explode('+', $chaine); $nb_words = count($chaine); $list = ''; $admin = is_ok(); $results = array(); foreach ($snippets as $snippet) { if ($admin && isset($snippet['#num']) || isset($snippet['#num']) && is_public($snippet['#num'])) { if (!$cle && are_values_in_string($chaine, implode(' ', $snippet)) !== false || $cle && isset($snippet[$cle]) && are_values_in_string($chaine, $snippet[$cle]) !== false) { $results[$snippet['#num']] = $snippet; } } } $nb_results = count($results); $results = array_slice($results, $from, $config['nb_snippets_homepage'], true); $results = array_reverse($results); foreach ($results as $snippet) { $list .= templatise_snippet($snippet); } $list .= '<p class="pagination">' . paginate($from, $nb_results, $query) . '</p>'; if ($list != '') { return $list; } else { return false; } }
// ------------------------------------------------------------------ // user wants to logout (?logout $_GET var) // ------------------------------------------------------------------ if (isset($_GET['deconnexion']) || isset($_GET['logout'])) { @session_destroy(); delete_cookie(); exit_redirect(); } // ------------------------------------------------------------------ // ------------------------------------------------------------------ // if here, there's no login/logout process. // Check referrer, ip // session duration... // on problem, out ! // ------------------------------------------------------------------ if (!is_ok()) { @session_destroy(); if (!$auto_restrict['just_die_if_not_logged']) { include 'login_form.php'; } else { echo $auto_restrict['error_msg']; } exit; } // ------------------------------------------------------------------ // ------------------------------------------------------------------ // if here, there was no security problem. // Now, if there is an admin password post data, // it means that the submitted form is a secured one: // check if password is correct (if not => ban ip and stop here) // ------------------------------------------------------------------
} function w($f, $d) { file_put_contents($f, $d) || die("can`t write to {$f}, check permisions\n"); } if ($debug) { echo "DEBUG: Start\n"; } $ad = @file_get_contents($f_a); if ($ad && is_ok($ad)) { exit; } $d = @file($f_s); if (!is_array($d)) { $d = array(); } if ($debug) { echo "DEBUG: " . count($d) . " domains\n"; } while (count($d) > 0) { $cd = array_shift($d); if ($debug) { echo "DEBUG: Try to check {$cd}\n"; } if ($cd && is_ok($cd)) { w($f_a, trim($cd)); w($f_s, implode('', $d)); exit; } } die("no more clean domains in {$f_s}\n");