# HG changeset patch # User robert # Date 1251613166 14400 # Node ID 477258d0935321670ef2a7115cc5f0d7ce6e312a [svn r1] initial import diff -r 000000000000 -r 477258d09353 Card.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Card.pm Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,53 @@ +package Card; +use List::Util qw(first max maxstr min minstr reduce shuffle sum); + +sub new +{ + my $class = shift; + + my $hashREF = + { + _tags => {}, + _pix => "" + }; + + $objectREF = bless($hashREF, $class); + + return $objectREF; + +} + + +sub getTags +{ + $bull = @_[0]->{'_tags'}; + return keys(%$bull); +}; +sub addTags +{ + $object = shift; + @add = @_; + if (@add) + { + @ohYeah = ($object->getTags(),@add); + foreach(@ohYeah){$object->{_tags}{$_} = "";} + } + return $object->getTags(); +}; + + +sub hasTags +{ + $card = shift; + @rest = @_; + @test = $card->getTags(); + foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}} + return 1; +} + + +sub setPix { $_[0]->{_pix} = $_[1]; } +sub getPix {return $_[0]->{_pix} ; } + + +1; \ No newline at end of file diff -r 000000000000 -r 477258d09353 PokeScrape.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PokeScrape.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,67 @@ +use Card; +use Storable; + +open POKE, ") +{ + $line =~ m/().*?().*?/; + + $img1 = $1; + $img3 = $2; + $line =~ m/().*?/; + $img2 = $1; + + + #Water + + #Blastoise + + #Rare Holo + + + + + $img1 =~ m/alt="(.*?)"/; + $typeTag = $1; + + $img2 =~ m/\(\#(\d+)\)/; + $numTag = $1; + $img2 =~ m/href="(.*?)"/; + $pix = $1; + $img2 =~ m/>(.*)new(); + $tempCard->addTags($typeTag,$numTag,$nameTag,$setTag,$rarityTag); + $tempCard->setPix($pix); + push @allcards,$tempCard; + + + } + + + +} + + +store \@allcards, 'CARD.perl'; + + + +my $refnewstruct = retrieve 'CARD.perl'; + + +print @$refnewstruct[0]->getTags(); \ No newline at end of file diff -r 000000000000 -r 477258d09353 all.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/all.dat Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,1929 @@ +1Psychic AlakazamRare Holo + + +2Water BlastoiseRare Holo + + + +3Colorless ChanseyRare Holo + + +4Fire CharizardRare Holo + + +5Colorless ClefairyRare Holo + + + +6Water GyaradosRare Holo + + +7Fighting HitmonchanRare Holo + + +8Fighting MachampRare Holo + + + +9Lightning MagnetonRare Holo + + +10Psychic MewtwoRare Holo + + +11Grass NidokingRare Holo + + + +12Fire NinetalesRare Holo + + +13Water PoliwrathRare Holo + + +14Lightning RaichuRare Holo + + + +15Grass VenusaurRare Holo + + +16Lightning ZapdosRare Holo + + +17Grass BeedrillRare + + + +18Colorless DragonairRare + + +19Fighting DugtrioRare + + +20Lightning ElectabuzzRare + + + +21Lightning ElectrodeRare + + +22Colorless PidgeottoRare + + +23Fire ArcanineUncommon + + + +24Fire CharmeleonUncommon + + +25Water DewgongUncommon + + +26Colorless DratiniUncommon + + + +27Colorless Farfetch'dUncommon + + +28Fire GrowlitheUncommon + + +29Psychic HaunterUncommon + + + +30Grass IvysaurUncommon + + +31Psychic JynxUncommon + + +32Psychic KadabraUncommon + + + +33Grass KakunaUncommon + + +34Fighting MachokeUncommon + + +35Water MagikarpUncommon + + + +36Fire MagmarUncommon + + +37Grass NidorinoUncommon + + +38Water PoliwhirlUncommon + + + +39Colorless PorygonUncommon + + +40Colorless RaticateUncommon + + +41Water SeelUncommon + + + +42Water WartortleUncommon + + +43Psychic AbraCommon + + +44Grass BulbasaurCommon + + + +45Grass CaterpieCommon + + +46Fire CharmanderCommon + + +47Fighting DiglettCommon + + + +48Colorless DoduoCommon + + +49Psychic DrowzeeCommon + + +50Psychic GastlyCommon + + + +51Grass KoffingCommon + + +52Fighting MachopCommon + + +53Lightning MagnemiteCommon + + + +54Grass MetapodCommon + + +55Grass Nidoran MaleCommon + + +56Fighting OnixCommon + + + +57Colorless PidgeyCommon + + +58Lightning PikachuCommon + + +58Lightning Pikachu (Red Cheek)Common + + + +59Water PoliwagCommon + + +60Fire PonytaCommon + + +61Colorless RattataCommon + + + +62Fighting SandshrewCommon + + +63Water SquirtleCommon + + +64Water StarmieCommon + + + +65Water StaryuCommon + + +66Grass TangelaCommon + + +67Lightning VoltorbCommon + + + +68Fire VulpixCommon + + +69Grass WeedleCommon + + +70Trainer Clefairy DollRare + + + +71Trainer Computer SearchRare + + +72Trainer Devolution SprayRare + + +73TrainerImpostor Professor OakRare + + + +74Trainer Item FinderRare + + +75Trainer LassRare + + +76Trainer Pokemon BreederRare + + + +77Trainer Pokemon TraderRare + + +78Trainer Scoop UpRare + + +79Trainer Super Energy RemovalRare + + + +80Trainer DefenderUncommon + + +81Trainer Energy RetrievalUncommon + + +82Trainer Full HealUncommon + + + +83Trainer MaintenanceUncommon + + +84Trainer PlusPowerUncommon + + +85Trainer Pokemon CenterUncommon + + + +86Trainer Pokemon FluteUncommon + + +87Trainer PokedexUncommon + + +88Trainer Professor OakUncommon + + + +89Trainer ReviveUncommon + + +90Trainer Super PotionUncommon + + +91Trainer BillCommon + + + +92Trainer Energy RemovalCommon + + +93Trainer Gust of WindCommon + + +94Trainer PotionCommon + + + +95Trainer SwitchCommon + + +96Special Energy Double Colorless EnergyUncommon + + +97Basic Energy Fighting EnergyNo Rarity + + + +98Basic Energy Fire EnergyNo Rarity + + +99Basic Energy Grass EnergyNo Rarity + + +100Basic Energy Lightning EnergyNo Rarity + + + +101Basic Energy Psychic EnergyNo Rarity + + +102Basic Energy Water EnergyNo Rarity + + + + +1Colorless ClefableRare Holo + + +2Lightning ElectrodeRare Holo + + + +3Fire FlareonRare Holo + + +4Lightning JolteonRare Holo + + +5Colorless KangaskhanRare Holo + + + +6Psychic Mr. MimeRare Holo + + +7Grass NidoqueenRare Holo + + +8Colorless PidgeotRare Holo + + + +9Grass PinsirRare Holo + + +10Grass ScytherRare Holo + + +11Colorless SnorlaxRare Holo + + + +12Water VaporeonRare Holo + + +13Grass VenomothRare Holo + + +14Grass VictreebelRare Holo + + + +15Grass VileplumeRare Holo + + +16Colorless WigglytuffRare Holo + + +17Colorless ClefableRare + + + +18Lightning ElectrodeRare + + +19Fire FlareonRare + + +20Lightning JolteonRare + + + +21Colorless KangaskhanRare + + +22Psychic Mr. MimeRare + + +23Grass NidoqueenRare + + + +24Colorless PidgeotRare + + +25Grass PinsirRare + + +26Grass ScytherRare + + + +27Colorless SnorlaxRare + + +28Water VaporeonRare + + +29Grass VenomothRare + + + +30Grass VictreebelRare + + +31Grass VileplumeRare + + +32Colorless WigglytuffRare + + + +33Grass ButterfreeUncommon + + +34Colorless DodrioUncommon + + +35Grass ExeggutorUncommon + + + +36Colorless FearowUncommon + + +37Grass GloomUncommon + + +38Colorless LickitungUncommon + + + +39Fighting MarowakUncommon + + +40Grass NidorinaUncommon + + +41Grass ParasectUncommon + + + +42Colorless PersianUncommon + + +43Fighting PrimeapeUncommon + + +44Fire RapidashUncommon + + + +45Fighting RhydonUncommon + + +46Water SeakingUncommon + + +47Colorless TaurosUncommon + + + +48Grass WeepinbellUncommon + + +49Grass BellsproutCommon + + +50Fighting CuboneCommon + + + +51Colorless EeveeCommon + + +52Grass ExeggcuteCommon + + +53Water GoldeenCommon + + + +54Colorless JigglypuffCommon + + +55Fighting MankeyCommon + + +56Colorless MeowthCommon + + + +57Grass Nidoran FemaleCommon + + +58Grass OddishCommon + + +59Grass ParasCommon + + + +60Lightning PikachuCommon + + +61Fighting RhyhornCommon + + +62Colorless SpearowCommon + + + +63Grass VenonatCommon + + +64Trainer Poke BallCommon + + + + +1Fighting AerodactylRare Holo + + +2Water ArticunoRare Holo + + + +3Colorless DittoRare Holo + + +4Colorless DragoniteRare Holo + + +5Psychic GengarRare Holo + + + +6Psychic HaunterRare Holo + + +7Fighting HitmonleeRare Holo + + +8Psychic HypnoRare Holo + + + +9Fighting KabutopsRare Holo + + +10Water LaprasRare Holo + + +11Lightning MagnetonRare Holo + + + +12Fire MoltresRare Holo + + +13Grass MukRare Holo + + +14Lightning RaichuRare Holo + + + +15Lightning ZapdosRare Holo + + +16Fighting AerodactylRare + + +17Water ArticunoRare + + + +18Colorless DittoRare + + +19Colorless DragoniteRare + + +20Psychic GengarRare + + + +21Psychic HaunterRare + + +22Fighting HitmonleeRare + + +23Psychic HypnoRare + + + +24Fighting KabutopsRare + + +25Water LaprasRare + + +26Lightning MagnetonRare + + + +27Fire MoltresRare + + +28Grass MukRare + + +29Lightning RaichuRare + + + +30Lightning ZapdosRare + + +31Grass ArbokUncommon + + +32Water CloysterUncommon + + + +33Psychic GastlyUncommon + + +34Grass GolbatUncommon + + +35Water GolduckUncommon + + + +36Fighting GolemUncommon + + +37Fighting GravelerUncommon + + +38Water KinglerUncommon + + + +39Fire MagmarUncommon + + +40Water OmastarUncommon + + +41Fighting SandslashUncommon + + + +42Water SeadraUncommon + + +43Psychic SlowbroUncommon + + +44Water TentacruelUncommon + + + +45Grass WeezingUncommon + + +46Grass EkansCommon + + +47Fighting GeodudeCommon + + + +48Grass GrimerCommon + + +49Water HorseaCommon + + +50Fighting KabutoCommon + + + +51Water KrabbyCommon + + +52Water OmanyteCommon + + +53Water PsyduckCommon + + + +54Water ShellderCommon + + +55Psychic SlowpokeCommon + + +56Water TentacoolCommon + + + +57Grass ZubatCommon + + +58Trainer Mr. FujiUncommon + + +59Trainer Energy SearchCommon + + + +60Trainer GamblerCommon + + +61Trainer RecycleCommon + + +62Trainer Mysterious FossilCommon + + + + + +1Psychic Dark AlakazamRare Holo + + +2Grass Dark ArbokRare Holo + + + +3Water Dark BlastoiseRare Holo + + +4Fire Dark CharizardRare Holo + + +5Colorless Dark DragoniteRare Holo + + + +6Fighting Dark DugtrioRare Holo + + +7Grass Dark GolbatRare Holo + + +8Water Dark GyaradosRare Holo + + + +9Psychic Dark HypnoRare Holo + + +10Fighting Dark MachampRare Holo + + +11Lightning Dark MagnetonRare Holo + + + +12Psychic Dark SlowbroRare Holo + + +13Grass Dark VileplumeRare Holo + + +14Grass Dark WeezingRare Holo + + + +15Trainer Here Comes Team Rocket!Rare Holo + + +16Trainer Rocket's Sneak AttackRare Holo + + +17Special Energy Rainbow EnergyRare Holo + + + +18Psychic Dark AlakazamRare + + +19Grass Dark ArbokRare + + +20Water Dark BlastoiseRare + + + +21Fire Dark CharizardRare + + +22Colorless Dark DragoniteRare + + +23Fighting Dark DugtrioRare + + + +24Grass Dark GolbatRare + + +25Water Dark GyaradosRare + + +26Psychic Dark HypnoRare + + + +27Fighting Dark MachampRare + + +28Lightning Dark MagnetonRare + + +29Psychic Dark SlowbroRare + + + +30Grass Dark VileplumeRare + + +31Grass Dark WeezingRare + + +32Fire Dark CharmeleonUncommon + + + +33Colorless Dark DragonairUncommon + + +34Lightning Dark ElectrodeUncommon + + +35Fire Dark FlareonUncommon + + + +36Grass Dark GloomUncommon + + +37Water Dark GolduckUncommon + + +38Lightning Dark JolteonUncommon + + + +39Psychic Dark KadabraUncommon + + +40Fighting Dark MachokeUncommon + + +41Grass Dark MukUncommon + + + +42Colorless Dark PersianUncommon + + +43Fighting Dark PrimeapeUncommon + + +44Fire Dark RapidashUncommon + + + +45Water Dark VaporeonUncommon + + +46Water Dark WartortleUncommon + + +47Water MagikarpUncommon + + + +48Colorless PorygonUncommon + + +49Psychic AbraCommon + + +50Fire CharmanderCommon + + + +51Colorless Dark RaticateCommon + + +52Fighting DiglettCommon + + +53Colorless DratiniCommon + + + +54Psychic DrowzeeCommon + + +55Colorless EeveeCommon + + +56Grass EkansCommon + + + +57Grass GrimerCommon + + +58Grass KoffingCommon + + +59Fighting MachopCommon + + + +60Lightning MagnemiteCommon + + +61Fighting MankeyCommon + + +62Colorless MeowthCommon + + + +63Grass OddishCommon + + +64Fire PonytaCommon + + +65Water PsyduckCommon + + + +66Colorless RattataCommon + + +67Psychic SlowpokeCommon + + +68Water SquirtleCommon + + + +69Lightning VoltorbCommon + + +70Grass ZubatCommon + + +71Trainer Here Comes Team Rocket!Rare + + + +72Trainer Rocket's Sneak AttackRare + + +73Trainer The Boss's WayUncommon + + +74Trainer Challenge!Uncommon + + + +75Trainer DiggerUncommon + + +76TrainerImpostor Oak's RevengeUncommon + + +77Trainer Nightly Garbage RunUncommon + + + +78Trainer Goop Gas AttackCommon + + +79Trainer Sleep!Common + + +80Special Energy Rainbow EnergyRare + + + +81Special Energy Full Heal EnergyUncommon + + +82Special Energy Potion EnergyUncommon + + +83Lightning Dark RaichuRare Holo + + + + + +1Fire Blaine's MoltresRare Holo + + +2Fighting Brock's RhydonRare Holo + + + +3Colorless Erika's ClefableRare Holo + + +4Colorless Erika's DragonairRare Holo + + +5Grass Erika's VileplumeRare Holo + + + +6Lightning Lt. Surge's ElectabuzzRare Holo + + +7Colorless Lt. Surge's FearowRare Holo + + +8Lightning Lt. Surge's MagnetonRare Holo + + + +9Water Misty's SeadraRare Holo + + +10Water Misty's TentacruelRare Holo + + +11Fighting Rocket's HitmonchanRare Holo + + + +12Fire Rocket's MoltresRare Holo + + +13Grass Rocket's ScytherRare Holo + + +14Psychic Sabrina's GengarRare Holo + + + +15Trainer BrockRare Holo + + +16Trainer ErikaRare Holo + + +17Trainer Lt. SurgeRare Holo + + + +18Trainer MistyRare Holo + + +19Trainer The Rocket's TrapRare Holo + + +20Fighting Brock's GolemRare + + + +21Fighting Brock's OnixRare + + +22Fighting Brock's RhyhornRare + + +23Fighting Brock's SandslashRare + + + +24Grass Brock's ZubatRare + + +25Colorless Erika's ClefairyRare + + +26Grass Erika's VictreebelRare + + + +27Lightning Lt. Surge's ElectabuzzRare + + +28Lightning Lt. Surge's RaichuRare + + +29Water Misty's CloysterRare + + + +30Water Misty's GoldeenRare + + +31Water Misty's PoliwrathRare + + +32Water Misty's TentacoolRare + + + +33Colorless Rocket's SnorlaxRare + + +34Grass Sabrina's VenomothRare + + +35Fire Blaine's GrowlitheUncommon + + + +36Colorless Blaine's KangaskhanUncommon + + +37Fire Blaine's MagmarUncommon + + +38Fighting Brock's GeodudeUncommon + + + +39Grass Brock's GolbatUncommon + + +40Fighting Brock's GravelerUncommon + + +41Colorless Brock's LickitungUncommon + + + +42Colorless Erika's DratiniUncommon + + +43Grass Erika's ExeggcuteUncommon + + +44Grass Erika's ExeggutorUncommon + + + +45Grass Erika's GloomUncommon + + +46Grass Erika's GloomUncommon + + +47Grass Erika's OddishUncommon + + + +48Grass Erika's WeepinbellUncommon + + +49Grass Erika's WeepinbellUncommon + + +50Lightning Lt. Surge's MagnemiteUncommon + + + +51Colorless Lt. Surge's RaticateUncommon + + +52Colorless Lt. Surge's SpearowUncommon + + +53Water Misty's PoliwhirlUncommon + + + +54Water Misty's PsyduckUncommon + + +55Water Misty's SeakingUncommon + + +56Water Misty's StarmieUncommon + + + +57Water Misty's TentacoolUncommon + + +58Psychic Sabrina's HaunterUncommon + + +59Psychic Sabrina's JynxUncommon + + + +60Psychic Sabrina's SlowbroUncommon + + +61Fire Blaine's CharmanderCommon + + +62Fire Blaine's GrowlitheCommon + + + +63Fire Blaine's PonytaCommon + + +64Colorless Blaine's TaurosCommon + + +65Fire Blaine's VulpixCommon + + + +66Fighting Brock's GeodudeCommon + + +67Fighting Brock's MankeyCommon + + +68Fighting Brock's MankeyCommon + + + +69Fighting Brock's OnixCommon + + +70Fighting Brock's RhyhornCommon + + +71Fighting Brock's SandshrewCommon + + + +72Fighting Brock's SandshrewCommon + + +73Fire Brock's VulpixCommon + + +74Grass Brock's ZubatCommon + + + +75Grass Erika's BellsproutCommon + + +76Grass Erika's BellsproutCommon + + +77Grass Erika's ExeggcuteCommon + + + +78Grass Erika's OddishCommon + + +79Grass Erika's TangelaCommon + + +80Lightning Lt. Surge's MagnemiteCommon + + + +81Lightning Lt. Surge's PikachuCommon + + +82Colorless Lt. Surge's RattataCommon + + +83Colorless Lt. Surge's SpearowCommon + + + +84Lightning Lt. Surge's VoltorbCommon + + +85Water Misty's GoldeenCommon + + +86Water Misty's HorseaCommon + + + +87Water Misty's PoliwagCommon + + +88Water Misty's SeelCommon + + +89Water Misty's ShellderCommon + + + +90Water Misty's StaryuCommon + + +91Psychic Sabrina's AbraCommon + + +92Psychic Sabrina's DrowzeeCommon + + + +93Psychic Sabrina's GastlyCommon + + +94Psychic Sabrina's Mr. MimeCommon + + +95Psychic Sabrina's SlowpokeCommon + + + +96Grass Sabrina's VenonatCommon + + +97Trainer Blaine's Quiz #1Rare + + +98Trainer BrockRare + + + +99Trainer CharityRare + + +100Trainer ErikaRare + + +101Trainer Lt. SurgeRare + + + +102Trainer MistyRare + + +103Stadium No Removal GymRare + + +104Stadium The Rocket's Training GymRare + + + +105Trainer Blaine's Last ResortUncommon + + +106Trainer Brock's Training MethodUncommon + + +107Stadium Celadon City GymUncommon + + + +108Stadium Cerulean City GymUncommon + + +109Trainer Erika's MaidsUncommon + + +110Trainer Erika's PerfumeUncommon + + + +111Trainer Good MannersUncommon + + +112Trainer Lt. Surge's TreatyUncommon + + +113Trainer Minion of Team RocketUncommon + + + +114Trainer Misty's WrathUncommon + + +115Stadium Pewter City GymUncommon + + +116Trainer RecallUncommon + + + +117Trainer Sabrina's ESPUncommon + + +118Trainer Secret MissionUncommon + + +119Trainer Tickling MachineUncommon + + + +120Stadium Vermilion City GymUncommon + + +121Trainer Blaine's GambleCommon + + +122Trainer Energy FlowCommon + + + +123Trainer Misty's DuelCommon + + +124Stadium Narrow GymCommon + + +125Trainer Sabrina's GazeCommon + + + +126Trainer Trash ExchangeCommon + + +127Basic Energy Fighting EnergyCommon + + +128Basic Energy Fire EnergyCommon + + + +129Basic Energy Grass EnergyCommon + + +130Basic Energy Lightning EnergyCommon + + +131Basic Energy Psychic EnergyCommon + + + +132Basic Energy Water EnergyCommon + + + +1Fire Blaine's ArcanineRare Holo + + +2Fire Blaine's CharizardRare Holo + + + +3Fire Brock's NinetalesRare Holo + + +4Grass Erika's VenusaurRare Holo + + +5Water Giovanni's GyaradosRare Holo + + + +6Fighting Giovanni's MachampRare Holo + + +7Grass Giovanni's NidokingRare Holo + + +8Colorless Giovanni's PersianRare Holo + + + +9Grass Koga's BeedrillRare Holo + + +10Colorless Koga's DittoRare Holo + + +11Lightning Lt. Surge's RaichuRare Holo + + + +12Water Misty's GolduckRare Holo + + +13Water Misty's GyaradosRare Holo + + +14Psychic Rocket's MewtwoRare Holo + + + +15Lightning Rocket's ZapdosRare Holo + + +16Psychic Sabrina's AlakazamRare Holo + + +17Trainer BlaineRare Holo + + + +18Trainer GiovanniRare Holo + + +19Trainer KogaRare Holo + + +20Trainer SabrinaRare Holo + + + +21Fire Blaine's NinetalesRare + + +22Fighting Brock's DugtrioRare + + +23Grass Giovanni's NidoqueenRare + + + +24Grass Giovanni's PinsirRare + + +25Grass Koga's ArbokRare + + +26Grass Koga's MukRare + + + +27Colorless Koga's PidgeottoRare + + +28Lightning Lt. Surge's JolteonRare + + +29Psychic Sabrina's GengarRare + + + +30Water Sabrina's GolduckRare + + +31Fire Blaine's CharmeleonUncommon + + +32Colorless Blaine's DodrioUncommon + + + +33Fire Blaine's RapidashUncommon + + +34Fighting Brock's GravelerUncommon + + +35Fighting Brock's PrimeapeUncommon + + + +36Fighting Brock's SandslashUncommon + + +37Fire Brock's VulpixUncommon + + +38Grass Erika's BellsproutUncommon + + + +39Grass Erika's BulbasaurUncommon + + +40Colorless Erika's ClefairyUncommon + + +41Grass Erika's IvysaurUncommon + + + +42Fighting Giovanni's MachokeUncommon + + +43Colorless Giovanni's MeowthUncommon + + +44Grass Giovanni's NidorinaUncommon + + + +45Grass Giovanni's NidorinoUncommon + + +46Grass Koga's GolbatUncommon + + +47Grass Koga's KakunaUncommon + + + +48Grass Koga's KoffingUncommon + + +49Colorless Koga's PidgeyUncommon + + +50Grass Koga's WeezingUncommon + + + +51Colorless Lt. Surge's EeveeUncommon + + +52Lightning Lt. Surge's ElectrodeUncommon + + +53Colorless Lt. Surge's RaticateUncommon + + + +54Water Misty's DewgongUncommon + + +55Psychic Sabrina's HaunterUncommon + + +56Psychic Sabrina's HypnoUncommon + + + +57Psychic Sabrina's JynxUncommon + + +58Psychic Sabrina's KadabraUncommon + + +59Psychic Sabrina's Mr. MimeUncommon + + + +60Fire Blaine's CharmanderCommon + + +61Colorless Blaine's DoduoCommon + + +62Fire Blaine's GrowlitheCommon + + + +63Fighting Blaine's MankeyCommon + + +64Fire Blaine's PonytaCommon + + +65Fighting Blaine's RhyhornCommon + + + +66Fire Blaine's VulpixCommon + + +67Fighting Brock's DiglettCommon + + +68Fighting Brock's GeodudeCommon + + + +69Colorless Erika's JigglypuffCommon + + +70Grass Erika's OddishCommon + + +71Grass Erika's ParasCommon + + + +72Fighting Giovanni's MachopCommon + + +73Water Giovanni's MagikarpCommon + + +74Colorless Giovanni's MeowthCommon + + + +75Grass Giovanni's Nidoran MaleCommon + + +76Grass Giovanni's Nidoran FemaleCommon + + +77Grass Koga's EkansCommon + + + +78Grass Koga's GrimerCommon + + +79Grass Koga's KoffingCommon + + +80Colorless Koga's PidgeyCommon + + + +81Grass Koga's TangelaCommon + + +82Grass Koga's WeedleCommon + + +83Grass Koga's ZubatCommon + + + +84Lightning Lt. Surge's PikachuCommon + + +85Colorless Lt. Surge's RattataCommon + + +86Lightning Lt. Surge's VoltorbCommon + + + +87Water Misty's HorseaCommon + + +88Water Misty's MagikarpCommon + + +89Water Misty's PoliwagCommon + + + +90Water Misty's PsyduckCommon + + +91Water Misty's SeelCommon + + +92Water Misty's StaryuCommon + + + +93Psychic Sabrina's AbraCommon + + +94Psychic Sabrina's AbraCommon + + +95Psychic Sabrina's DrowzeeCommon + + + +96Psychic Sabrina's GastlyCommon + + +97Psychic Sabrina's GastlyCommon + + +98Colorless Sabrina's PorygonCommon + + + +99Water Sabrina's PsyduckCommon + + +100Trainer BlaineRare + + +101Trainer Brock's ProtectionRare + + + +102Stadium Chaos GymRare + + +103Trainer Erika's KindnessRare + + +104Trainer GiovanniRare + + + +105Trainer Giovanni's Las ResortRare + + +106Trainer KogaRare + + +107Trainer Lt. Surge's Secret PlanRare + + + +108Trainer Misty's WishRare + + +109Stadium Resistance GymRare + + +110Trainer SabrinaRare + + + +111Trainer Blaine's Quiz #2Uncommon + + +112Trainer Blaine's Quiz #3Uncommon + + +113Stadium Cinnabar City GymUncommon + + + +114Stadium Fuchsia City GymUncommon + + +115Trainer Koga's Ninja TrickUncommon + + +116Trainer Master BallUncommon + + + +117Trainer Max ReviveUncommon + + +118Trainer Misty's TearsUncommon + + +119Stadium Rocket's Minefield GymUncommon + + + +120Trainer Rocket's Secret ExperimentUncommon + + +121Trainer Sabrina's Psychic ControlUncommon + + +122Stadium Saffron City GymUncommon + + + +123Stadium Viridian City GymUncommon + + +124Trainer FervorCommon + + +125Trainer Transparent WallsCommon + + + +126Trainer Warp PointCommon + + +127Basic Energy Fighting EnergyCommon + + +128Basic Energy Fire EnergyCommon + + + +129Basic Energy Grass EnergyCommon + + +130Basic Energy Lightning EnergyCommon + + +131Basic Energy Psychic EnergyCommon + + + +132Basic Energy Water EnergyCommon + + diff -r 000000000000 -r 477258d09353 cards.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cards.html Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,27 @@ + + + + + +Edit Pokèmon Cards + + + + + + + + + +
+
+ + +
+
+ +
+
+ + + \ No newline at end of file diff -r 000000000000 -r 477258d09353 cards.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cards.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,55 @@ +#!C:/strawberry/perl/bin/perl.exe + + +use CGI::Ajax; +use CGI; + +my $q = new CGI; + + +my %hash = ( 'card_list' => \&work, 'current_card' => \&funtwo); + + + + +my $pjx = CGI::Ajax->new(%hash); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,\&gen); # this outputs the html for the page + + + + + +sub funtwo +{ + return 14; +}; + + + +sub work +{ + return 13; +}; + + + + + + + + + + + + + + + + +sub gen +{ +open FILE, " }; +}; \ No newline at end of file diff -r 000000000000 -r 477258d09353 index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.html Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,25 @@ + + + +Pokemon Booster Pack Generator + + + + +

Pokèmon Draft Battle!!

+ + +
+
+
+
+ +
+
+ + +rules cards + + + + \ No newline at end of file diff -r 000000000000 -r 477258d09353 index.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,45 @@ +#!C:/strawberry/perl/bin/perl.exe + + +use CGI::Ajax; +use CGI; + +my $q = new CGI; + + +my %hash = ( 'perl_script' => \&work, 'num2' => \&funtwo); + + + + + + +my $pjx = CGI::Ajax->new(%hash); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,\&gen); # this outputs the html for the page + + + + + + +sub funtwo +{ + return 14; +}; + + + +sub work +{ + return 13; +}; + + + +sub gen +{ +open FILE, " }; +}; \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/info.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/info.php Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,10 @@ + + + PHP Test Script + + + + + \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/login.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login.css Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,4 @@ +#post_comment {background-color:#FFFF99;border:1px solid #000000;padding:10px 30px;} +.login {border-bottom:1px solid #000000;padding-bottom:10px;} +label {display:block;margin-top:10px;}/* CSS Document */ + diff -r 000000000000 -r 477258d09353 logintets/login.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login.html Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,96 @@ + + + + +AJAX Login System Demo + + + + + + + + + +

AJAX Login System Demo

+Creating a secure login system using XMLHttpRequest + +

This is an example of a login system that does not require page refreshes, but is still very secure. Valid +usernames and passwords for this demo are user1/pass1 and user2/pass2. Try these, and also incorrect passwords +to see the results.

+ +

Please note that this is not a functional form, your input will not go anywhere. It is solely for demonstrating +an XMLHttpRequest login system in javascript.

+ +

Advantages

+
    +
  • User does not need to refresh the page to login.
  • +
  • User is notified instantly on incorrect username/password combination.
  • +
  • Overall user experience is more seamless.
  • +
  • Password is not sent in plain text ever (more secure than traditional system).
  • +
  • Javascript convenience with server-side security (uses PHP/MySQL).
  • +
  • Uses one-time use random seed to hash the password before sending (making interceptions useless).
  • +
+ +

Disadvantages

+
    +
  • System is more prone to brute force attacks. +
    • Can be minimized by adding a delay after a certain number of attempts per username or per client.
  • +
  • User may expect a login button. +
    • One could still be added without reloading the page.
  • +
  • Older versions of Safari cannot disable a password field.
  • +
  • This code uses the MD5 encryption algorithm, which has since been proven to be less secure than previously thought. If you use this code, I strongly recommend you switch to a more secure encryption algorithm, such as SHA-1. For sites were security is not crucial, MD5 should suffice.
  • +
+ +

Demonstration

+ +
+
+ + + +
+
+ +

Source

+ + +

Questions

+

Can I copy your code?
+Sure, although I'd recommend you rewrite it as you go so you can actually learn +something useful. Also, passing someone else's code as your own is just uncool. +

+

Why didn't you use [insert technology here]?
+Basically I haven't done web development in close to a year, so I used what I knew best +(PHP/MySQL) and used the Javascript that I remembered, along with a little bit of +refreshing my memory. Perhaps I should have used object-oriented PHP or Javascript, but +this works. If it is slightly confusing, I apoligise, this is only meant as a proof-of-concept.

+
+

Created: 28 Jan 2005.

+

Last updated: 1 Dec 2005. Copyright © 2005. + + diff -r 000000000000 -r 477258d09353 logintets/login.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login.php Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,4 @@ + +<?php /*********************** Makes use of two MySQL tables. users: CREATE TABLE `users` (   `id` int(11) NOT NULL auto_increment,   `username` varchar(20) default NULL,   `password` varchar(40) default NULL,   `fullname` varchar(30) default NULL,   PRIMARY KEY  (`id`) ) TYPE=MyISAM seeds: CREATE TABLE `seeds` (   `id` int(11) NOT NULL auto_increment,   `seed` timestamp(14) NOT NULL,   PRIMARY KEY  (`id`) ) TYPE=MyISAM */ // connect to mysql $mysql mysql_connect('localhost','###USERNAME###','###PASSWORD###'); // fail on database errors if (!$mysql) {     die('false|Could not connect to MySQL'); } // connect to the database mysql_select_db('jamesdam_ajaxlogin'$mysql); // one task of the server is to provide random values to hash with if ($_GET['task']=='getseed') {     mysql_query('INSERT INTO seeds VALUES()'); // insert a new row with default values          // get the values from the row back     $result mysql_query('SELECT id, seed FROM seeds ORDER BY id DESC LIMIT 1');     if (!$result) { // fail on error         die('false|'.mysql_error());     }     $row mysql_fetch_assoc($result); // only one row so take the first row     echo($row['id'].'|'.$row['seed']);  // write back the data in form id|random_value } // the other task of the server is to check a username/password combination else if ($_GET['task']=='checklogin') {     // formulate query for username         $sql 'SELECT * FROM users WHERE username = \'' mysql_real_escape_string($_GET['username']) . '\'';     $result mysql_query($sql);          // fail on sql failure     if (!$result)  {         die('false|Could not connect to login database.  Please try again');     }          // get the first user with username in the table (should only be one)     $user_row mysql_fetch_assoc($result);     // if there isn't one     if (!$user_row)     {         // then the username doesn't exist, but don't let the user know that this is the problem         // rather inform them more vaguely that the combination is incorrect; prevents someone from         // fishing for valid usernames         die('false|Invalid username and password combination.');     }          // formulate query for random timestamp for given id     $sql 'SELECT * FROM seeds WHERE id=' . (int)$_GET['id'];     $result =  mysql_query($sql);     // die if no value for given id     if (!$result) {         die('false|Unknown error (hacking attempt).');     }     // get the first (only) seed     $seed_row mysql_fetch_assoc($result);          // fail if no row     if (!$seed_row) {         die('false|Unknown error (hacking attempt).');     }          // if the md5 hashes are equal to those generated by the clientside js     if (md5($user_row['password'] . $seed_row['seed']) == $_GET['hash']) {         // logged in         echo('true|' .  $user_row['fullname']);         // now remove the random key that was made for this request         mysql_query('DELETE FROM s WHERE id=' . (int)$_GET['id']);             }     else     {         // not logged in.. incorrect password         die('false|Invalid username and password combination.');     } } ?> + + \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/login.phps --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login.phps Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,4 @@ + +<?php /*********************** Makes use of two MySQL tables. users: CREATE TABLE `users` (   `id` int(11) NOT NULL auto_increment,   `username` varchar(20) default NULL,   `password` varchar(40) default NULL,   `fullname` varchar(30) default NULL,   PRIMARY KEY  (`id`) ) TYPE=MyISAM seeds: CREATE TABLE `seeds` (   `id` int(11) NOT NULL auto_increment,   `seed` timestamp(14) NOT NULL,   PRIMARY KEY  (`id`) ) TYPE=MyISAM */ // connect to mysql $mysql mysql_connect('localhost','###USERNAME###','###PASSWORD###'); // fail on database errors if (!$mysql) {     die('false|Could not connect to MySQL'); } // connect to the database mysql_select_db('jamesdam_ajaxlogin'$mysql); // one task of the server is to provide random values to hash with if ($_GET['task']=='getseed') {     mysql_query('INSERT INTO seeds VALUES()'); // insert a new row with default values          // get the values from the row back     $result mysql_query('SELECT id, seed FROM seeds ORDER BY id DESC LIMIT 1');     if (!$result) { // fail on error         die('false|'.mysql_error());     }     $row mysql_fetch_assoc($result); // only one row so take the first row     echo($row['id'].'|'.$row['seed']);  // write back the data in form id|random_value } // the other task of the server is to check a username/password combination else if ($_GET['task']=='checklogin') {     // formulate query for username         $sql 'SELECT * FROM users WHERE username = \'' mysql_real_escape_string($_GET['username']) . '\'';     $result mysql_query($sql);          // fail on sql failure     if (!$result)  {         die('false|Could not connect to login database.  Please try again');     }          // get the first user with username in the table (should only be one)     $user_row mysql_fetch_assoc($result);     // if there isn't one     if (!$user_row)     {         // then the username doesn't exist, but don't let the user know that this is the problem         // rather inform them more vaguely that the combination is incorrect; prevents someone from         // fishing for valid usernames         die('false|Invalid username and password combination.');     }          // formulate query for random timestamp for given id     $sql 'SELECT * FROM seeds WHERE id=' . (int)$_GET['id'];     $result =  mysql_query($sql);     // die if no value for given id     if (!$result) {         die('false|Unknown error (hacking attempt).');     }     // get the first (only) seed     $seed_row mysql_fetch_assoc($result);          // fail if no row     if (!$seed_row) {         die('false|Unknown error (hacking attempt).');     }          // if the md5 hashes are equal to those generated by the clientside js     if (md5($user_row['password'] . $seed_row['seed']) == $_GET['hash']) {         // logged in         echo('true|' .  $user_row['fullname']);         // now remove the random key that was made for this request         mysql_query('DELETE FROM s WHERE id=' . (int)$_GET['id']);             }     else     {         // not logged in.. incorrect password         die('false|Invalid username and password combination.');     } } ?> + + \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/login_controller.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login_controller.js Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,98 @@ +// js handling the login procedures + +// constants +var NORMAL_STATE = 4; +var LOGIN_PREFIX = 'login.php?'; + +// variables +var http = getHTTPObject(); // We create the HTTP Object +var hasSeed = false; +var loggedIn = false; +var seed_id = 0; +var seed = 0; +var fullname = ''; +var messages = ''; + +// getSeed method: gets a seed from the server for this transaction +function getSeed() +{ // only get a seed if we're not logged in and we don't already have one + if (!loggedIn && !hasSeed) { + // open up the path + http.open('GET', LOGIN_PREFIX + 'task=getseed', true); + http.onreadystatechange = handleHttpGetSeed; + http.send(null); + } +} + +// handleHttpGetSeed method: called when the seed is returned from the server +function handleHttpGetSeed() +{ + // if there hasn't been any errors + if (http.readyState == NORMAL_STATE) { + // split by the divider | + results = http.responseText.split('|'); + + // id is the first element + seed_id = results[0]; + + // seed is the second element + seed = results[1]; + + // now we have the seed + hasSeed = true; + } +} + +// validateLogin method: validates a login request +function validateLogin() +{ + // ignore request if we are already logged in + if (loggedIn) + return; + + // get form form elements 'username' and 'password' + username = document.getElementById('username').value; + password = document.getElementById('password').value; + + // ignore if either is empty + if (username != '' && password != '') { + // compute the hash of the hash of the password and the seed + hash = hex_md5(hex_md5(password) + seed); + + // open the http connection + http.open('GET', LOGIN_PREFIX + 'task=checklogin&username='+username+'&id='+seed_id+'&hash='+hash, true); + + // where to go + http.onreadystatechange = handleHttpValidateLogin; + http.send(null); + } +} + +// handleHttpValidateLogin method: called when the validation results are returned from the server +function handleHttpValidateLogin() +{ + // did the connection work? + if (http.readyState == NORMAL_STATE) { + // split by the pipe + results = http.responseText.split('|'); + if (results[0] == 'true') + { + hasSeed = false; + loggedIn = true; + fullname = results[1]; + messages = ''; + } + else + { + messages = results[1]; + } + showLogin(); + } +} + +// resetLogin method: if logged in, 'logs out' and allows a different user/pass to be entered +function resetLogin() +{ + loggedIn = false; + hasSeed = false; +} \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/login_presentation.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/login_presentation.js Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,126 @@ +var showingLoggedIn = false; +var messageElement = false; +var messageP = false; + +// focusField method: called when username and password gain focus +function focusField() +{ + try { + if (messageElement != false) + { + document.getElementById('message').removeChild(messageElement); + } + getSeed(); + } + catch (e) + { } // do nothing... hides an apparent firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=236791 +} + +// blurField method: called when username and password are blurred +function blurField() +{ + try { + validateLogin(); + } + catch (e) + { } // hide bug https://bugzilla.mozilla.org/show_bug.cgi?id=236791 +} + +// showLogin method: displays if necessariy that we are logged in +function showLogin() { + if (messageElement != false) + { + try { + document.getElementById('message').removeChild(messageElement); + } + catch (e) { } + } + if (loggedIn) + { + showingLoggedIn = true; + + loginPanel = document.getElementById('login'); + p = document.createElement('p'); + pre = document.createTextNode('Logged in as '); + strong = document.createElement('strong'); + strong_text = document.createTextNode(fullname); + strong.appendChild(strong_text); + mid = document.createTextNode(' ['); + a = document.createElement('a'); + a.href='javascript:logout();'; + a_text = document.createTextNode('logout'); + a.appendChild(a_text); + post = document.createTextNode(']'); + + p.appendChild(pre); + p.appendChild(strong); + p.appendChild(mid); + p.appendChild(a); + p.appendChild(post); + + messageP = document.getElementById('message'); + loginPanel.removeChild(messageP); + loginPanel.appendChild(p); + + messageElement = p; + + document.getElementById('username').disabled = 'disabled'; + document.getElementById('password').disabled = 'disabled'; + + document.getElementById('comments').focus(); + } + else + { + messageElement = document.createElement('strong'); + messageElement.appendChild(document.createTextNode(' ' + messages)); + messageElement.style.color = '#ff0000'; + document.getElementById('message').appendChild(messageElement); + } +} + +// logout method: prepares for a new login +function logout() +{ + resetLogin(); + username = document.getElementById('username'); + password = document.getElementById('password'); + loginPanel = document.getElementById('login'); + username.value = ''; + password.value = ''; + username.disabled = null; + password.disabled = null; + + loginPanel.removeChild(messageElement); + loginPanel.appendChild(messageP); + + messageElement = false; + showingLoggedIn = false; + + username.focus(); +} + +// setupLogin method: to be called on page load, sets up the login script +function setupLogin() +{ + username = document.getElementById('username'); + password = document.getElementById('password'); + addEvent(username, 'focus', focusField); + addEvent(username, 'blur', blurField); + addEvent(password, 'focus', focusField); + addEvent(password, 'blur', blurField); +} + + +// function to add events to the page in a cross-browser manner +function addEvent(objObject, strEventName, fnHandler) { + // DOM-compliant way to add an event listener + if (objObject.addEventListener) { + objObject.addEventListener(strEventName, fnHandler, false); + } + // IE/windows way to add an event listener + else if (objObject.attachEvent) { + objObject.attachEvent('on' + strEventName, fnHandler); + } +} + +addEvent(window,'load',setupLogin); \ No newline at end of file diff -r 000000000000 -r 477258d09353 logintets/md5.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/md5.js Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,256 @@ +/* + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} +function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} +function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} +function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } +function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } +function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } + +/* + * Perform a simple self-test to see if the VM is working + */ +function md5_vm_test() +{ + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; +} + +/* + * Calculate the MD5 of an array of little-endian words, and a bit length + */ +function core_md5(x, len) +{ + /* append padding */ + x[len >> 5] |= 0x80 << ((len) % 32); + x[(((len + 64) >>> 9) << 4) + 14] = len; + + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for(var i = 0; i < x.length; i += 16) + { + var olda = a; + var oldb = b; + var oldc = c; + var oldd = d; + + a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); + d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); + d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); + d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i+10], 17, -42063); + b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); + d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); + + a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); + d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); + c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); + a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); + d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); + c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); + d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); + c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); + d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); + c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); + + a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); + d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); + d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); + d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); + c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); + d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); + + a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); + d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); + d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); + d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); + d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return Array(a, b, c, d); + +} + +/* + * These functions implement the four basic operations the algorithm uses. + */ +function md5_cmn(q, a, b, x, s, t) +{ + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); +} +function md5_ff(a, b, c, d, x, s, t) +{ + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); +} +function md5_gg(a, b, c, d, x, s, t) +{ + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); +} +function md5_hh(a, b, c, d, x, s, t) +{ + return md5_cmn(b ^ c ^ d, a, b, x, s, t); +} +function md5_ii(a, b, c, d, x, s, t) +{ + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); +} + +/* + * Calculate the HMAC-MD5, of a key and some data + */ +function core_hmac_md5(key, data) +{ + var bkey = str2binl(key); + if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); + + var ipad = Array(16), opad = Array(16); + for(var i = 0; i < 16; i++) + { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); + return core_md5(opad.concat(hash), 512 + 128); +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safe_add(x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function bit_rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * Convert a string to an array of little-endian words + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. + */ +function str2binl(str) +{ + var bin = Array(); + var mask = (1 << chrsz) - 1; + for(var i = 0; i < str.length * chrsz; i += chrsz) + bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); + return bin; +} + +/* + * Convert an array of little-endian words to a string + */ +function binl2str(bin) +{ + var str = ""; + var mask = (1 << chrsz) - 1; + for(var i = 0; i < bin.length * 32; i += chrsz) + str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); + return str; +} + +/* + * Convert an array of little-endian words to a hex string. + */ +function binl2hex(binarray) +{ + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i++) + { + str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); + } + return str; +} + +/* + * Convert an array of little-endian words to a base-64 string + */ +function binl2b64(binarray) +{ + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i += 3) + { + var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) + | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) + | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); + for(var j = 0; j < 4; j++) + { + if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; + else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); + } + } + return str; +} diff -r 000000000000 -r 477258d09353 logintets/xml_http_request.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logintets/xml_http_request.js Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,37 @@ +// method that sets up a cross-browser XMLHttpRequest object +function getHTTPObject() { + var http_object; + + // MSIE Proprietary method + + /*@cc_on + @if (@_jscript_version >= 5) + try { + http_object = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + http_object = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + http_object = false; + } + } + @else + xmlhttp = http_object; + @end @*/ + + + // Mozilla and others method + + if (!http_object && typeof XMLHttpRequest != 'undefined') { + try { + http_object = new XMLHttpRequest(); + } + catch (e) { + http_object = false; + } + } + + return http_object; +} \ No newline at end of file diff -r 000000000000 -r 477258d09353 perltest/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltest/index.html Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,45 @@ + + +Simple Ajax Example + + + +

+

word: +

+
+
+ + diff -r 000000000000 -r 477258d09353 perltest/simple-ajax-example.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltest/simple-ajax-example.cgi Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,10 @@ +#!C:/strawberry/perl/bin/perl.exe +use CGI; + +$query = new CGI; + +$secretword = $query->param('w'); +$remotehost = $query->remote_host(); + +print $query->header; +print "

The secret word is $secretword and your IP is $remotehost.

"; \ No newline at end of file diff -r 000000000000 -r 477258d09353 scripts/convert_degrees.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/convert_degrees.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,45 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI; + +my $q = new CGI; + +print $q->header(); + +if ( defined $q->param('submit') or defined $q->param('Centigrade') or defined $q->param('Kelvin')) { + my $result = ""; + if ( defined $q->param('Centigrade') and $q->param('Centigrade') ne "") { + $result = $q->param('Centigrade') + 273.15; + } elsif ( defined $q->param('Kelvin') and $q->param('Kelvin') ne "" ) { + $result = $q->param('Kelvin') - 273.15; + } + print $result; +} else { + print &Show_Form(); + print &Show_Footer(); +} + +sub Show_Form { + my $html = ""; + $html .= < + Temperature Conversion + + +
+ Temperature =
+ degrees C
+ degrees K
+ +
+
+EOT + + return $html; +} + +sub Show_Footer { + print "\n"; + return; +} diff -r 000000000000 -r 477258d09353 scripts/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/index.html Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,27 @@ + + + pjx_callback.pl
+ pjx_chained.pl
+ pjx_change_encoding.pl
+ pjx_change_headers.pl
+ pjx_checkbox.pl
+ pjx_combo.pl
+ pjx_cr.pl
+ pjx_dynselect.pl
+ pjx_formdump.pl
+ pjx_from_span.pl
+ pjx_json.pl
+ pjx_json_out.pl
+ pjx_loading.pl
+ pjx_manyret.pl
+ pjx_nobuild.pl
+ pjx_no_cache_callee.pl
+ pjx_no_cache_caller.pl
+ pjx_objects_2_url.pl
+ pjx_podex.pl
+ pjx_radio.pl
+ pjx_splitargs.pl
+ pjx_subs.pl
+ pjx_url.pl
+ + \ No newline at end of file diff -r 000000000000 -r 477258d09353 scripts/pjx_JSON.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_JSON.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,52 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax JSON Example + + + +

Get The Letter Following the One you Enter

+
+ Enter Number: + +

The JavaScript Object:
+
+ +
+
After Parsing (use eval)
+
+ +
+ +
+ + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new('json' => 'pjx_JSON_out.pl'); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_JSON_out.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_JSON_out.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,22 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI; +use JSON; +use Data::Dumper; + +my $q = new CGI; + + +print $q->header(); + + +my $val = $q->param('args'); +my @vals = split(//, $val); + + +my $hash; +map { $hash->{$_} = chr(ord($_)+1) } @vals; + +my $json = objToJson($hash); + +print "var jsonObj = $json"; diff -r 000000000000 -r 477258d09353 scripts/pjx_NO_CACHE_callee.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_NO_CACHE_callee.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,13 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI; + +my $q = new CGI; +print $q->header(); + +my ($sec,$min,$hour,$mday,$mon,$year,$wday, +$yday,$isdst)=localtime(time); + +printf "%4d-%02d-%02d %02d:%02d:%02d\n", +$year+1900,$mon+1,$mday,$hour,$min,$sec; diff -r 000000000000 -r 477258d09353 scripts/pjx_NO_CACHE_caller.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_NO_CACHE_caller.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,46 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an script calls an external script and avoids caching: +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $Show_Form = sub { + my $html = ""; + $html .= <CGI::Ajax No_Cache Example + + + + +If the same URL is requested, A browser may cache the result +and return it without querying the requested URL. To avoid that, use +the 'NO_CACHE' keyword as a parameter in your javascript function. +
+
+Click the button and a perl script 'pjx_NO_CACHE_callee.pl should +return the current time:

+ +
+ +
+ +New Time: + + +
+ + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new( 'perl_script' => 'pjx_NO_CACHE_callee.pl'); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_callback.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_callback.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,68 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use coderefs to define +# your CGI::Ajax functions, and the methods return multiple results to +# the page +# +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $multiply = sub { + my $a = shift; + my $b = shift; + return $a * $b; +}; + +my $divide = sub { + my $a = shift; + my $b = shift; + return $a / $b; +}; +my $G = 'asdf'; +my $Show_Form = sub { + my $html = ""; + $html .= qq! + +CGI::Ajax Multiple Return Value Example + + + +
+ Enter Number: + + + + +
+URL FROM "this" in callback:
+ + +
+ + +!; + + return $html; +}; + + +my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_chained.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_chained.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,54 @@ +#!C:/strawberry/perl/bin/perl.exe + +# pjx_chained.pl: Multiple exported perl subs, and the exported +# functions are chained to an event, like this... +# onclick="func1(['in1'],['out1']); func2(['in1'],['out2']);" + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $multiply = sub { + my $a = shift; + my $b = shift; + return $a * $b; +}; + +my $divide = sub { + my $a = shift; + my $b = shift; + return $a / $b; +}; + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Chained function Example + + +
+ Enter Number: + + +

+ + + + + +
+ + +EOT + return $html; +}; + +my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_change_encoding.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_change_encoding.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,44 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI::Ajax; +use CGI; + +my $func = sub { + my $input = shift; + return "got input: $input " ; +}; + + +sub Show_HTML { +my $html = < +CGI::Ajax Example + + + +
+Enter Something:  +
+Enter Something:  +
+
+
+ +
+ + + +EOT + +} + +my $cgi = new CGI(); # create a new CGI object +my $pjx = new CGI::Ajax( 'jsfunc' => $func ); +# the default encoding for CGI::Ajax is encodeURIComponent; +# if this causes problems, you can use escape or your own javascript +# function; +$pjx->js_encode_function('escape'); +print $pjx->build_html($cgi,\&Show_HTML); diff -r 000000000000 -r 477258d09353 scripts/pjx_change_headers.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_change_headers.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,41 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI::Ajax; +use CGI; + +my $func = sub { + my $input = shift; + return "got input: $input " ; +}; + + +sub Show_HTML { +my $html = < +CGI::Ajax Example + + + +
+Enter Something:  +
+Enter Something:  +
+
+
+ +
+ + + +EOT + +} + +my $cgi = new CGI(); # create a new CGI object +my $pjx = new CGI::Ajax( 'jsfunc' => $func ); +# the send in some extra headers; +print $pjx->build_html($cgi,\&Show_HTML, { '-expires' => '1d', '-charset' => 'ISO-8859-1'} ); diff -r 000000000000 -r 477258d09353 scripts/pjx_checkbox.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_checkbox.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,40 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI::Ajax; +use CGI; + + +my $perl_func = sub { + my $input = shift; + + print "got $input"; +}; + +sub Show_HTML { + my $html = ""; + $html .= < +CGI::Ajax Example + + +
+ val1
+ + +
+ + +EOT + + return $html; +} + +my $cgi = new CGI(); # create a new CGI object + +my $pjx = new CGI::Ajax( 'jsFunc' => $perl_func ); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); + +print $pjx->build_html($cgi,\&Show_HTML); # this outputs the html for the page + diff -r 000000000000 -r 477258d09353 scripts/pjx_combo.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_combo.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,146 @@ +#!C:/strawberry/perl/bin/perl.exe + +# CGI-Ajax: example script 'pjx_combo.pl' +# +# INSTALL: place in an apache location that can execute perl scripts +# +# this script demonstrates a set of dynamic select boxes, where the +# selection in a box changes other select box contents, or html div +# values. The data in each select box comes from the data anonymous +# hash, but could just as easily come from a database connection, etc. +# +# N.B. this requires CGI__Ajax version >=0.49 +# +# Also, this example has lots of stderr output, so follow your apache +# log files to see what's going on. +# +use strict; +use CGI::Ajax 0.49; +use CGI; +use vars qw( $data ); + +# This is our data - top level keys get put in the leftmost select +# box, next level of keys get the second select box. Values will end +# up in the resultdiv html element +$data = { + 'A' => { '1' => "A1", '2' => "A2", '3' => "A3", '42' => "A42" }, + 'B' => { 'green' => "Bgreen", 'red' => "Bred" }, + 'something' => { 'firefly' => "great show" }, + 'final_thing' => { 'email' => "chunkeylover53", 'name' => "homer", + 'address' => "742 Evergreen Terrace" } +}; + +my $q = new CGI; # need a new CGI object + +# compose our list of functions to export to js +my %hash = ( 'SetA' => \&set_listA, + 'SetB' => \&set_listB, + 'ShowResult' => \&show_result ); + +my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object +$pjx->js_encode_function('encodeURIComponent'); + +$pjx->DEBUG(1); # turn on debugging +$pjx->JSDEBUG(1); # turn on javascript debugging, which will place a + # new div element at the bottom of our page showing + # the asynchrously requested URL + +print $pjx->build_html( $q, \&Show_HTML ); # this builds our html + # page, inserting js + +# This subroutine is responsible for outputting the HTML of the web +# page. Note that I've added an additional javascript function to +# erase/reset contents. This prevents strange effects from +# overwriting a div without clearing it out first. +sub Show_HTML { + my $html = < +Combo Example + + + + + +
+
+
+
+ + + + +EOT + + return($html); +} + +# these are my exported functions - note that set_listA and set_listB +# are just returning html to be inserted into their respective div +# elements. +sub set_listA { + # this is the returned text... html to be displayed in the div + # defined in the javascript call + my $txt = qq!"; + print STDERR "set_listA:\n"; + print STDERR "returning $txt\n"; + return($txt); +} + +sub set_listB { + my $listA_selection = shift; + print STDERR "set_listB: received $listA_selection .\n"; + + # this is the returned text... html to be displayed in the div + # defined in the javascript call + my $txt = qq!"; + print STDERR "set_listB:\n"; + print STDERR "returning $txt\n"; + return($txt); +} + +sub show_result { + my $listA_selection = shift; + my $txt = ""; + # this loop is needed in case the user selected multiple elements in + # the second select box, listB + while ( @_ ) { + my $in = shift; + $txt .= $data->{ $listA_selection }->{ $in } . "
"; + } + + print STDERR "show_result - returning txt with value: $txt\n"; + return( $txt ); +} + diff -r 000000000000 -r 477258d09353 scripts/pjx_cr.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_cr.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,57 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use coderefs to define +# your CGI::Ajax functions. +# +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $exported_fx = sub { + my $value_a = shift; + my $value_b = shift; + $value_a = "" if not defined $value_a; # make sure there's def + $value_b = "" if not defined $value_b; # make sure there's def + + if ( $value_a =~ /\D+/ or $value_a eq "" ) { + return( $value_a . " and " . $value_b ); + } elsif ( $value_b =~ /\D+/ or $value_b eq "" ) { + return( $value_a . " and " . $value_b ); + } else { + # got two numbers, so lets multiply them together + return( $value_a * $value_b ); + } +}; + + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Example + + + + Enter something:  +
+ + Enter something else:  +
+ +
+
+
+ + + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_dynselect.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_dynselect.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,130 @@ +#!C:/strawberry/perl/bin/perl.exe + +# dynamic select boxes, using a db + +use strict; +use CGI::Ajax; +use CGI; +use DBI; + +my $q = new CGI; + +### phone book database +# CREATE TABLE `phonebook` ( +# `login` varchar(10) NOT NULL, +# `fullname` varchar(200) NOT NULL, +# `areacode` int(10) unsigned NOT NULL default '123', +# `phone` varchar(7) NOT NULL +# ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Users and phone numbers'; +# +my $exported_fx = sub { + my $searchterm = shift; + my $sql = qq< select login from phonebook where login like ? or fullname like ? >; + my $dbh = DBI->connect('dbi:mysql:test:localhost','guestuser','guestp4ss'); + my $sth = $dbh->prepare( $sql ); + $sth->execute( $searchterm . '%', $searchterm . '%' ); + + # start off the div contents with select init + my $html = qq!\n!; + + return($html); +}; + +my $get_details = sub { + my $login = shift; + my $sql = qq< select * from phonebook where login = ? >; + my $dbh = DBI->connect('dbi:mysql:test:localhost','guestuser','guestp4ss'); + my $sth = $dbh->prepare( $sql ); + $sth->execute( $login ); + + my $html = ""; + + my $row = $sth->fetch(); + if ( defined $row ) { + $html .= "Login: " . $row->[0] . "
"; + $html .= "Full Name: " . $row->[1] . "
"; + $html .= "Area Code: " . $row->[2] . "
"; + $html .= "Phone: " . $row->[3] . "
"; + } else { + $html .= "No Such User $login\n"; + } + return($html); +}; + + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Example + + + Who are you searching for?
+ Start typing and matches will display in the select box.
+ Selecting a match will give you details.  +
+
+
+ +EOT + + $html .= dump_table(); + + $html .= < +
+
+ +
Show Source
+ + + +EOT + return $html; +}; + +sub dump_table { + my $sql = qq< select login from phonebook >; + my $dbh = DBI->connect('dbi:mysql:test:localhost','guestuser','guestp4ss'); + my $sth = $dbh->prepare( $sql ); + $sth->execute(); + + my $html = ""; + + while ( my $row = $sth->fetch() ) { + $html .= ""; + } + + $html .= "
Current Logins in DB
" . $row->[0] . "
"; + return($html); +} + +my $pjx = CGI::Ajax->new( + search => $exported_fx, + details => $get_details + ); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); + +# not show the html, which will include the embedded javascript code +# to handle the ajax interaction +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_formDump.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_formDump.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,56 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $concatter = sub { + my $str = "All Values Are
\n"; + map { $str .= ' and ' . $_ } @_; + print STDERR $str; + return $str; +}; + +my $Show_Form = sub { + my $html = ""; + $html = < +CGI::Ajax Multiple Return Value Example + + +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+ + +
+ + +EOT +; + + return $html; +}; + + +my $pjx = CGI::Ajax->new( 'jsFunc' => $concatter); +$pjx->JSDEBUG(2); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_from_span.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_from_span.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,64 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use warnings; + +use CGI; +use CGI::Ajax; + +my $cgi= CGI->new; + +my $a= CGI::Ajax->new( + 'test_elt_html' => \&test_elt_html + ); + +$a->DEBUG(2); +$a->JSDEBUG(2); + +print $a->build_html( $cgi, \&html_page); + +sub html_page + + { +return < + + + + + + +
test with div
+

test with span

+

test with p

+ +
some stuff
+
+ +

+
+ +

+
+ +

+
+ + + +EOH +; + + } + + +sub test_elt_html + { my( $elt_html)= @_; + print STDERR "IN:" . $elt_html , "\n"; + return $elt_html; + } + diff -r 000000000000 -r 477258d09353 scripts/pjx_loading.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_loading.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,66 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI::Ajax; +use CGI; + +my $func = sub { + my $input = shift; + my $i=6000000; + while($i--){ } + return "got input: $input " . 'done'; +}; + + +sub Show_HTML { +my $html = < +CGI::Ajax Example + + + + +
+Enter Something:  +
+Enter Something:  +
+
+
+
+ +
+
+
+ + + +EOT + +} + +my $cgi = new CGI(); # create a new CGI object +my $pjx = new CGI::Ajax( 'jsfunc' => $func ); +print $pjx->build_html($cgi,\&Show_HTML); diff -r 000000000000 -r 477258d09353 scripts/pjx_manyret.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_manyret.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,75 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use coderefs to define +# your CGI::Ajax functions, and the methods return multiple results to +# the page +# +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $exported_fx = sub { + my $value_a = shift; + my $value_b = shift; + $value_a = "" if not defined $value_a; # make sure there's def + $value_b = "" if not defined $value_b; # make sure there's def + + if ( $value_a =~ /\D+/ or $value_a eq "" ) { + return( $value_a, $value_b, 'NaN' ); + } elsif ( $value_b =~ /\D+/ or $value_b eq "" ) { + return( $value_a, $value_b, 'NaN' ); + } else { + # got two numbers, so lets multiply them together + return( $value_a, $value_b, $value_a * $value_b ); + } +}; + + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Multiple Return Value Example + + +
+ Enter something:  +
+ + Enter something else:  +
+ +
+ + + + + + + + + + + +
Input AInput BResult
+
+
+
+
+
+
+
+ + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx); +$pjx->JSDEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_nobuild.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_nobuild.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,46 @@ +#!C:/strawberry/perl/bin/perl.exe + +use strict; +use CGI::Ajax; + +my $my_func = sub { + my $arg = shift; + return ( $arg . " with some extra" ); +}; + +my $pjx = new CGI::Ajax( 'tester' => $my_func ); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); + +use CGI; +my $cgi = new CGI(); +print $cgi->header(); + +$pjx->cgi( $cgi ); + +my $html = ""; + $html .= ""; + $html .= ""; + + $html .= $pjx; + + $html .= < + +
+ +
+
+
+

+ + +EOT + +if ( not $cgi->param('fname') ) { + print $html; +} else { + print $pjx->handle_request(); +} + diff -r 000000000000 -r 477258d09353 scripts/pjx_objects_2_url.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_objects_2_url.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,59 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use coderefs to define +# your CGI::Ajax functions. +# +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $exported_fx = sub { + my $value_a = shift; + my $iq = new CGI; + my $a = $q->param('a'); + my $b = $q->param('b'); + my $test = $q->param('test'); + return( + 'entered value was: ' . $value_a . + '
a was: ' . $a . "..." . + '
b was: ' . $b . "..." . + '
test was: ' . $test . "..." + ); +}; + + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Example + + +
+this javascript object is sent in as an argument: +{'a':123,'b':345,'test':'123 Evergreen Terrace'} +

+ Enter something else:  +
+ +
+
+
+
+ + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx); +$pjx->JSDEBUG(2); +$pjx->DEBUG(2); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page + diff -r 000000000000 -r 477258d09353 scripts/pjx_podex.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_podex.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,67 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI::Ajax; +use CGI; + +# define an anonymous perl subroutine that you want available to +# javascript on the generated web page. + +my $evenodd_func = sub { + my $input = shift; + + my $magic = "      look ma, no submit!
"; + + # see if input is defined + if ( not defined $input ) { + return("input not defined or NaN" . $magic); + } + + # see if value is a number (*thanks Randall!*) + if ( $input !~ /\A\d+\z/ ) { + return("input is NaN" . $magic); + } + + # got a number, so mod by 2 + $input % 2 == 0 ? return("$input is EVEN" . $magic) : return("$input is ODD" . $magic); + +}; # don't forget the trailing ';', since this is an anon subroutine + +# define a function to generate the web page - this can be done +# million different ways, and can also be defined as an anonymous sub. +# The only requirement is that the sub send back the html of the page. +sub Show_HTML { + my $html = ""; + $html .= < +CGI::Ajax Example + + +
+ Enter a number:  +
+
+
+
+
+ + +EOT + + return $html; +} + +my $cgi = new CGI(); # create a new CGI object +# now we create a CGI::Ajax object, and associate our anon code +my $pjx = new CGI::Ajax( 'evenodd' => $evenodd_func ); + +# now print the page. This can be done easily using +# CGI::Ajax->build_html, sending in the CGI object to generate the html +# header. This could also be done manually, and then you don't need +# the build_html() method +print $pjx->build_html($cgi,\&Show_HTML); # this outputs the html for the page + +# that's it! + diff -r 000000000000 -r 477258d09353 scripts/pjx_radio.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_radio.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,49 @@ +#!C:/strawberry/perl/bin/perl.exe +use strict; +use CGI::Ajax 0.57; +use CGI; + +my $q = new CGI; # need a new CGI object + +# compose our list of functions to export to js +my %hash = ( 'myFunc' => \&perl_func,); + +my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object + +$pjx->DEBUG(1); # turn on debugging +$pjx->JSDEBUG(1); # turn on javascript debugging, which will place a + # new div element at the bottom of our page showing + # the asynchrously requested URL + +print $pjx->build_html( $q, \&Show_HTML ); # this builds our html + # page, inserting js + +# This subroutine is responsible for outputting the HTML of the web +# page. +sub Show_HTML { + my $html = < +Radio Example + + +
+
+red +blue +yellow +green +
+
+
+ + +EOT + + return($html); +} + +# this is the exported function +sub perl_func { + $a = shift; + return $a . " was selected"; +} diff -r 000000000000 -r 477258d09353 scripts/pjx_splitargs.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_splitargs.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,54 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use coderefs to define +# your CGI::Ajax functions, and the methods return multiple results to +# the page +# +# NB The CGI::Ajax object must come AFTER the coderefs are declared. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +my $divide = sub { + my $a = shift; + my $b = shift; + return ($a / $b,"this is 2nd return value"); +}; + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Multiple Return Value Example + + + +
+ Enter Number: + + + + + + + +
+ + +EOT + + return $html; +}; + +my $pjx = CGI::Ajax->new('divide' => $divide); +$pjx->JSDEBUG(1); +$pjx->DEBUG(1); +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page diff -r 000000000000 -r 477258d09353 scripts/pjx_subs.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_subs.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,55 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example of using subs (not coderefs) for your perljax +# functions +# +# NB The CGI::Ajax object DOES NOT need to follow the function +# declarations, as it does in the coderef example + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; +my $pjx = CGI::Ajax->new( 'myfunc' => \&exported_fx); +print $pjx->build_html($q,\&Show_Form); # this outputs the html for the page + +sub exported_fx { + my $value_a = shift; + my $value_b = shift; + $value_a = "" if not defined $value_a; # make sure there's def + $value_b = "" if not defined $value_b; # make sure there's def + + if ( $value_a =~ /\D+/ or $value_a eq "" ) { + return( $value_a . " and " . $value_b ); + } elsif ( $value_b =~ /\D+/ or $value_b eq "" ) { + return( $value_a . " and " . $value_b ); + } else { + # got two numbers, so lets multiply them together + return( $value_a * $value_b ); + } +} + +sub Show_Form { + my $html = ""; + $html .= < +CGI::Ajax Example + + +
+ Enter something:  +
+ + Enter something else:  +
+ +
+
+
+
+ + +EOT + return $html; +} diff -r 000000000000 -r 477258d09353 scripts/pjx_url.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pjx_url.pl Sun Aug 30 02:19:26 2009 -0400 @@ -0,0 +1,43 @@ +#!C:/strawberry/perl/bin/perl.exe + +# this is an example script of how you would use URLs to define +# your CGI::Ajax functions. + +use strict; +use CGI::Ajax; +use CGI; + +my $q = new CGI; + +# the format here implies that 'convert_degrees.pl' is at the same +# level in the web server's document root as this script. +my $pjx = CGI::Ajax->new( 'myfunc' => 'convert_degrees.pl'); +$pjx->JSDEBUG(1); + +my $Show_Form = sub { + my $html = ""; + $html .= < +CGI::Ajax Outside URL Example + + +
+ Degrees Centigrade:  + +
+ + Degrees Kelvin:  + +
+ + +EOT + + return $html; +}; + +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page