asked on
How can I log in with php to another site? (knowing the user name and password)Expect that each site will be different, so your script design will use a polymorphic adapter pattern.
<?php // RAY_count_words.php
error_reporting(E_ALL);
echo "<pre>";
// DEMONSTRATE HOW TO COUNT ALL THE WORDS USED ON A WEB PAGE
// USEFUL MAN PAGES:
// http://php.net/manual/en/function.file-get-contents.php
// http://php.net/manual/en/function.preg-replace.php
// http://php.net/manual/en/function.explode.php
// http://php.net/manual/en/array.sorting.php
// ACQUIRE THE DATA
$url = 'http://www.apache.org/';
$htm = file_get_contents($url);
// MUNG THE DATA INTO LOWER-CASE
$htm = strtolower($htm);
// REMOVE CSS AND JAVASCRIPT
$htm = preg_replace("/\<style.*style\>/", NULL, $htm);
$htm = preg_replace("/\<script.*script\>/", NULL, $htm);
// REMOVE THE HTML TAGS
$htm = strip_tags($htm);
// REMOVE EVERYTHING ELSE BUT LETTERS AND BLANKS
$htm = preg_replace('/[^a-z ]/', ' ', $htm);
// CONVERT ANY EXCESS WHITESPACE TO SINGLE BLANKS
$htm = trim(preg_replace('/\s\s+/', ' ', $htm));
// ACTIVATE THIS TO SEE THE "CLEAN" STRING
// echo PHP_EOL . htmlentities($htm);
// MAKE AN ARRAY OF WORDS
$arr = explode(' ', $htm);
// TURN THE ARRAY OF WORDS INTO UNIQUE KEYS, AND ZERO THE COUNTS
$unq = array_flip($arr);
foreach ($unq as $key => $nothing)
{
$unq[$key] = 0;
}
// COUNT THE WORDS
foreach ($arr as $wrd)
{
$unq[$wrd]++;
}
// SHOW THE WORK PRODUCTS
echo PHP_EOL . "THERE ARE " . count($unq) . " UNIQUE WORDS AMONG ". count($arr) . " TOTAL WORDS";
echo PHP_EOL . "IN ALPHABETICAL ORDER: ";
ksort($unq);
print_r($unq);
echo PHP_EOL . "IN FREQUENCY ORDER: ";
arsort($unq);
print_r($unq);
Best of luck with the project (it's a big one), ~Ray
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
Or your own websites beside this one.
for yahoo,gmail use OpenId
OpenID is a decentralized authentication protocol that makes it easy for people to sign up and access web accounts.
Yahoo, Google and facebook are all OpenID providers, so simply implementing it on your site will be enough for your users to be able to login using them (and any other OpenID provider).