Ejemplo n.º 1
0
             $result = $db->query($query);
             $created_post_id = $db->last_insert_id;
             /*
              * Start of the indexing process.
              */
             // Setting some vars
             $text = $_POST['post_content'];
             $title = $_POST['post_title'];
             $post_id = $created_post_id;
             $tags = $_POST['post_tags'];
             // Add new post to index
             search::add_to_index($text, $post_id, search::WEIGHT_POST);
             //indexing text.
             search::add_to_index($title, $post_id, search::WEIGHT_TITLE);
             //indexing title.
             search::add_to_index($tags, $post_id, search::WEIGHT_TAG);
             // indexing tags.
             write_rss_feed();
             // updating tags table.
             if (!empty($tags)) {
                 $tags = search::split_text($tags);
                 foreach ($tags as $tag) {
                     $query = "INSERT INTO tags (post_id, tag_data) VALUES ({$post_id}, '{$tag}')";
                     $db->query($query);
                 }
             }
             redirect('../?view&id=' . $created_post_id);
         }
     }
     break;
 default:
Ejemplo n.º 2
0
 case "reindex":
     if (isset($_POST['submit'])) {
         $db->query("TRUNCATE search_word");
         $db->query("TRUNCATE search_index");
         $post = $db->fetch_array("SELECT * FROM post");
         // Indexing text
         foreach ($post as $post) {
             search::add_to_index($post['post_content'], $post['post_id'], search::WEIGHT_POST);
             //indexing text
             search::add_to_index($post['post_title'], $post['post_id'], serach::WEIGHT_TITLE);
             //indexing title
         }
         // Indexing Tags
         $tags = $db->fetch_array("SELECT * FROM tags");
         foreach ($tags as $tag) {
             search::add_to_index($tag['tag'], $tag['post_id'], search::WEIGHT_TAG);
         }
         if ($_POST['method'] == "ajax") {
             echo "success";
             die;
         }
         $smarty->assign('ask', false);
     } else {
         $smarty->assign('ask', true);
     }
     break;
 default:
     $smarty->assign("ask", true);
     $stats['total_words'] = $db->num_rows("SELECT * FROM search_word");
     $smarty->assign("stats", $stats);
     break;