Exemple #1
0
    * @since 1.0
    *
    * @caller ajax user action
    * @calls is_ajax
    * @ingorup user actions
    *
    * @param bool is_ajax() checks if it's an ajax call
    *
    * @var string $action is the function name called from ajax
    */
    if (isset($_POST['action']) && !empty($_POST['action'])) {
        $action = $_POST['action'];
        if ($action === 'make_doc') {
            make_doc($_POST['docParams'], $_POST['projectParams']);
        } elseif ($action === 'save_doc') {
            save_doc($_POST['dir'], $_POST['title'], $_POST['pages']);
        } elseif ($action === 'delete_doc') {
            delete_doc($_POST['dir']);
        } elseif ($action === 'update_editor_instructions') {
            update_editor_instructions($_POST['dir']);
        } elseif ($action === 'try_to_unlock') {
            try_to_unlock($_POST['passwordAttempt'], $_POST['dir']);
        } elseif ($action === 'lock_page') {
            lock_page($_POST['dir']);
        } elseif ($action === 'download_doc') {
            make_word_doc($_POST['Doc'], $_POST['dir']);
        }
    }
}
function add_index_file($dir)
{
                break;
            }
            $doc[] = $line;
            $size += strlen($line);
            $counter++;
        }
        $doc[] = stream_get_contents($fp, -1, $size);
        //the rest of the file
        //add the doc to the doc array
        $doc_arr[] = $doc;
    }
}
//get words (create an array with all the words in all the document, and the id of the doc in which they appear
$words_arr = array();
foreach ($doc_arr as $doc) {
    $id = save_doc($doc);
    $terms = str_word_count($doc[3], 1);
    foreach ($terms as $term) {
        $words_arr[] = array("term" => strtolower($term), "id" => $id);
    }
}
//sort
$term_arr = array();
foreach ($words_arr as $key => $row) {
    $term_arr[$key] = $row['term'];
}
array_multisort($term_arr, SORT_ASC, $words_arr);
//remove duplicates
$temp_index = array();
//will be the final index array (the posting files)
$prev_row["term"] = "";