library/src/blockclass/BP-BlockClass.cc
// Extracts results from preg url matching regular expression (uses retrieved page membuffer as search).  This
// routine will use this->httpSession data if no buffer is passed in)
Extracts results from preg url matching regular expression (uses retrieved page membuffer as search).  This
routine will use this->httpSession data if no buffer is passed in)
Extracts results from preg url matching regular expression ( uses retrieved page membuffer as search ) . This routine will use this - > httpSession data if no buffer is passed in )
BP_ERROR_T Block::extractNewResultsFromPREGSearch
(
		char * buff_search,
		size_t buff_len
)
{
	if(!this->mysqlSession)
		return ERR_FAILURE;
	if(!buff_search && !buff_len)
	{
		if(!this->httpSession)
			return ERR_FAILURE;
		if(!this->httpSession->page)
			return ERR_FAILURE;
		if(!this->httpSession->page->page_data)
			return ERR_FAILURE;
		if(!this->httpSession->page->page_data_size)
			return ERR_FAILURE;
		buff_search = this->httpSession->page->page_data;
		buff_len    = this->httpSession->page->page_data_size;
	}
	char * regexp = "[a-zA-Z0-9\-]{1,}\\:\\/\\/[\\!\\:\\@\\.a-zA-Z0-9\\-]{1,}(?:[\\.a-zA-Z0-9\\-]{1,})(?:\\.construction|\\.photography|\\.enterprises|\\.contractors|\\.technology|\\.equipment|\\.directory|\\.ventures|\\.plumbing|\\.lighting|\\.holdings|\\.graphics|\\.diamonds|\\.clothing|\\.singles|\\.kitchen|\\.gallery|\\.voyage|\\.travel|\\.tattoo|\\.museum|\\.estate|\\.camera|\\.today|\\.tips|\\.sexy|\\.post|\\.name|\\.mobi|\\.menu|\\.land|\\.jobs|\\.info|\\.guru|\\.coop|\\.bike|\\.asia|\\.arpa|\\.aero|\\.xxx|\\.uno|\\.tel|\\.pro|\\.org|\\.net|\\.mil|\\.int|\\.gov|\\.edu|\\.com|\\.cat|\\.biz|\\.zw|\\.zm|\\.za|\\.yt|\\.ye|\\.ws|\\.wf|\\.vu|\\.vn|\\.vi|\\.vg|\\.ve|\\.vc|\\.va|\\.uz|\\.uy|\\.us|\\.uk|\\.ug|\\.ua|\\.tz|\\.tw|\\.tv|\\.tt|\\.tr|\\.tp|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.cm|\\.cl|\\.ck|\\.ci|\\.ch|\\.cg|\\.cf|\\.cd|\\.cc|\\.ca|\\.bz|\\.by|\\.bw|\\.bv|\\.bt|\\.bs|\\.br|\\.bo|\\.bn|\\.bm|\\.bj|\\.bi|\\.bh|\\.bg|\\.bf|\\.be|\\.bd|\\.bb|\\.ba|\\.az|\\.ax|\\.aw|\\.au|\\.at|\\.as|\\.ar|\\.aq|\\.ao|\\.an|\\.am|\\.al|\\.ai|\\.ag|\\.af|\\.ae|\\.ad|\\.ac){1,}(?:[\\:\\/0-9]{0,})\\/(?:[0-9a-zA-Z\\-\\~]{1,}[\\/]){0,}[a-zA-Z0-9\\.\\:\\-\\?\\&\\(\\)\\=\\*\\%%\\$\\#\\@\\!\\,]{0,}";
	BP_REGEX_MATCH_INFO match_info = {0};
	size_t matched = BP_MatchRegularExpressionPCRE
	(
			buff_search,
			buff_len,
			regexp,
			0,
			1024,
			&match_info,
			true
	);
	if(matched == ERR_SUCCESS)
	{
		size_t n = 0;
		for
		(
				;
				n < match_info.pcre_num_matched;
				n++
		)
		{
			if(match_info.preg_matches[n].matched_string[bpstrlen(match_info.preg_matches[n].matched_string)-1] == '"')
				match_info.preg_matches[n].matched_string[bpstrlen(match_info.preg_matches[n].matched_string)-1] = '/';
			if(
				( this->checkResultExists(match_info.preg_matches[n].matched_string,  0) != ERR_SUCCESS ) &&
				( this->checkResultExists(match_info.preg_matches[n].matched_string,  1) != ERR_SUCCESS ) &&
				( this->checkResultExists(match_info.preg_matches[n].matched_string,  2) != ERR_SUCCESS )
			)
			{
				char *tmp = match_info.preg_matches[n].matched_string;
				printf("\n Attempting to insert: %s", match_info.preg_matches[n].matched_string);
				this->insertNewResult(10, match_info.preg_matches[n].matched_string, 0, this->web_result_id);
			}
		}
	}
	BP_DestroyRegexpMatchInfo(&match_info);
	return ERR_SUCCESS;
}
BP_ERROR_T Block :: extractNewResultsFromPREGSearch ( char * buff_search , size_t buff_len ) { if ( ! this -> mysqlSession ) return ERR_FAILURE ; if ( ! buff_search && ! buff_len ) { if ( ! this -> httpSession ) return ERR_FAILURE ; if ( ! this -> httpSession -> page ) return ERR_FAILURE ; if ( ! this -> httpSession -> page -> page_data ) return ERR_FAILURE ; if ( ! this -> httpSession -> page -> page_data_size ) return ERR_FAILURE ; buff_search = this -> httpSession -> page -> page_data ; buff_len = this -> httpSession -> page -> page_data_size ; } char * regexp = " \- \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ " ; BP_REGEX_MATCH_INFO match_info = { 0 } ; size_t matched = BP_MatchRegularExpressionPCRE ( buff_search , buff_len , regexp , 0 , 1024 , & match_info , true ) ; if ( matched == ERR_SUCCESS ) { size_t n = 0 ; for ( ; n < match_info . pcre_num_matched ; n ++ ) { if ( match_info . preg_matches [ n ] . matched_string [ bpstrlen ( match_info . preg_matches [ n ] . matched_string ) - 1 ] == ' ' ) match_info . preg_matches [ n ] . matched_string [ bpstrlen ( match_info . preg_matches [ n ] . matched_string ) - 1 ] = ' ' ; if ( ( this -> checkResultExists ( match_info . preg_matches [ n ] . matched_string , 0 ) != ERR_SUCCESS ) && ( this -> checkResultExists ( match_info . preg_matches [ n ] . matched_string , 1 ) != ERR_SUCCESS ) && ( this -> checkResultExists ( match_info . preg_matches [ n ] . matched_string , 2 ) != ERR_SUCCESS ) ) { char * tmp = match_info . preg_matches [ n ] . matched_string ; printf ( " \n " , match_info . preg_matches [ n ] . matched_string ) ; this -> insertNewResult ( 10 , match_info . preg_matches [ n ] . matched_string , 0 , this -> web_result_id ) ; } } } BP_DestroyRegexpMatchInfo ( & match_info ) ; return ERR_SUCCESS ; }
Extracts results from preg url matching regular expression (uses retrieved page membuffer as search).
Extracts results from preg url matching regular expression ( uses retrieved page membuffer as search ) .
// ensure we have a mysql session // if we don't have a buffer to search, we try to set buffer from // http session. // run session checks // set the search from input if not provided already // loose url grabbing regexp // create zeroed out inout structure // get matches // check to see if we matched ok // iterate through matches // run basic checks // only insert if the result doesn't exist // check for insertion // Think this was causing a bug where items would insert with a missing trucation // if(!isalpha(tmp[bpstrlen(tmp)-1])) // 	tmp[bpstrlen(tmp)-1] = (char ) 0x00; // display message if desired // insert the new result // clear out match info // return indicating success