1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
void GET_WORDS(string str)
{
match_results results;
string rxstring;
rxstring="[ ]{1}([0-9a-z-]{3,32})[ ]{1}"; // SIMPLE WORD
rpattern pat(rxstring, NOCASE | EXTENDED | GLOBAL | ALLBACKREFS | SINGLELINE);
match_results::backref_type br = pat.match( str, results );
// If it worked or not...
if( br.matched )
{
stringstream blubb;
string bla;
int i = 1;
while (i < results.cbackrefs())
{
blubb.clear();
blubb << results.backref(i);
bla = blubb.str();
blubb.str(""); // erase the stringstream content !!!
cout << bla << endl;
OUTPUT_TO_FILE(bla);
i=i+2;
}
}
}
void SQL_GET_CONTENT()
{
MYSQL mysql;
char content [4096];
stringstream blubb;
string bla;
//Initialisation de MySQL
mysql_init(&mysql);
string Basicquery = "SELECT CONTENT FROM URLTITLEMETACONTENT LIMIT 0,100;";
//Connection Option...
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"libmysqld_client");
//If connection succeded...
//Sleep(10);
if(mysql_real_connect(&mysql,"localhost","toogle_user1","toogle_user1","toogle",0,NULL,0))
{
// mysql_set_character_set(&mysql, "utf8");
cout << "Connected to MySQL" << endl;
printf("Charset: %s\\", mysql_character_set_name(&mysql));
mysql_query(&mysql, Basicquery.c_str());
if (mysql_errno(&mysql))
{
cout << "SQL ERROR" << endl;
}
else
{
MYSQL_RES *result = NULL;
MYSQL_ROW row = NULL;
//On met le jeu de résultat dans le pointeur result
result = mysql_store_result(&mysql);
while ((row = mysql_fetch_row(result))!=NULL)
{
sprintf(content,"%s",row[0]);
blubb << content;
bla = blubb.str();
blubb.str("");
// stripscript(bla);
// stripstyle(bla);
// stripCodeComment(bla);
// striptags(bla);
// striplinereturn(bla);
GET_WORDS(bla);
}
}
mysql_close(&mysql);
}
else
{
cout << "COULD NOT CONNECT TO DB" << endl;
}
} |
Partager