| 1 | package WWW::Promotion; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | C<WWW::Promotion> - WWW::Promotion is a Perl module that allow to submit | ||
| 6 | your site to lot of search engines. | ||
| 7 | |||
| 8 | =head1 DESCRIPTION | ||
| 9 | |||
| 10 | WWW::Promotion is used to submit your site to lot of search engines. It is | ||
| 11 | possible to download SPT5 interface for WWW::Promotion at | ||
| 12 | http://www.tapor.com/promotion/. Also on http://www.tapor.com/promotion/ your | ||
| 13 | may find huge database of search engines. WWW::Promotion is | ||
| 14 | world wide standart for promoting websites. | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | ############################################################################## | ||
| 19 | use strict; | ||
| 20 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %Promotion %Setup @internal_promotion_categories $outputhandler); | ||
| 21 | |||
| 22 | require Exporter; | ||
| 23 | |||
| 24 | use TAPORlib 8.70; | ||
| 25 | |||
| 26 | @ISA = qw(Exporter); | ||
| 27 | @EXPORT = qw(&WWW_Promotion | ||
| 28 | @internal_promotion_categories | ||
| 29 | ); | ||
| 30 | @EXPORT_OK = qw(); | ||
| 31 | |||
| 32 | $VERSION = "5.20"; | ||
| 33 | |||
| 34 | ############################################################################## | ||
| 35 | |||
| 36 | =head1 IMPORTED FUNCTIONS/VARS | ||
| 37 | |||
| 38 | =head1 | ||
| 39 | |||
| 40 | =head2 @internal_promotion_categories | ||
| 41 | |||
| 42 | Description: | ||
| 43 | |||
| 44 | Array of internal categories, which can you use to promote your website. | ||
| 45 | If you will use other category WWW::Promotion will return an error. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | @internal_promotion_categories = ( | ||
| 50 | |||
| 51 | "Art", | ||
| 52 | "Internet", | ||
| 53 | "Bussiness", | ||
| 54 | "Entertainment", | ||
| 55 | "Other", | ||
| 56 | |||
| 57 | ); | ||
| 58 | |||
| 59 | ############################################################################## | ||
| 60 | |||
| 61 | =head2 %out=&WWW_Promotion(\%Promotion,\%Setup); | ||
| 62 | |||
| 63 | Description: | ||
| 64 | |||
| 65 | This function used to promote your website. | ||
| 66 | |||
| 67 | Usage: | ||
| 68 | |||
| 69 | #--------------------------------------------------------------------- | ||
| 70 | # Required fields. If this fields not passed, module will not continue. | ||
| 71 | #--------------------------------------------------------------------- | ||
| 72 | $Promotion{'title'} = "Super Page"; | ||
| 73 | $Promotion{'url'} = "http://www.url.com"; | ||
| 74 | $Promotion{'description'} = "Blah-Blah this page is"; | ||
| 75 | |||
| 76 | # In this feild you may use only internal categories of WWW::Promotion. | ||
| 77 | # See &GetInternalPromotionCategories() procedure. | ||
| 78 | $Promotion{'category'} = "Other"; | ||
| 79 | |||
| 80 | #--------------------------------------------------------------------- | ||
| 81 | # Not required fields. If this fields not passed, defaults will be used. | ||
| 82 | #--------------------------------------------------------------------- | ||
| 83 | # Default: $Promotion{'description'} with words separated by ", " | ||
| 84 | $Promotion{'keywords'} = "Blah-Blah, this, page, is"; | ||
| 85 | |||
| 86 | # Default: $Promotion{'description'} | ||
| 87 | $Promotion{'comments'} = "Blah-Blah this page is"; | ||
| 88 | |||
| 89 | # Default "Mr." | ||
| 90 | $Promotion{'nametitle'} = "Mr."; | ||
| 91 | |||
| 92 | # Default: "John" | ||
| 93 | $Promotion{'firstname'} = "John"; | ||
| 94 | |||
| 95 | # Default: "Doe" | ||
| 96 | $Promotion{'lastname'} = "Doe"; | ||
| 97 | |||
| 98 | # Default: "W." | ||
| 99 | $Promotion{'middlename'} = "W."; | ||
| 100 | |||
| 101 | # Default: "$Promotion{'firstname'} $Promotion{'lastname'}" | ||
| 102 | $Promotion{'contactname'} = "John Doe"; | ||
| 103 | |||
| 104 | # Default: Random generated email address with domain "@mail.com" | ||
| 105 | $Promotion{'email'} = "blah-blah\@mail.com"; | ||
| 106 | |||
| 107 | # Default: "123 Baltimor Street 5" | ||
| 108 | $Promotion{'address'} = "123 Baltimor Street 5"; | ||
| 109 | |||
| 110 | # Default: "Boston" | ||
| 111 | $Promotion{'city'} = "Boston"; | ||
| 112 | |||
| 113 | # Default: "MA" | ||
| 114 | $Promotion{'state'} = "MA"; | ||
| 115 | |||
| 116 | # Default: "United States of America" | ||
| 117 | $Promotion{'country'} = "United States of America"; | ||
| 118 | |||
| 119 | # Default: "US" | ||
| 120 | $Promotion{'countrycode'} = "US"; | ||
| 121 | |||
| 122 | # Default: "46723" | ||
| 123 | $Promotion{'zip'} = "46723"; | ||
| 124 | |||
| 125 | # Default: "At Home" | ||
| 126 | $Promotion{'company'} = "At Home"; | ||
| 127 | |||
| 128 | # Default: Random generated phone. | ||
| 129 | $Promotion{'phone'} = "1-234-567-8911"; | ||
| 130 | |||
| 131 | # Default: Random generated fax. | ||
| 132 | $Promotion{'fax'} = "1-234-567-8911"; | ||
| 133 | |||
| 134 | # Default: Random generated string with six chars. | ||
| 135 | $Promotion{'password'} = "password"; | ||
| 136 | |||
| 137 | # Default: "English" | ||
| 138 | $Promotion{'language'} = "English"; | ||
| 139 | |||
| 140 | # WWW::Promotion will use this file to print what it doing. | ||
| 141 | # Default: "/dev/null" | ||
| 142 | $Setup{'logfile'} = "/dev/null"; | ||
| 143 | |||
| 144 | # Whitch proxy server module must use to connect to servers. | ||
| 145 | # If not spicified that SP5 will connect direct. | ||
| 146 | $Setup{'proxy'} = "blah-blah.com:8080"; | ||
| 147 | |||
| 148 | # FASTMODE PROMOTION [tm] | ||
| 149 | # Does WWW::Promotion use fastmode ? | ||
| 150 | # 1 - yes | ||
| 151 | # 0 - no | ||
| 152 | # p.s: FASTMODE PROMOTION [tm] may be done only via proxy server. | ||
| 153 | # If executed without $Setup{'proxy'} module will exit with error. | ||
| 154 | # Default: 0 | ||
| 155 | $Setup{'fastmode'} = 1; | ||
| 156 | |||
| 157 | # Timeout to connect to server. | ||
| 158 | # Default: 10 | ||
| 159 | $Setup{'timeoutconnect'} = 10; | ||
| 160 | |||
| 161 | # Timeout to wait answer from server. | ||
| 162 | # Default: 60 | ||
| 163 | $Setup{'timeoutrequest'} = 60; | ||
| 164 | |||
| 165 | # You may provide three directories that contains search engines. | ||
| 166 | # See "Search engine database" part of this document for more info about. | ||
| 167 | $Setup{'enginesdir1'} = "./ENGINES1"; | ||
| 168 | $Setup{'enginesdir2'} = "./ENGINES2"; | ||
| 169 | $Setup{'enginesdir3'} = "./ENGINES3"; | ||
| 170 | |||
| 171 | # Output handler. | ||
| 172 | # See "Output handler" part of this document for more info about. | ||
| 173 | $Setup{'outputhandler'} = \&OutputHandler; | ||
| 174 | |||
| 175 | # Final action | ||
| 176 | # Execute Promotion | ||
| 177 | %out=WWW_Promotion(\%Promotion,\%Setup); | ||
| 178 | |||
| 179 | Output: | ||
| 180 | |||
| 181 | $out{'error'} | ||
| 182 | TRUE if error, then $out{'errortxt'} contains error description. | ||
| 183 | |||
| 184 | =cut | ||
| 185 | |||
| 186 | sub WWW_Promotion { | ||
| 187 | my ($LPromotion,$LSetup) = @_; | ||
| 188 | |||
| 189 | %Promotion = %$LPromotion; | ||
| 190 | %Setup = %$LSetup; | ||
| 191 | |||
| 192 | my %out; | ||
| 193 | |||
| 194 | if(!$Setup{'logfile'}) {$Setup{'logfile'} = "/dev/null";} | ||
| 195 | my $logfile = $Setup{'logfile'}; | ||
| 196 | |||
| 197 | #------------------------------------------------------------------------- | ||
| 198 | add_string_to_file($logfile,"WWW::Promotion: v$VERSION\n\n"); | ||
| 199 | #------------------------- Checking input data --------------------------- | ||
| 200 | if(!$Promotion{'title'}) | ||
| 201 | { | ||
| 202 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","\$Promotion{'title'} must be passed"); | ||
| 203 | goto print_error_to_log_and_exit; | ||
| 204 | } | ||
| 205 | if(!$Promotion{'url'}) | ||
| 206 | { | ||
| 207 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","\$Promotion{'url'} must be passed"); | ||
| 208 | goto print_error_to_log_and_exit; | ||
| 209 | } | ||
| 210 | if(!($Promotion{'url'} =~ m/^http:\/\//i)) | ||
| 211 | { | ||
| 212 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","Invalid url '$Promotion{'url'}'"); | ||
| 213 | goto print_error_to_log_and_exit; | ||
| 214 | } | ||
| 215 | if(!$Promotion{'description'}) | ||
| 216 | { | ||
| 217 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","\$Promotion{'description'} must be passed"); | ||
| 218 | goto print_error_to_log_and_exit; | ||
| 219 | } | ||
| 220 | if(!$Promotion{'category'}) | ||
| 221 | { | ||
| 222 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","\$Promotion{'category'} must be passed"); | ||
| 223 | goto print_error_to_log_and_exit; | ||
| 224 | } | ||
| 225 | else | ||
| 226 | { | ||
| 227 | my $ok=0; | ||
| 228 | foreach (@internal_promotion_categories) | ||
| 229 | { | ||
| 230 | if($_ eq $Promotion{'category'}) | ||
| 231 | { | ||
| 232 | $ok=1; | ||
| 233 | last; | ||
| 234 | } | ||
| 235 | } | ||
| 236 | if(!$ok) | ||
| 237 | { | ||
| 238 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","\$Promotion{'category'} has invalid internal category"); | ||
| 239 | goto print_error_to_log_and_exit; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | my $internalcategory = $Promotion{'category'}; | ||
| 243 | |||
| 244 | if(defined($Setup{'fastmode'}) && !defined($Setup{'proxy'})) | ||
| 245 | { | ||
| 246 | $out{'errortxt'} = create_error_string("WWW::Promotion::WWW_Promotion()","FASTMODE [tm] may be done only via proxy - \$Setup{'proxy'}!"); | ||
| 247 | goto print_error_to_log_and_exit; | ||
| 248 | } | ||
| 249 | #-------------------------------- Defaults ------------------------------- | ||
| 250 | if($Setup{'outputhandler'}) | ||
| 251 | { | ||
| 252 | $outputhandler = $Setup{'outputhandler'}; | ||
| 253 | } | ||
| 254 | |||
| 255 | if(!$Promotion{'keywords'}) | ||
| 256 | { | ||
| 257 | my @keywords = split(/ /,$Promotion{'description'}); | ||
| 258 | $Promotion{'keywords'} = join(',',@keywords); | ||
| 259 | } | ||
| 260 | if(!$Promotion{'comments'}) | ||
| 261 | { | ||
| 262 | $Promotion{'comments'} = $Promotion{'description'}; | ||
| 263 | } | ||
| 264 | if(!$Promotion{'nametitle'}) | ||
| 265 | { | ||
| 266 | $Promotion{'nametitle'} = "Mr."; | ||
| 267 | } | ||
| 268 | if(!$Promotion{'firstname'}) | ||
| 269 | { | ||
| 270 | $Promotion{'firstname'} = "John"; | ||
| 271 | } | ||
| 272 | if(!$Promotion{'lastname'}) | ||
| 273 | { | ||
| 274 | $Promotion{'lastname'} = "Doe"; | ||
| 275 | } | ||
| 276 | if(!$Promotion{'middlename'}) | ||
| 277 | { | ||
| 278 | $Promotion{'middlename'} = "W."; | ||
| 279 | } | ||
| 280 | if(!$Promotion{'contactname'}) | ||
| 281 | { | ||
| 282 | $Promotion{'contactname'} = "$Promotion{'firstname'} $Promotion{'lastname'}"; | ||
| 283 | } | ||
| 284 | if(!$Promotion{'email'}) | ||
| 285 | { | ||
| 286 | $Promotion{'email'} = GenerateRandomString(5); | ||
| 287 | $Promotion{'email'} = $Promotion{'email'} . "\@mail.com"; | ||
| 288 | } | ||
| 289 | if(!$Promotion{'address'}) | ||
| 290 | { | ||
| 291 | $Promotion{'address'} = "123 Baltimor Street 5"; | ||
| 292 | } | ||
| 293 | if(!$Promotion{'city'}) | ||
| 294 | { | ||
| 295 | $Promotion{'city'} = "Boston"; | ||
| 296 | } | ||
| 297 | if(!$Promotion{'state'}) | ||
| 298 | { | ||
| 299 | $Promotion{'state'} = "MA"; | ||
| 300 | } | ||
| 301 | if(!$Promotion{'country'}) | ||
| 302 | { | ||
| 303 | $Promotion{'country'} = "United States of America"; | ||
| 304 | } | ||
| 305 | if(!$Promotion{'countrycode'}) | ||
| 306 | { | ||
| 307 | $Promotion{'countrycode'} = "US"; | ||
| 308 | } | ||
| 309 | if(!$Promotion{'zip'}) | ||
| 310 | { | ||
| 311 | $Promotion{'zip'} = "46723"; | ||
| 312 | } | ||
| 313 | if(!$Promotion{'company'}) | ||
| 314 | { | ||
| 315 | $Promotion{'company'} = "At Home"; | ||
| 316 | } | ||
| 317 | if(!$Promotion{'phone'}) | ||
| 318 | { | ||
| 319 | $Promotion{'phone'} = "1-" . int(rand(9)) . int(rand(9)) . int(rand(9)) . "-". int(rand(9)) . int(rand(9)) . int(rand(9)) . "-" . int(rand(9)) . int(rand(9)) . int(rand(9)) . int(rand(9)); | ||
| 320 | } | ||
| 321 | if(!$Promotion{'fax'}) | ||
| 322 | { | ||
| 323 | $Promotion{'fax'} = "1-" . int(rand(9)) . int(rand(9)) . int(rand(9)) . "-". int(rand(9)) . int(rand(9)) . int(rand(9)) . "-" . int(rand(9)) . int(rand(9)) . int(rand(9)) . int(rand(9)); | ||
| 324 | } | ||
| 325 | if(!$Promotion{'password'}) | ||
| 326 | { | ||
| 327 | $Promotion{'password'} = GenerateRandomString(6); | ||
| 328 | } | ||
| 329 | if(!$Promotion{'language'}) | ||
| 330 | { | ||
| 331 | $Promotion{'language'} = "English"; | ||
| 332 | } | ||
| 333 | if(!$Promotion{'url-without-http'}) | ||
| 334 | { | ||
| 335 | $Promotion{'url-without-http'} = $Promotion{'url'}; | ||
| 336 | $Promotion{'url-without-http'} =~ s/^http:\/\///i; | ||
| 337 | } | ||
| 338 | if(!$Promotion{'street'}) | ||
| 339 | { | ||
| 340 | $Promotion{'street'} = $Promotion{'address'}; | ||
| 341 | } | ||
| 342 | |||
| 343 | if(!$Setup{'timeoutconnect'}) {$Setup{'timeoutconnect'} = 10;} | ||
| 344 | if(!$Setup{'timeoutrequest'}) {$Setup{'timeoutrequest'} = 60;} | ||
| 345 | #------------------------------------------------------------------------- | ||
| 346 | add_string_to_file($logfile,"Input Promotion hash:\n\n"); | ||
| 347 | foreach (sort keys %Promotion) | ||
| 348 | { | ||
| 349 | $Promotion{$_} = Delete_CRLF_from_End_Of_String($Promotion{$_}); | ||
| 350 | add_string_to_file($logfile,"\$Promotion{'$_'} = '$Promotion{$_}'\n"); | ||
| 351 | } | ||
| 352 | add_string_to_file($logfile,"\n"); | ||
| 353 | #------------------------------------------------------------------------- | ||
| 354 | add_string_to_file($logfile,"Input Setup hash:\n\n"); | ||
| 355 | foreach (sort keys %Setup) | ||
| 356 | { | ||
| 357 | $Setup{$_} = Delete_CRLF_from_End_Of_String($Setup{$_}); | ||
| 358 | add_string_to_file($logfile,"\$Setup{'$_'} = '$Setup{$_}'\n"); | ||
| 359 | } | ||
| 360 | add_string_to_file($logfile,"\n"); | ||
| 361 | #------------------------------------------------------------------------- | ||
| 362 | my @filestosubmitto; | ||
| 363 | my @tmp; | ||
| 364 | if(defined($Setup{'enginesdir1'})) | ||
| 365 | { | ||
| 366 | @tmp = (); | ||
| 367 | @tmp = GetAllFilesInDir($Setup{'enginesdir1'}); | ||
| 368 | push(@filestosubmitto,@tmp); | ||
| 369 | } | ||
| 370 | if(defined($Setup{'enginesdir2'})) | ||
| 371 | { | ||
| 372 | @tmp = (); | ||
| 373 | @tmp = GetAllFilesInDir($Setup{'enginesdir2'}); | ||
| 374 | push(@filestosubmitto,@tmp); | ||
| 375 | } | ||
| 376 | if(defined($Setup{'enginesdir3'})) | ||
| 377 | { | ||
| 378 | @tmp = (); | ||
| 379 | @tmp = GetAllFilesInDir($Setup{'enginesdir3'}); | ||
| 380 | push(@filestosubmitto,@tmp); | ||
| 381 | } | ||
| 382 | #------------------------------------------------------------------------- | ||
| 383 | my %data = (); | ||
| 384 | |||
| 385 | $data{'action'} = "sendheader"; | ||
| 386 | |||
| 387 | if($outputhandler) { &$outputhandler(%data); } | ||
| 388 | |||
| 389 | foreach my $se (@filestosubmitto) | ||
| 390 | { | ||
| 391 | %data = (); | ||
| 392 | $data{'se'} = $se; | ||
| 393 | $data{'action'} = "sedata"; | ||
| 394 | |||
| 395 | if(!open(FILE,$se)) {next;} | ||
| 396 | my @bodyse = <FILE>; | ||
| 397 | close(FILE); | ||
| 398 | |||
| 399 | my($GET,$POST,$SEname,$SEurl,$Referer,$Host,$Content,$Server,$Country); | ||
| 400 | my(@Category); | ||
| 401 | |||
| 402 | undef($GET); | ||
| 403 | undef($POST); | ||
| 404 | undef($SEname); | ||
| 405 | undef($SEurl); | ||
| 406 | undef($Referer); | ||
| 407 | undef($Host); | ||
| 408 | undef($Content); | ||
| 409 | undef($Server); | ||
| 410 | undef($Country); | ||
| 411 | @Category = (); | ||
| 412 | |||
| 413 | foreach (@bodyse) | ||
| 414 | { | ||
| 415 | $_ = Delete_CRLF_from_End_Of_String($_); | ||
| 416 | |||
| 417 | if(/^GET\s*([^\s\r\n]*)/i) { $GET = $1; } | ||
| 418 | if(/^POST\s*([^\s\r\n]*)/i) { $POST = $1; } | ||
| 419 | |||
| 420 | if(/^SEname:\s*([^\r\n]*)/i) { $SEname = $1; } | ||
| 421 | if(/^SEurl:\s*([^\r\n]*)/i) { $SEurl = $1; } | ||
| 422 | |||
| 423 | if(/^Referer:\s*([^\s\r\n]*)/i) { $Referer = $1; } | ||
| 424 | if(/^Host:\s*([^\s\r\n]*)/i) { $Host = $1; } | ||
| 425 | if(/^Content:\s*([^\r\n]*)/i) { $Content = $1; } | ||
| 426 | if(/^Server:\s*([^\r\n]*)/i) { $Server = $1; } | ||
| 427 | if(/^Country:\s*([^\r\n]*)/i) { $Country = $1; } | ||
| 428 | |||
| 429 | if(/^Category:\s*([^\r\n]*)/i) { push(@Category,$1); } | ||
| 430 | } | ||
| 431 | #--------------------------------------------------------------------- | ||
| 432 | # Checking data | ||
| 433 | my($Method,$Url); | ||
| 434 | |||
| 435 | if(defined($GET) && defined($POST)) | ||
| 436 | { | ||
| 437 | add_string_to_file($logfile,"\nWWW::Promotion::WWW_Promotion() Error in $se - 2 Methods POST & GET are defined!\n"); | ||
| 438 | next; | ||
| 439 | } | ||
| 440 | if(defined($GET)) | ||
| 441 | { | ||
| 442 | $Method = 'GET'; | ||
| 443 | my @parts = split(/\?/,$GET); | ||
| 444 | $Url = $parts[0]; | ||
| 445 | $Content = $parts[1]; | ||
| 446 | } | ||
| 447 | elsif(defined($POST)) | ||
| 448 | { | ||
| 449 | $Method = 'POST'; | ||
| 450 | $Url = $POST; | ||
| 451 | } | ||
| 452 | else | ||
| 453 | { | ||
| 454 | add_string_to_file($logfile,"\nWWW::Promotion::WWW_Promotion() Error in $se - Can't find Method!\n"); | ||
| 455 | next; | ||
| 456 | } | ||
| 457 | if(!$Content) | ||
| 458 | { | ||
| 459 | add_string_to_file($logfile,"\nWWW::Promotion::WWW_Promotion() Error in $se - Can't find content!\n"); | ||
| 460 | next; | ||
| 461 | } | ||
| 462 | #--------------------------------------------------------------------- | ||
| 463 | # ðÅÒÅ×ÏÄÉÍ $url Ë ×ÉÄÕ http:// | ||
| 464 | unless($Url =~ m/^http:\/\//) { $Url = "http://$Host/$Url"; } | ||
| 465 | # õÂÉÒÁÅÍ Ä×ÏÊÎÙÅ // | ||
| 466 | $Url =~ s|^http://||; | ||
| 467 | $Url =~ s|//|/|g; | ||
| 468 | $Url = "http://$Url"; | ||
| 469 | #--------------------------------------------------------------------- | ||
| 470 | add_string_to_file($logfile,"\n"); | ||
| 471 | add_string_to_file_spec_output($logfile,"WWW::Promotion::WWW_Promotion()","Search Engine","\n"); | ||
| 472 | add_string_to_file($logfile,"Search Engine: $se\n"); | ||
| 473 | if(defined($Country)) { add_string_to_file($logfile,"Country: $Country\n"); } | ||
| 474 | if(defined($SEname)) { add_string_to_file($logfile,"SEname: $SEname\n"); } | ||
| 475 | if(defined($SEurl)) { add_string_to_file($logfile,"SEurl: $SEurl\n"); } | ||
| 476 | add_string_to_file($logfile,"Method: $Method\n"); | ||
| 477 | if(defined($Referer)) { add_string_to_file($logfile,"Referer: $Referer\n"); } | ||
| 478 | if(defined($Host)) { add_string_to_file($logfile,"Host: $Host\n"); } | ||
| 479 | add_string_to_file($logfile,"Url: $Url\n"); | ||
| 480 | add_string_to_file($logfile,"Content: $Content\n"); | ||
| 481 | if(defined($Server)) { add_string_to_file($logfile,"Server: $Server\n"); } | ||
| 482 | if($#Category >=0 ) | ||
| 483 | { | ||
| 484 | foreach (@Category) | ||
| 485 | { | ||
| 486 | add_string_to_file($logfile,"Category: $_\n"); | ||
| 487 | } | ||
| 488 | } | ||
| 489 | add_string_to_file($logfile,"\n"); | ||
| 490 | |||
| 491 | if(defined($Country)) { $data{'Country'} = $Country; } | ||
| 492 | if(defined($Server)) { $data{'Server'} = $Server; } | ||
| 493 | if(defined($SEname)) { $data{'SEname'} = $SEname; } | ||
| 494 | if(defined($SEurl)) { $data{'SEurl'} = $SEurl; } | ||
| 495 | |||
| 496 | #--------------------------------------------------------------------- | ||
| 497 | # Internal category -> Search Engine category | ||
| 498 | delete($Promotion{'category'}); | ||
| 499 | |||
| 500 | if($#Category >= 0) | ||
| 501 | { | ||
| 502 | |||
| 503 | add_string_to_file($logfile,"--- Selecting category for Search Engine (Internal category -> Search Engine category) ---\n"); | ||
| 504 | add_string_to_file($logfile,"Internal category: '$internalcategory'\n"); | ||
| 505 | |||
| 506 | foreach (@Category) | ||
| 507 | { | ||
| 508 | if(/<\*\*\*>/i) | ||
| 509 | { | ||
| 510 | $_ =~ m/\s*(.*?)\s*<\*\*\*>\s*(.*?)\s*$/i; | ||
| 511 | my $cat = $1; | ||
| 512 | my $intcat = $2; | ||
| 513 | |||
| 514 | if($intcat =~ m/^$internalcategory$/i) | ||
| 515 | { | ||
| 516 | $Promotion{'category'} = $cat; | ||
| 517 | last; | ||
| 518 | } | ||
| 519 | } | ||
| 520 | if(/^$internalcategory$/i) | ||
| 521 | { | ||
| 522 | $Promotion{'category'} = $internalcategory; | ||
| 523 | last; | ||
| 524 | } | ||
| 525 | } | ||
| 526 | if(!$Promotion{'category'}) | ||
| 527 | { | ||
| 528 | $_ = $Category[0]; | ||
| 529 | add_string_to_file($logfile,"CATWARN!!! Using first default category: '$_'\n"); | ||
| 530 | if(/<\*\*\*>/i) | ||
| 531 | { | ||
| 532 | $_ =~ m/\s*(.*?)\s*<\*\*\*>/i; | ||
| 533 | $Promotion{'category'} = $1; | ||
| 534 | } | ||
| 535 | else | ||
| 536 | { | ||
| 537 | $Promotion{'category'} = $_; | ||
| 538 | } | ||
| 539 | } | ||
| 540 | } | ||
| 541 | |||
| 542 | if($Promotion{'category'}) | ||
| 543 | { | ||
| 544 | add_string_to_file($logfile,"Selected Search Engine category is: '$Promotion{'category'}'\n"); | ||
| 545 | } | ||
| 546 | #--------------------------------------------------------------------- | ||
| 547 | # Set new Content | ||
| 548 | foreach my $key (keys %Promotion) | ||
| 549 | { | ||
| 550 | $Content =~ s/<\*\*\*$key\*\*\*>/$Promotion{$key}/ig; | ||
| 551 | $Referer =~ s/<\*\*\*$key\*\*\*>/$Promotion{$key}/ig; | ||
| 552 | } | ||
| 553 | $Content =~ s|<\*\*\*RANDOM:([0-9]+)-([0-9]+):\*\*\*>|$1+(int rand($2-$1+1))|igme; | ||
| 554 | $Referer =~ s|<\*\*\*RANDOM:([0-9]+)-([0-9]+):\*\*\*>|$1+(int rand($2-$1+1))|igme; | ||
| 555 | $Content =~ s|<\*\*\*ONERANDOMKEYWORD\*\*\*>|&getrandomkeyword()|igme; | ||
| 556 | $Referer =~ s|<\*\*\*ONERANDOMKEYWORD\*\*\*>|&getrandomkeyword()|igme; | ||
| 557 | #--------------------------------------------------------------------- | ||
| 558 | while($Content =~ /(<\*\*\*[^\*]*\*\*\*>)/g) | ||
| 559 | { | ||
| 560 | add_string_to_file($logfile,"Keyword not changed => $1\n"); | ||
| 561 | } | ||
| 562 | add_string_to_file($logfile,"\n"); | ||
| 563 | add_string_to_file($logfile,"After <***KEYS***> to VALUES:\n"); | ||
| 564 | add_string_to_file($logfile,"New Referer: $Referer\n"); | ||
| 565 | add_string_to_file($logfile,"New Content: $Content\n"); | ||
| 566 | |||
| 567 | my %pagenow = (); | ||
| 568 | |||
| 569 | $pagenow{'logfile'} = $Setup{'logfile'}; | ||
| 570 | |||
| 571 | $pagenow{'method'} = $Method; | ||
| 572 | $pagenow{'url'} = $Url; | ||
| 573 | $pagenow{'referer'} = $Referer; | ||
| 574 | $pagenow{'content'} = $Content; | ||
| 575 | |||
| 576 | $pagenow{'proxy'} = $Setup{'proxy'} ? $Setup{'proxy'} : undef; | ||
| 577 | $pagenow{'norequest'} = $Setup{'fastmode'} ? 1 : undef; | ||
| 578 | $pagenow{'timeoutconnect'} = $Setup{'timeoutconnect'} ? $Setup{'timeoutconnect'} : 10; | ||
| 579 | $pagenow{'timeoutrequest'} = $Setup{'timeoutrequest'} ? $Setup{'timeoutrequest'} : 60; | ||
| 580 | |||
| 581 | my %out = GetPageNow_4(%pagenow); | ||
| 582 | if($out{'error'}) | ||
| 583 | { | ||
| 584 | my $error = create_error_string("WWW::Promotion::WWW_Promotion()","Error in $se - $out{'errortxt'}!"); | ||
| 585 | add_string_to_file($logfile,"\n$error\n"); | ||
| 586 | $data{'error'} = 1; | ||
| 587 | $data{'errortxt'} = $error; | ||
| 588 | if($outputhandler) { &$outputhandler(%data); } | ||
| 589 | } | ||
| 590 | else | ||
| 591 | { | ||
| 592 | $data{'body'} = $out{'body'}; | ||
| 593 | if($outputhandler) { &$outputhandler(%data); } | ||
| 594 | } | ||
| 595 | #--------------------------------------------------------------------- | ||
| 596 | } | ||
| 597 | %data = (); | ||
| 598 | $data{'action'} = "sendfooter"; | ||
| 599 | if($outputhandler) { &$outputhandler(%data); } | ||
| 600 | $out{'error'} = 0; | ||
| 601 | delete $out{'errortxt'}; | ||
| 602 | return %out; | ||
| 603 | |||
| 604 | print_error_to_log_and_exit: | ||
| 605 | $out{'error'} = 1; | ||
| 606 | add_string_to_file($logfile,"\n$out{'errortxt'}\n"); | ||
| 607 | return %out; | ||
| 608 | } | ||
| 609 | ############################################################################## | ||
| 610 | sub getrandomkeyword { | ||
| 611 | my @keywords=split(/,/,$Promotion{'keywords'}); | ||
| 612 | |||
| 613 | return $keywords[int(rand(@keywords))]; | ||
| 614 | } | ||
| 615 | ############################################################################## | ||
| 616 | |||
| 617 | =head1 Search Engine Database (SEDB) | ||
| 618 | |||
| 619 | SEDB contains an information about search engines. WWW::Promotion | ||
| 620 | will use this information to submit your URL. | ||
| 621 | |||
| 622 | SEDB it is a directory which contains files. Each file contains | ||
| 623 | an information about one search engine. Files has various names | ||
| 624 | and may reside in different subdirectories inside SEDB. This files | ||
| 625 | has the following format: | ||
| 626 | |||
| 627 | POST http://www.rex-search.com/add/add.cgi HTTP/1.0 | ||
| 628 | Content: thispage=3&catnum=&url=<***URL***>&navigate=&yourname=<***CONTACTNAME***>&email=<***EMAIL***>&name=<***TITLE***>&keys=<***KEYWORDS***>&desc=<***DESCRIPTION***>&confirm=&urlfail=&refer=http%3A%2F%2Fwww.rex-search.com%2Fadd%2F&cat=<***CATEGORY***>&catkeep=Submit+this+Site | ||
| 629 | |||
| 630 | Or | ||
| 631 | |||
| 632 | GET http://www.ditto.com/urlrequest/AddResponse.asp?txtUserName=<***CONTACTNAME***>&txtURL=<***URL***>&txtEmail=<***EMAIL***>&submit1=Submit&xfrm=True&cs=AddRemoveURL&ac=AddRemoveURL&Action=Add HTTP/1.0 | ||
| 633 | |||
| 634 | The first line describes which method to use for submit. Also it | ||
| 635 | contains the address where to post data. "HTTP/1.0" in this line | ||
| 636 | unessential, WWW::Promotion will ignore it. This line is required, | ||
| 637 | without it the module will log a bad file and process the next file. | ||
| 638 | For method POST it is required second line (Content:), which contains | ||
| 639 | search engine cantent data. In method GET content is placed in the | ||
| 640 | first line through "?". In a case if the address contains a relative | ||
| 641 | address it is required third line (Host:), which describes which | ||
| 642 | address of server to use for connect. | ||
| 643 | |||
| 644 | Also the file may contain unessential lines: | ||
| 645 | |||
| 646 | Referer: http://www.ditto.com/urlrequest/addurl.asp | ||
| 647 | Inform the module to use this referer. Advanced technology, the | ||
| 648 | engines "think" you are submitting from their form. | ||
| 649 | |||
| 650 | Host: www.ditto.com | ||
| 651 | Inform the module which server to use for connect. It is required | ||
| 652 | only when the first line contains a relative address on a server | ||
| 653 | (for example " GET / HTTP/1.0 "). | ||
| 654 | |||
| 655 | Country: United States | ||
| 656 | Country of the search engine. WWW::Promotion uses this info for | ||
| 657 | OutputHandler. | ||
| 658 | |||
| 659 | SEname: Magellan | ||
| 660 | Name of the search engine. WWW::Promotion uses this info for | ||
| 661 | OutputHandler. | ||
| 662 | |||
| 663 | SEurl: http://www.url.com | ||
| 664 | URL of the search engine. WWW::Promotion uses this info for | ||
| 665 | OutputHandler. | ||
| 666 | |||
| 667 | Server: Netscape-Enterprise/2.01 | ||
| 668 | The software which is used in the search engine. | ||
| 669 | WWW::Promotion uses this info for OutputHandler. | ||
| 670 | |||
| 671 | Category: SEcat-Internet <***> Internet | ||
| 672 | Category: SEcat-Business <***> Business | ||
| 673 | Categories determined in the search engine. These lines may | ||
| 674 | be more than one. Format: | ||
| 675 | |||
| 676 | Category: (a category of the search engine)<***>(an internal category of the module). | ||
| 677 | |||
| 678 | The module will search for conformity of an internal category | ||
| 679 | with a category of a search engine. If you for example have | ||
| 680 | defined an internal category "Other", the module will search for | ||
| 681 | line "Category: SEcat <***> Other" and will use the category | ||
| 682 | "SEcat" for submit. In a case if it does not find the | ||
| 683 | appropriate category it will use first of determined. | ||
| 684 | (Category:) it is required only when a content contains a key | ||
| 685 | <***CATEGORY***>. See below. | ||
| 686 | |||
| 687 | The content contains keys which in process of submiting of your | ||
| 688 | URL will be replaced with the data, which you have entered. | ||
| 689 | The following keys can be used in the content: | ||
| 690 | |||
| 691 | |||
| 692 | <***TITLE***> -> Ttile of the page (Ex: Super Page) | ||
| 693 | <***URL***> -> URL of the page (Ex: http://www.url.com) | ||
| 694 | <***URL-WITHOUT-HTTP***> -> URL without http:// (Ex: www.url.com) | ||
| 695 | <***DESCRIPTION***> -> Description (Ex: Blah-Blah this page is) | ||
| 696 | <***KEYWORDS***> -> Keywords (Ex: test, test2, test3) | ||
| 697 | <***ONERANDOMKEYWORD***> -> One random keyword. Keywords are | ||
| 698 | separeted by points. (Ex: test2) | ||
| 699 | |||
| 700 | <***CONTACTNAME***> -> Contact name (Ex: John Doe) | ||
| 701 | <***NAMETITLE***> -> Nametitle (Ex: Mr.) | ||
| 702 | <***FIRSTNAME***> -> Your first name (Ex: John) | ||
| 703 | <***MIDDLENAME***> -> Your middle name (Ex: W.) | ||
| 704 | <***LASTNAME***> -> Your last name (Ex: Doe) | ||
| 705 | <***EMAIL***> -> E-MAIL address (Ex: blah@blah.com) | ||
| 706 | |||
| 707 | <***ADDRESS***> -> Street address (Ex: 464 Ave Street Gold) | ||
| 708 | <***CITY***> -> City (Ex: Boston) | ||
| 709 | <***STATE***> -> State (Ex: MA) | ||
| 710 | <***COUNTRY***> -> Country (Ex: "United States of America") | ||
| 711 | <***COUNTRYCODE***> -> Country code (Ex: US) | ||
| 712 | <***ZIP***> -> ZIP code (Ex: 68738) | ||
| 713 | |||
| 714 | <***COMPANY***> -> Company name (Ex: IBM, Inc) | ||
| 715 | <***PHONE***> -> Phone (Ex: 1-234-233-2132) | ||
| 716 | <***FAX***> -> Fax (Ex: 1-234-233-2132) | ||
| 717 | |||
| 718 | <***RANDOM:50-60:***> -> Random number between 50 and 60. | ||
| 719 | <***PASSWORD***> -> Password (Ex: aaazzz) | ||
| 720 | |||
| 721 | <***CATEGORY***> -> Internal category (Ex: Other) | ||
| 722 | <***COMMENTS***> -> Comments (Ex: This page is) | ||
| 723 | <***LANGUAGE***> -> Language (Ex: English) | ||
| 724 | |||
| 725 | |||
| 726 | If you want to create your own file which describe a search engine | ||
| 727 | use your liked text editor or PERL script NEWSE.cgi delivered with | ||
| 728 | SPT5 (http://www.tapor.com/promotion/). | ||
| 729 | |||
| 730 | =head1 &OutputHandler() Procedure | ||
| 731 | |||
| 732 | It's procedure which will be called by the module for a conclusion | ||
| 733 | of the data about submit process. Procedure OutputHandler has the | ||
| 734 | following format: | ||
| 735 | |||
| 736 | sub OutputHandler { | ||
| 737 | local (%data) = _; | ||
| 738 | } | ||
| 739 | |||
| 740 | Hash %data will contains data from WWW::Promotion module. The module | ||
| 741 | sends 3 types of the data: | ||
| 742 | |||
| 743 | 1. $data{'action'} eq "sendheader" | ||
| 744 | |||
| 745 | WWW:: Promotion tell to you to send header of HTML page to the client | ||
| 746 | browser. It's sent once by the module. | ||
| 747 | |||
| 748 | 2 $data{'action'} eq "sedata" | ||
| 749 | |||
| 750 | WWW::Promotion tell you to send the information on the search engine, | ||
| 751 | which was processed. | ||
| 752 | |||
| 753 | 3 $data{'action'} eq "sendfooter" | ||
| 754 | |||
| 755 | WWW::Promotion tell you to send footer of HTML page to the client | ||
| 756 | browser. It is sent once by the module. | ||
| 757 | |||
| 758 | When $data{'action'} it is equal "sedata" the hash %data contains | ||
| 759 | also other keys: | ||
| 760 | |||
| 761 | $data{'SEname'} | ||
| 762 | The name of the search engine. Defined if a file of search engine | ||
| 763 | contains a line (SEname:). | ||
| 764 | |||
| 765 | $data{'SEurl'} | ||
| 766 | The URL of the search engine. Defined if a file of search engine | ||
| 767 | contains a line (SEurl:). | ||
| 768 | |||
| 769 | $data{'se'} | ||
| 770 | Contains filename of file in a SE database. It is always defined. | ||
| 771 | |||
| 772 | $data {'Country'} | ||
| 773 | The country of the search engine. Defined if a file of search engine | ||
| 774 | contains a line (Country:). | ||
| 775 | |||
| 776 | $data{'error'} | ||
| 777 | TRUE if there was an error at submit process, $data {'errortxt'} | ||
| 778 | contains the text of the error. | ||
| 779 | |||
| 780 | $data {'Server'} | ||
| 781 | The software which is used in the search engine. | ||
| 782 | Defined if a file of search engine contains a line (Server:). | ||
| 783 | |||
| 784 | =head1 FASTMODE [tm] | ||
| 785 | |||
| 786 | FASTMODE[tm] is method to submit your URL. In the FASTMODE submission is | ||
| 787 | blazing fast. When $Setup{'fastmode'} flag is passed to WWW_Promotion | ||
| 788 | procedure WWW::Promotion looks for $Setup{'proxy'} and if $Setup{'proxy'} | ||
| 789 | not defined it returns error. | ||
| 790 | |||
| 791 | Why FASTMODE is fast ? | ||
| 792 | |||
| 793 | Because WWW::Promotion will not wait answer from server. | ||
| 794 | It will continue to the next search engine without waiting answer | ||
| 795 | from previous one. This is may be done only via proxy server. | ||
| 796 | |||
| 797 | =head1 COPYRIGHT | ||
| 798 | |||
| 799 | Copyright (c) 1999-2001 TAPOR, Inc. All rights reserved. | ||
| 800 | This program is free software; you can redistribute it and/or modify | ||
| 801 | it under the same terms as Perl itself. | ||
| 802 | |||
| 803 | http://www.tapor.com/promotion/ | ||
| 804 | |||
| 805 | =cut |