Skip to content

Commit

Permalink
Added VimeoVideoTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooaki authored and Ephigenia committed Oct 19, 2010
1 parent 1b6413c commit bf64872
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 111 deletions.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ report page.
# REQUIREMENTS

* PHP 5.2 or later
* PHP Curl module (e.g. "php5-curl" package)
* PHP Curl module (e.g. "php5-curl" package)

# INSTALLATION

1. copy all files into an extra directory in your webspace
2. make the directory `/app/data` writable by the user running cron.php
(see below)
3. cp `/app/config/config.php.dist` to `/app/config/config.php` and edit it
4. create a cron job that calls cron.php periodically (e.g. every 10mins)
4. create a cron job that calls cron.php periodically (e.g. every 10mins)
example: `*/10 * * * * user php5 -f /path/to/cron.php 2>&1 > /dev/null`
5. open the Franklin html directory in your webbrowser to see the reports

# TESTS

* `name` Optional name for a test, used also as chart title
* `interval` time interval between checks for the current test.
* `interval` time interval between checks for the current test.
f.e. `+1 day`, `+30 minutes` or shorter `2h`

## Facebook Group Fan Count
Expand Down Expand Up @@ -58,7 +58,7 @@ Make sure you enabled the Awareness API in the Feedburner configuration.
## Google Results Count

Number of results on a google search query. You can use this to get the number
of indexed pages or backlinks to your website that are known to google. You
of indexed pages or backlinks to your website that are known to google. You
also can make up custom queries.

* `search` query to search
Expand All @@ -85,15 +85,15 @@ specific by using the needed parameters.

Get the position on lesercharts.de depending on the url of the website.

* `search` Name of the entry on lesercharts.de, it’s usually the name in the
* `search` Name of the entry on lesercharts.de, it’s usually the name in the
first column

## Twitter Followers Count

Detect the number of followers of a twitter user

* `username` name of the twitter user to check, not the real name of the user
name is the uri part in the twitter profile url.
name is the uri part in the twitter profile url.
f.e. `www.twitter.com/horrorblogorg` -> `username` would be `horrorblogorg`

## Twitter Search API Results Count
Expand All @@ -105,7 +105,7 @@ number of results found.

* `q` Query search, parameter, check the Twitter Search API for examples
* `since` Since parameter to limit search results for since a date, a week
or some days are recommended.
or some days are recommended.
* `geocode`
* `locale`

Expand All @@ -115,6 +115,13 @@ This for now rather basic test exports pageViews or visits from google
analytics data to franklin. Please see the `config.php.dist` file for an
example.

## Vimeo Video

This test uses the Vimeo Simple API and retrieves stats about a vimeo video.

* `videoID` Vimeo Video ID
* `property` Reads 'stats_number_of_plays', 'stats_number_of_likes' or 'stats_number_of_comments'

# UPDATES/FEEDBACK

Franklin will be updated from time to time. Check the official [Franklin
Expand All @@ -127,7 +134,7 @@ to the developers.
* 2010-10-17
* added night and fancy_dark theme
* removed grid color from themes cause it wasn’t used

* 2010-10-16
* Devided Back and Frontend, set your webroot to `/html/` directory! Also
take care that the data directory change, copy your data files there!
Expand All @@ -145,7 +152,7 @@ to the developers.

* 2010-08-21
* Added possibility to add display configiration for tests
* Some tests have `number` as their default display (rollover shows
* Some tests have `number` as their default display (rollover shows
chart)
* chart data is shiftet to minimum to see progress zoomed

Expand All @@ -157,7 +164,7 @@ to the developers.
* Added google SERP (Search Engine Results Page) Test that can test on
which position your site is on when you search for a term in a country
and language, see the example on how to configure it.
* Also added a very simple and static Log class that logs the results of
* Also added a very simple and static Log class that logs the results of
all tests when in DEBUG_DEBUG or larger, modify your Franling::$debug
if you want to surpress the messages.
* Fixed bug where chart was not rendered when chart title inclueded a
Expand All @@ -167,15 +174,15 @@ to the developers.
* Added Test that records the number of facebook group members
* Fixed Twitterfollowers Regexp
* Added some documentation for some of the most used Tests

* 2010-06-15
* Fixed bug when no data available (empty charts)
* Deleted old charting classes in `lib/chart`

* 2010-06-09
* Updated all charts to use google chart API instead of own library
* Added light and dark skin that can be changed by hand

* 2010-05-15
* Fixed Google Results Count Test using Google Ajax REST API now
* Fixed Alexa Site Rank test
Expand Down
198 changes: 99 additions & 99 deletions app/lib/network/Pagerank.php
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
<?php

define('GOOGLE_MAGIC', 0xE6359A60);

class_exists('CURL') or require dirname(__FILE__).'/CURL.php';

/**
* Pagerank class
*
* Thanks to http://www.anwaelte-in-vulkane-werfen.de/349/php-klasse-zur-abfrage-des-google-pagerank/
*
* @author Ephigenia // Marcel Eichner <[email protected]>
* @since 30.04.2009
* @package Franklin
* @subpackage Franklin.Network
*/
class Pagerank
{
private function zeroFill($a, $b) {
$z = hexdec(80000000);
if ($z & $a) {
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
} else {
$a = ($a>>$b);
}
return $a;
}

private function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,15));
return array($a,$b,$c);
}

private function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
$mix = $this->mix($a,$b,$c);
$a = $mix[0]; $b = $mix[1]; $c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;

switch($len) {
case 11: $c+=($url[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
}
$mix = $this->mix($a,$b,$c);

return $mix[2];
}

private function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}

function getrank($url) {
$url = 'info:'.$url;
$ch = $this->GoogleCH($this->strord($url));
$curl = new CURL('http://www.google.com/search?client=navclient-auto&ch=6'.$ch.'&features=Rank&q='.urlencode($url));

$response = trim($curl->exec(true, false));
var_dump($response);
$rank = (int) substr(strrchr($response, ':'), 1);
return $rank;
}
}
<?php

define('GOOGLE_MAGIC', 0xE6359A60);

class_exists('CURL') or require dirname(__FILE__).'/CURL.php';

/**
* Pagerank class
*
* Thanks to http://www.anwaelte-in-vulkane-werfen.de/349/php-klasse-zur-abfrage-des-google-pagerank/
*
* @author Ephigenia // Marcel Eichner <[email protected]>
* @since 30.04.2009
* @package Franklin
* @subpackage Franklin.Network
*/
class Pagerank
{
private function zeroFill($a, $b) {
$z = hexdec(80000000);
if ($z & $a) {
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
} else {
$a = ($a>>$b);
}
return $a;
}

private function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,15));
return array($a,$b,$c);
}

private function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
$mix = $this->mix($a,$b,$c);
$a = $mix[0]; $b = $mix[1]; $c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;

switch($len) {
case 11: $c+=($url[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
}
$mix = $this->mix($a,$b,$c);

return $mix[2];
}

private function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}

function getrank($url) {
$url = 'info:'.$url;
$ch = $this->GoogleCH($this->strord($url));
$curl = new CURL('http://www.google.com/search?client=navclient-auto&ch=6'.$ch.'&features=Rank&q='.urlencode($url));

$response = trim($curl->exec(true, false));
var_dump($response);
$rank = (int) substr(strrchr($response, ':'), 1);
return $rank;
}
}
?>
35 changes: 35 additions & 0 deletions app/lib/tests/VimeoVideoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* Franklin: <http://code.marceleichner.de/project/franklin>
* Copyright 2009+, Ephigenia M. Eichner, Kopernikusstr. 8, 10245 Berlin
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @copyright copyright 2007+, Ephigenia M. Eichner
* @link http://code.ephigenia.de/projects/franklin/
* @filesource
*/

class_exists('ScrapeTest') or require dirname(__FILE__).'/ScrapeTest.php';

/**
* A {@link Test}A that records properties (likes, plays, comments) from Vimeo
*
* @package Franklin
* @subpackage Franklin.Test
* @author Ephigenia // Martin Fleck <[email protected]>
* @since 2010-10-19
*/
class VimeoVideoTest extends ScrapeTest
{

public function afterConstruct()
{
$this->url = 'http://vimeo.com/api/v2/video/' . $this->videoID . '.xml';
$this->regexp = '@<' . $this->property . '>(.*)</' . $this->property . '>@';
return parent::afterConstruct();
}

}

0 comments on commit bf64872

Please sign in to comment.