Sabtu, 24 Desember 2011

Creating Your Own Article Rewriter with Ajax


What is article rewriter? Article rewriter is a kind of program that rewrote a paper or an article with the words that are different from the original article, so as to create a little unique content. For the lazy writing but want to make for chasing dollars from google adsense, usually using articel rewriter to copy and paste an article. But here we will see how the code rewriter to make the code simpler.

We will make the code rewriter with using PHP, MySQL and jQuery Ajax for data communication and display. We will also learn how to make a highlight words already in the rewrite. For details, please see Demo Article Rewriter. And the following algorithm and the code:

Rewriter algorithm is as follows:

Make text textarea to rewrite articles that will be
Taking the text of the article and send it through ajax
Processing the text sent to the server for at-rewrite, by searching the word synonyms in the database.
Showing results rewrite.
Make text textarea to rewrite articles that will be

<textarea rows="10" cols="80" name="komentar" id="artikel"> </ textarea>
<b> Result: </ b>
<br>
<img src="ajax-loader.gif" style="display:none" id="loading">
<br>
<!--- Rewrite the display the results --->
<Div id = "re-articel" style = "width: 650; height: 200; border: 1px solid black;
text-align: left; padding: 10; overflow: auto ">
</ Div>
Taking the text of the article and send it through ajax
<script type="text/javascript" src="jquery-1.4.4.min.js"> </ script>
<script>
$ (Document). Ready (function () {
    $ ("# Button"). Click (function () {
        / / Show loading animation
        $ ("# Loading"). Show ();
        / / Retrieve text from a textarea
        var article = $ ("# article"). val ();
        / / Send a text article to the server
        $. Ajax ({
            type: "POST",
            url: "rewriter.php",
            Data: "article =" + articles,
            success: function (msg) {
                / / If it is sent is shown
                $ ("# Re-articel"). Html (msg);
                $ ("# Loading"). Hide ();
            }
        });
    });
    $ ("# Reset"). Click (function () {
        $ ("# Re-articel"). Html ("");
    });
});
</ Script>
Processing the text sent to the server for at-rewrite, by searching the word synonyms in the database.

In the above code we send the text of the article to the server to be processed by the PHP code rewriter.php

<? Php
if ($ _POST ['article']) {
include "koneksi.php";
$ Article = nl2br ($ _POST ['article']);
/ / We separate sentences based on a space
/ / To retrieve the words
$ Ar = explode ("", $ article);
$ Result = "";
foreach ($ ar as $ value) {
    if (preg_match ("/ \ .|'/",$ value)) {
        / / We find these words in MySQL database
        $ Search = mysql_query ("select * from synonyms where kata1 = '$ value'");
        $ J = mysql_num_rows ($ search);
        if ($ j> 0) {
            $ Ka = mysql_fetch_array ($ search);
            $ Result = $ result. "<span Class='re'>". Stripslashes ($ ka ['kata2'])."</ span> ";
        Else {}
            $ Cari2 = mysql_query ("select * from synonyms where kata2 = '$ value'");
            $ J2 = mysql_num_rows ($ cari2);
            if ($ j2> 0) {
                $ Ka2 = mysql_fetch_array ($ cari2);
                $ Result = $ result. "<span Class='re'>". Stripslashes ($ ka2 ['kata1'])."</ span> ";
            Else {}
                $ Result = $ hasil.stripslashes ($ value). "";
            }
        }
    Else {}
        $ Ka = preg_replace ("/ \ ./","",$ value);
        $ Search = mysql_query ("select * from synonyms where kata1 = '$ ka'");
        $ J = mysql_num_rows ($ search);
        if ($ j> 0) {
            $ Kax = mysql_fetch_array ($ search);
            $ Result = $ result. "<span Class='re'>". Stripslashes ($ kax ['kata2'])."</ span>. ";
        Else {}
            $ Result = $ hasil.stripslashes ($ ka) "..";
        }
    }
}
echo $ result;
}
?>
Showing results rewrite.

$ ("# Re-articel"). Html (msg);
Where # is the tag re-articel <div> who had ID = re-articel

For the full code please download the source code. For demo see article rewriter.
via codingwear

3 komentar:

  1. Useful information. Thanks for sharing with us!

    It is very important to check your content regularly by using
    I’ll implement this code and create a new article rewriter tool.

    BalasHapus
  2. Good Job please give me this script tool with the database thank you

    BalasHapus