function getRandomTimestamp() { $randomDigit = mt_rand(0, 6) * -1; return strtotime($randomDigit . ' day'); } function createDoc() { global $titles, $authors, $categories, $tags; $title = getRandomArrayItem($titles); $author = getRandomArrayItem($authors); $category = getRandomArrayItem($categories); $articleTags = array(); $numOfTags = rand(1, 5); for ($j = 0; $j < $numOfTags; $j++) { $tag = getRandomArrayItem($tags); if (!in_array($tag, $articleTags)) { array_push($articleTags, $tag); } } $publishedAt = new MongoDate(getRandomTimestamp()); $rating = mt_rand(1, 10); return array('title' => $title, 'author' => $author, 'category' => $category, 'tags' => $articleTags, 'published_at' => $publishedAt, 'rating' => $rating); } $mongo = DBConnection::instantiate(); $collection = $mongo->getCollection('sample_articles'); echo "Generating sample data..."; for ($i = 0; $i < 1000; $i++) { $document = createDoc(); $collection->insert($document); } echo "Finished!";
function indexer($file, $tab_mot_vide) { global $conn; //______________________ traitement head________________________ $title = get_title_With_ER($file); $keywords = get_meta_keywords($file); $description = get_meta_description($file); $chaine_head = $keywords . " " . $description . " "; // conversion entites html ascii $chaine_head = entitesHTML2Caracts($chaine_head); //minuscule $chaine = strtolower($chaine_head); //les separateurs pour decouper le texte en mots $separateurs = " |{}[])(-_;,:.'’»«\$!?\"*\\/&=#"; //decoupage du texte en elements/mots $tab_mots_head = explodeBIS($separateurs, $chaine); //affichage des mots //print_tab($tab_mots); //echo "<br><br>"; //calcul de la frequence des mots //suppression des doublons $tab_mots_occurrences_head = array_count_values($tab_mots_head); //print_tab($tab_mots_occurrences); // calcul du poids des mots $tab_mots_poids_head = occ2poids($tab_mots_occurrences_head, 2); //print_tab($tab_mots_poids_head); //______________________ Fin traitement head________________________ //______________________ traitement body________________________ $body = get_Body($file); // body sans balises scripts $body_sans_scripts = strip_scripts($body); // suppression des balises html $clean_body = strip_tags($body_sans_scripts); // conversion entites html ascii $clean_body = entitesHTML2Caracts($clean_body); //minuscule $clean_body = strtolower($clean_body); //les separateurs pour decouper le texte en mots $separateurs = " |{}[])(-_;,:.'’»«\$!?\"*\\/&=#"; //decoupage du texte en elements/mots $tab_mots_body = explodeBIS($separateurs, $clean_body); //affichage des mots //print_tab($tab_mots); //echo "<br><br>"; //calcul de la frequence des mots //suppression des doublons $tab_mots_occurrences_body = array_count_values($tab_mots_body); //print_tab($tab_mots_occurrences); // calcul du poids des mots $tab_mots_poids_body = $tab_mots_occurrences_body; //print_tab($tab_mots_poids_body); //________________________ fin traitement body ______________________ // fusion des deux tableaux $tab_mots_poids = fusion_tabH_tabB_tabV($tab_mots_poids_head, $tab_mots_poids_body, $tab_mot_vide); //print_tab($tab_mots_poids); //création du doccument dans la BDD $data = array('adr' => mysqli_real_escape_string($conn, $file), 'title' => mysqli_real_escape_string($conn, $title), 'description' => mysqli_real_escape_string($conn, $description)); $id_doc = createDoc($data); foreach ($tab_mots_poids as $mot => $poids) { if (!cleanChaine($mot)) { $data = array('id_doc' => mysqli_real_escape_string($conn, $id_doc), 'mot' => mysqli_real_escape_string($conn, trim($mot)), 'poids' => mysqli_real_escape_string($conn, $poids)); createMot($data); } } }
function region($subnet) { $towerIds = getTowerIds(); global $config; global $body; global $enableAll; global $kmlCreation; include_once $config['base_path'] . '/plugins/gpsmap/class/hosts_class.php'; $kmlDomain = read_config_option("gpsmap_kmldomain"); $iparray = array(); $ipwriteout = array(); $hostArrays = array(); $hostArray = array(); $towerArray = array(); $back = ""; //we are going to parse every node and sort them by region numbers, IE the IP range seleced in the setup. if ($enableAll) { $result = mysql_query("SELECT * FROM `host` LEFT JOIN gpsmap_templates ON host.host_template_id = gpsmap_templates.templateID ORDER BY hostname"); } else { $result = mysql_query("SELECT * FROM `host` LEFT JOIN gpsmap_templates ON host.host_template_id = gpsmap_templates.templateID WHERE disabled='' ORDER BY hostname"); } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if (isset($row['latitude']) && isset($row['longitude']) && $row['latitude'] != '' && $row['latitude'] != '' && $row['latitude'] != '0' && $row['longitude'] != '0') { if (list($first, $second, $third, $fourth) = explode('.', gethostbyname($row["hostname"]))) { $status = $row['status']; $upimage = $row['upimage'] ? $row['upimage'] : "Green"; $downimage = $row['downimage'] ? $row['downimage'] : "Red"; $recoverimage = $row['recoverimage'] ? $row['recoverimage'] : "Yellow"; // ((condition) ? (true) : (false)) if ($status == 3) { $status = "up"; } elseif ($status == 1) { $status = "down"; } elseif ($status == 2) { $status = "recovering"; } else { $status = "undefined"; } if ($row['disabled'] == "on") { $status = "disabled"; } $start = $row['start']; $lat = coordCheck($row['latitude']); $lon = coordCheck($row['longitude']); $stop = $row['stop']; $group = $row['groupnum']; if (in_array($row['host_template_id'], $towerIds)) { $towerArray[] = new host($row['id'], $row['host_template_id'], $lat, $lon, $first . $second . $third . $fourth, $row['description'], $row['hostname'], 0, $row['availability'], $status, $row['cur_time'], $row['GPScoverage'], $upimage, $downimage, $recoverimage, $start, $stop, $group); } else { $hostArray[] = new host($row['id'], $row['host_template_id'], $lat, $lon, $first . $second . $third . $fourth, $row['description'], $row['hostname'], 0, $row['availability'], $status, $row['cur_time'], $row['GPScoverage'], $upimage, $downimage, $recoverimage, 0, 360, $group); } } } } $hostArrays[] = $towerArray; $hostArrays[] = $hostArray; $preempt = str_word_count($subnet, 0, '.'); if ($subnet == "all") { $preempt = 0; } //This section deals with traversal of the subnets //sort by top level, and display all top IP range so they can be selected, and iterate this down through level 4 //if subnet level is met we want to display the lower ones. //for 1 we want to display all top level IP foreach ($hostArrays as $hostArray) { foreach ($hostArray as $host) { list($first, $second, $third, $fourth) = explode('.', $host->hostname); switch ($preempt) { case 0: if (!in_array($first . '.', $iparray)) { $iparray[] = $first . '.'; } break; case 1: if (!strcasecmp($subnet, $first . '.')) { if (!in_array($first . '.' . $second . '.', $iparray)) { $iparray[] = $first . '.' . $second . '.'; } } else { //set disable if it does not match $host->showMap = 0; } break; case 2: if (!strcasecmp($subnet, $first . '.' . $second . '.')) { if (!in_array($first . '.' . $second . '.' . $third . '.', $iparray)) { $iparray[] = $first . '.' . $second . '.' . $third . '.'; } } else { $host->showMap = 0; } break; case 3: if (!strcasecmp($subnet, $first . '.' . $second . '.' . $third . '.')) { if (!in_array($first . '.' . $second . '.' . $third . '.' . $fourth . '.', $iparray)) { $iparray[] = $first . '.' . $second . '.' . $third . '.' . $fourth; $ipwriteout[] = "<a href=\"../../graph_view.php?action=preview&host_id=" . $host->id . "\">IP " . $first . '.' . $second . '.' . $third . '.' . $fourth . "</a><br/>"; } } else { $host->showMap = 0; } break; default: $host->showMap = 0; break; } } } //process data collected and create interface output foreach ($iparray as $ipout) { if ($preempt != 3) { $ipwriteout[] = "<a href=\"./gpsmap.php?subnet=" . $ipout . "\">IP " . $ipout . "</a>-(<a href=\"http://" . $kmlDomain . $config['url_path'] . "plugins/gpsmap/XML/" . $ipout . ".xml\">X</a>-<a href=\"http://" . $kmlDomain . $config['url_path'] . "plugins/gpsmap/XML/" . $ipout . ".kml\">K</a>)<br/>"; } } //print out the information we have gathered. $body .= '<div id="gpstopmenu" style="border:1px solid black; overflow: auto; width:100%; background-color:lightgrey;">'; $body .= "<div id=\"gpsnav\"style=\"width:75px; overflow:auto; background-color:lightgrey; float:left; position:relative;\"><a href=\"./gpsmap.php\"><u>Start Over</u></a><br/><br/>"; $body .= "<img src=\"./images/print.gif\" class=\"print\" alt=\"print\" title=\"print\" onclick=\"window.open('print.php')\" />"; $body .= "</div>"; $tempHold = " "; $i = 1; foreach ($ipwriteout as $ipoutput) { $tempHold .= $ipoutput; if ($i % 6 == 0) { $body .= "<div id=\"iplevels\" style=\"width:120px; overflow: auto; float:left; background-color:lightgrey; position: relative;\">" . $tempHold . "</div>"; $tempHold = " "; } $i++; } //print out what is left $body .= "<div id=\"iplevels\" style=\"width:120px; overflow:auto; float:left; background-color:lightgrey; position: relative;\">" . $tempHold . "</div>"; $tempHold = " "; $body .= "</div>"; if ($subnet == "") { createDoc($hostArrays, "all"); } else { createDoc($hostArrays, $subnet); } if ($subnet == "") { $subnet = "all"; } $filename = $config['base_path'] . "/plugins/gpsmap/XML/" . $subnet . "-top.html"; $f = fopen($filename, "w"); fwrite($f, $body); fclose($f); $body = ""; }
$outputDir = __DIR__ . '/../docs/wikidocs'; if (!is_dir($outputDir)) { mkdir($outputDir); } $files = new RecursiveDirectoryIterator($libDir); $files = new RecursiveIteratorIterator($files, RecursiveIteratorIterator::LEAVES_ONLY); include_once $libDir . '/Sabre/autoload.php'; // Finding all classnames $classNames = findClassNames($files); echo "Found: " . count($classNames) . " classes and interfaces\n"; echo "Generating class tree\n"; $classTree = getClassTree($classNames); $packageList = array(); foreach ($classNames as $className) { echo "Creating docs for: " . $className . "\n"; $output = createDoc($className, isset($classTree[$className]) ? $classTree[$className] : array()); file_put_contents($outputDir . '/' . $className . '.wiki', $output); } echo "Creating indexes\n"; $output = createSidebarIndex($packageList); file_put_contents($outputDir . '/APIIndex.wiki', $output); function findClassNames($files) { $classNames = array(); foreach ($files as $fileName => $fileInfo) { $tokens = token_get_all(file_get_contents($fileName)); foreach ($tokens as $tokenIndex => $token) { if ($token[0] === T_CLASS || $token[0] === T_INTERFACE) { $classNames[] = $tokens[$tokenIndex + 2][1]; } }