1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-29 02:40:25 +02:00

Renormalized all text file line endings

This commit is contained in:
Deltik
2019-03-29 19:13:32 -05:00
parent 6fd0a6a8a2
commit 1f824faa69
180 changed files with 77527 additions and 77527 deletions

38
.gitignore vendored
View File

@@ -1,19 +1,19 @@
# Ignore PhpStorm IDE files
.idea
.project
.htaccess
e107_config.php
e107_config_*.php
e107_media/*
e107_system/*
/.settings
e107_core/override
test/*
tmp/*
phpunit/
# Ignore Vim swap files
*.swp
*.swo
e107.htaccess
e107InstallLog.log
# Ignore PhpStorm IDE files
.idea
.project
.htaccess
e107_config.php
e107_config_*.php
e107_media/*
e107_system/*
/.settings
e107_core/override
test/*
tmp/*
phpunit/
# Ignore Vim swap files
*.swp
*.swo
e107.htaccess
e107InstallLog.log

156
README.md
View File

@@ -1,78 +1,78 @@
## e107 [Content Management System][1] (CMS) - v2
[![Join the chat at https://gitter.im/e107inc/e107](https://badges.gitter.im/e107inc/e107.svg)](https://gitter.im/e107inc/e107?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
### What is e107?
e107 is a free (open-source) content management system which allows you to easily manage and publish your content online. Developers can save time in building websites and powerful online applications. Users can avoid programming completely! Blogs, Websites, Intranets - e107 does it all.
### Requirements
#### Minimum
* A Web-Server (Apache or Microsoft IIS) running PHP v5.6 or higher and MySQL 4.x or 5.x.
* FTP access to your webserver and an FTP program such as Filezilla
* Username/Password to your MySQL Database
#### Recommended
* A Linux based Webserver running Apache 2.x, PHP 7.x and MySQL 5.x (LAMP)
* A registered Domain Name
* Access to a Server Control Panel (such as cPanel)
### Standard Installation
* Unzip/Extract the compressed file onto your server.
* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup)
* Follow the installation wizard
### Git Installation (developer version)
* Run the following commands ( where 'youraccount' is the folder above your public_html folder and xxx:xxx is the default owner for your files - this can be found using FileZilla and FTP)
```
cd youraccount
git clone https://github.com/e107inc/e107.git public_html
chown -R xxx:xxx public_html
```
* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup)
* Follow the installation wizard
### Reporting Bugs
Be sure you are using the most recent version prior to reporting an issue.
You may report any bugs or feature requests on GitHub (https://github.com/e107inc/e107/issues)
### Pull-Requests
* Please submit 1 pull-request for each Github #issue you may work on.
* Make sure that only the lines you have changed actually show up in a file-comparison (diff) ie. some text-editors alter every line so this should be avoided.
* Make sure you are using rebase on your local .git/config file.
ie. [branch "master"]
rebase = true`
* Here's a small tutorial to give you a start on [CONTRIBUTING](CONTRIBUTING.md)
### Donations
If you like e107 and wish to help it to improve - please consider making a small donation.
* Bitcoin address: 18C7W2YvkzSjvPoW1y46PjkTdCr9UzC3F7
* Paypal: donate (at) e107.org
### Support
* http://e107help.org
### License
* e107 is released under the terms and conditions of the GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
[1]: http://e107.org
[2]: http://www.e107.org
## e107 [Content Management System][1] (CMS) - v2
[![Join the chat at https://gitter.im/e107inc/e107](https://badges.gitter.im/e107inc/e107.svg)](https://gitter.im/e107inc/e107?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
### What is e107?
e107 is a free (open-source) content management system which allows you to easily manage and publish your content online. Developers can save time in building websites and powerful online applications. Users can avoid programming completely! Blogs, Websites, Intranets - e107 does it all.
### Requirements
#### Minimum
* A Web-Server (Apache or Microsoft IIS) running PHP v5.6 or higher and MySQL 4.x or 5.x.
* FTP access to your webserver and an FTP program such as Filezilla
* Username/Password to your MySQL Database
#### Recommended
* A Linux based Webserver running Apache 2.x, PHP 7.x and MySQL 5.x (LAMP)
* A registered Domain Name
* Access to a Server Control Panel (such as cPanel)
### Standard Installation
* Unzip/Extract the compressed file onto your server.
* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup)
* Follow the installation wizard
### Git Installation (developer version)
* Run the following commands ( where 'youraccount' is the folder above your public_html folder and xxx:xxx is the default owner for your files - this can be found using FileZilla and FTP)
```
cd youraccount
git clone https://github.com/e107inc/e107.git public_html
chown -R xxx:xxx public_html
```
* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup)
* Follow the installation wizard
### Reporting Bugs
Be sure you are using the most recent version prior to reporting an issue.
You may report any bugs or feature requests on GitHub (https://github.com/e107inc/e107/issues)
### Pull-Requests
* Please submit 1 pull-request for each Github #issue you may work on.
* Make sure that only the lines you have changed actually show up in a file-comparison (diff) ie. some text-editors alter every line so this should be avoided.
* Make sure you are using rebase on your local .git/config file.
ie. [branch "master"]
rebase = true`
* Here's a small tutorial to give you a start on [CONTRIBUTING](CONTRIBUTING.md)
### Donations
If you like e107 and wish to help it to improve - please consider making a small donation.
* Bitcoin address: 18C7W2YvkzSjvPoW1y46PjkTdCr9UzC3F7
* Paypal: donate (at) e107.org
### Support
* http://e107help.org
### License
* e107 is released under the terms and conditions of the GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
[1]: http://e107.org
[2]: http://www.e107.org

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
//<?php
$class = e107::getBB()->getClass('b');
return "<strong class='bbcode bold {$class}'>$code_text</strong>";
//<?php
$class = e107::getBB()->getClass('b');
return "<strong class='bbcode bold {$class}'>$code_text</strong>";

View File

@@ -1,63 +1,63 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* DIV block bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Div HTML blocks handling
*
* [block=class=xxx&style=xxx&id=xxx]$content[/block]
* [block=xxx]$content[/block] equals to [block=class=xxx]$content[/block]
* If $content is missing, HTML comment will be used - '<!-- -->'
*/
class bb_block extends e_bb_base
{
/**
* Called prior to save
*
*/
function toDB($code_text, $parm)
{
// just for now
if(!ADMIN) return $code_text; // TODO - pref
// transform to class, equal sign at 0 position is not well formed parm string
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
$safe = array();
if(vartrue($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']);
if(vartrue($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']);
if(vartrue($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']);
if($safe)
{
return '[block='.eHelper::buildAttr($safe).']'.$code_text.'[/block]';
}
return '[block]'.$code_text.'[/block]';
}
/**
* Translate youtube bbcode into the appropriate HTML
*/
function toHTML($code_text, $parm)
{
// transform to class, equal sign at 0 position is not well formed parm string
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
// add auto-generated class name and parameter class if available
$class = e107::getBB()->getClass('block').(varset($parms['class']) ? ' '.$parms['class'] : '');
$class = ' class="'.$class.'"';
$id = vartrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
if(empty($code_text)) $code_text = '<!-- -->';
return '<div'.$id.$class.$style.'>'.$code_text.'</div>';
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* DIV block bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Div HTML blocks handling
*
* [block=class=xxx&style=xxx&id=xxx]$content[/block]
* [block=xxx]$content[/block] equals to [block=class=xxx]$content[/block]
* If $content is missing, HTML comment will be used - '<!-- -->'
*/
class bb_block extends e_bb_base
{
/**
* Called prior to save
*
*/
function toDB($code_text, $parm)
{
// just for now
if(!ADMIN) return $code_text; // TODO - pref
// transform to class, equal sign at 0 position is not well formed parm string
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
$safe = array();
if(vartrue($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']);
if(vartrue($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']);
if(vartrue($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']);
if($safe)
{
return '[block='.eHelper::buildAttr($safe).']'.$code_text.'[/block]';
}
return '[block]'.$code_text.'[/block]';
}
/**
* Translate youtube bbcode into the appropriate HTML
*/
function toHTML($code_text, $parm)
{
// transform to class, equal sign at 0 position is not well formed parm string
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
// add auto-generated class name and parameter class if available
$class = e107::getBB()->getClass('block').(varset($parms['class']) ? ' '.$parms['class'] : '');
$class = ' class="'.$class.'"';
$id = vartrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
if(empty($code_text)) $code_text = '<!-- -->';
return '<div'.$id.$class.$style.'>'.$code_text.'</div>';
}
}

View File

@@ -1,75 +1,75 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Heading bb code
*/
if (!defined('e107_INIT')) { exit; }
/**
* Basic usage [h=2]text[/h] // this will break things.
* The same [h]text[/h] as heading number defaults to '2' // this won't.
* Advanced usage [h=2|class=className&id=element-id&style=some: style; and: moresStyle]text[/h]
* 'class' defaults to 'bbcode' (if left empty)
*/
class bb_h extends e_bb_base
{
/**
* Called prior to save
* Sanitize and re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
$bparms = eHelper::scDualParams($parm);
$h = $bparms[1] ? intval($bparms[1]) : 2;
$parms = $bparms[2];
unset($bparms);
if(vartrue($parms['class']))
{
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if(vartrue($parms['id']))
{
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if(vartrue($parms['style']))
{
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if($safe)
{
return '[h='.$h.'|'.eHelper::buildAttr($safe).']'.$code_text.'[/h]';
}
return '[h='.$h.']'.$code_text.'[/h]';
}
/**
* Translate to <h*> tag
*/
function toHTML($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
$bparms = eHelper::scDualParams($parm);
$h = 'h'.($bparms[1] ? intval($bparms[1]) : 2);
$parms = $bparms[2];
unset($bparms);
$class = " class='".e107::getBB()->getClass($h)."'"; // consistent classes across all themes.
$id = vartrue($parms['id']) ? ' id='.eHelper::secureIdAttr($parms['id']) : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
return "<{$h}{$id}{$class}{$style}>".$code_text."</{$h}>";
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Heading bb code
*/
if (!defined('e107_INIT')) { exit; }
/**
* Basic usage [h=2]text[/h] // this will break things.
* The same [h]text[/h] as heading number defaults to '2' // this won't.
* Advanced usage [h=2|class=className&id=element-id&style=some: style; and: moresStyle]text[/h]
* 'class' defaults to 'bbcode' (if left empty)
*/
class bb_h extends e_bb_base
{
/**
* Called prior to save
* Sanitize and re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
$bparms = eHelper::scDualParams($parm);
$h = $bparms[1] ? intval($bparms[1]) : 2;
$parms = $bparms[2];
unset($bparms);
if(vartrue($parms['class']))
{
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if(vartrue($parms['id']))
{
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if(vartrue($parms['style']))
{
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if($safe)
{
return '[h='.$h.'|'.eHelper::buildAttr($safe).']'.$code_text.'[/h]';
}
return '[h='.$h.']'.$code_text.'[/h]';
}
/**
* Translate to <h*> tag
*/
function toHTML($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
$bparms = eHelper::scDualParams($parm);
$h = 'h'.($bparms[1] ? intval($bparms[1]) : 2);
$parms = $bparms[2];
unset($bparms);
$class = " class='".e107::getBB()->getClass($h)."'"; // consistent classes across all themes.
$id = vartrue($parms['id']) ? ' id='.eHelper::secureIdAttr($parms['id']) : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
return "<{$h}{$id}{$class}{$style}>".$code_text."</{$h}>";
}
}

View File

@@ -1,35 +1,35 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Strip HTML new lines bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Does nothing when saving in DB
* Removes new lines produced by nl2br when translating to HTML
*/
class bb_nobr extends e_bb_base
{
private $_nobrRegEx = '#[^\w\s\-]#';
/**
* Called prior to save
* Re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
return '[nobr]'.$code_text.'[/nobr]';
}
/**
* Strip new lines
*/
function toHTML($code_text, $parm)
{
return str_replace(E_NL, "\n", trim($code_text));
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Strip HTML new lines bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Does nothing when saving in DB
* Removes new lines produced by nl2br when translating to HTML
*/
class bb_nobr extends e_bb_base
{
private $_nobrRegEx = '#[^\w\s\-]#';
/**
* Called prior to save
* Re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
return '[nobr]'.$code_text.'[/nobr]';
}
/**
* Strip new lines
*/
function toHTML($code_text, $parm)
{
return str_replace(E_NL, "\n", trim($code_text));
}
}

View File

@@ -1,70 +1,70 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Paragraph bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Basic usage [p=CSS-className]text[/p]
* Advanced usage [p=class=className&id=element-id&style=some: style; and: moresStyle]text[/p]
* 'class' defaults to 'bbcode' (if left empty)
*/
class bb_p extends e_bb_base
{
/**
* Called prior to save
* Sanitize and re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
$safe = array();
if(vartrue($parms['class']))
{
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if(vartrue($parms['id']))
{
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if(vartrue($parms['style']))
{
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if($safe)
{
return '[p='.eHelper::buildAttr($safe).']'.$code_text.'[/p]';
}
return '[p]'.$code_text.'[/p]';
}
/**
* Translate to <p> tag
*/
function toHTML($code_text, $parm)
{
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$code_text = trim($code_text);
$parms = eHelper::scParams($parm);
$class = " ".e107::getBB()->getClass('p'); // consistent classes across all themes.
$id = vartrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
return "<p{$id}{$class}{$style}>".$code_text.'</p>';
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Paragraph bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Basic usage [p=CSS-className]text[/p]
* Advanced usage [p=class=className&id=element-id&style=some: style; and: moresStyle]text[/p]
* 'class' defaults to 'bbcode' (if left empty)
*/
class bb_p extends e_bb_base
{
/**
* Called prior to save
* Sanitize and re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
$safe = array();
if(vartrue($parms['class']))
{
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if(vartrue($parms['id']))
{
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if(vartrue($parms['style']))
{
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if($safe)
{
return '[p='.eHelper::buildAttr($safe).']'.$code_text.'[/p]';
}
return '[p]'.$code_text.'[/p]';
}
/**
* Translate to <p> tag
*/
function toHTML($code_text, $parm)
{
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$code_text = trim($code_text);
$parms = eHelper::scParams($parm);
$class = " ".e107::getBB()->getClass('p'); // consistent classes across all themes.
$id = vartrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
$style = vartrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
return "<p{$id}{$class}{$style}>".$code_text.'</p>';
}
}

View File

@@ -1,370 +1,370 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* YouTube BBcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Youtube handling
*
* [youtube=tiny|small|medium|large|huge or width,height]ID{&query options}[/youtube]
*
* examples:
* [youtube=560,340]N2wivHYCRho?hd=1&color1=&color2=&cc_load_policy=0&autoplay=0[/youtube]
* [youtube=big|privacy]N2wivHYCRho?hd=1&hl=en[/youtube]
*
* Will also convert Youtube embed code, and youtube 'watch' urls. (http://www.youtube.com/watch?v=)
* Youtube ID is the only required data!
* TODO - use swfobject JS - XHTML validation
*/
/**
* Class-based bbcode validation
*
* Class name must be 'bb_'.bbname - where bbname is the name of the bbcode. (Note some bbcodes begin '_', and this is retained)
*
* This class must contain exactly two public methods:
* toDB($code_text, $parm) - called prior to text being saved
* toHTML($code_text, $parm) - called prior to text being displayed
*/
class bb_youtube extends e_bb_base
{
/**
* Called prior to save
*
* If user has posted the complete youtube 'copy and paste' text between the tags, parse it and generate the relevant bbcode
*/
function toDB($code_text, $parm)
{
$bbpars = array();
$widthString = '';
$parm = trim($parm);
// Convert Simple URLs.
if(strpos($code_text,"youtube.com/watch?v=")!==FALSE || strpos($code_text,"youtube.com/watch#!v=")!==FALSE )
{
$validUrls = array("http://", "https://", "www.","youtube.com/watch?v=","youtube.com/watch#!v=");
$tmp = str_replace($validUrls,'',$code_text);
$qrs = explode("&",$tmp);
$code_text = $qrs[0];
unset($qrs);
}
if ($parm)
{
if (strpos($parm, '|') !== FALSE)
{
list($widthString, $parm) = explode('|', $parm);
}
elseif (in_array($parm, array('tiny', 'small', 'medium','large', 'big', 'huge')) || (strpos($parm, ',') !== FALSE))
{ // Assume we're just setting a width
$widthString = $parm;
$parm = '';
}
if ($parm)
{
$bbpars = explode('&', $parm);
}
}
/*
echo '<br />Parm= '.$parm;
echo "<br />COde= ".htmlspecialchars($code_text);
echo "<br />Width= ".$widthString;
*/
$params = array(); // Accumulator for parameters from youtube code
$ok = 0;
if (strpos($code_text, '<') === FALSE)
{ // 'Properly defined' bbcode (we hope)
$picRef = $code_text;
}
else
{
//libxml_use_internal_errors(TRUE);
if (FALSE === ($info = simplexml_load_string($code_text)))
{
//print_a($matches);
//$xmlErrs = libxml_get_errors();
//print_a($xmlErrs);
$ok = 1;
}
else
{
$info1 = (array)$info;
if (!isset($info1['embed']))
{
$ok = 2;
}
else
{
$info2 = (array)$info1['embed'];
if (!isset($info2['@attributes']))
{
$ok = 3;
}
}
}
if ($ok != 0)
{
print_a($info);
return '[sanitised]'.$ok.'B'.htmlspecialchars($matches[0]).'B[/sanitised]';
}
$target = (array)$info2['@attributes'];
unset($info);
$ws = varset($target['width'], 0);
$hs = varset($target['height'], 0);
if (($ws == 0) || ($hs == 0) || !isset($target['src'])) return '[sanitised]A'.htmlspecialchars($matches[0]).'A[/sanitised]';
if (!$widthString)
{
$widthString = $ws.','.$hs; // Set size of window
}
list($url, $query) = explode('?', $target['src']);
if (strpos($url, 'youtube-nocookie.com') !== FALSE)
{
$bb_params[] = 'privacy';
}
parse_str($query, $vals); // Various options set here
if (varset($vals['allowfullscreen'], 'true') != 'true')
{
$params[] = 'fs=0';
}
if (varset($vals['border'], 0) != 0)
{
$params[] = 'border=1';
}
if (varset($vals['rel'], 1) != 1)
{
$params[] = 'rel='.intval($vals['rel']);
}
if (varset($vals['hd'], 1) != 0)
{
$params[] = 'hd='.intval($vals['hd']);
}
if (varset($vals['hl'], 1) != 0)
{
$params[] = 'hl='.$vals['hl'];
}
if (varset($vals['color1'], 1) != 0)
{
$params[] = 'color1='.$vals['color1'];
}
if (varset($vals['color2'], 1) != 0)
{
$params[] = 'color2='.$vals['color2'];
}
if (varset($vals['cc_load_policy'], 1) != 0)
{
$params[] = 'cc_load_policy='.intval($vals['cc_load_policy']);
}
if (ADMIN && varset($vals['autoplay'], 1) != 0)
{
$params[] = 'autoplay='.intval($vals['autoplay']);
}
$picRef = substr($url, strrpos($url, '/') + 1);
}
$yID = preg_replace('/[^0-9a-z]/i', '', $picRef);
if (($yID != $picRef) || (strlen($yID) > 20))
{ // Possible hack attempt
}
// $params = array_merge($params, $bbpars); // Any parameters set in bbcode override those in HTML
// Could check for valid array indices here
$paramString = implode('&', $params);
if ($paramString) $picRef .= '?'.$paramString;
if($widthString)
{
$widthString = "=".$widthString;
if(count($bbpars))
{
$widthString .= "|".implode("&",$bbpars);
}
}
$ans = '[youtube'.$widthString.']'.$picRef.'[/youtube]';
return $ans;
}
/**
* Translate youtube bbcode into the appropriate <EMBED> object
*/
function toHTML($code_text, $parm)
{
if(empty($code_text)) return '';
list($dimensions,$tmp) = explode('|', $parm, 2);
if($tmp)
{
parse_str(varset($tmp, ''), $bbparm);
}
if(strpos($code_text,"&")!==FALSE && strpos($code_text,"?")===FALSE) // DEPRECATED
{
$parms = explode('&', $code_text, 2);
}
else
{
$parms = explode('?', $code_text, 2); // CORRECT SEPARATOR
}
$code_text = $parms[0];
parse_str(varset($parms[1], ''), $params);
// print_a($params);
if(empty($dimensions)) $dimensions = 'medium'; // (default as per YouTube spec)
// formula: width x (height+25px)
switch ($dimensions)
{
case 'tiny':
$params['w'] = 320; // 200;
$params['h'] = 205; // 180;
break;
case 'small':
$params['w'] = 560; // 445;
$params['h'] = 340; // 364;
break;
case 'medium':
$params['w'] = 640; // 500;
$params['h'] = 385; // 405;
break;
case 'big':
case 'large':
$params['w'] = 853; // 660;
$params['h'] = 505; // 525;
break;
case 'huge':
$params['w'] = 1280; // 980;
$params['h'] = 745; // 765;
break;
default: // maximum 1920 x 1080 (+25)
$dim = explode(',', $dimensions, 2);
$params['w'] = (integer) varset($dim[0], 445);
if($params['w'] > 1920 || $params['w'] < 100) $params['w'] = 640;
$params['h'] = (integer) varset($dim[1], 364);
if($params['h'] > 1105 || $params['h'] < 67) $params['h'] = 385;
break;
}
$yID = preg_replace('/[^0-9a-z\-_\&\?]/i', '', $code_text);
$url = isset($bbparm['privacy']) ? 'https://www.youtube-nocookie.com/v/' : 'https://www.youtube.com/v/';
$url .= $yID.'?';
if(isset($params['nofull']) || !varset($params['fs']))
{
$fscr = 'false';
$url = $url.'fs='.intval($params['fs']);
}
else
{
$fscr = 'true';
$url = $url.'fs=1';
}
if(isset($params['border'])) $url = $url.'&amp;border='.intval($params['border']);
if(isset($params['norel'])) // BC non-standard val.
{
$url = $url.'&amp;rel=0';
}
elseif(isset($params['rel']))
{
$url = $url.'&amp;rel='.intval($params['rel']);
}
if(isset($params['hd'])) $url = $url.'&amp;hd='.intval($params['hd']);
$hl = 'en_US';
if(isset($params['hl']))
{
$params['hl'] = preg_replace('/[^0-9a-z\-_]/i', '', $params['hl']);
if(strlen($params['hl']) == 2 || strlen($params['hl']) == 5)
{
$hl = $params['hl'];
}
}
$url = $url.'&amp;hl='.$hl;
$color = array();
if(isset($params['color1'])) $color[1] = $params['color1'];
if(isset($params['color2'])) $color[2] = $params['color2'];
foreach ($color as $key => $value)
{
if (ctype_xdigit($value) && strlen($value) == 6)
{
$url = $url.'&amp;color'.$key.'='.$value;
}
}
if(isset($params['cc_load_policy']))
{
$url .= "&amp;cc_load_policy=".intval($params['cc_load_policy']);
}
if(isset($params['autoplay']))
{
$url .= "&amp;autoplay=".intval($params['autoplay']);
}
$class = "bbcode ".e107::getBB()->getClass('youtube'); // consistent classes across all themes.
$ret = "<!-- Start YouTube-".$dimensions."-".$yID." -->\n"; // <-- DO NOT MODIFY - used for detection by bbcode handler.
if(e107::getConfig()->get('youtube_bbcode_responsive') == 1) // Responsive Mode.
{
$ret .= e107::getParser()->toVideo($yID.".youtube");
}
else // Legacy Mode.
{
$ret .= '<object class="'.$class.'" width="'.$params['w'].'" height="'.$params['h'].'" >
<param name="movie" value="'.$url.'" />
<param name="allowFullScreen" value="'.$fscr.'" />
<param name="allowscriptaccess" value="always" />
<param name="wmode" value="transparent" />
';
// Not XHTML - but needed for compatibility.
$ret .= '<embed class="'.$class.'" src="'.$url.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="'.$fscr.'" wmode="transparent" width="'.$params['w'].'" height="'.$params['h'].'" />';
$ret .= '</object>';
}
$ret .= "<!-- End YouTube -->"; // <-- DO NOT MODIFY.
return $ret;
}
// Wysiwyg representation of bbcode render.
function toWYSIWYG($code_text,$parm)
{
//eg. an image of the video thumbnail
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* YouTube BBcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Youtube handling
*
* [youtube=tiny|small|medium|large|huge or width,height]ID{&query options}[/youtube]
*
* examples:
* [youtube=560,340]N2wivHYCRho?hd=1&color1=&color2=&cc_load_policy=0&autoplay=0[/youtube]
* [youtube=big|privacy]N2wivHYCRho?hd=1&hl=en[/youtube]
*
* Will also convert Youtube embed code, and youtube 'watch' urls. (http://www.youtube.com/watch?v=)
* Youtube ID is the only required data!
* TODO - use swfobject JS - XHTML validation
*/
/**
* Class-based bbcode validation
*
* Class name must be 'bb_'.bbname - where bbname is the name of the bbcode. (Note some bbcodes begin '_', and this is retained)
*
* This class must contain exactly two public methods:
* toDB($code_text, $parm) - called prior to text being saved
* toHTML($code_text, $parm) - called prior to text being displayed
*/
class bb_youtube extends e_bb_base
{
/**
* Called prior to save
*
* If user has posted the complete youtube 'copy and paste' text between the tags, parse it and generate the relevant bbcode
*/
function toDB($code_text, $parm)
{
$bbpars = array();
$widthString = '';
$parm = trim($parm);
// Convert Simple URLs.
if(strpos($code_text,"youtube.com/watch?v=")!==FALSE || strpos($code_text,"youtube.com/watch#!v=")!==FALSE )
{
$validUrls = array("http://", "https://", "www.","youtube.com/watch?v=","youtube.com/watch#!v=");
$tmp = str_replace($validUrls,'',$code_text);
$qrs = explode("&",$tmp);
$code_text = $qrs[0];
unset($qrs);
}
if ($parm)
{
if (strpos($parm, '|') !== FALSE)
{
list($widthString, $parm) = explode('|', $parm);
}
elseif (in_array($parm, array('tiny', 'small', 'medium','large', 'big', 'huge')) || (strpos($parm, ',') !== FALSE))
{ // Assume we're just setting a width
$widthString = $parm;
$parm = '';
}
if ($parm)
{
$bbpars = explode('&', $parm);
}
}
/*
echo '<br />Parm= '.$parm;
echo "<br />COde= ".htmlspecialchars($code_text);
echo "<br />Width= ".$widthString;
*/
$params = array(); // Accumulator for parameters from youtube code
$ok = 0;
if (strpos($code_text, '<') === FALSE)
{ // 'Properly defined' bbcode (we hope)
$picRef = $code_text;
}
else
{
//libxml_use_internal_errors(TRUE);
if (FALSE === ($info = simplexml_load_string($code_text)))
{
//print_a($matches);
//$xmlErrs = libxml_get_errors();
//print_a($xmlErrs);
$ok = 1;
}
else
{
$info1 = (array)$info;
if (!isset($info1['embed']))
{
$ok = 2;
}
else
{
$info2 = (array)$info1['embed'];
if (!isset($info2['@attributes']))
{
$ok = 3;
}
}
}
if ($ok != 0)
{
print_a($info);
return '[sanitised]'.$ok.'B'.htmlspecialchars($matches[0]).'B[/sanitised]';
}
$target = (array)$info2['@attributes'];
unset($info);
$ws = varset($target['width'], 0);
$hs = varset($target['height'], 0);
if (($ws == 0) || ($hs == 0) || !isset($target['src'])) return '[sanitised]A'.htmlspecialchars($matches[0]).'A[/sanitised]';
if (!$widthString)
{
$widthString = $ws.','.$hs; // Set size of window
}
list($url, $query) = explode('?', $target['src']);
if (strpos($url, 'youtube-nocookie.com') !== FALSE)
{
$bb_params[] = 'privacy';
}
parse_str($query, $vals); // Various options set here
if (varset($vals['allowfullscreen'], 'true') != 'true')
{
$params[] = 'fs=0';
}
if (varset($vals['border'], 0) != 0)
{
$params[] = 'border=1';
}
if (varset($vals['rel'], 1) != 1)
{
$params[] = 'rel='.intval($vals['rel']);
}
if (varset($vals['hd'], 1) != 0)
{
$params[] = 'hd='.intval($vals['hd']);
}
if (varset($vals['hl'], 1) != 0)
{
$params[] = 'hl='.$vals['hl'];
}
if (varset($vals['color1'], 1) != 0)
{
$params[] = 'color1='.$vals['color1'];
}
if (varset($vals['color2'], 1) != 0)
{
$params[] = 'color2='.$vals['color2'];
}
if (varset($vals['cc_load_policy'], 1) != 0)
{
$params[] = 'cc_load_policy='.intval($vals['cc_load_policy']);
}
if (ADMIN && varset($vals['autoplay'], 1) != 0)
{
$params[] = 'autoplay='.intval($vals['autoplay']);
}
$picRef = substr($url, strrpos($url, '/') + 1);
}
$yID = preg_replace('/[^0-9a-z]/i', '', $picRef);
if (($yID != $picRef) || (strlen($yID) > 20))
{ // Possible hack attempt
}
// $params = array_merge($params, $bbpars); // Any parameters set in bbcode override those in HTML
// Could check for valid array indices here
$paramString = implode('&', $params);
if ($paramString) $picRef .= '?'.$paramString;
if($widthString)
{
$widthString = "=".$widthString;
if(count($bbpars))
{
$widthString .= "|".implode("&",$bbpars);
}
}
$ans = '[youtube'.$widthString.']'.$picRef.'[/youtube]';
return $ans;
}
/**
* Translate youtube bbcode into the appropriate <EMBED> object
*/
function toHTML($code_text, $parm)
{
if(empty($code_text)) return '';
list($dimensions,$tmp) = explode('|', $parm, 2);
if($tmp)
{
parse_str(varset($tmp, ''), $bbparm);
}
if(strpos($code_text,"&")!==FALSE && strpos($code_text,"?")===FALSE) // DEPRECATED
{
$parms = explode('&', $code_text, 2);
}
else
{
$parms = explode('?', $code_text, 2); // CORRECT SEPARATOR
}
$code_text = $parms[0];
parse_str(varset($parms[1], ''), $params);
// print_a($params);
if(empty($dimensions)) $dimensions = 'medium'; // (default as per YouTube spec)
// formula: width x (height+25px)
switch ($dimensions)
{
case 'tiny':
$params['w'] = 320; // 200;
$params['h'] = 205; // 180;
break;
case 'small':
$params['w'] = 560; // 445;
$params['h'] = 340; // 364;
break;
case 'medium':
$params['w'] = 640; // 500;
$params['h'] = 385; // 405;
break;
case 'big':
case 'large':
$params['w'] = 853; // 660;
$params['h'] = 505; // 525;
break;
case 'huge':
$params['w'] = 1280; // 980;
$params['h'] = 745; // 765;
break;
default: // maximum 1920 x 1080 (+25)
$dim = explode(',', $dimensions, 2);
$params['w'] = (integer) varset($dim[0], 445);
if($params['w'] > 1920 || $params['w'] < 100) $params['w'] = 640;
$params['h'] = (integer) varset($dim[1], 364);
if($params['h'] > 1105 || $params['h'] < 67) $params['h'] = 385;
break;
}
$yID = preg_replace('/[^0-9a-z\-_\&\?]/i', '', $code_text);
$url = isset($bbparm['privacy']) ? 'https://www.youtube-nocookie.com/v/' : 'https://www.youtube.com/v/';
$url .= $yID.'?';
if(isset($params['nofull']) || !varset($params['fs']))
{
$fscr = 'false';
$url = $url.'fs='.intval($params['fs']);
}
else
{
$fscr = 'true';
$url = $url.'fs=1';
}
if(isset($params['border'])) $url = $url.'&amp;border='.intval($params['border']);
if(isset($params['norel'])) // BC non-standard val.
{
$url = $url.'&amp;rel=0';
}
elseif(isset($params['rel']))
{
$url = $url.'&amp;rel='.intval($params['rel']);
}
if(isset($params['hd'])) $url = $url.'&amp;hd='.intval($params['hd']);
$hl = 'en_US';
if(isset($params['hl']))
{
$params['hl'] = preg_replace('/[^0-9a-z\-_]/i', '', $params['hl']);
if(strlen($params['hl']) == 2 || strlen($params['hl']) == 5)
{
$hl = $params['hl'];
}
}
$url = $url.'&amp;hl='.$hl;
$color = array();
if(isset($params['color1'])) $color[1] = $params['color1'];
if(isset($params['color2'])) $color[2] = $params['color2'];
foreach ($color as $key => $value)
{
if (ctype_xdigit($value) && strlen($value) == 6)
{
$url = $url.'&amp;color'.$key.'='.$value;
}
}
if(isset($params['cc_load_policy']))
{
$url .= "&amp;cc_load_policy=".intval($params['cc_load_policy']);
}
if(isset($params['autoplay']))
{
$url .= "&amp;autoplay=".intval($params['autoplay']);
}
$class = "bbcode ".e107::getBB()->getClass('youtube'); // consistent classes across all themes.
$ret = "<!-- Start YouTube-".$dimensions."-".$yID." -->\n"; // <-- DO NOT MODIFY - used for detection by bbcode handler.
if(e107::getConfig()->get('youtube_bbcode_responsive') == 1) // Responsive Mode.
{
$ret .= e107::getParser()->toVideo($yID.".youtube");
}
else // Legacy Mode.
{
$ret .= '<object class="'.$class.'" width="'.$params['w'].'" height="'.$params['h'].'" >
<param name="movie" value="'.$url.'" />
<param name="allowFullScreen" value="'.$fscr.'" />
<param name="allowscriptaccess" value="always" />
<param name="wmode" value="transparent" />
';
// Not XHTML - but needed for compatibility.
$ret .= '<embed class="'.$class.'" src="'.$url.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="'.$fscr.'" wmode="transparent" width="'.$params['w'].'" height="'.$params['h'].'" />';
$ret .= '</object>';
}
$ret .= "<!-- End YouTube -->"; // <-- DO NOT MODIFY.
return $ret;
}
// Wysiwyg representation of bbcode render.
function toWYSIWYG($code_text,$parm)
{
//eg. an image of the video thumbnail
}
}
?>

View File

@@ -1,4 +1,4 @@
//<?
$class = e107::getBB()->getClass('blockquote');
//<?
$class = e107::getBB()->getClass('blockquote');
return "<blockquote class='indent {$class}'>{$code_text}</blockquote>";

View File

@@ -1,5 +1,5 @@
//<?
$class = e107::getBB()->getClass('center');
//<?
$class = e107::getBB()->getClass('center');
return "<div class='{$class}' style='text-align:center'>$code_text</div>";

View File

@@ -1,4 +1,4 @@
//<?
$class = e107::getBB()->getClass('i');
//<?
$class = e107::getBB()->getClass('i');
return "<em class='bbcode italic {$class}'>$code_text</em>";

View File

@@ -1,4 +1,4 @@
//<?
$class = e107::getBB()->getClass('justify');
//<?
$class = e107::getBB()->getClass('justify');
return "<div class='{$justify}' style='text-align:justify'>$code_text</div>";

View File

@@ -1,7 +1,7 @@
/* $Id: sanitised.bb 11660 2010-08-16 16:41:35Z secretr $ */
// decode (just in case) and re-code sanitised string if debug and ADMIN
if(defsettrue('ADMIN') && defsettrue('E107_DEBUG_LEVEL'))
{
return '<span class="sanitised"> SANITISED: '.htmlentities(html_entity_decode(rawurldecode($code_text), ENT_QUOTES, CHARSET), ENT_QUOTES, CHARSET).' SANITISED END</span>';
}
/* $Id: sanitised.bb 11660 2010-08-16 16:41:35Z secretr $ */
// decode (just in case) and re-code sanitised string if debug and ADMIN
if(defsettrue('ADMIN') && defsettrue('E107_DEBUG_LEVEL'))
{
return '<span class="sanitised"> SANITISED: '.htmlentities(html_entity_decode(rawurldecode($code_text), ENT_QUOTES, CHARSET), ENT_QUOTES, CHARSET).' SANITISED END</span>';
}
return '<span class="sanitised">##'.LAN_SANITISED.'##</span>';

View File

@@ -1,3 +1,3 @@
//<?
$class = e107::getBB()->getClass('u');
//<?
$class = e107::getBB()->getClass('u');
return "<span class='bbcode underline {$class}' style='text-decoration:underline'>$code_text</span>";

View File

@@ -1,185 +1,185 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Front page controller
*
* $URL$
* $Id$
*/
class core_index_index_controller extends eController
{
/**
* Do frontpage checks
* Valid formats for frontpage preference value:
* - url:Blog/My Blog Title.html (no redirect)
* - url:news.php?extend.2 (no redirect)
* - route:news/view/item?id=2 (no redirect)
* - news.php?extend.2 (no redirect)
* - http://mysite.com/news.php?extend.2 (redirect)
* - http://mysite.com/Blog/My Blog Title.html (redirect)
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
*/
public function actionIndex()
{
$pref = eFront::app()->getPref();
$tp = e107::getParser();
$indexRoute = 'index/index/index';
if (file_exists(e_BASE.'index_include.php'))
{
include (e_BASE.'index_include.php');
}
$location = '';
$class_list = explode(',', USERCLASS_LIST);
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
{ // 0.7 method
$location = $pref['frontpage']['all'];
}
else
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
if(vartrue($pref['frontpage']))
{
foreach ($pref['frontpage'] as $fk=>$fp)
{
if (in_array($fk, $class_list))
{
$location = $fp;
break;
}
}
}
}
if (!$location)
{ // Try and use the 'old' method (this bit can go later)
if (ADMIN)
{
$location = $pref['frontpage'][e_UC_ADMIN];
}
elseif (USER)
{ // This is the key bit - what to do for a 'normal' logged in user
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
foreach ($class_list as $fp_class)
{
$inclass = false;
if (!$inclass && check_class($fp_class['userclass_id']))
{
$location = $pref['frontpage'][$fp_class['userclass_id']];
$inclass = true;
}
}
$location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
}
else
{
$location = $pref['frontpage'][e_UC_GUEST];
}
}
$location = trim($location);
$request = $this->getRequest();
// Defaults to news
if(!$location) $location = 'url:/news';
// Former Welcome Message front-page. Should be handled by current theme layout
elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
{
define('e_FRONTPAGE', true);
$this->_forward('front');
return;
}
elseif($location[0] === '{')
{
$location = $tp->replaceConstants($location, true);
}
// new url format; if set to 'url:' only it'll resolve current main module (if any)
if(strpos($location, 'url:') === 0)
{
$url = substr($location, 4);
$request->setPathInfo($url)->setRequestParams(array());
$router = eFront::instance()->getRouter();
if($router->route($request, true))
{
if($request->getRoute() == $indexRoute)
{
throw new eException('Infinite loop detected while dispatching front page.', 2);
}
define('e_FRONTPAGE', true);
$this->_forward($request->getRoute());
return;
}
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
}
// route is provided
elseif(strpos($location, 'route:') === 0)
{
list($route, $qstr) = explode('?', substr($location, 6).'?');
if(!$qstr) $qstr = array();
else parse_str($qstr, $qstr);
$request->setRoute($route);
$request->setRequestParams($qstr);
if($request->getRoute() == $indexRoute)
{
throw new eException('Infinite loop detected while dispatching front page.', 2);
}
define('e_FRONTPAGE', true);
$this->_forward($request->getRoute(), $qstr);
return;
}
// redirect to this address
elseif(strpos($location, 'http://') === 0 || strpos($location, 'https://') === 0)
{
if(e_REQUEST_URL != $location)
{
header("Location: {$location}");
exit;
}
}
// Enter in legacy mod, include the front page
elseif(strpos($location, '.php') !== false)
{
list($page, $qstr) = explode("?", $location."?");
$request->setLegacyPage($page)
->setLegacyQstring($qstr);
$request->routed = true;
define('e_FRONTPAGE', true);
eFront::isLegacy('{e_BASE}'.$page);
return $this;
}
// Redirect
else
{
$location = SITEURL.$location;
if(e_REQUEST_URL != $location)
{
header("Location: {$location}");
exit;
}
}
// we can't do much
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
}
public function actionFront()
{
// we could notify current theme we are in front page controlled by the theme layout only...
// switch off tablerender
$this->getResponse()->setParam('render', false);
}
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Front page controller
*
* $URL$
* $Id$
*/
class core_index_index_controller extends eController
{
/**
* Do frontpage checks
* Valid formats for frontpage preference value:
* - url:Blog/My Blog Title.html (no redirect)
* - url:news.php?extend.2 (no redirect)
* - route:news/view/item?id=2 (no redirect)
* - news.php?extend.2 (no redirect)
* - http://mysite.com/news.php?extend.2 (redirect)
* - http://mysite.com/Blog/My Blog Title.html (redirect)
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
*/
public function actionIndex()
{
$pref = eFront::app()->getPref();
$tp = e107::getParser();
$indexRoute = 'index/index/index';
if (file_exists(e_BASE.'index_include.php'))
{
include (e_BASE.'index_include.php');
}
$location = '';
$class_list = explode(',', USERCLASS_LIST);
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
{ // 0.7 method
$location = $pref['frontpage']['all'];
}
else
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
if(vartrue($pref['frontpage']))
{
foreach ($pref['frontpage'] as $fk=>$fp)
{
if (in_array($fk, $class_list))
{
$location = $fp;
break;
}
}
}
}
if (!$location)
{ // Try and use the 'old' method (this bit can go later)
if (ADMIN)
{
$location = $pref['frontpage'][e_UC_ADMIN];
}
elseif (USER)
{ // This is the key bit - what to do for a 'normal' logged in user
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
foreach ($class_list as $fp_class)
{
$inclass = false;
if (!$inclass && check_class($fp_class['userclass_id']))
{
$location = $pref['frontpage'][$fp_class['userclass_id']];
$inclass = true;
}
}
$location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
}
else
{
$location = $pref['frontpage'][e_UC_GUEST];
}
}
$location = trim($location);
$request = $this->getRequest();
// Defaults to news
if(!$location) $location = 'url:/news';
// Former Welcome Message front-page. Should be handled by current theme layout
elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
{
define('e_FRONTPAGE', true);
$this->_forward('front');
return;
}
elseif($location[0] === '{')
{
$location = $tp->replaceConstants($location, true);
}
// new url format; if set to 'url:' only it'll resolve current main module (if any)
if(strpos($location, 'url:') === 0)
{
$url = substr($location, 4);
$request->setPathInfo($url)->setRequestParams(array());
$router = eFront::instance()->getRouter();
if($router->route($request, true))
{
if($request->getRoute() == $indexRoute)
{
throw new eException('Infinite loop detected while dispatching front page.', 2);
}
define('e_FRONTPAGE', true);
$this->_forward($request->getRoute());
return;
}
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
}
// route is provided
elseif(strpos($location, 'route:') === 0)
{
list($route, $qstr) = explode('?', substr($location, 6).'?');
if(!$qstr) $qstr = array();
else parse_str($qstr, $qstr);
$request->setRoute($route);
$request->setRequestParams($qstr);
if($request->getRoute() == $indexRoute)
{
throw new eException('Infinite loop detected while dispatching front page.', 2);
}
define('e_FRONTPAGE', true);
$this->_forward($request->getRoute(), $qstr);
return;
}
// redirect to this address
elseif(strpos($location, 'http://') === 0 || strpos($location, 'https://') === 0)
{
if(e_REQUEST_URL != $location)
{
header("Location: {$location}");
exit;
}
}
// Enter in legacy mod, include the front page
elseif(strpos($location, '.php') !== false)
{
list($page, $qstr) = explode("?", $location."?");
$request->setLegacyPage($page)
->setLegacyQstring($qstr);
$request->routed = true;
define('e_FRONTPAGE', true);
eFront::isLegacy('{e_BASE}'.$page);
return $this;
}
// Redirect
else
{
$location = SITEURL.$location;
if(e_REQUEST_URL != $location)
{
header("Location: {$location}");
exit;
}
}
// we can't do much
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
}
public function actionFront()
{
// we could notify current theme we are in front page controlled by the theme layout only...
// switch off tablerender
$this->getResponse()->setParam('render', false);
}
}

View File

@@ -1,62 +1,62 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2016 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* @file
* System error controller.
*/
/**
* Class core_system_error_controller.
*/
class core_system_error_controller extends eController
{
/**
* Pre-action callback, fired only if dispatch status is still true
* and action method is found.
*/
public function preAction()
{
e107::coreLan('error');
}
/**
* Alias for "Error 403".
*/
public function action403()
{
$this->_forward('forbidden');
}
/**
* Alias for "Error 404".
*/
public function action404()
{
$this->_forward('notfound');
}
/**
* Error 403.
*/
public function actionForbidden()
{
e107::getError()->render(403);
}
/**
* Error 404.
*/
public function actionNotfound()
{
e107::getError()->render(404);
}
}
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2016 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* @file
* System error controller.
*/
/**
* Class core_system_error_controller.
*/
class core_system_error_controller extends eController
{
/**
* Pre-action callback, fired only if dispatch status is still true
* and action method is found.
*/
public function preAction()
{
e107::coreLan('error');
}
/**
* Alias for "Error 403".
*/
public function action403()
{
$this->_forward('forbidden');
}
/**
* Alias for "Error 404".
*/
public function action404()
{
$this->_forward('notfound');
}
/**
* Error 403.
*/
public function actionForbidden()
{
e107::getError()->render(403);
}
/**
* Error 404.
*/
public function actionNotfound()
{
e107::getError()->render(404);
}
}

View File

@@ -1,23 +1,23 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* System index controller
*
* $URL$
* $Id$
*/
class core_system_index_controller extends eController
{
/**
* Redirect to site Index
*/
public function actionIndex()
{
$this->_redirect('/', false, 301);
}
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* System index controller
*
* $URL$
* $Id$
*/
class core_system_index_controller extends eController
{
/**
* Redirect to site Index
*/
public function actionIndex()
{
$this->_redirect('/', false, 301);
}
}

View File

@@ -1,164 +1,164 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* System XUP controller
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/update_routines.php $
* $Revision: 12933 $
* $Id: update_routines.php 12933 2012-08-06 08:55:51Z e107coders $
* $Author: e107coders $
*/
e107::coreLan('user');
class core_system_xup_controller extends eController
{
var $backUrl = null;
public function init()
{
//$back = 'system/xup/test';
$this->backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true;
}
public function actionSignup()
{
$allow = true;
$session = e107::getSession();
if($session->get('HAuthError'))
{
$allow = false;
$session->set('HAuthError', null);
}
if($allow && vartrue($_GET['provider']))
{
require_once(e_HANDLER."user_handler.php");
$provider = new e_user_provider($_GET['provider']);
try
{
$provider->signup($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
}
}
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
}
public function actionLogin()
{
$allow = true;
$session = e107::getSession();
if($session->get('HAuthError'))
{
$allow = false;
$session->set('HAuthError', null);
}
if($allow && vartrue($_GET['provider']))
{
require_once(e_HANDLER."user_handler.php");
$provider = new e_user_provider($_GET['provider']);
try
{
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
}
}
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
}
public function actionTest()
{
echo '<h3>'.LAN_XUP_ERRM_07.'</h3>';
if(getperms('0'))
{
echo e107::getMessage()->addError(LAN_XUP_ERRM_08)->render();
return;
}
if(isset($_GET['lgt']))
{
e107::getUser()->logout();
}
$profileData = null;
$provider = e107::getUser()->getProvider();
if($provider)
{
$profileData = $provider->getUserProfile();
if(!empty($profileData))
{
print_a($profileData);
}
}
echo ' '.LAN_XUP_ERRM_11.' '.(e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
$testUrl = SITEURL."?route=system/xup/test";
$providers = e107::getPref('social_login', array());
foreach($providers as $key=>$var)
{
if($var['enabled'] == 1)
{
echo '<h3>'.$key.'</h3><ul>';
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/login?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/signup?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
echo "</ul>";
}
// print_a($var);
}
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?lgt').'">'.LAN_XUP_ERRM_12.'</a>';
/*
echo '<h3>Facebook</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
echo '<h3>Twitter</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
*/
}
public function actionEndpoint()
{
require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
require_once( e_HANDLER."hybridauth/vendor/autoload.php");
try
{
Hybrid_Endpoint::process();
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
$session = e107::getSession();
$session->set('HAuthError', true);
}
}
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* System XUP controller
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/update_routines.php $
* $Revision: 12933 $
* $Id: update_routines.php 12933 2012-08-06 08:55:51Z e107coders $
* $Author: e107coders $
*/
e107::coreLan('user');
class core_system_xup_controller extends eController
{
var $backUrl = null;
public function init()
{
//$back = 'system/xup/test';
$this->backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true;
}
public function actionSignup()
{
$allow = true;
$session = e107::getSession();
if($session->get('HAuthError'))
{
$allow = false;
$session->set('HAuthError', null);
}
if($allow && vartrue($_GET['provider']))
{
require_once(e_HANDLER."user_handler.php");
$provider = new e_user_provider($_GET['provider']);
try
{
$provider->signup($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
}
}
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
}
public function actionLogin()
{
$allow = true;
$session = e107::getSession();
if($session->get('HAuthError'))
{
$allow = false;
$session->set('HAuthError', null);
}
if($allow && vartrue($_GET['provider']))
{
require_once(e_HANDLER."user_handler.php");
$provider = new e_user_provider($_GET['provider']);
try
{
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
}
}
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
}
public function actionTest()
{
echo '<h3>'.LAN_XUP_ERRM_07.'</h3>';
if(getperms('0'))
{
echo e107::getMessage()->addError(LAN_XUP_ERRM_08)->render();
return;
}
if(isset($_GET['lgt']))
{
e107::getUser()->logout();
}
$profileData = null;
$provider = e107::getUser()->getProvider();
if($provider)
{
$profileData = $provider->getUserProfile();
if(!empty($profileData))
{
print_a($profileData);
}
}
echo ' '.LAN_XUP_ERRM_11.' '.(e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
$testUrl = SITEURL."?route=system/xup/test";
$providers = e107::getPref('social_login', array());
foreach($providers as $key=>$var)
{
if($var['enabled'] == 1)
{
echo '<h3>'.$key.'</h3><ul>';
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/login?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/signup?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
echo "</ul>";
}
// print_a($var);
}
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?lgt').'">'.LAN_XUP_ERRM_12.'</a>';
/*
echo '<h3>Facebook</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
echo '<h3>Twitter</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
*/
}
public function actionEndpoint()
{
require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
require_once( e_HANDLER."hybridauth/vendor/autoload.php");
try
{
Hybrid_Endpoint::process();
}
catch (Exception $e)
{
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
$session = e107::getSession();
$session->set('HAuthError', true);
}
}
}

View File

@@ -1,2 +1,2 @@
//<?
//<?
return SITECONTACTINFO;

View File

@@ -1,149 +1,149 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/extended_timezones.php,v $
* $Revision$
* $Date$
* $Author$
*/
if(!defined('e107_INIT'))
{
exit;
}
/**
* @file
* This file is used with the extended user field 'predefined list' type. It is
* invoked when the value field is 'timezones'.
*
* It is an example of an extended user field which access a predetermined list
* of key-pair values. In this example all the data is loaded into memory; for
* other applications the data may be read from a database, possibly with
* caching.
*
* The objective is to provide a uniform interface to such data.
*
* The class name must be the same as the file name - i.e. the list name
* prefixed with 'extended_'.
*
* The variable name must be 'timezones_list', and is an array of possible
* values, each of which is a value => text pair.
*
* The text is displayed in a drop-down; the value is returned.
*
* If function timezones_value() exists, it is called to create the displayed
* text.
*/
/**
* Class extended_timezones.
*/
class extended_timezones
{
/**
* @var array
*/
private $timezonesList = array();
/**
* @var bool
*/
private $isEOF = false; // True if at last element of list.
/**
* @var bool
*/
private $bufferValid = false;
/**
* Constructor.
*/
public function __construct()
{
$this->timezonesList = systemTimeZones();
}
/**
* Call before using the 'next' format option, to ensure the array is
* indexed from the beginning.
*/
public function pointerReset()
{
$this->isEOF = (false === reset($this->timezonesList));
$this->bufferValid = true;
}
/**
* Return a formatted timezone value
*
* @param mixed $key
* The key value to select.
* @param string $formatSpec
* Defines format of return value.
*
* @return mixed
* (according to $formatSpec).
* false - if no value available.
* 'array' - a single-element array; key as passed, and value to match key
* 'next' - as 'array', but ignores the passed $key and moves to next value.
* 'default' - a string usable for display.
*/
public function getValue($key, $formatSpec = '')
{
if($formatSpec == 'next')
{
// Make sure buffer is defined.
if(!$this->bufferValid)
{
$this->pointerReset();
}
if($this->isEOF)
{
return false;
}
$key = key($this->timezonesList);
$val = current($this->timezonesList);
if(false === $val)
{
$this->isEOF = true;
return false;
}
$this->isEOF = (false === next($this->timezonesList));
return array($key => $val);
}
$exists = isset($this->timezonesList[$key]);
if(!$exists)
{
return false;
}
$val = $this->timezonesList[$key];
if($formatSpec == 'array')
{
return array($key => $val);
}
// Default (as per earlier implementations) - can be specified with
// 'display' format.
return $val;
}
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/extended_timezones.php,v $
* $Revision$
* $Date$
* $Author$
*/
if(!defined('e107_INIT'))
{
exit;
}
/**
* @file
* This file is used with the extended user field 'predefined list' type. It is
* invoked when the value field is 'timezones'.
*
* It is an example of an extended user field which access a predetermined list
* of key-pair values. In this example all the data is loaded into memory; for
* other applications the data may be read from a database, possibly with
* caching.
*
* The objective is to provide a uniform interface to such data.
*
* The class name must be the same as the file name - i.e. the list name
* prefixed with 'extended_'.
*
* The variable name must be 'timezones_list', and is an array of possible
* values, each of which is a value => text pair.
*
* The text is displayed in a drop-down; the value is returned.
*
* If function timezones_value() exists, it is called to create the displayed
* text.
*/
/**
* Class extended_timezones.
*/
class extended_timezones
{
/**
* @var array
*/
private $timezonesList = array();
/**
* @var bool
*/
private $isEOF = false; // True if at last element of list.
/**
* @var bool
*/
private $bufferValid = false;
/**
* Constructor.
*/
public function __construct()
{
$this->timezonesList = systemTimeZones();
}
/**
* Call before using the 'next' format option, to ensure the array is
* indexed from the beginning.
*/
public function pointerReset()
{
$this->isEOF = (false === reset($this->timezonesList));
$this->bufferValid = true;
}
/**
* Return a formatted timezone value
*
* @param mixed $key
* The key value to select.
* @param string $formatSpec
* Defines format of return value.
*
* @return mixed
* (according to $formatSpec).
* false - if no value available.
* 'array' - a single-element array; key as passed, and value to match key
* 'next' - as 'array', but ignores the passed $key and moves to next value.
* 'default' - a string usable for display.
*/
public function getValue($key, $formatSpec = '')
{
if($formatSpec == 'next')
{
// Make sure buffer is defined.
if(!$this->bufferValid)
{
$this->pointerReset();
}
if($this->isEOF)
{
return false;
}
$key = key($this->timezonesList);
$val = current($this->timezonesList);
if(false === $val)
{
$this->isEOF = true;
return false;
}
$this->isEOF = (false === next($this->timezonesList));
return array($key => $val);
}
$exists = isset($this->timezonesList[$key]);
if(!$exists)
{
return false;
}
$val = $this->timezonesList[$key];
if($formatSpec == 'array')
{
return array($key => $val);
}
// Default (as per earlier implementations) - can be specified with
// 'display' format.
return $val;
}
}

View File

@@ -1,133 +1,133 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Full SEF URLs support and the most risky one, almost the same as sef_noid, just working with rules only
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_full_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}news.php',
'format' => 'path',
'defaultRoute' => 'list/items',
'urlSuffix' => '',
'allowVars' => false,
'matchValue' => 'empty',
'mapVars' => array(
'news_id' => 'id',
'news_sef' => 'name',
),
),
'rules' => array(
'/' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'list.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
'All' => array('list/all', 'allowVars' => array('page'), 'legacyQuery' => 'all.0.{page}'),
'Short/<name:{sefsecure}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'cat.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
'Short/<id:{number}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id'), 'legacyQuery' => 'cat.{id}.{page}'),
'Day/<id:{number}>' => array('list/day', 'allowVars' => array('page'), 'legacyQuery' => 'day.{id}.{page}'),
'Month/<id:{number}>' => array('list/month', 'allowVars' => array('page'), 'legacyQuery' => 'month.{id}.{page}'),
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={$page}'),
'<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITEF_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITEF_DESCR, //
'examples' => array("{SITEURL}news/news-category/news-title","{SITEURL}news/category/news-category")
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['news_id']);
}
else $request->setRequestParam('name', 0);
}
/**
* list/items by name callback
* @param eRequest $request
*/
public function categoryIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$id = e107::getParser()->toDB($name);
if($sql->select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['category_id']);
}
else $request->setRequestParam('name', 0);
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Full SEF URLs support and the most risky one, almost the same as sef_noid, just working with rules only
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_full_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}news.php',
'format' => 'path',
'defaultRoute' => 'list/items',
'urlSuffix' => '',
'allowVars' => false,
'matchValue' => 'empty',
'mapVars' => array(
'news_id' => 'id',
'news_sef' => 'name',
),
),
'rules' => array(
'/' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'list.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
'All' => array('list/all', 'allowVars' => array('page'), 'legacyQuery' => 'all.0.{page}'),
'Short/<name:{sefsecure}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'cat.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
'Short/<id:{number}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id'), 'legacyQuery' => 'cat.{id}.{page}'),
'Day/<id:{number}>' => array('list/day', 'allowVars' => array('page'), 'legacyQuery' => 'day.{id}.{page}'),
'Month/<id:{number}>' => array('list/month', 'allowVars' => array('page'), 'legacyQuery' => 'month.{id}.{page}'),
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={$page}'),
'<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITEF_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITEF_DESCR, //
'examples' => array("{SITEURL}news/news-category/news-title","{SITEURL}news/category/news-category")
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['news_id']);
}
else $request->setRequestParam('name', 0);
}
/**
* list/items by name callback
* @param eRequest $request
*/
public function categoryIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$id = e107::getParser()->toDB($name);
if($sql->select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['category_id']);
}
else $request->setRequestParam('name', 0);
}
}

View File

@@ -1,327 +1,327 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* SEF URLs support, example of manually (rules-less) created/parsed urls
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_noid_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'noSingleEntry' => false, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'list/items', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '.html', // [optional] default empty; string to append to the URL (e.g. .html)
),
);
}
/**
* When returning array, module or it's corresponding alias will be prefixed
* Create link so that it can be mapped by the parse() method
* - view/item?id=xxx -> news/xxx
* - list/items[?page=xxx] -> news[?page=xxx]
* - list/category?id=xxx[&page=xxx] -> news/Category/xxx?page=xxx
* - list/category?id=0[&page=xxx] -> news?page=xxx
* - list/short?id=xxx[&page=xxx] -> news/Short/xxx?page=xxx
* - list/category?id=xxx[&page=xxx] -> news?page=xxx
* - list/day?id=xxx -> news/Day-id
* - list/month?id=xxx -> news/Month-id
* - list/year?id=xxx -> news/Year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE?page=[FROM] (recursive parse() call)
* - list/all
* - list/tag
*/
public function create($route, $params = array(), $options = array())
{
if('--FROM--' != vartrue($params['page'])) $page = varset($params['page']) ? intval($params['page']) : '0';
else $page = '--FROM--';
if(!$route) $route = 'list/items';
if(is_string($route)) $route = explode('/', $route, 2);
if('index' == $route[0])
{
$route[0] = 'list';
$route[1] = 'items';
}
elseif('index' == $route[1])
{
$route[1] = 'items';
}
$r = array();
$parm = array();
if($route[0] == 'view')
{
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['news_id']) && !empty($params['news_id'])) $params['id'] = $params['news_id'];
if(isset($params['news_sef']) && !empty($params['news_sef'])) $params['id'] = $params['news_sef']; // TODO - news_sef
switch ($route[1])
{
case 'item':
$r[0] = $params['id']; // news/ID
break;
default:
break;
}
}
elseif($route[0] == 'list')
{
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['category_id']) && !empty($params['category_id'])) $params['id'] = $params['category_id'];
if(isset($params['category_sef']) && !empty($params['category_sef'])) $params['name'] = $params['category_sef']; // TODO - news_sef
switch ($route[1])
{
case 'items':
$r[0] = '';
if($page) $parm = array('page' => $page); // news?page=xxx
break;
case 'all':
$r[0] = 'All';
if($page) $parm = array('page' => $page); // news/All?page=xxx
break;
case 'tag': // news/tag/xxxx
$r[0] = 'tag';
$r[1] = $params['tag'];
if($page) $parm = array('page' => $page);
break;
case 'author': // news/author/xxxx
$r[0] = 'author';
$r[1] = $params['author'];
if($page) $parm = array('page' => $page);
break;
case 'category':
case 'short':
if(!vartrue($params['id']))
{
$r[0] = '';
if($page) $parm = array('page' => $page); // news?page=xxx
}
else
{
// news/Category/Category-Name?page=xxx
// news/Short/Category-Name?page=xxx
$r[0] = $route[1] == 'category' ? 'Category' : 'Short';
$r[1] = !empty($params['name']) ? $params['name'] : $params['id'];
if($page) $parm = array('page' => $page);
}
break;
case 'day':
case 'month':
case 'year':
$r = array($route[1], intval($params['id']));
if($page) $parm = array('page' => $page);
break;
default:
break;
}
}
if(empty($r)) return false;
//XXX TODO Find a better place to put this check.
$urlFormat = e107::getConfig()->get('url_sef_translate');
if($urlFormat == 'dashl' || $urlFormat == 'underscorel' || $urlFormat == 'plusl') // convert template to lowercase when using lowercase SEF URL format.
{
$r[0] = strtolower($r[0]);
}
return array($r, $parm);
}
/**
* Manually parse request
* Pathinfo DOESN'T contain leading 'module' (e.g news or alias 'Blog')
* Retruned route shouldn't contain module as well, unless you manipulate $request directly and set $request->routed to true
* Mapped URLs:
* - news/News-Item -> extend.xxx
* - news/Category/Category-Name?page=10 -> list.xxx.10
* - news/Day|Month-xxx -> day|month-xxx
*/
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
$page = !empty($params['page']) ? intval($params['page']) : '0';
if(!$pathInfo)
{
## this var is used by default from legacy() method
## you may override legacy() method
## Keep in mind legacy() is not triggered at all if parse() returns false or $request->routed is set to true
$this->legacyQueryString = $page ? 'default.0.'.$page : '';
return $config['defaultRoute'];
}
## no controller/action pair - news item view - map to extend.xxx
if(strpos($pathInfo, '/') === false && strtolower($pathInfo) != 'all')
{
$route = 'view/item';
$id = is_numeric($pathInfo) ? intval($pathInfo) : $this->itemIdByTitle($pathInfo);
if(!$id)
{
## let news.php handle missing news item
$this->legacyQueryString = 'extend.0';
return $route;
}
$this->legacyQueryString = 'extend.'.$id;
return $route;
}
$parts = explode('/', $pathInfo, 2);
$parts[0] = strtolower($parts[0]);
switch ($parts[0])
{
# map to list.xxx.xxx
case 'short':
case 'category':
# Hardcoded leading string for categories, could be pref or LAN constant
if(!vartrue($parts[1]))
{
## force not found as we don't want to have duplicated content (default.0.xxx)
return false;
}
else
{
if(!is_numeric($parts[1])) $id = $this->categoryIdByTitle($parts[1]);
else $id = intval($parts[1]);
}
if(!$id)
{
# let news.php handle it
$id = 0;
}
$action = $parts[0] == 'short' ? 'cat' : 'list';
$this->legacyQueryString = $action.'.'.$id.'.'.$page;
return 'item/list';
break;
# could be pref or LAN constant
case 'day':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'day.'.$id.'.'.$page;
return 'list/day';
break;
# could be pref or LAN constant
case 'month':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'month.'.$id.'.'.$page;
return 'list/month';
break;
# could be pref or LAN constant - not supported yet
case 'year':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'year.'.$id.'.'.$page;
//return 'list/year';
break;
case 'all':
$this->legacyQueryString = 'all.0.'.$page;
return 'list/all';
break;
case 'tag': // url: news/tag/xxxxx
$this->legacyQueryString = 'tag='.$parts[1];
return 'list/tag';
break;
case 'author': // url: news/author/xxxxx
$this->legacyQueryString = 'author='.$parts[1].'&page='.$page;
return 'list/author';
break;
# force not found
default:
return false;
break;
}
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITE_DESCR, //
'examples' => array("{SITEURL}news/news-title")
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
//retrieve news_id by news_sef (
public function itemIdByTitle($id)
{
$sql = e107::getDb('url');
$tp = e107::getParser();
$id = $tp->toDB($id);
if($sql->select('news', 'news_id', "news_sef='{$id}'"))
{
$id = $sql->fetch();
return $id['news_id'];
}
return false;
}
//retrieve category_id by Title (XXX - category_sef column, equals to category_sef if not set explicit)
public function categoryIdByTitle($id)
{
$sql = e107::getDb('url');
$tp = e107::getParser();
$id = $tp->toDB($id);
if($sql->select('news_category', 'category_id', "category_sef='{$id}'"))
{
$id = $sql->fetch();
return $id['category_id'];
}
return false;
}
}
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* SEF URLs support, example of manually (rules-less) created/parsed urls
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_noid_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'noSingleEntry' => false, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'list/items', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '.html', // [optional] default empty; string to append to the URL (e.g. .html)
),
);
}
/**
* When returning array, module or it's corresponding alias will be prefixed
* Create link so that it can be mapped by the parse() method
* - view/item?id=xxx -> news/xxx
* - list/items[?page=xxx] -> news[?page=xxx]
* - list/category?id=xxx[&page=xxx] -> news/Category/xxx?page=xxx
* - list/category?id=0[&page=xxx] -> news?page=xxx
* - list/short?id=xxx[&page=xxx] -> news/Short/xxx?page=xxx
* - list/category?id=xxx[&page=xxx] -> news?page=xxx
* - list/day?id=xxx -> news/Day-id
* - list/month?id=xxx -> news/Month-id
* - list/year?id=xxx -> news/Year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE?page=[FROM] (recursive parse() call)
* - list/all
* - list/tag
*/
public function create($route, $params = array(), $options = array())
{
if('--FROM--' != vartrue($params['page'])) $page = varset($params['page']) ? intval($params['page']) : '0';
else $page = '--FROM--';
if(!$route) $route = 'list/items';
if(is_string($route)) $route = explode('/', $route, 2);
if('index' == $route[0])
{
$route[0] = 'list';
$route[1] = 'items';
}
elseif('index' == $route[1])
{
$route[1] = 'items';
}
$r = array();
$parm = array();
if($route[0] == 'view')
{
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['news_id']) && !empty($params['news_id'])) $params['id'] = $params['news_id'];
if(isset($params['news_sef']) && !empty($params['news_sef'])) $params['id'] = $params['news_sef']; // TODO - news_sef
switch ($route[1])
{
case 'item':
$r[0] = $params['id']; // news/ID
break;
default:
break;
}
}
elseif($route[0] == 'list')
{
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['category_id']) && !empty($params['category_id'])) $params['id'] = $params['category_id'];
if(isset($params['category_sef']) && !empty($params['category_sef'])) $params['name'] = $params['category_sef']; // TODO - news_sef
switch ($route[1])
{
case 'items':
$r[0] = '';
if($page) $parm = array('page' => $page); // news?page=xxx
break;
case 'all':
$r[0] = 'All';
if($page) $parm = array('page' => $page); // news/All?page=xxx
break;
case 'tag': // news/tag/xxxx
$r[0] = 'tag';
$r[1] = $params['tag'];
if($page) $parm = array('page' => $page);
break;
case 'author': // news/author/xxxx
$r[0] = 'author';
$r[1] = $params['author'];
if($page) $parm = array('page' => $page);
break;
case 'category':
case 'short':
if(!vartrue($params['id']))
{
$r[0] = '';
if($page) $parm = array('page' => $page); // news?page=xxx
}
else
{
// news/Category/Category-Name?page=xxx
// news/Short/Category-Name?page=xxx
$r[0] = $route[1] == 'category' ? 'Category' : 'Short';
$r[1] = !empty($params['name']) ? $params['name'] : $params['id'];
if($page) $parm = array('page' => $page);
}
break;
case 'day':
case 'month':
case 'year':
$r = array($route[1], intval($params['id']));
if($page) $parm = array('page' => $page);
break;
default:
break;
}
}
if(empty($r)) return false;
//XXX TODO Find a better place to put this check.
$urlFormat = e107::getConfig()->get('url_sef_translate');
if($urlFormat == 'dashl' || $urlFormat == 'underscorel' || $urlFormat == 'plusl') // convert template to lowercase when using lowercase SEF URL format.
{
$r[0] = strtolower($r[0]);
}
return array($r, $parm);
}
/**
* Manually parse request
* Pathinfo DOESN'T contain leading 'module' (e.g news or alias 'Blog')
* Retruned route shouldn't contain module as well, unless you manipulate $request directly and set $request->routed to true
* Mapped URLs:
* - news/News-Item -> extend.xxx
* - news/Category/Category-Name?page=10 -> list.xxx.10
* - news/Day|Month-xxx -> day|month-xxx
*/
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
$page = !empty($params['page']) ? intval($params['page']) : '0';
if(!$pathInfo)
{
## this var is used by default from legacy() method
## you may override legacy() method
## Keep in mind legacy() is not triggered at all if parse() returns false or $request->routed is set to true
$this->legacyQueryString = $page ? 'default.0.'.$page : '';
return $config['defaultRoute'];
}
## no controller/action pair - news item view - map to extend.xxx
if(strpos($pathInfo, '/') === false && strtolower($pathInfo) != 'all')
{
$route = 'view/item';
$id = is_numeric($pathInfo) ? intval($pathInfo) : $this->itemIdByTitle($pathInfo);
if(!$id)
{
## let news.php handle missing news item
$this->legacyQueryString = 'extend.0';
return $route;
}
$this->legacyQueryString = 'extend.'.$id;
return $route;
}
$parts = explode('/', $pathInfo, 2);
$parts[0] = strtolower($parts[0]);
switch ($parts[0])
{
# map to list.xxx.xxx
case 'short':
case 'category':
# Hardcoded leading string for categories, could be pref or LAN constant
if(!vartrue($parts[1]))
{
## force not found as we don't want to have duplicated content (default.0.xxx)
return false;
}
else
{
if(!is_numeric($parts[1])) $id = $this->categoryIdByTitle($parts[1]);
else $id = intval($parts[1]);
}
if(!$id)
{
# let news.php handle it
$id = 0;
}
$action = $parts[0] == 'short' ? 'cat' : 'list';
$this->legacyQueryString = $action.'.'.$id.'.'.$page;
return 'item/list';
break;
# could be pref or LAN constant
case 'day':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'day.'.$id.'.'.$page;
return 'list/day';
break;
# could be pref or LAN constant
case 'month':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'month.'.$id.'.'.$page;
return 'list/month';
break;
# could be pref or LAN constant - not supported yet
case 'year':
if(!vartrue($parts[1])) $id = 0;
else $id = intval($parts[1]);
$this->legacyQueryString = 'year.'.$id.'.'.$page;
//return 'list/year';
break;
case 'all':
$this->legacyQueryString = 'all.0.'.$page;
return 'list/all';
break;
case 'tag': // url: news/tag/xxxxx
$this->legacyQueryString = 'tag='.$parts[1];
return 'list/tag';
break;
case 'author': // url: news/author/xxxxx
$this->legacyQueryString = 'author='.$parts[1].'&page='.$page;
return 'list/author';
break;
# force not found
default:
return false;
break;
}
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITE_DESCR, //
'examples' => array("{SITEURL}news/news-title")
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
//retrieve news_id by news_sef (
public function itemIdByTitle($id)
{
$sql = e107::getDb('url');
$tp = e107::getParser();
$id = $tp->toDB($id);
if($sql->select('news', 'news_id', "news_sef='{$id}'"))
{
$id = $sql->fetch();
return $id['news_id'];
}
return false;
}
//retrieve category_id by Title (XXX - category_sef column, equals to category_sef if not set explicit)
public function categoryIdByTitle($id)
{
$sql = e107::getDb('url');
$tp = e107::getParser();
$id = $tp->toDB($id);
if($sql->select('news_category', 'category_id', "category_sef='{$id}'"))
{
$id = $sql->fetch();
return $id['category_id'];
}
return false;
}
}

View File

@@ -1,210 +1,210 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Most balanced config - performance and friendly URLs
* It contains a lot of examples (mostly complex), use them to play around and learn things :/
* Generally, things are much more simpler...
*
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script; override per rule is allowed
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'list/items', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '',
'allowMain' => true,
### default vars mapping (create URL), override per rule is allowed
'mapVars' => array(
'news_id' => 'id',
'news_sef' => 'name',
),
### match will only check if parameter is empty to invalidate the assembling vs current rule
'matchValue' => 'empty',
### Numerical array containing allowed vars by default (create URL, used for legacyQuery parsing in parse routine as well),
### false means - disallow all vars beside those required by the rules
### Override per rule is allowed
'allowVars' => false,
### Best news - you don't need to write one and the same
### regex over and over again. Even better news - you might avoid
### writing regex at all! Just use the core regex templates, they
### should fit almost every case.
### Here is a test custom regex template:
'varTemplates' => array('testIt' => '[\d]+'),
/* Predefined Core regex templates, see usage below
'az' => '[A-Za-z]+', // NOTE - it won't match non-latin word characters!
'alphanum' => '[\w\pL]+',
'sefsecure' => '[\w\pL.\-\s!,]+',
'secure' => '[^\/\'"\\<%]+',
'number' => '[\d]+',
'username' => '[\w\pL.\-\s!,]+',
'azOptional' => '[A-Za-z]{0,}',
'alphanumOptional' => '[\w\pL]{0,}',
'sefsecureOptional' => '[\w\pL.\-\s!,]{0,}',
'secureOptional' => '[^\/\'"\\<%]{0,}',
'numberOptional' => '[\d]{0,}',
'usernameOptional' => '[\w\pL.\-\s!,]{0,}',
*/
),
'rules' => array(
### simple matches first - PERFORMANCE
'' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
## URL with ID and Title - no DB call, balanced performance, name optional
## Demonstrating the usage of custom user defined regex template defined above - 'testIt'
'Category/<id:{testIt}>/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id', 'category_sef' => 'name'), 'legacyQuery' => 'list.{id}.{page}'),
## URL with Title only - prettiest and slowest! Example with direct regex - no templates
//'Category/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'list.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
## URL with ID only - best performance, fallback when no sef name provided
'Category/<id:{number}>' => array('list/category', 'allowVars' => array('page'), 'legacyQuery' => 'list.{id}.{page}', 'mapVars' => array('category_id' => 'id')),
### View item requested by id or string, if you remove the catch ALL example, uncomment at least on row from this block
### leading category name example - could be enabled together with the next example to handle creating of URLs without knowing the category title
// 'View/<category:[\w\pL.\-\s]+>/<name:[\w\pL.\-\s]+>' => array('view/item', 'mapVars' => array('news_sef' => 'name', 'category_sef' => 'category'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// to be noted here - value 'name' is replaced by item id within the callback method; TODO replace news_sef with news_sef field
// 'View/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// 'View/<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
## All news
'All' => array('list/all', 'allowVars' => array('page'), 'legacyQuery' => 'all.0.{page}'),
## URL with ID and Title - no DB call, balanced performance!
'Short/<id:{number}>/<name:{sefsecure}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id', 'category_sef' => 'name'), 'legacyQuery' => 'cat.{id}.{page}'),
## fallback when name is not provided
'Short/<id:{number}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id'), 'legacyQuery' => 'cat.{id}.{page}'),
// less used after
//'Brief/<id:[\d]+>' => array('list/short', 'allowVars' => array('page'), 'legacyQuery' => 'cat.{id}.{page}', 'mapVars' => array('category_id' => 'id')),
'Day/<id:{number}>' => array('list/day', 'allowVars' => array('page'), 'legacyQuery' => 'day.{id}.{page}'),
'Month/<id:{number}>' => array('list/month', 'allowVars' => array('page'), 'legacyQuery' => 'month.{id}.{page}'),
//'Year/<id:[\d]+>' => array('list/year', 'allowVars' => array('page'), 'legacyQuery' => 'year.{id}.{page}'), not supported yet
### View news item - kinda catch all - very bad performance when News is chosen as default namespace - two additional DB queries on every site call!
## Leading category name - uncomment to enable
//'<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'View/<id:{number}>/<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
// Base location as item view - fallback if category sef is missing
//'<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// fallback if news sef is missing
'View/<id:{number}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{id}'),
'View/<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={page}'),
)
);
}
/**
* Query mapping in format route?params:
* - item/view?id=xxx -> ?extend.id
* - list/items[?page=xxx] -> default.0.page
* - list/category?id=xxx[&page=xxx] -> list.id.page
* - list/category?id=0[&page=xxx] -> default.0.page
* - list/short?id=xxx[&page=xxx] -> cat.id.page
* - list/day?id=xxx -> ?day-id
* - list/month?id=xxx -> ?month-id
* - list/year?id=xxx -> ?year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE.[FROM] (recursive parse() call)
*/
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITEX_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITEX_DESCR, //
'examples' => array('{SITEURL}news/1/news-title')
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
/*public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->db_Select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
{
$name = $sql->db_Fetch();
$request->setRequestParam('name', $name['news_id']);
}
else $request->setRequestParam('name', 0);
}*/
/**
* list/items by name callback
* @param eRequest $request
*/
/*public function categoryIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$id = e107::getParser()->toDB($name);
if($sql->db_Select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
{
$name = $sql->db_Fetch();
$request->setRequestParam('name', $name['category_id']);
}
else $request->setRequestParam('name', 0);
}*/
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Most balanced config - performance and friendly URLs
* It contains a lot of examples (mostly complex), use them to play around and learn things :/
* Generally, things are much more simpler...
*
*/
if (!defined('e107_INIT')){ exit; }
class core_news_sef_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script; override per rule is allowed
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'list/items', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '',
'allowMain' => true,
### default vars mapping (create URL), override per rule is allowed
'mapVars' => array(
'news_id' => 'id',
'news_sef' => 'name',
),
### match will only check if parameter is empty to invalidate the assembling vs current rule
'matchValue' => 'empty',
### Numerical array containing allowed vars by default (create URL, used for legacyQuery parsing in parse routine as well),
### false means - disallow all vars beside those required by the rules
### Override per rule is allowed
'allowVars' => false,
### Best news - you don't need to write one and the same
### regex over and over again. Even better news - you might avoid
### writing regex at all! Just use the core regex templates, they
### should fit almost every case.
### Here is a test custom regex template:
'varTemplates' => array('testIt' => '[\d]+'),
/* Predefined Core regex templates, see usage below
'az' => '[A-Za-z]+', // NOTE - it won't match non-latin word characters!
'alphanum' => '[\w\pL]+',
'sefsecure' => '[\w\pL.\-\s!,]+',
'secure' => '[^\/\'"\\<%]+',
'number' => '[\d]+',
'username' => '[\w\pL.\-\s!,]+',
'azOptional' => '[A-Za-z]{0,}',
'alphanumOptional' => '[\w\pL]{0,}',
'sefsecureOptional' => '[\w\pL.\-\s!,]{0,}',
'secureOptional' => '[^\/\'"\\<%]{0,}',
'numberOptional' => '[\d]{0,}',
'usernameOptional' => '[\w\pL.\-\s!,]{0,}',
*/
),
'rules' => array(
### simple matches first - PERFORMANCE
'' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
'Category' => array('list/items', 'allowVars' => array('page'), 'legacyQuery' => 'default.0.{page}', ),
## URL with ID and Title - no DB call, balanced performance, name optional
## Demonstrating the usage of custom user defined regex template defined above - 'testIt'
'Category/<id:{testIt}>/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id', 'category_sef' => 'name'), 'legacyQuery' => 'list.{id}.{page}'),
## URL with Title only - prettiest and slowest! Example with direct regex - no templates
//'Category/<name:{sefsecure}>' => array('list/category', 'allowVars' => array('page'), 'mapVars' => array('category_sef' => 'name'), 'legacyQuery' => 'list.{name}.{page}', 'parseCallback' => 'categoryIdByTitle'),
## URL with ID only - best performance, fallback when no sef name provided
'Category/<id:{number}>' => array('list/category', 'allowVars' => array('page'), 'legacyQuery' => 'list.{id}.{page}', 'mapVars' => array('category_id' => 'id')),
### View item requested by id or string, if you remove the catch ALL example, uncomment at least on row from this block
### leading category name example - could be enabled together with the next example to handle creating of URLs without knowing the category title
// 'View/<category:[\w\pL.\-\s]+>/<name:[\w\pL.\-\s]+>' => array('view/item', 'mapVars' => array('news_sef' => 'name', 'category_sef' => 'category'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// to be noted here - value 'name' is replaced by item id within the callback method; TODO replace news_sef with news_sef field
// 'View/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// 'View/<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
## All news
'All' => array('list/all', 'allowVars' => array('page'), 'legacyQuery' => 'all.0.{page}'),
## URL with ID and Title - no DB call, balanced performance!
'Short/<id:{number}>/<name:{sefsecure}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id', 'category_sef' => 'name'), 'legacyQuery' => 'cat.{id}.{page}'),
## fallback when name is not provided
'Short/<id:{number}>' => array('list/short', 'allowVars' => array('page'), 'mapVars' => array('category_id' => 'id'), 'legacyQuery' => 'cat.{id}.{page}'),
// less used after
//'Brief/<id:[\d]+>' => array('list/short', 'allowVars' => array('page'), 'legacyQuery' => 'cat.{id}.{page}', 'mapVars' => array('category_id' => 'id')),
'Day/<id:{number}>' => array('list/day', 'allowVars' => array('page'), 'legacyQuery' => 'day.{id}.{page}'),
'Month/<id:{number}>' => array('list/month', 'allowVars' => array('page'), 'legacyQuery' => 'month.{id}.{page}'),
//'Year/<id:[\d]+>' => array('list/year', 'allowVars' => array('page'), 'legacyQuery' => 'year.{id}.{page}'), not supported yet
### View news item - kinda catch all - very bad performance when News is chosen as default namespace - two additional DB queries on every site call!
## Leading category name - uncomment to enable
//'<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
'View/<id:{number}>/<category:{sefsecure}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('category_sef' => 'category', 'news_sef' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
// Base location as item view - fallback if category sef is missing
//'<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'),
// fallback if news sef is missing
'View/<id:{number}>/<name:{sefsecure}>' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_sef' => 'name'), 'legacyQuery' => 'extend.{id}'),
'View/<id:{number}>' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'),
'Tag/<tag:{secure}>' => array('list/tag', 'allowVars' => array('page'), 'legacyQuery' => 'tag={tag}&page={page}'),
'Author/<author:{secure}>' => array('list/author', 'allowVars' => array('page'), 'legacyQuery' => 'author={author}&page={page}'),
)
);
}
/**
* Query mapping in format route?params:
* - item/view?id=xxx -> ?extend.id
* - list/items[?page=xxx] -> default.0.page
* - list/category?id=xxx[&page=xxx] -> list.id.page
* - list/category?id=0[&page=xxx] -> default.0.page
* - list/short?id=xxx[&page=xxx] -> cat.id.page
* - list/day?id=xxx -> ?day-id
* - list/month?id=xxx -> ?month-id
* - list/year?id=xxx -> ?year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE.[FROM] (recursive parse() call)
*/
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_NEWS_REWRITEX_LABEL, // Current profile name
'description' => LAN_EURL_NEWS_REWRITEX_DESCR, //
'examples' => array('{SITEURL}news/1/news-title')
),
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
/*public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->db_Select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
{
$name = $sql->db_Fetch();
$request->setRequestParam('name', $name['news_id']);
}
else $request->setRequestParam('name', 0);
}*/
/**
* list/items by name callback
* @param eRequest $request
*/
/*public function categoryIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name) return;
elseif(is_numeric($name))
{
return;
}
$sql = e107::getDb('url');
$id = e107::getParser()->toDB($name);
if($sql->db_Select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
{
$name = $sql->db_Fetch();
$request->setRequestParam('name', $name['category_id']);
}
else $request->setRequestParam('name', 0);
}*/
}

View File

@@ -1,208 +1,208 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Default config - create ONLY - old legacy URLs
* All possible config options added here - to be used as a reference.
* A good programming practice is to remove all non-used options.
*/
if (!defined('e107_INIT')){ exit; }
class core_news_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => false, // [optional] default false; disallow this module (while using this config) to be set as site main URL namespace
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'list/new',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html), not used when format is 'get' or legacy non-empty
### [optional] used only when assembling URLs via rules();
### if 'empty' - check if the required parameter is empty (results in assemble fail),
### if 1 or true - it uses the route pattern to match every parameter - EXTREMELY SLOW, be warned
'matchValue' => false,
### [optional] vars mapping (create URL routine), override per rule is allowed
### Keys of this array will be used as a map for finding values from the provided parameters array.
### Those values will be assigned to new keys - corresponding values of mapVars array
### It gives extremely flexibility when used with allowVars. For example we pass $news item array as
### it's retrieved from the DB, with no modifications. This gives us the freedom to create any variations of news
### URLs using the DB data with a single line URL rule. Another aspect of this feature is the simplified code
### for URL assembling - we just do eRouter::create($theRoute, $newsDbArray)
### Not used when in selfCreate mod (create url)
'mapVars' => array(
//'news_id' => 'id',
//'news_sef' => 'name',
),
### [optional] allowed vars definition (create URL routine), override per rule is allowed
### This numerical array serves as a filter for passed vars when creating URLs
### Everything outside this scope is ignored while assembling URLs. Exception are route variables.
### For example: when <id:[\d]+> is present in the route string, there is no need to extra allow 'id'
### To disallow everything but route variables, set allowVars to false
### When format is get, false value will disallow everything (no params) and default preserved variables
### will be extracted from mapVars (if available)
### Default value is empty array
### Not used when in selfCreate mod (create url)
'allowVars' => array(/*'page', 'name'*/),
### Those are regex templates, allowing us to avoid the repeating regex patterns writing in your rules.
### varTemplates are merged with the core predefined templates. Full list with core regex templates and examples can be found
### in rewrite_extended news URL config
'varTemplates' => array(/*'testIt' => '[\d]+'*/),
),
'rules' => array(), // rule set array - can't be used with format 'get' and noSingleEntry true
);
}
/**
* If create returns string, 'module' value won't be prefixed from the router
* Query mapping in format route?params:
* - view/item?id=xxx -> ?extend.id
* - list/items[?page=xxx] -> default.0.page
* - list/category?id=xxx[&page=xxx] -> list.id.page
* - list/category?id=0[&page=xxx] -> default.0.page
* - list/short?id=xxx[&page=xxx] -> cat.id.page
* - list/day?id=xxx -> ?day-id
* - list/month?id=xxx -> ?month-id
* - list/year?id=xxx -> ?year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE.[FROM] (recursive parse() call)
*/
public function create($route, $params = array(),$options = array())
{
if(!$params) return 'news.php';
if(!$route) $route = 'list/items';
if(is_string($route)) $route = explode('/', $route, 2);
if('index' == $route[0])
{
$route[0] = 'list';
$route[1] = 'items';
}
elseif('index' == $route[1])
{
$route[1] = 'items';
}
// return print_a($route,true);
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['news_id']) && !empty($params['news_id'])) $params['id'] = $params['news_id'];
//if(isset($params['news_sef']) && !empty($params['news_sef'])) $params['id'] = $params['news_sef'];
//if(isset($params['category_sef']) && !empty($params['category_sef'])) $params['category'] = $params['category_sef'];
$url = 'news.php?';
if('--FROM--' != vartrue($params['page'])) $page = varset($params['page']) ? intval($params['page']) : '0';
else $page = '--FROM--';
if($route[0] == 'view')
{
switch ($route[1])
{
case 'item':
$url .= 'extend.'.$params['id']; //item.* view is deprecated
break;
default:
$url = 'news.php';
break;
}
}
elseif($route[0] == 'list')
{
switch ($route[1])
{
case '':
case 'items':
if(!$page) $url = 'news.php';
else $url .= 'default.0.'.$page; //item.* view is deprecated
break;
case 'category':
if(!vartrue($params['id']))
{
$url .= 'default.0.'.$page;
}
else
{
$url .= 'list.'.$params['id'].'.'.$page; // 'category_id' would break news_categories_menu.
}
break;
case 'all':
$url .= 'all.'.$params['id'].'.'.$page;
break;
case 'tag':
$url .= 'tag='.$params['tag'].'&page='.$page;
break;
case 'author':
$url .= 'author='.$params['author'].'&page='.$page;
break;
case 'short':
$url .= 'cat.'.$params['id'].'.'.$page;
break;
case 'day':
case 'month':
case 'year':
if($page) $page = '.'.$page;
$url .= $route[1].'.'.$params['id'].$page;
break;
default:
$url = 'news.php';
break;
}
}
else
{
$url = 'news.php';
}
return $url;
}
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}news.php?extend.1")
),
// 'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*
* Default config - create ONLY - old legacy URLs
* All possible config options added here - to be used as a reference.
* A good programming practice is to remove all non-used options.
*/
if (!defined('e107_INIT')){ exit; }
class core_news_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => false, // [optional] default false; disallow this module (while using this config) to be set as site main URL namespace
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}news.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'list/new',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html), not used when format is 'get' or legacy non-empty
### [optional] used only when assembling URLs via rules();
### if 'empty' - check if the required parameter is empty (results in assemble fail),
### if 1 or true - it uses the route pattern to match every parameter - EXTREMELY SLOW, be warned
'matchValue' => false,
### [optional] vars mapping (create URL routine), override per rule is allowed
### Keys of this array will be used as a map for finding values from the provided parameters array.
### Those values will be assigned to new keys - corresponding values of mapVars array
### It gives extremely flexibility when used with allowVars. For example we pass $news item array as
### it's retrieved from the DB, with no modifications. This gives us the freedom to create any variations of news
### URLs using the DB data with a single line URL rule. Another aspect of this feature is the simplified code
### for URL assembling - we just do eRouter::create($theRoute, $newsDbArray)
### Not used when in selfCreate mod (create url)
'mapVars' => array(
//'news_id' => 'id',
//'news_sef' => 'name',
),
### [optional] allowed vars definition (create URL routine), override per rule is allowed
### This numerical array serves as a filter for passed vars when creating URLs
### Everything outside this scope is ignored while assembling URLs. Exception are route variables.
### For example: when <id:[\d]+> is present in the route string, there is no need to extra allow 'id'
### To disallow everything but route variables, set allowVars to false
### When format is get, false value will disallow everything (no params) and default preserved variables
### will be extracted from mapVars (if available)
### Default value is empty array
### Not used when in selfCreate mod (create url)
'allowVars' => array(/*'page', 'name'*/),
### Those are regex templates, allowing us to avoid the repeating regex patterns writing in your rules.
### varTemplates are merged with the core predefined templates. Full list with core regex templates and examples can be found
### in rewrite_extended news URL config
'varTemplates' => array(/*'testIt' => '[\d]+'*/),
),
'rules' => array(), // rule set array - can't be used with format 'get' and noSingleEntry true
);
}
/**
* If create returns string, 'module' value won't be prefixed from the router
* Query mapping in format route?params:
* - view/item?id=xxx -> ?extend.id
* - list/items[?page=xxx] -> default.0.page
* - list/category?id=xxx[&page=xxx] -> list.id.page
* - list/category?id=0[&page=xxx] -> default.0.page
* - list/short?id=xxx[&page=xxx] -> cat.id.page
* - list/day?id=xxx -> ?day-id
* - list/month?id=xxx -> ?month-id
* - list/year?id=xxx -> ?year-id
* - list/nextprev?route=xxx -> PARSED_ROUTE.[FROM] (recursive parse() call)
*/
public function create($route, $params = array(),$options = array())
{
if(!$params) return 'news.php';
if(!$route) $route = 'list/items';
if(is_string($route)) $route = explode('/', $route, 2);
if('index' == $route[0])
{
$route[0] = 'list';
$route[1] = 'items';
}
elseif('index' == $route[1])
{
$route[1] = 'items';
}
// return print_a($route,true);
## news are passing array as it is retrieved from the DB, map vars to proper values
if(isset($params['news_id']) && !empty($params['news_id'])) $params['id'] = $params['news_id'];
//if(isset($params['news_sef']) && !empty($params['news_sef'])) $params['id'] = $params['news_sef'];
//if(isset($params['category_sef']) && !empty($params['category_sef'])) $params['category'] = $params['category_sef'];
$url = 'news.php?';
if('--FROM--' != vartrue($params['page'])) $page = varset($params['page']) ? intval($params['page']) : '0';
else $page = '--FROM--';
if($route[0] == 'view')
{
switch ($route[1])
{
case 'item':
$url .= 'extend.'.$params['id']; //item.* view is deprecated
break;
default:
$url = 'news.php';
break;
}
}
elseif($route[0] == 'list')
{
switch ($route[1])
{
case '':
case 'items':
if(!$page) $url = 'news.php';
else $url .= 'default.0.'.$page; //item.* view is deprecated
break;
case 'category':
if(!vartrue($params['id']))
{
$url .= 'default.0.'.$page;
}
else
{
$url .= 'list.'.$params['id'].'.'.$page; // 'category_id' would break news_categories_menu.
}
break;
case 'all':
$url .= 'all.'.$params['id'].'.'.$page;
break;
case 'tag':
$url .= 'tag='.$params['tag'].'&page='.$page;
break;
case 'author':
$url .= 'author='.$params['author'].'&page='.$page;
break;
case 'short':
$url .= 'cat.'.$params['id'].'.'.$page;
break;
case 'day':
case 'month':
case 'year':
if($page) $page = '.'.$page;
$url .= $route[1].'.'.$params['id'].$page;
break;
default:
$url = 'news.php';
break;
}
}
else
{
$url = 'news.php';
}
return $url;
}
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_NEWS, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}news.php?extend.1")
),
// 'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,151 +1,151 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_sef_noid_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'allowVars' => array(
'page',
),
),
'rules' => array(
'chapter/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
'book/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
'<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
### Used for assembling only
'<other:{secure}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
'/' => array('list/index', 'allowVars' => false, 'legacyQuery' => '', ), // page list
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_PAGE_SEFNOID_LABEL, // Current profile name
'description' => LAN_EURL_PAGE_SEFNOID_DESCR, //
'examples' => array("{SITEURL}page/page-title")
),
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
// e107::getMessage()->addDebug('name = '.$name);
// e107::getMessage()->addDebug(print_r($request,true));
// e107::getAdminLog()->toFile('page_sef_noid_url');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name || is_numeric($name))
{
if(ADMIN)
{
e107::getMessage()->addError("One of your pages is missing a SEF URL value");
}
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['page_id'])
->setRequestParam('id', $name['page_id']);
}
else
{
if(ADMIN)
{
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
}
$request->setRequestParam('name', 0)
->setRequestParam('id', 0);
}
}
/**
* chapter/index and book/index by name callback
* @param eRequest $request
*/
public function chapterIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name || is_numeric($name))
{
if(ADMIN)
{
e107::getMessage()->addError("One of your page-chapters is missing a SEF URL value");
}
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
{
$name = $sql->fetch();
$request->setRequestParam('id', $name['chapter_id'])
->setRequestParam('name', $name['chapter_id']);
}
else
{
if(ADMIN)
{
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
}
$request->setRequestParam('id', 0)
->setRequestParam('name', 0);
}
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_sef_noid_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'allowVars' => array(
'page',
),
),
'rules' => array(
'chapter/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
'book/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
'<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
### Used for assembling only
'<other:{secure}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
'/' => array('list/index', 'allowVars' => false, 'legacyQuery' => '', ), // page list
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_PAGE_SEFNOID_LABEL, // Current profile name
'description' => LAN_EURL_PAGE_SEFNOID_DESCR, //
'examples' => array("{SITEURL}page/page-title")
),
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* view/item by name callback
* @param eRequest $request
*/
public function itemIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
// e107::getMessage()->addDebug('name = '.$name);
// e107::getMessage()->addDebug(print_r($request,true));
// e107::getAdminLog()->toFile('page_sef_noid_url');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name || is_numeric($name))
{
if(ADMIN)
{
e107::getMessage()->addError("One of your pages is missing a SEF URL value");
}
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
{
$name = $sql->fetch();
$request->setRequestParam('name', $name['page_id'])
->setRequestParam('id', $name['page_id']);
}
else
{
if(ADMIN)
{
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
}
$request->setRequestParam('name', 0)
->setRequestParam('id', 0);
}
}
/**
* chapter/index and book/index by name callback
* @param eRequest $request
*/
public function chapterIdByTitle(eRequest $request)
{
$name = $request->getRequestParam('name');
if(($id = $request->getRequestParam('id')))
{
$request->setRequestParam('name', $id);
return;
}
elseif(!$name || is_numeric($name))
{
if(ADMIN)
{
e107::getMessage()->addError("One of your page-chapters is missing a SEF URL value");
}
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
{
$name = $sql->fetch();
$request->setRequestParam('id', $name['chapter_id'])
->setRequestParam('name', $name['chapter_id']);
}
else
{
if(ADMIN)
{
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
}
$request->setRequestParam('id', 0)
->setRequestParam('name', 0);
}
}
}

View File

@@ -1,67 +1,67 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_sef_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(
'page_id' => 'id',
'page_sef' => 'name',
),
'allowVars' => array(
'page',
),
),
'rules' => array(
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
### Used for assembling only
'<id:{number}>/<other:{sefsecureOptional}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', ),
'chapter/<id:{number}>/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}' ),
'book/<id:{number}>/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}' ),
### page list
'/' => array('list/index', 'legacyQuery' => '', ),
) // rule set array
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_PAGE_SEF_LABEL, // Current profile name
'description' => LAN_EURL_PAGE_SEF_DESCR, //
'examples' => array("{SITEURL}page/1/page-name")
),
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_sef_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(
'page_id' => 'id',
'page_sef' => 'name',
),
'allowVars' => array(
'page',
),
),
'rules' => array(
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
### Used for assembling only
'<id:{number}>/<other:{sefsecureOptional}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', ),
'chapter/<id:{number}>/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}' ),
'book/<id:{number}>/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}' ),
### page list
'/' => array('list/index', 'legacyQuery' => '', ),
) // rule set array
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_PAGE_SEF_LABEL, // Current profile name
'description' => LAN_EURL_PAGE_SEF_DESCR, //
'examples' => array("{SITEURL}page/1/page-name")
),
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,131 +1,131 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(),
'allowVars' => array(),
),
'rules' => array() // rule set array
);
}
/**
*
*/
public function create($route, $params = array(), $options = array())
{
if(!$params) return 'page.php';
if(is_string($route))
{
$route = explode('/', $route, 2);
}
if(!varset($route[1])) $route[1] = 'index';
$url = 'page.php?';
if(isset($params['chapter_id']) && !empty($params['chapter_id']))
{
$params['id'] = $params['chapter_id'];
}
switch ($route[0])
{
case 'book':
if(!empty($params['book_id']))
{
$params['id'] = $params['book_id'];
}
$url .= "bk=".intval($params['id']);
break;
case 'chapter':
$url .= "ch=".intval($params['id']);
break;
case 'view':
default:
## aliases as retrieved from the DB, map vars to proper values
if(isset($params['page_title']) && !empty($params['page_title']))
{
$params['name'] = $params['page_title'];
}
if(isset($params['page_id']) && !empty($params['page_id']))
{
$params['id'] = $params['page_id'];
}
if('--FROM--' != vartrue($params['page']))
{
$page = varset($params['page']) ? intval($params['page']) : '0';
}
else
{
$page = '--FROM--';
}
$url .= "id=".intval($params['id']).($page ? '.'.$page : '');
break;
}
return $url;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}page.php?1","{SITEURL}page.php?id=1")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
}
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Custom page routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_page_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(),
'allowVars' => array(),
),
'rules' => array() // rule set array
);
}
/**
*
*/
public function create($route, $params = array(), $options = array())
{
if(!$params) return 'page.php';
if(is_string($route))
{
$route = explode('/', $route, 2);
}
if(!varset($route[1])) $route[1] = 'index';
$url = 'page.php?';
if(isset($params['chapter_id']) && !empty($params['chapter_id']))
{
$params['id'] = $params['chapter_id'];
}
switch ($route[0])
{
case 'book':
if(!empty($params['book_id']))
{
$params['id'] = $params['book_id'];
}
$url .= "bk=".intval($params['id']);
break;
case 'chapter':
$url .= "ch=".intval($params['id']);
break;
case 'view':
default:
## aliases as retrieved from the DB, map vars to proper values
if(isset($params['page_title']) && !empty($params['page_title']))
{
$params['name'] = $params['page_title'];
}
if(isset($params['page_id']) && !empty($params['page_id']))
{
$params['id'] = $params['page_id'];
}
if('--FROM--' != vartrue($params['page']))
{
$page = varset($params['page']) ? intval($params['page']) : '0';
}
else
{
$page = '--FROM--';
}
$url .= "id=".intval($params['id']).($page ? '.'.$page : '');
break;
}
return $url;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_PAGE, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}page.php?1","{SITEURL}page.php?id=1")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
}

View File

@@ -1,50 +1,50 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Search routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_search_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'legacy' => '{e_BASE}search.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script to be included
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'index/index', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
// rule set array
'rules' => array(
'/' => array('index/index', 'defaultVars' => array('id' => 0)),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SEARCH, // Module name
'label' => LAN_EURL_SEARCH_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_SEARCH_REWRITE_DESCR, //
'examples' => array("{SITEURL}search/")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Search routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_search_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'legacy' => '{e_BASE}search.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script to be included
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'index/index', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
// rule set array
'rules' => array(
'/' => array('index/index', 'defaultVars' => array('id' => 0)),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SEARCH, // Module name
'label' => LAN_EURL_SEARCH_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_SEARCH_REWRITE_DESCR, //
'examples' => array("{SITEURL}search/")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,67 +1,67 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Search routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_search_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}search.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
'rules' => array() // rule set array
);
}
/**
* Query mapping
*/
public function create($route, $params = array(), $options=array())
{
if(!$params) return 'search.php';
return 'search.php?'.eFront::instance()->getRouter()->createPathInfo($params, $options);
}
/*
public function parse($pathInfo)
{
// this config doesn't support parsing, it's done by the module entry script (search.php)
// this means Search is not available via single entry point if this config is currently active
return false;
}*/
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SEARCH, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}search.php")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Search routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_search_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}search.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
'rules' => array() // rule set array
);
}
/**
* Query mapping
*/
public function create($route, $params = array(), $options=array())
{
if(!$params) return 'search.php';
return 'search.php?'.eFront::instance()->getRouter()->createPathInfo($params, $options);
}
/*
public function parse($pathInfo)
{
// this config doesn't support parsing, it's done by the module entry script (search.php)
// this means Search is not available via single entry point if this config is currently active
return false;
}*/
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SEARCH, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}search.php")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,53 +1,53 @@
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* System routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_system_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'format' => 'path',
'defaultRoute' => 'error/notfound',
'errorRoute' => 'error/notfound',
),
// rule set array
'rules' => array(
'error404' => 'error/notfound',
'hello' => 'error/hello-world',
'<controller>/<action>' => '<controller>/<action>',
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SYSTEM, // Module name
'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, //
'examples' => array("{SITEURL}system/error/404")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* System routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_system_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'allowMain' => true,
'format' => 'path',
'defaultRoute' => 'error/notfound',
'errorRoute' => 'error/notfound',
),
// rule set array
'rules' => array(
'error404' => 'error/notfound',
'hello' => 'error/hello-world',
'<controller>/<action>' => '<controller>/<action>',
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SYSTEM, // Module name
'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, //
'examples' => array("{SITEURL}system/error/404")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,44 +1,44 @@
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* System routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_system_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'error/notfound', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SYSTEM, // Module name
'label' => LAN_EURL_SYSTEM_DEFAULT_LABEL, // Current profile name
'description' => LAN_EURL_SYSTEM_DEFAULT_DESCR, //
'examples' => array("{SITEURL}?route=system/error/notfound")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* System routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_system_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'defaultRoute' => 'error/notfound', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
),
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_SYSTEM, // Module name
'label' => LAN_EURL_SYSTEM_DEFAULT_LABEL, // Current profile name
'description' => LAN_EURL_SYSTEM_DEFAULT_DESCR, //
'examples' => array("{SITEURL}?route=system/error/notfound")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@@ -1,102 +1,102 @@
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* User routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_user_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => false, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}user.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script to be included
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => false, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'myprofile/view', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array( // vars mapping (create URL)
'user_id' => 'id',
'user_name' => 'name',
),
'allowVars' => false, // allowed vars (create URL, used for legacyQuery parsing in parse routine as well), false means - disallow all vars beside those required by the rules
'legacyQuery' => '' // default legacy query string template, null to disable, override possible by rule
),
// rule set array
'rules' => array(
// simple matches first - PERFORMANCE
'' => array('myprofile/view', 'defaultVars' => array('id' => 0)),
'settings' => array('myprofile/edit', 'defaultVars' => array('id' => 0), 'legacy' => '{e_BASE}usersettings.php'),
'list' => array('profile/list', 'allowVars' => array('page'), 'legacyQuery' => '{page}'),
'login' => array('login/index', 'legacy' => '{e_BASE}login.php'),
'register' => array('register/index', 'legacy' => '{e_BASE}signup.php'),
// Regex involved next
//'<id:[\d]+>' => array('profile/view', 'legacyQuery' => 'id.{id}'),
// 'edit/<id:[\d]+>' => array('profile/edit', 'legacy' => '{e_ADMIN}users.php', 'legacyQuery' => 'mode=main&action=edit&id={id}'),
// Named requests - important to be in the end in this order!
// 'edit/<name:[\w\pL.\-\s]+>' => array('profile/edit','legacy' => '{e_ADMIN}users.php', 'legacyQuery' => 'mode=main&action=edit&id={id}', 'parseCallback' => 'idByName'),
// Last one - close to catch all!
'<name:[\w\pL.\-\s\|]+>' => array('profile/view', 'legacyQuery' => 'id.{id}', 'parseCallback' => 'idByName'),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_USER, // Module name
'label' => LAN_EURL_USER_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_USER_REWRITE_DESCR, //
'examples' => array("{SITEURL}user/UserDisplayName")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* profile/edit & profile/view callback
* @param eRequest $request
*/
public function idByName(eRequest $request)
{
$name = $request->getRequestParam('name');
if(!$name) return;
// if id only is passed, don't do DB query
if(is_numeric($name))
{
$request->setRequestParam('id', $name)->setRequestParam('name', null);
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('user', 'user_id', "user_name='{$name}' OR REPLACE(user_name, ' ', '-') ='{$name}' " )) // XXX - new user_sef field? Discuss.
{
$name = $sql->fetch();
$request->setRequestParam('id', $name['user_id']);
}
}
}
<?php
/*
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* User routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_user_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => false, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}user.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script to be included
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => false, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'myprofile/view', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array( // vars mapping (create URL)
'user_id' => 'id',
'user_name' => 'name',
),
'allowVars' => false, // allowed vars (create URL, used for legacyQuery parsing in parse routine as well), false means - disallow all vars beside those required by the rules
'legacyQuery' => '' // default legacy query string template, null to disable, override possible by rule
),
// rule set array
'rules' => array(
// simple matches first - PERFORMANCE
'' => array('myprofile/view', 'defaultVars' => array('id' => 0)),
'settings' => array('myprofile/edit', 'defaultVars' => array('id' => 0), 'legacy' => '{e_BASE}usersettings.php'),
'list' => array('profile/list', 'allowVars' => array('page'), 'legacyQuery' => '{page}'),
'login' => array('login/index', 'legacy' => '{e_BASE}login.php'),
'register' => array('register/index', 'legacy' => '{e_BASE}signup.php'),
// Regex involved next
//'<id:[\d]+>' => array('profile/view', 'legacyQuery' => 'id.{id}'),
// 'edit/<id:[\d]+>' => array('profile/edit', 'legacy' => '{e_ADMIN}users.php', 'legacyQuery' => 'mode=main&action=edit&id={id}'),
// Named requests - important to be in the end in this order!
// 'edit/<name:[\w\pL.\-\s]+>' => array('profile/edit','legacy' => '{e_ADMIN}users.php', 'legacyQuery' => 'mode=main&action=edit&id={id}', 'parseCallback' => 'idByName'),
// Last one - close to catch all!
'<name:[\w\pL.\-\s\|]+>' => array('profile/view', 'legacyQuery' => 'id.{id}', 'parseCallback' => 'idByName'),
)
);
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_USER, // Module name
'label' => LAN_EURL_USER_REWRITE_LABEL, // Current profile name
'description' => LAN_EURL_USER_REWRITE_DESCR, //
'examples' => array("{SITEURL}user/UserDisplayName")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
### CUSTOM METHODS ###
/**
* profile/edit & profile/view callback
* @param eRequest $request
*/
public function idByName(eRequest $request)
{
$name = $request->getRequestParam('name');
if(!$name) return;
// if id only is passed, don't do DB query
if(is_numeric($name))
{
$request->setRequestParam('id', $name)->setRequestParam('name', null);
return;
}
$sql = e107::getDb('url');
$name = e107::getParser()->toDB($name);
if($sql->select('user', 'user_id', "user_name='{$name}' OR REPLACE(user_name, ' ', '-') ='{$name}' " )) // XXX - new user_sef field? Discuss.
{
$name = $sql->fetch();
$request->setRequestParam('id', $name['user_id']);
}
}
}

View File

@@ -1,130 +1,130 @@
<?php
/*
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* User routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_user_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}user.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(),
'allowVars' => array(),
),
'rules' => array() // rule set array
);
}
/**
* Query mapping in format route?params:
* - profile/view?id=xxx -> user.php?id.xxx
* - profile/list?page=xxx -> user.php?xxx
* - myprofile/view -> user.php
* - profile/edit?id=xxx -> usersettings.php?xxx
* - myprofile/edit -> usersettings.php
* - login/index (or just 'login') -> login.php
* - register/index (or just 'register') -> signup.php
*/
public function create($route, $params = array(), $options = array())
{
// Some routes require no params
//if(!$params) return 'user.php';
if(is_string($route)) $route = explode('/', $route, 2);
if(!varset($route[1])) $route[1] = 'index';
## aliases as retrieved from the DB, map vars to proper values
if(isset($params['user_name']) && !empty($params['user_name'])) $params['id'] = $params['user_name'];
if(isset($params['user_id']) && !empty($params['user_id'])) $params['id'] = $params['user_id'];
$url = 'user.php';
$page = vartrue($params['page']) ? intval($params['page']) : '0';
if($route[0] == 'profile')
{
// Params required for user view, list & edit
if(!$params) return 'user.php';
switch ($route[1])
{
case '':
case 'view':
$url .= '?id.'.$params['id'];
break;
case 'list':
$url .= $page ? '?'.$page : '';
break;
case 'edit':
//$url = e_ADMIN_ABS."user.php?mode=main&action=edit&id=".$params['id'];// 'usersettings.php?'.$params['id'];
$url = e_ADMIN."users.php?mode=main&action=edit&id=".$params['id'];// 'usersettings.php?'.$params['id'];
break;
}
}
elseif($route[0] == 'myprofile')
{
switch ($route[1])
{
case '':
case 'view':
// user.php
break;
case 'edit':
$url = 'usersettings.php';
break;
}
}
elseif($route[0] == 'login')
{
$url = 'login.php';
}
elseif($route[0] == 'register') $url = 'signup.php'; // XXX signup URL parameters
return $url;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_USER, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}user.php?id.1")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
public function parse($pathInfo, $params = array(), eRequest $request = NULL, eRouter $router = NULL, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
}
<?php
/*
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* User routing config
*/
if (!defined('e107_INIT')){ exit; }
class core_user_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_BASE}user.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
'mapVars' => array(),
'allowVars' => array(),
),
'rules' => array() // rule set array
);
}
/**
* Query mapping in format route?params:
* - profile/view?id=xxx -> user.php?id.xxx
* - profile/list?page=xxx -> user.php?xxx
* - myprofile/view -> user.php
* - profile/edit?id=xxx -> usersettings.php?xxx
* - myprofile/edit -> usersettings.php
* - login/index (or just 'login') -> login.php
* - register/index (or just 'register') -> signup.php
*/
public function create($route, $params = array(), $options = array())
{
// Some routes require no params
//if(!$params) return 'user.php';
if(is_string($route)) $route = explode('/', $route, 2);
if(!varset($route[1])) $route[1] = 'index';
## aliases as retrieved from the DB, map vars to proper values
if(isset($params['user_name']) && !empty($params['user_name'])) $params['id'] = $params['user_name'];
if(isset($params['user_id']) && !empty($params['user_id'])) $params['id'] = $params['user_id'];
$url = 'user.php';
$page = vartrue($params['page']) ? intval($params['page']) : '0';
if($route[0] == 'profile')
{
// Params required for user view, list & edit
if(!$params) return 'user.php';
switch ($route[1])
{
case '':
case 'view':
$url .= '?id.'.$params['id'];
break;
case 'list':
$url .= $page ? '?'.$page : '';
break;
case 'edit':
//$url = e_ADMIN_ABS."user.php?mode=main&action=edit&id=".$params['id'];// 'usersettings.php?'.$params['id'];
$url = e_ADMIN."users.php?mode=main&action=edit&id=".$params['id'];// 'usersettings.php?'.$params['id'];
break;
}
}
elseif($route[0] == 'myprofile')
{
switch ($route[1])
{
case '':
case 'view':
// user.php
break;
case 'edit':
$url = 'usersettings.php';
break;
}
}
elseif($route[0] == 'login')
{
$url = 'login.php';
}
elseif($route[0] == 'register') $url = 'signup.php'; // XXX signup URL parameters
return $url;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
static $admin = array(
'labels' => array(
'name' => LAN_EURL_CORE_USER, // Module name
'label' => LAN_EURL_DEFAULT, // Current profile name
'description' => LAN_EURL_LEGACY, //
'examples' => array("{SITEURL}user.php?id.1")
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
public function parse($pathInfo, $params = array(), eRequest $request = NULL, eRouter $router = NULL, $config = array())
{
// this config doesn't support parsing, it's done by the module entry script (news.php)
// this means News are not available via single entry point if this config is currently active
return false;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,116 +1,116 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Benchmark handler
*
* $URL$
* $Id$
*/
/**
* @package e107
* @subpackage e107_handlers
* @version $Id$
* @author secretr
*
* Simple, quick and efective way of testing performance of parts of your code
* Example:
* <code> <?php
* require_once e_HANDLER.'benchmark.php';
*
* $bench = new e_benchmark();
* $bench->start();
*
* // Do something, e.g. loop 1000000 times
*
* // stop timer and check your e_LOG folder
* $bench->end()->logResult('myevent');
* //OR print out the result (don't forget to stop the timer if used without the above line!
* $bench->printResult();
* </code>
*/
class e_benchmark
{
protected $time_start;
protected $time_end;
/**
* Constructor
*/
function __construct()
{
$this->time_end = $this->time_start = 0;
}
/**
* Start timer
* @return benchmark
*/
public function start()
{
$this->time_start = microtime(true);
return $this;
}
/**
* Stop timer
* @return benchmark
*/
public function end()
{
$this->time_end = microtime(true);
return $this;
}
/**
* Calculate result
* @return integer
*/
public function result()
{
return ($this->time_end - $this->time_start);
}
/**
* Write result to a file in system log
* @param string $id identifier of the current benchmark event e.g. 'thumbnail.create'
* @param string $heading additional data to be shown in the log (header) e.g. '[Some Event]'
* @param boolean $append overwrite or append to the log file
* @return benchmark
*/
public function logResult($id, $heading = '', $append = true)
{
file_put_contents(e_LOG.'Benchmark_'.$id.'.log', $this->formatData($heading), ($append ? FILE_APPEND : 0));
return $this;
}
/**
* Send result to the stdout
*
* @param string $heading
* @return string
*/
public function printResult($heading = '')
{
print('<pre>'.$this->formatData($heading).'</pre>');
return $this;
}
/**
* Format data for loging/printing
*
* @param string $heading
* @return string
*/
function formatData($heading)
{
$data = "------------- Log Start -------------\n".date('r')." ".$heading."\n";
$data .= "Result: ".$this->result()." sec\n------------- Log End -------------\n\n";
return $data;
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Benchmark handler
*
* $URL$
* $Id$
*/
/**
* @package e107
* @subpackage e107_handlers
* @version $Id$
* @author secretr
*
* Simple, quick and efective way of testing performance of parts of your code
* Example:
* <code> <?php
* require_once e_HANDLER.'benchmark.php';
*
* $bench = new e_benchmark();
* $bench->start();
*
* // Do something, e.g. loop 1000000 times
*
* // stop timer and check your e_LOG folder
* $bench->end()->logResult('myevent');
* //OR print out the result (don't forget to stop the timer if used without the above line!
* $bench->printResult();
* </code>
*/
class e_benchmark
{
protected $time_start;
protected $time_end;
/**
* Constructor
*/
function __construct()
{
$this->time_end = $this->time_start = 0;
}
/**
* Start timer
* @return benchmark
*/
public function start()
{
$this->time_start = microtime(true);
return $this;
}
/**
* Stop timer
* @return benchmark
*/
public function end()
{
$this->time_end = microtime(true);
return $this;
}
/**
* Calculate result
* @return integer
*/
public function result()
{
return ($this->time_end - $this->time_start);
}
/**
* Write result to a file in system log
* @param string $id identifier of the current benchmark event e.g. 'thumbnail.create'
* @param string $heading additional data to be shown in the log (header) e.g. '[Some Event]'
* @param boolean $append overwrite or append to the log file
* @return benchmark
*/
public function logResult($id, $heading = '', $append = true)
{
file_put_contents(e_LOG.'Benchmark_'.$id.'.log', $this->formatData($heading), ($append ? FILE_APPEND : 0));
return $this;
}
/**
* Send result to the stdout
*
* @param string $heading
* @return string
*/
public function printResult($heading = '')
{
print('<pre>'.$this->formatData($heading).'</pre>');
return $this;
}
/**
* Format data for loging/printing
*
* @param string $heading
* @return string
*/
function formatData($heading)
{
$data = "------------- Log Start -------------\n".date('r')." ".$heading."\n";
$data .= "Result: ".$this->result()." sec\n------------- Log End -------------\n\n";
return $data;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,414 +1,414 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Auth class
*
* Hybrid_Auth class provide a simple way to authenticate users via OpenID and OAuth.
*
* Generally, Hybrid_Auth is the only class you should instanciate and use throughout your application.
*/
class Hybrid_Auth {
public static $version = "2.9.6";
/**
* Configuration array
* @var array
*/
public static $config = array();
/**
* Auth cache
* @var Hybrid_Storage
*/
public static $store = null;
/**
* Error pool
* @var Hybrid_Error
*/
public static $error = null;
/**
* Logger
* @var Hybrid_Logger
*/
public static $logger = null;
/**
* Try to start a new session of none then initialize Hybrid_Auth
*
* Hybrid_Auth constructor will require either a valid config array or
* a path for a configuration file as parameter. To know more please
* refer to the Configuration section:
* http://hybridauth.sourceforge.net/userguide/Configuration.html
*
* @param array $config Configuration array or path to a configratuion file
*/
function __construct($config) {
Hybrid_Auth::initialize($config);
}
/**
* Try to initialize Hybrid_Auth with given $config hash or file
*
* @param array $config Configuration array or path to a configratuion file
* @return void
* @throws Exception
*/
public static function initialize($config) {
if (!is_array($config) && !file_exists($config)) {
throw new Exception("Hybriauth config does not exist on the given path.", 1);
}
if (!is_array($config)) {
$config = include $config;
}
// build some need'd paths
$config["path_base"] = realpath(dirname(__FILE__)) . "/";
$config["path_libraries"] = $config["path_base"] . "thirdparty/";
$config["path_resources"] = $config["path_base"] . "resources/";
$config["path_providers"] = $config["path_base"] . "Providers/";
// reset debug mode
if (!isset($config["debug_mode"])) {
$config["debug_mode"] = false;
$config["debug_file"] = null;
}
# load hybridauth required files, a autoload is on the way...
require_once $config["path_base"] . "Error.php";
require_once $config["path_base"] . "Exception.php";
require_once $config["path_base"] . "Logger.php";
require_once $config["path_base"] . "Provider_Adapter.php";
require_once $config["path_base"] . "Provider_Model.php";
require_once $config["path_base"] . "Provider_Model_OpenID.php";
require_once $config["path_base"] . "Provider_Model_OAuth1.php";
require_once $config["path_base"] . "Provider_Model_OAuth2.php";
require_once $config["path_base"] . "User.php";
require_once $config["path_base"] . "User_Profile.php";
require_once $config["path_base"] . "User_Contact.php";
require_once $config["path_base"] . "User_Activity.php";
if (!class_exists("Hybrid_Storage", false)) {
require_once $config["path_base"] . "Storage.php";
}
// hash given config
Hybrid_Auth::$config = $config;
// instance of log mng
Hybrid_Auth::$logger = new Hybrid_Logger();
// instance of errors mng
Hybrid_Auth::$error = new Hybrid_Error();
// start session storage mng
Hybrid_Auth::$store = new Hybrid_Storage();
Hybrid_Logger::info("Enter Hybrid_Auth::initialize()");
Hybrid_Logger::info("Hybrid_Auth::initialize(). PHP version: " . PHP_VERSION);
Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth version: " . Hybrid_Auth::$version);
Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl());
// PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
if (!function_exists('curl_init')) {
Hybrid_Logger::error('Hybridauth Library needs the CURL PHP extension.');
throw new Exception('Hybridauth Library needs the CURL PHP extension.');
}
// PHP JSON extension [http://php.net/manual/en/book.json.php]
if (!function_exists('json_decode')) {
Hybrid_Logger::error('Hybridauth Library needs the JSON PHP extension.');
throw new Exception('Hybridauth Library needs the JSON PHP extension.');
}
// session.name
if (session_name() != "PHPSESSID") {
Hybrid_Logger::info('PHP session.name diff from default PHPSESSID. http://php.net/manual/en/session.configuration.php#ini.session.name.');
}
// safe_mode is on
if (ini_get('safe_mode')) {
Hybrid_Logger::info('PHP safe_mode is on. http://php.net/safe-mode.');
}
// open basedir is on
if (ini_get('open_basedir')) {
Hybrid_Logger::info('PHP open_basedir is on. http://php.net/open-basedir.');
}
Hybrid_Logger::debug("Hybrid_Auth initialize. dump used config: ", serialize($config));
Hybrid_Logger::debug("Hybrid_Auth initialize. dump current session: ", Hybrid_Auth::storage()->getSessionData());
Hybrid_Logger::info("Hybrid_Auth initialize: check if any error is stored on the endpoint...");
if (Hybrid_Error::hasError()) {
$m = Hybrid_Error::getErrorMessage();
$c = Hybrid_Error::getErrorCode();
$p = Hybrid_Error::getErrorPrevious();
Hybrid_Logger::error("Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#$c, '$m'");
Hybrid_Error::clearError();
// try to provide the previous if any
// Exception::getPrevious (PHP 5 >= 5.3.0) http://php.net/manual/en/exception.getprevious.php
if (version_compare(PHP_VERSION, '5.3.0', '>=') && ($p instanceof Exception)) {
throw new Exception($m, $c, $p);
} else {
throw new Exception($m, $c);
}
}
Hybrid_Logger::info("Hybrid_Auth initialize: no error found. initialization succeed.");
}
/**
* Hybrid storage system accessor
*
* Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be accessed directly by
* Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
* Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
*
* @return Hybrid_Storage
*/
public static function storage() {
return Hybrid_Auth::$store;
}
/**
* Get hybridauth session data
* @return string|null
*/
function getSessionData() {
return Hybrid_Auth::storage()->getSessionData();
}
/**
* Restore hybridauth session data
*
* @param string $sessiondata Serialized session data
* @retun void
*/
function restoreSessionData($sessiondata = null) {
Hybrid_Auth::storage()->restoreSessionData($sessiondata);
}
/**
* Try to authenticate the user with a given provider.
*
* If the user is already connected we just return and instance of provider adapter,
* ELSE, try to authenticate and authorize the user with the provider.
*
* $params is generally an array with required info in order for this provider and HybridAuth to work,
* like :
* hauth_return_to: URL to call back after authentication is done
* openid_identifier: The OpenID identity provider identifier
* google_service: can be "Users" for Google user accounts service or "Apps" for Google hosted Apps
*
* @param string $providerId ID of the provider
* @param array $params Params
* @return
*/
public static function authenticate($providerId, $params = null) {
Hybrid_Logger::info("Enter Hybrid_Auth::authenticate( $providerId )");
if (!Hybrid_Auth::storage()->get("hauth_session.$providerId.is_logged_in")) {
// if user not connected to $providerId then try setup a new adapter and start the login process for this provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User not connected to the provider. Try to authenticate..");
$provider_adapter = Hybrid_Auth::setup($providerId, $params);
$provider_adapter->login();
} else {
// else, then return the adapter instance for the given provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User is already connected to this provider. Return the adapter instance.");
return Hybrid_Auth::getAdapter($providerId);
}
}
/**
* Return the adapter instance for an authenticated provider
*
* @param string $providerId ID of the provider
* @return Hybrid_Provider_Adapter
*/
public static function getAdapter($providerId = null) {
Hybrid_Logger::info("Enter Hybrid_Auth::getAdapter( $providerId )");
return Hybrid_Auth::setup($providerId);
}
/**
* Setup an adapter for a given provider
*
* @param string $providerId ID of the provider
* @param array $params Adapter params
* @return Hybrid_Provider_Adapter
*/
public static function setup($providerId, $params = null) {
Hybrid_Logger::debug("Enter Hybrid_Auth::setup( $providerId )", $params);
if (!$params) {
$params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ), no params given. Trying to get the stored for this provider.", $params);
}
if (!$params) {
$params = array();
Hybrid_Logger::info("Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session");
}
if (is_array($params) && !isset($params["hauth_return_to"])) {
$params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"]);
}
# instantiate a new IDProvider Adapter
$provider = new Hybrid_Provider_Adapter();
$provider->factory($providerId, $params);
return $provider;
}
/**
* Check if the current user is connected to a given provider
*
* @param string $providerId ID of the provider
* @return bool
*/
public static function isConnectedWith($providerId) {
return (bool) Hybrid_Auth::storage()->get("hauth_session.{$providerId}.is_logged_in");
}
/**
* Return array listing all authenticated providers
* @return array
*/
public static function getConnectedProviders() {
$idps = array();
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if (Hybrid_Auth::isConnectedWith($idpid)) {
$idps[] = $idpid;
}
}
return $idps;
}
/**
* Return array listing all enabled providers as well as a flag if you are connected
*
* <code>
* array(
* 'Facebook' => array(
* 'connected' => true
* )
* )
* </code>
* @return array
*/
public static function getProviders() {
$idps = array();
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if ($params['enabled']) {
$idps[$idpid] = array('connected' => false);
if (Hybrid_Auth::isConnectedWith($idpid)) {
$idps[$idpid]['connected'] = true;
}
}
}
return $idps;
}
/**
* A generic function to logout all connected provider at once
* @return void
*/
public static function logoutAllProviders() {
$idps = Hybrid_Auth::getConnectedProviders();
foreach ($idps as $idp) {
$adapter = Hybrid_Auth::getAdapter($idp);
$adapter->logout();
}
}
/**
* Utility function, redirect to a given URL with php header or using javascript location.href
*
* @param string $url URL to redirect to
* @param string $mode PHP|JS
*/
public static function redirect($url, $mode = "PHP") {
if(!$mode){
$mode = 'PHP';
}
Hybrid_Logger::info("Enter Hybrid_Auth::redirect( $url, $mode )");
// Ensure session is saved before sending response, see https://github.com/symfony/symfony/pull/12341
if ((PHP_VERSION_ID >= 50400 && PHP_SESSION_ACTIVE === session_status()) || (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id())) {
session_write_close();
}
if ($mode == "PHP") {
header("Location: $url");
} elseif ($mode == "JS") {
echo '<html>';
echo '<head>';
echo '<script type="text/javascript">';
echo 'function redirect(){ window.top.location.href="' . $url . '"; }';
echo '</script>';
echo '</head>';
echo '<body onload="redirect()">';
echo 'Redirecting, please wait...';
echo '</body>';
echo '</html>';
}
die();
}
/**
* Utility function, return the current url
*
* @param bool $request_uri true to get $_SERVER['REQUEST_URI'], false for $_SERVER['PHP_SELF']
* @return string
*/
public static function getCurrentUrl($request_uri = true) {
if (php_sapi_name() == 'cli') {
return '';
}
$protocol = 'http://';
if ((isset($_SERVER['HTTPS']) && ( $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1 ))
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
$protocol = 'https://';
}
$url = $protocol . $_SERVER['HTTP_HOST'];
if ($request_uri) {
$url .= $_SERVER['REQUEST_URI'];
} else {
$url .= $_SERVER['PHP_SELF'];
}
// return current url
return $url;
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Auth class
*
* Hybrid_Auth class provide a simple way to authenticate users via OpenID and OAuth.
*
* Generally, Hybrid_Auth is the only class you should instanciate and use throughout your application.
*/
class Hybrid_Auth {
public static $version = "2.9.6";
/**
* Configuration array
* @var array
*/
public static $config = array();
/**
* Auth cache
* @var Hybrid_Storage
*/
public static $store = null;
/**
* Error pool
* @var Hybrid_Error
*/
public static $error = null;
/**
* Logger
* @var Hybrid_Logger
*/
public static $logger = null;
/**
* Try to start a new session of none then initialize Hybrid_Auth
*
* Hybrid_Auth constructor will require either a valid config array or
* a path for a configuration file as parameter. To know more please
* refer to the Configuration section:
* http://hybridauth.sourceforge.net/userguide/Configuration.html
*
* @param array $config Configuration array or path to a configratuion file
*/
function __construct($config) {
Hybrid_Auth::initialize($config);
}
/**
* Try to initialize Hybrid_Auth with given $config hash or file
*
* @param array $config Configuration array or path to a configratuion file
* @return void
* @throws Exception
*/
public static function initialize($config) {
if (!is_array($config) && !file_exists($config)) {
throw new Exception("Hybriauth config does not exist on the given path.", 1);
}
if (!is_array($config)) {
$config = include $config;
}
// build some need'd paths
$config["path_base"] = realpath(dirname(__FILE__)) . "/";
$config["path_libraries"] = $config["path_base"] . "thirdparty/";
$config["path_resources"] = $config["path_base"] . "resources/";
$config["path_providers"] = $config["path_base"] . "Providers/";
// reset debug mode
if (!isset($config["debug_mode"])) {
$config["debug_mode"] = false;
$config["debug_file"] = null;
}
# load hybridauth required files, a autoload is on the way...
require_once $config["path_base"] . "Error.php";
require_once $config["path_base"] . "Exception.php";
require_once $config["path_base"] . "Logger.php";
require_once $config["path_base"] . "Provider_Adapter.php";
require_once $config["path_base"] . "Provider_Model.php";
require_once $config["path_base"] . "Provider_Model_OpenID.php";
require_once $config["path_base"] . "Provider_Model_OAuth1.php";
require_once $config["path_base"] . "Provider_Model_OAuth2.php";
require_once $config["path_base"] . "User.php";
require_once $config["path_base"] . "User_Profile.php";
require_once $config["path_base"] . "User_Contact.php";
require_once $config["path_base"] . "User_Activity.php";
if (!class_exists("Hybrid_Storage", false)) {
require_once $config["path_base"] . "Storage.php";
}
// hash given config
Hybrid_Auth::$config = $config;
// instance of log mng
Hybrid_Auth::$logger = new Hybrid_Logger();
// instance of errors mng
Hybrid_Auth::$error = new Hybrid_Error();
// start session storage mng
Hybrid_Auth::$store = new Hybrid_Storage();
Hybrid_Logger::info("Enter Hybrid_Auth::initialize()");
Hybrid_Logger::info("Hybrid_Auth::initialize(). PHP version: " . PHP_VERSION);
Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth version: " . Hybrid_Auth::$version);
Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl());
// PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
if (!function_exists('curl_init')) {
Hybrid_Logger::error('Hybridauth Library needs the CURL PHP extension.');
throw new Exception('Hybridauth Library needs the CURL PHP extension.');
}
// PHP JSON extension [http://php.net/manual/en/book.json.php]
if (!function_exists('json_decode')) {
Hybrid_Logger::error('Hybridauth Library needs the JSON PHP extension.');
throw new Exception('Hybridauth Library needs the JSON PHP extension.');
}
// session.name
if (session_name() != "PHPSESSID") {
Hybrid_Logger::info('PHP session.name diff from default PHPSESSID. http://php.net/manual/en/session.configuration.php#ini.session.name.');
}
// safe_mode is on
if (ini_get('safe_mode')) {
Hybrid_Logger::info('PHP safe_mode is on. http://php.net/safe-mode.');
}
// open basedir is on
if (ini_get('open_basedir')) {
Hybrid_Logger::info('PHP open_basedir is on. http://php.net/open-basedir.');
}
Hybrid_Logger::debug("Hybrid_Auth initialize. dump used config: ", serialize($config));
Hybrid_Logger::debug("Hybrid_Auth initialize. dump current session: ", Hybrid_Auth::storage()->getSessionData());
Hybrid_Logger::info("Hybrid_Auth initialize: check if any error is stored on the endpoint...");
if (Hybrid_Error::hasError()) {
$m = Hybrid_Error::getErrorMessage();
$c = Hybrid_Error::getErrorCode();
$p = Hybrid_Error::getErrorPrevious();
Hybrid_Logger::error("Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#$c, '$m'");
Hybrid_Error::clearError();
// try to provide the previous if any
// Exception::getPrevious (PHP 5 >= 5.3.0) http://php.net/manual/en/exception.getprevious.php
if (version_compare(PHP_VERSION, '5.3.0', '>=') && ($p instanceof Exception)) {
throw new Exception($m, $c, $p);
} else {
throw new Exception($m, $c);
}
}
Hybrid_Logger::info("Hybrid_Auth initialize: no error found. initialization succeed.");
}
/**
* Hybrid storage system accessor
*
* Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be accessed directly by
* Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
* Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
*
* @return Hybrid_Storage
*/
public static function storage() {
return Hybrid_Auth::$store;
}
/**
* Get hybridauth session data
* @return string|null
*/
function getSessionData() {
return Hybrid_Auth::storage()->getSessionData();
}
/**
* Restore hybridauth session data
*
* @param string $sessiondata Serialized session data
* @retun void
*/
function restoreSessionData($sessiondata = null) {
Hybrid_Auth::storage()->restoreSessionData($sessiondata);
}
/**
* Try to authenticate the user with a given provider.
*
* If the user is already connected we just return and instance of provider adapter,
* ELSE, try to authenticate and authorize the user with the provider.
*
* $params is generally an array with required info in order for this provider and HybridAuth to work,
* like :
* hauth_return_to: URL to call back after authentication is done
* openid_identifier: The OpenID identity provider identifier
* google_service: can be "Users" for Google user accounts service or "Apps" for Google hosted Apps
*
* @param string $providerId ID of the provider
* @param array $params Params
* @return
*/
public static function authenticate($providerId, $params = null) {
Hybrid_Logger::info("Enter Hybrid_Auth::authenticate( $providerId )");
if (!Hybrid_Auth::storage()->get("hauth_session.$providerId.is_logged_in")) {
// if user not connected to $providerId then try setup a new adapter and start the login process for this provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User not connected to the provider. Try to authenticate..");
$provider_adapter = Hybrid_Auth::setup($providerId, $params);
$provider_adapter->login();
} else {
// else, then return the adapter instance for the given provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User is already connected to this provider. Return the adapter instance.");
return Hybrid_Auth::getAdapter($providerId);
}
}
/**
* Return the adapter instance for an authenticated provider
*
* @param string $providerId ID of the provider
* @return Hybrid_Provider_Adapter
*/
public static function getAdapter($providerId = null) {
Hybrid_Logger::info("Enter Hybrid_Auth::getAdapter( $providerId )");
return Hybrid_Auth::setup($providerId);
}
/**
* Setup an adapter for a given provider
*
* @param string $providerId ID of the provider
* @param array $params Adapter params
* @return Hybrid_Provider_Adapter
*/
public static function setup($providerId, $params = null) {
Hybrid_Logger::debug("Enter Hybrid_Auth::setup( $providerId )", $params);
if (!$params) {
$params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ), no params given. Trying to get the stored for this provider.", $params);
}
if (!$params) {
$params = array();
Hybrid_Logger::info("Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session");
}
if (is_array($params) && !isset($params["hauth_return_to"])) {
$params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"]);
}
# instantiate a new IDProvider Adapter
$provider = new Hybrid_Provider_Adapter();
$provider->factory($providerId, $params);
return $provider;
}
/**
* Check if the current user is connected to a given provider
*
* @param string $providerId ID of the provider
* @return bool
*/
public static function isConnectedWith($providerId) {
return (bool) Hybrid_Auth::storage()->get("hauth_session.{$providerId}.is_logged_in");
}
/**
* Return array listing all authenticated providers
* @return array
*/
public static function getConnectedProviders() {
$idps = array();
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if (Hybrid_Auth::isConnectedWith($idpid)) {
$idps[] = $idpid;
}
}
return $idps;
}
/**
* Return array listing all enabled providers as well as a flag if you are connected
*
* <code>
* array(
* 'Facebook' => array(
* 'connected' => true
* )
* )
* </code>
* @return array
*/
public static function getProviders() {
$idps = array();
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if ($params['enabled']) {
$idps[$idpid] = array('connected' => false);
if (Hybrid_Auth::isConnectedWith($idpid)) {
$idps[$idpid]['connected'] = true;
}
}
}
return $idps;
}
/**
* A generic function to logout all connected provider at once
* @return void
*/
public static function logoutAllProviders() {
$idps = Hybrid_Auth::getConnectedProviders();
foreach ($idps as $idp) {
$adapter = Hybrid_Auth::getAdapter($idp);
$adapter->logout();
}
}
/**
* Utility function, redirect to a given URL with php header or using javascript location.href
*
* @param string $url URL to redirect to
* @param string $mode PHP|JS
*/
public static function redirect($url, $mode = "PHP") {
if(!$mode){
$mode = 'PHP';
}
Hybrid_Logger::info("Enter Hybrid_Auth::redirect( $url, $mode )");
// Ensure session is saved before sending response, see https://github.com/symfony/symfony/pull/12341
if ((PHP_VERSION_ID >= 50400 && PHP_SESSION_ACTIVE === session_status()) || (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id())) {
session_write_close();
}
if ($mode == "PHP") {
header("Location: $url");
} elseif ($mode == "JS") {
echo '<html>';
echo '<head>';
echo '<script type="text/javascript">';
echo 'function redirect(){ window.top.location.href="' . $url . '"; }';
echo '</script>';
echo '</head>';
echo '<body onload="redirect()">';
echo 'Redirecting, please wait...';
echo '</body>';
echo '</html>';
}
die();
}
/**
* Utility function, return the current url
*
* @param bool $request_uri true to get $_SERVER['REQUEST_URI'], false for $_SERVER['PHP_SELF']
* @return string
*/
public static function getCurrentUrl($request_uri = true) {
if (php_sapi_name() == 'cli') {
return '';
}
$protocol = 'http://';
if ((isset($_SERVER['HTTPS']) && ( $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1 ))
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
$protocol = 'https://';
}
$url = $protocol . $_SERVER['HTTP_HOST'];
if ($request_uri) {
$url .= $_SERVER['REQUEST_URI'];
} else {
$url .= $_SERVER['PHP_SELF'];
}
// return current url
return $url;
}
}

View File

@@ -1,88 +1,88 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Errors manager
*
* HybridAuth errors are stored in Hybrid::storage() and not displayed directly to the end user
*/
class Hybrid_Error {
/**
* Store error in session
*
* @param string $message Error message
* @param int $code Error code
* @param string $trace Back trace
* @param string $previous Previous exception
*/
public static function setError($message, $code = null, $trace = null, $previous = null) {
Hybrid_Logger::info("Enter Hybrid_Error::setError( $message )");
Hybrid_Auth::storage()->set("hauth_session.error.status", 1);
Hybrid_Auth::storage()->set("hauth_session.error.message", $message);
Hybrid_Auth::storage()->set("hauth_session.error.code", $code);
Hybrid_Auth::storage()->set("hauth_session.error.trace", $trace);
Hybrid_Auth::storage()->set("hauth_session.error.previous", $previous);
}
/**
* Clear the last error
* @return void
*/
public static function clearError() {
Hybrid_Logger::info("Enter Hybrid_Error::clearError()");
Hybrid_Auth::storage()->delete("hauth_session.error.status");
Hybrid_Auth::storage()->delete("hauth_session.error.message");
Hybrid_Auth::storage()->delete("hauth_session.error.code");
Hybrid_Auth::storage()->delete("hauth_session.error.trace");
Hybrid_Auth::storage()->delete("hauth_session.error.previous");
}
/**
* Checks to see if there is a an error.
* @return boolean true if there is an error.
*/
public static function hasError() {
return (bool) Hybrid_Auth::storage()->get("hauth_session.error.status");
}
/**
* Return error message
* @return string
*/
public static function getErrorMessage() {
return Hybrid_Auth::storage()->get("hauth_session.error.message");
}
/**
* Return error code
* @return int
*/
public static function getErrorCode() {
return Hybrid_Auth::storage()->get("hauth_session.error.code");
}
/**
* Return string detailed error backtrace as string
* @return string
*/
public static function getErrorTrace() {
return Hybrid_Auth::storage()->get("hauth_session.error.trace");
}
/**
* Detailed error backtrace as string
* @return string
*/
public static function getErrorPrevious() {
return Hybrid_Auth::storage()->get("hauth_session.error.previous");
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Errors manager
*
* HybridAuth errors are stored in Hybrid::storage() and not displayed directly to the end user
*/
class Hybrid_Error {
/**
* Store error in session
*
* @param string $message Error message
* @param int $code Error code
* @param string $trace Back trace
* @param string $previous Previous exception
*/
public static function setError($message, $code = null, $trace = null, $previous = null) {
Hybrid_Logger::info("Enter Hybrid_Error::setError( $message )");
Hybrid_Auth::storage()->set("hauth_session.error.status", 1);
Hybrid_Auth::storage()->set("hauth_session.error.message", $message);
Hybrid_Auth::storage()->set("hauth_session.error.code", $code);
Hybrid_Auth::storage()->set("hauth_session.error.trace", $trace);
Hybrid_Auth::storage()->set("hauth_session.error.previous", $previous);
}
/**
* Clear the last error
* @return void
*/
public static function clearError() {
Hybrid_Logger::info("Enter Hybrid_Error::clearError()");
Hybrid_Auth::storage()->delete("hauth_session.error.status");
Hybrid_Auth::storage()->delete("hauth_session.error.message");
Hybrid_Auth::storage()->delete("hauth_session.error.code");
Hybrid_Auth::storage()->delete("hauth_session.error.trace");
Hybrid_Auth::storage()->delete("hauth_session.error.previous");
}
/**
* Checks to see if there is a an error.
* @return boolean true if there is an error.
*/
public static function hasError() {
return (bool) Hybrid_Auth::storage()->get("hauth_session.error.status");
}
/**
* Return error message
* @return string
*/
public static function getErrorMessage() {
return Hybrid_Auth::storage()->get("hauth_session.error.message");
}
/**
* Return error code
* @return int
*/
public static function getErrorCode() {
return Hybrid_Auth::storage()->get("hauth_session.error.code");
}
/**
* Return string detailed error backtrace as string
* @return string
*/
public static function getErrorTrace() {
return Hybrid_Auth::storage()->get("hauth_session.error.trace");
}
/**
* Detailed error backtrace as string
* @return string
*/
public static function getErrorPrevious() {
return Hybrid_Auth::storage()->get("hauth_session.error.previous");
}
}

View File

@@ -1,102 +1,102 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Debugging and Logging manager
*/
class Hybrid_Logger {
/**
* Constructor
*/
function __construct() {
// if debug mode is set to true, then check for the writable log file
if (Hybrid_Auth::$config["debug_mode"]) {
if (!isset(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true' but no log file path 'debug_file' is set.", 1);
} elseif (!file_exists(Hybrid_Auth::$config["debug_file"]) && !is_writable(Hybrid_Auth::$config["debug_file"])) {
if (!touch(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' can not be created.", 1);
}
} elseif (!is_writable(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1);
}
}
}
/**
* Logs a debug message with an object dump
*
* @param string $message Debug message
* @param stdClass $object Object being debugged
* @return void
*/
public static function debug($message, $object = null) {
if (Hybrid_Auth::$config["debug_mode"] === true) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
"DEBUG",
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message,
print_r($object, true) . PHP_EOL,
)), FILE_APPEND
);
}
}
/**
* Logs an info message
*
* @param string $message Info message
* @return void
*/
public static function info($message) {
if (in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info'), true)) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
"INFO",
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message . PHP_EOL,
)), FILE_APPEND);
}
}
/**
* Logs an error message with an object dump
*
* @param string $message Error message
* @param stdClass $object Object being debugged
* @return void
*/
public static function error($message, $object = null) {
if (isset(Hybrid_Auth::$config["debug_mode"]) && in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info', 'error'), true)) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
'ERROR',
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message,
print_r($object, true) . PHP_EOL
)), FILE_APPEND);
}
}
/**
* Dumps the data in the way suitable to be output in log files for debug purposes
*
* @param mixed $data
*
* @return string
*/
public static function dumpData($data) {
return var_export($data, true);
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Debugging and Logging manager
*/
class Hybrid_Logger {
/**
* Constructor
*/
function __construct() {
// if debug mode is set to true, then check for the writable log file
if (Hybrid_Auth::$config["debug_mode"]) {
if (!isset(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true' but no log file path 'debug_file' is set.", 1);
} elseif (!file_exists(Hybrid_Auth::$config["debug_file"]) && !is_writable(Hybrid_Auth::$config["debug_file"])) {
if (!touch(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' can not be created.", 1);
}
} elseif (!is_writable(Hybrid_Auth::$config["debug_file"])) {
throw new Exception("'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1);
}
}
}
/**
* Logs a debug message with an object dump
*
* @param string $message Debug message
* @param stdClass $object Object being debugged
* @return void
*/
public static function debug($message, $object = null) {
if (Hybrid_Auth::$config["debug_mode"] === true) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
"DEBUG",
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message,
print_r($object, true) . PHP_EOL,
)), FILE_APPEND
);
}
}
/**
* Logs an info message
*
* @param string $message Info message
* @return void
*/
public static function info($message) {
if (in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info'), true)) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
"INFO",
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message . PHP_EOL,
)), FILE_APPEND);
}
}
/**
* Logs an error message with an object dump
*
* @param string $message Error message
* @param stdClass $object Object being debugged
* @return void
*/
public static function error($message, $object = null) {
if (isset(Hybrid_Auth::$config["debug_mode"]) && in_array(Hybrid_Auth::$config["debug_mode"], array(true, 'info', 'error'), true)) {
$dt = new DateTime('now', new DateTimeZone( 'UTC' ));
file_put_contents(Hybrid_Auth::$config["debug_file"], implode(' -- ', array(
'ERROR',
$_SERVER['REMOTE_ADDR'],
$dt->format(DATE_ATOM),
$message,
print_r($object, true) . PHP_EOL
)), FILE_APPEND);
}
}
/**
* Dumps the data in the way suitable to be output in log files for debug purposes
*
* @param mixed $data
*
* @return string
*/
public static function dumpData($data) {
return var_export($data, true);
}
}

View File

@@ -1,340 +1,340 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Provider_Adapter is the basic class which Hybrid_Auth will use
* to connect users to a given provider.
*
* Basically Hybrid_Provider_Adapter will create a bridge from your php
* application to the provider api.
*
* Hybrid_Auth will automatically load Hybrid_Provider_Adapter and create
* an instance of it for each authenticated provider.
*/
class Hybrid_Provider_Adapter {
/**
* Provider ID (or unique name)
* @var mixed
*/
public $id = null;
/**
* Provider adapter specific config
* @var array
*/
public $config = null;
/**
* Provider adapter extra parameters
* @var array
*/
public $params = array();
/**
* Provider adapter wrapper path
* @var string
*/
public $wrapper = null;
/**
* Provider adapter instance
* @var Hybrid_Provider_Model
*/
public $adapter = null;
/**
* Create a new adapter switch IDp name or ID
*
* @param string $id The id or name of the IDp
* @param array $params (optional) required parameters by the adapter
* @return Hybrid_Provider_Adapter
* @throws Exception
*/
function factory($id, $params = array()) {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::factory( $id )");
# init the adapter config and params
$this->id = $id;
$this->params = $params;
$this->id = $this->getProviderCiId($this->id);
$this->config = $this->getConfigById($this->id);
# check the IDp id
if (!$this->id) {
throw new Exception("No provider ID specified.", 2);
}
# check the IDp config
if (!$this->config) {
throw new Exception("Unknown Provider ID, check your configuration file.", 3);
}
# check the IDp adapter is enabled
if (!$this->config["enabled"]) {
throw new Exception("The provider '{$this->id}' is not enabled.", 3);
}
# include the adapter wrapper
if (isset($this->config["wrapper"]) && is_array($this->config["wrapper"])) {
if (isset($this->config["wrapper"]["path"])) {
require_once $this->config["wrapper"]["path"];
}
if (!class_exists($this->config["wrapper"]["class"])) {
throw new Exception("Unable to load the adapter class.", 3);
}
$this->wrapper = $this->config["wrapper"]["class"];
} else {
require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php";
$this->wrapper = "Hybrid_Providers_" . $this->id;
}
# create the adapter instance, and pass the current params and config
$this->adapter = new $this->wrapper($this->id, $this->config, $this->params);
return $this;
}
/**
* Hybrid_Provider_Adapter::login(), prepare the user session and the authentication request
* for index.php
* @return void
* @throw Exception
*/
function login() {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::login( {$this->id} ) ");
if (!$this->adapter) {
throw new Exception("Hybrid_Provider_Adapter::login() should not directly used.");
}
// clear all unneeded params
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.hauth_return_to");
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.hauth_endpoint");
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.id_provider_params");
}
// make a fresh start
$this->logout();
# get hybridauth base url
if (empty(Hybrid_Auth::$config["base_url"])) {
// the base url wasn't provide, so we must use the current
// url (which makes sense actually)
$url = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? 'http' : 'https';
$url .= '://' . $_SERVER['HTTP_HOST'];
$url .= $_SERVER['REQUEST_URI'];
$HYBRID_AUTH_URL_BASE = $url;
} else {
$HYBRID_AUTH_URL_BASE = Hybrid_Auth::$config["base_url"];
}
// make sure params is array
if (!is_array($this->params)) {
$this->params = array();
}
# we make use of session_id() as storage hash to identify the current user
# using session_regenerate_id() will be a problem, but ..
$this->params["hauth_token"] = session_id();
# set request timestamp
$this->params["hauth_time"] = time();
# for default HybridAuth endpoint url hauth_login_start_url
# auth.start required the IDp ID
# auth.time optional login request timestamp
if (!isset($this->params["login_start"]) ) {
$this->params["login_start"] = $HYBRID_AUTH_URL_BASE . ( strpos($HYBRID_AUTH_URL_BASE, '?') ? '&' : '?' ) . "hauth.start={$this->id}&hauth.time={$this->params["hauth_time"]}";
}
# for default HybridAuth endpoint url hauth_login_done_url
# auth.done required the IDp ID
if (!isset($this->params["login_done"]) ) {
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE . ( strpos($HYBRID_AUTH_URL_BASE, '?') ? '&' : '?' ) . "hauth.done={$this->id}";
}
# workaround to solve windows live authentication since microsoft disallowed redirect urls to contain any parameters
# http://mywebsite.com/path_to_hybridauth/?hauth.done=Live will not work
if ($this->id=="Live") {
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE."live.php";
}
# Workaround to fix broken callback urls for the Facebook OAuth client
if ($this->adapter->useSafeUrls) {
$this->params['login_done'] = str_replace('hauth.done', 'hauth_done', $this->params['login_done']);
}
if (isset($this->params["hauth_return_to"])) {
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.hauth_return_to", $this->params["hauth_return_to"]);
}
if (isset($this->params["login_done"])) {
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.hauth_endpoint", $this->params["login_done"]);
}
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.id_provider_params", $this->params);
// store config to be used by the end point
Hybrid_Auth::storage()->config("CONFIG", Hybrid_Auth::$config);
// move on
Hybrid_Logger::debug("Hybrid_Provider_Adapter::login( {$this->id} ), redirect the user to login_start URL.");
// redirect
if (empty($this->params["redirect_mode"])) {
Hybrid_Auth::redirect($this->params["login_start"]);
} else {
Hybrid_Auth::redirect($this->params["login_start"],$this->params["redirect_mode"]);
}
}
/**
* Let hybridauth forget all about the user for the current provider
* @return bool
*/
function logout() {
$this->adapter->logout();
}
// --------------------------------------------------------------------
/**
* Return true if the user is connected to the current provider
* @return bool
*/
public function isUserConnected() {
return $this->adapter->isUserConnected();
}
// --------------------------------------------------------------------
/**
* Call adapter methods defined in the adapter model:
* getUserProfile()
* getUserContacts()
* getUserActivity()
* setUserStatus()
*
* @param string $name Method name
* @param array $arguments Call arguments
* @return mixed
* @throws Exception
*/
public function __call($name, $arguments) {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::$name(), Provider: {$this->id}");
if (!$this->isUserConnected()) {
throw new Exception("User not connected to the provider {$this->id}.", 7);
}
if (!method_exists($this->adapter, $name)) {
throw new Exception("Call to undefined function Hybrid_Providers_{$this->id}::$name().");
}
return call_user_func_array(array($this->adapter, $name), $arguments);
}
/**
* If the user is connected, then return the access_token and access_token_secret
* if the provider api use oauth
*
* <code>
* array(
* 'access_token' => '',
* 'access_token_secret' => '',
* 'refresh_token' => '',
* 'expires_in' => '',
* 'expires_at' => '',
* )
* </code>
* @return array
*/
public function getAccessToken() {
if (!$this->adapter->isUserConnected()) {
Hybrid_Logger::error("User not connected to the provider.");
throw new Exception("User not connected to the provider.", 7);
}
return array(
"access_token" => $this->adapter->token("access_token"), // OAuth access token
"access_token_secret" => $this->adapter->token("access_token_secret"), // OAuth access token secret
"refresh_token" => $this->adapter->token("refresh_token"), // OAuth refresh token
"expires_in" => $this->adapter->token("expires_in"), // OPTIONAL. The duration in seconds of the access token lifetime
"expires_at" => $this->adapter->token("expires_at"), // OPTIONAL. Timestamp when the access_token expire. if not provided by the social api, then it should be calculated: expires_at = now + expires_in
);
}
/**
* Naive getter of the current connected IDp API client
* @return stdClass
* @throws Exception
*/
function api() {
if (!$this->adapter->isUserConnected()) {
Hybrid_Logger::error("User not connected to the provider.");
throw new Exception("User not connected to the provider.", 7);
}
return $this->adapter->api;
}
/**
* Redirect the user to hauth_return_to (the callback url)
* @return void
*/
function returnToCallbackUrl() {
// get the stored callback url
$callback_url = Hybrid_Auth::storage()->get("hauth_session.{$this->id}.hauth_return_to");
// if the user presses the back button in the browser and we already deleted the hauth_return_to from
// the session in the previous request, we will redirect to '/' instead of displaying a blank page.
if (!$callback_url) {
$callback_url = '/';
}
// remove some unneeded stored data
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_return_to");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_endpoint");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.id_provider_params");
// back to home
Hybrid_Auth::redirect($callback_url);
}
/**
* Return the provider config by id
*
* @param string $id Config key
* @return mixed
*/
function getConfigById($id) {
if (isset(Hybrid_Auth::$config["providers"][$id])) {
return Hybrid_Auth::$config["providers"][$id];
}
return null;
}
/**
* Return the provider config by id; case insensitive
*
* @param string $id Provider id
* @return mixed
*/
function getProviderCiId($id) {
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if (strtolower($idpid) == strtolower($id)) {
return $idpid;
}
}
return null;
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Provider_Adapter is the basic class which Hybrid_Auth will use
* to connect users to a given provider.
*
* Basically Hybrid_Provider_Adapter will create a bridge from your php
* application to the provider api.
*
* Hybrid_Auth will automatically load Hybrid_Provider_Adapter and create
* an instance of it for each authenticated provider.
*/
class Hybrid_Provider_Adapter {
/**
* Provider ID (or unique name)
* @var mixed
*/
public $id = null;
/**
* Provider adapter specific config
* @var array
*/
public $config = null;
/**
* Provider adapter extra parameters
* @var array
*/
public $params = array();
/**
* Provider adapter wrapper path
* @var string
*/
public $wrapper = null;
/**
* Provider adapter instance
* @var Hybrid_Provider_Model
*/
public $adapter = null;
/**
* Create a new adapter switch IDp name or ID
*
* @param string $id The id or name of the IDp
* @param array $params (optional) required parameters by the adapter
* @return Hybrid_Provider_Adapter
* @throws Exception
*/
function factory($id, $params = array()) {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::factory( $id )");
# init the adapter config and params
$this->id = $id;
$this->params = $params;
$this->id = $this->getProviderCiId($this->id);
$this->config = $this->getConfigById($this->id);
# check the IDp id
if (!$this->id) {
throw new Exception("No provider ID specified.", 2);
}
# check the IDp config
if (!$this->config) {
throw new Exception("Unknown Provider ID, check your configuration file.", 3);
}
# check the IDp adapter is enabled
if (!$this->config["enabled"]) {
throw new Exception("The provider '{$this->id}' is not enabled.", 3);
}
# include the adapter wrapper
if (isset($this->config["wrapper"]) && is_array($this->config["wrapper"])) {
if (isset($this->config["wrapper"]["path"])) {
require_once $this->config["wrapper"]["path"];
}
if (!class_exists($this->config["wrapper"]["class"])) {
throw new Exception("Unable to load the adapter class.", 3);
}
$this->wrapper = $this->config["wrapper"]["class"];
} else {
require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php";
$this->wrapper = "Hybrid_Providers_" . $this->id;
}
# create the adapter instance, and pass the current params and config
$this->adapter = new $this->wrapper($this->id, $this->config, $this->params);
return $this;
}
/**
* Hybrid_Provider_Adapter::login(), prepare the user session and the authentication request
* for index.php
* @return void
* @throw Exception
*/
function login() {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::login( {$this->id} ) ");
if (!$this->adapter) {
throw new Exception("Hybrid_Provider_Adapter::login() should not directly used.");
}
// clear all unneeded params
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.hauth_return_to");
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.hauth_endpoint");
Hybrid_Auth::storage()->delete("hauth_session.{$idpid}.id_provider_params");
}
// make a fresh start
$this->logout();
# get hybridauth base url
if (empty(Hybrid_Auth::$config["base_url"])) {
// the base url wasn't provide, so we must use the current
// url (which makes sense actually)
$url = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ? 'http' : 'https';
$url .= '://' . $_SERVER['HTTP_HOST'];
$url .= $_SERVER['REQUEST_URI'];
$HYBRID_AUTH_URL_BASE = $url;
} else {
$HYBRID_AUTH_URL_BASE = Hybrid_Auth::$config["base_url"];
}
// make sure params is array
if (!is_array($this->params)) {
$this->params = array();
}
# we make use of session_id() as storage hash to identify the current user
# using session_regenerate_id() will be a problem, but ..
$this->params["hauth_token"] = session_id();
# set request timestamp
$this->params["hauth_time"] = time();
# for default HybridAuth endpoint url hauth_login_start_url
# auth.start required the IDp ID
# auth.time optional login request timestamp
if (!isset($this->params["login_start"]) ) {
$this->params["login_start"] = $HYBRID_AUTH_URL_BASE . ( strpos($HYBRID_AUTH_URL_BASE, '?') ? '&' : '?' ) . "hauth.start={$this->id}&hauth.time={$this->params["hauth_time"]}";
}
# for default HybridAuth endpoint url hauth_login_done_url
# auth.done required the IDp ID
if (!isset($this->params["login_done"]) ) {
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE . ( strpos($HYBRID_AUTH_URL_BASE, '?') ? '&' : '?' ) . "hauth.done={$this->id}";
}
# workaround to solve windows live authentication since microsoft disallowed redirect urls to contain any parameters
# http://mywebsite.com/path_to_hybridauth/?hauth.done=Live will not work
if ($this->id=="Live") {
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE."live.php";
}
# Workaround to fix broken callback urls for the Facebook OAuth client
if ($this->adapter->useSafeUrls) {
$this->params['login_done'] = str_replace('hauth.done', 'hauth_done', $this->params['login_done']);
}
if (isset($this->params["hauth_return_to"])) {
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.hauth_return_to", $this->params["hauth_return_to"]);
}
if (isset($this->params["login_done"])) {
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.hauth_endpoint", $this->params["login_done"]);
}
Hybrid_Auth::storage()->set("hauth_session.{$this->id}.id_provider_params", $this->params);
// store config to be used by the end point
Hybrid_Auth::storage()->config("CONFIG", Hybrid_Auth::$config);
// move on
Hybrid_Logger::debug("Hybrid_Provider_Adapter::login( {$this->id} ), redirect the user to login_start URL.");
// redirect
if (empty($this->params["redirect_mode"])) {
Hybrid_Auth::redirect($this->params["login_start"]);
} else {
Hybrid_Auth::redirect($this->params["login_start"],$this->params["redirect_mode"]);
}
}
/**
* Let hybridauth forget all about the user for the current provider
* @return bool
*/
function logout() {
$this->adapter->logout();
}
// --------------------------------------------------------------------
/**
* Return true if the user is connected to the current provider
* @return bool
*/
public function isUserConnected() {
return $this->adapter->isUserConnected();
}
// --------------------------------------------------------------------
/**
* Call adapter methods defined in the adapter model:
* getUserProfile()
* getUserContacts()
* getUserActivity()
* setUserStatus()
*
* @param string $name Method name
* @param array $arguments Call arguments
* @return mixed
* @throws Exception
*/
public function __call($name, $arguments) {
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::$name(), Provider: {$this->id}");
if (!$this->isUserConnected()) {
throw new Exception("User not connected to the provider {$this->id}.", 7);
}
if (!method_exists($this->adapter, $name)) {
throw new Exception("Call to undefined function Hybrid_Providers_{$this->id}::$name().");
}
return call_user_func_array(array($this->adapter, $name), $arguments);
}
/**
* If the user is connected, then return the access_token and access_token_secret
* if the provider api use oauth
*
* <code>
* array(
* 'access_token' => '',
* 'access_token_secret' => '',
* 'refresh_token' => '',
* 'expires_in' => '',
* 'expires_at' => '',
* )
* </code>
* @return array
*/
public function getAccessToken() {
if (!$this->adapter->isUserConnected()) {
Hybrid_Logger::error("User not connected to the provider.");
throw new Exception("User not connected to the provider.", 7);
}
return array(
"access_token" => $this->adapter->token("access_token"), // OAuth access token
"access_token_secret" => $this->adapter->token("access_token_secret"), // OAuth access token secret
"refresh_token" => $this->adapter->token("refresh_token"), // OAuth refresh token
"expires_in" => $this->adapter->token("expires_in"), // OPTIONAL. The duration in seconds of the access token lifetime
"expires_at" => $this->adapter->token("expires_at"), // OPTIONAL. Timestamp when the access_token expire. if not provided by the social api, then it should be calculated: expires_at = now + expires_in
);
}
/**
* Naive getter of the current connected IDp API client
* @return stdClass
* @throws Exception
*/
function api() {
if (!$this->adapter->isUserConnected()) {
Hybrid_Logger::error("User not connected to the provider.");
throw new Exception("User not connected to the provider.", 7);
}
return $this->adapter->api;
}
/**
* Redirect the user to hauth_return_to (the callback url)
* @return void
*/
function returnToCallbackUrl() {
// get the stored callback url
$callback_url = Hybrid_Auth::storage()->get("hauth_session.{$this->id}.hauth_return_to");
// if the user presses the back button in the browser and we already deleted the hauth_return_to from
// the session in the previous request, we will redirect to '/' instead of displaying a blank page.
if (!$callback_url) {
$callback_url = '/';
}
// remove some unneeded stored data
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_return_to");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_endpoint");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.id_provider_params");
// back to home
Hybrid_Auth::redirect($callback_url);
}
/**
* Return the provider config by id
*
* @param string $id Config key
* @return mixed
*/
function getConfigById($id) {
if (isset(Hybrid_Auth::$config["providers"][$id])) {
return Hybrid_Auth::$config["providers"][$id];
}
return null;
}
/**
* Return the provider config by id; case insensitive
*
* @param string $id Provider id
* @return mixed
*/
function getProviderCiId($id) {
foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
if (strtolower($idpid) == strtolower($id)) {
return $idpid;
}
}
return null;
}
}

View File

@@ -1,247 +1,247 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Provider_Model provide a common interface for supported IDps on HybridAuth.
*
* Basically, each provider adapter has to define at least 4 methods:
* Hybrid_Providers_{provider_name}::initialize()
* Hybrid_Providers_{provider_name}::loginBegin()
* Hybrid_Providers_{provider_name}::loginFinish()
* Hybrid_Providers_{provider_name}::getUserProfile()
*
* HybridAuth also come with three others models
* Class Hybrid_Provider_Model_OpenID for providers that uses the OpenID 1 and 2 protocol.
* Class Hybrid_Provider_Model_OAuth1 for providers that uses the OAuth 1 protocol.
* Class Hybrid_Provider_Model_OAuth2 for providers that uses the OAuth 2 protocol.
*/
abstract class Hybrid_Provider_Model {
/**
* IDp ID (or unique name)
* @var mixed
*/
public $providerId = null;
/**
* Specific provider adapter config
* @var array
*/
public $config = null;
/**
* Provider extra parameters
* @var array
*/
public $params = null;
/**
* Endpoint URL for that provider
* @var string
*/
public $endpoint = null;
/**
* Hybrid_User obj, represents the current loggedin user
* @var Hybrid_User
*/
public $user = null;
/**
* The provider api client (optional)
* @var stdClass
*/
public $api = null;
/**
* Model should use "gzip,deflate" for CURLOPT_ENCODING
* @var stdClass
*/
public $compressed = false;
/** @var bool $useSafeUrls Enable this to replace '.' with '_' characters in the callback urls */
public $useSafeUrls = false;
/**
* Common providers adapter constructor
*
* @param mixed $providerId Provider ID
* @param array $config Provider adapter config
* @param array $params Provider extra params
*/
function __construct($providerId, $config, $params = null) {
# init the IDp adapter parameters, get them from the cache if possible
if (!$params) {
$this->params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
} else {
$this->params = $params;
}
// idp id
$this->providerId = $providerId;
// set HybridAuth endpoint for this provider
$this->endpoint = Hybrid_Auth::storage()->get("hauth_session.$providerId.hauth_endpoint");
// idp config
$this->config = $config;
// new user instance
$this->user = new Hybrid_User();
$this->user->providerId = $providerId;
// initialize the current provider adapter
$this->initialize();
Hybrid_Logger::debug("Hybrid_Provider_Model::__construct( $providerId ) initialized. dump current adapter instance: ", serialize($this));
}
/**
* IDp wrappers initializer
*
* The main job of wrappers initializer is to performs (depend on the IDp api client it self):
* - include some libs needed by this provider,
* - check IDp key and secret,
* - set some needed parameters (stored in $this->params) by this IDp api client
* - create and setup an instance of the IDp api client on $this->api
*
* @return void
* @throws Exception
*/
abstract protected function initialize();
/**
* Begin login
*
* @return void
* @throws Exception
*/
abstract public function loginBegin();
/**
* Finish login
* @return void
* @throws Exception
*/
abstract public function loginFinish();
/**
* Generic logout, just erase current provider adapter stored data to let Hybrid_Auth all forget about it
* @return bool
*/
function logout() {
Hybrid_Logger::info("Enter [{$this->providerId}]::logout()");
$this->clearTokens();
return true;
}
/**
* Grab the user profile from the IDp api client
* @return Hybrid_User_Profile
* @throws Exception
*/
function getUserProfile() {
Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Load the current logged in user contacts list from the IDp api client
* @return Hybrid_User_Contact[]
* @throws Exception
*/
function getUserContacts() {
Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return the user activity stream
* @return Hybrid_User_Activity[]
* @throws Exception
*/
function getUserActivity($stream) {
Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Set user status
* @return mixed Provider response
* @throws Exception
*/
function setUserStatus($status) {
Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return the user status
* @return mixed Provider response
* @throws Exception
*/
function getUserStatus($statusid) {
Hybrid_Logger::error("HybridAuth do not provide user's status for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return true if the user is connected to the current provider
* @return bool
*/
public function isUserConnected() {
return (bool) Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.is_logged_in");
}
/**
* Set user to connected
* @return void
*/
public function setUserConnected() {
Hybrid_Logger::info("Enter [{$this->providerId}]::setUserConnected()");
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 1);
}
/**
* Set user to unconnected
* @return void
*/
public function setUserUnconnected() {
Hybrid_Logger::info("Enter [{$this->providerId}]::setUserUnconnected()");
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 0);
}
/**
* Get or set a token
* @return string
*/
public function token($token, $value = null) {
if ($value === null) {
return Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.token.$token");
} else {
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.token.$token", $value);
}
}
/**
* Delete a stored token
* @return void
*/
public function deleteToken($token) {
Hybrid_Auth::storage()->delete("hauth_session.{$this->providerId}.token.$token");
}
/**
* Clear all existent tokens for this provider
* @return void
*/
public function clearTokens() {
Hybrid_Auth::storage()->deleteMatch("hauth_session.{$this->providerId}.");
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Provider_Model provide a common interface for supported IDps on HybridAuth.
*
* Basically, each provider adapter has to define at least 4 methods:
* Hybrid_Providers_{provider_name}::initialize()
* Hybrid_Providers_{provider_name}::loginBegin()
* Hybrid_Providers_{provider_name}::loginFinish()
* Hybrid_Providers_{provider_name}::getUserProfile()
*
* HybridAuth also come with three others models
* Class Hybrid_Provider_Model_OpenID for providers that uses the OpenID 1 and 2 protocol.
* Class Hybrid_Provider_Model_OAuth1 for providers that uses the OAuth 1 protocol.
* Class Hybrid_Provider_Model_OAuth2 for providers that uses the OAuth 2 protocol.
*/
abstract class Hybrid_Provider_Model {
/**
* IDp ID (or unique name)
* @var mixed
*/
public $providerId = null;
/**
* Specific provider adapter config
* @var array
*/
public $config = null;
/**
* Provider extra parameters
* @var array
*/
public $params = null;
/**
* Endpoint URL for that provider
* @var string
*/
public $endpoint = null;
/**
* Hybrid_User obj, represents the current loggedin user
* @var Hybrid_User
*/
public $user = null;
/**
* The provider api client (optional)
* @var stdClass
*/
public $api = null;
/**
* Model should use "gzip,deflate" for CURLOPT_ENCODING
* @var stdClass
*/
public $compressed = false;
/** @var bool $useSafeUrls Enable this to replace '.' with '_' characters in the callback urls */
public $useSafeUrls = false;
/**
* Common providers adapter constructor
*
* @param mixed $providerId Provider ID
* @param array $config Provider adapter config
* @param array $params Provider extra params
*/
function __construct($providerId, $config, $params = null) {
# init the IDp adapter parameters, get them from the cache if possible
if (!$params) {
$this->params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
} else {
$this->params = $params;
}
// idp id
$this->providerId = $providerId;
// set HybridAuth endpoint for this provider
$this->endpoint = Hybrid_Auth::storage()->get("hauth_session.$providerId.hauth_endpoint");
// idp config
$this->config = $config;
// new user instance
$this->user = new Hybrid_User();
$this->user->providerId = $providerId;
// initialize the current provider adapter
$this->initialize();
Hybrid_Logger::debug("Hybrid_Provider_Model::__construct( $providerId ) initialized. dump current adapter instance: ", serialize($this));
}
/**
* IDp wrappers initializer
*
* The main job of wrappers initializer is to performs (depend on the IDp api client it self):
* - include some libs needed by this provider,
* - check IDp key and secret,
* - set some needed parameters (stored in $this->params) by this IDp api client
* - create and setup an instance of the IDp api client on $this->api
*
* @return void
* @throws Exception
*/
abstract protected function initialize();
/**
* Begin login
*
* @return void
* @throws Exception
*/
abstract public function loginBegin();
/**
* Finish login
* @return void
* @throws Exception
*/
abstract public function loginFinish();
/**
* Generic logout, just erase current provider adapter stored data to let Hybrid_Auth all forget about it
* @return bool
*/
function logout() {
Hybrid_Logger::info("Enter [{$this->providerId}]::logout()");
$this->clearTokens();
return true;
}
/**
* Grab the user profile from the IDp api client
* @return Hybrid_User_Profile
* @throws Exception
*/
function getUserProfile() {
Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Load the current logged in user contacts list from the IDp api client
* @return Hybrid_User_Contact[]
* @throws Exception
*/
function getUserContacts() {
Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return the user activity stream
* @return Hybrid_User_Activity[]
* @throws Exception
*/
function getUserActivity($stream) {
Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Set user status
* @return mixed Provider response
* @throws Exception
*/
function setUserStatus($status) {
Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return the user status
* @return mixed Provider response
* @throws Exception
*/
function getUserStatus($statusid) {
Hybrid_Logger::error("HybridAuth do not provide user's status for {$this->providerId} yet.");
throw new Exception("Provider does not support this feature.", 8);
}
/**
* Return true if the user is connected to the current provider
* @return bool
*/
public function isUserConnected() {
return (bool) Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.is_logged_in");
}
/**
* Set user to connected
* @return void
*/
public function setUserConnected() {
Hybrid_Logger::info("Enter [{$this->providerId}]::setUserConnected()");
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 1);
}
/**
* Set user to unconnected
* @return void
*/
public function setUserUnconnected() {
Hybrid_Logger::info("Enter [{$this->providerId}]::setUserUnconnected()");
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 0);
}
/**
* Get or set a token
* @return string
*/
public function token($token, $value = null) {
if ($value === null) {
return Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.token.$token");
} else {
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.token.$token", $value);
}
}
/**
* Delete a stored token
* @return void
*/
public function deleteToken($token) {
Hybrid_Auth::storage()->delete("hauth_session.{$this->providerId}.token.$token");
}
/**
* Clear all existent tokens for this provider
* @return void
*/
public function clearTokens() {
Hybrid_Auth::storage()->deleteMatch("hauth_session.{$this->providerId}.");
}
}

View File

@@ -1,174 +1,174 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OAuth 1 based service provider, Hybrid_Provider_Model_OAuth1
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth1 have to implement
* at least 2 methods:
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
*
* Hybrid_Provider_Model_OAuth1 use OAuth1Client v0.1 which can be found on
* Hybrid/thirdparty/OAuth/OAuth1Client.php
*/
class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model {
/**
* Provider API client
* @var OAuth1Client
*/
public $api = null;
/**
* Request_tokens as received from provider
* @var stdClas
*/
public $request_tokens_raw = null;
/**
* Access_tokens as received from provider
* @var stdClass
*/
public $access_tokens_raw = null;
/**
* Try to get the error message from provider api
*
* @param int $code Error code
* @return string
*/
function errorMessageByStatus($code = null) {
$http_status_codes = array(
200 => "OK: Success!",
304 => "Not Modified: There was no new data to return.",
400 => "Bad Request: The request was invalid.",
401 => "Unauthorized.",
403 => "Forbidden: The request is understood, but it has been refused.",
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
406 => "Not Acceptable.",
500 => "Internal Server Error: Something is broken.",
502 => "Bad Gateway.",
503 => "Service Unavailable."
);
if (!$code && $this->api) {
$code = $this->api->http_code;
}
if (isset($http_status_codes[$code])) {
return $code . " " . $http_status_codes[$code];
}
}
/**
* {@inheritdoc}
*/
function initialize() {
// 1 - check application credentials
if (!$this->config["keys"]["key"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application key and secret are required in order to connect to {$this->providerId}.", 4);
}
// 2 - include OAuth lib and client
if (! class_exists('OAuthConsumer') ) {
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
}
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
// 3.1 - setup access_token if any stored
if ($this->token("access_token")) {
$this->api = new OAuth1Client(
$this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("access_token"), $this->token("access_token_secret")
);
}
// 3.2 - setup request_token if any stored, in order to exchange with an access token
elseif ($this->token("request_token")) {
$this->api = new OAuth1Client(
$this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("request_token"), $this->token("request_token_secret")
);
}
// 3.3 - instanciate OAuth client with client credentials
else {
$this->api = new OAuth1Client($this->config["keys"]["key"], $this->config["keys"]["secret"]);
}
// Set curl proxy if exist
if (isset(Hybrid_Auth::$config["proxy"])) {
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$tokens = $this->api->requestToken($this->endpoint);
// request tokens as received from provider
$this->request_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
}
$this->token("request_token", $tokens["oauth_token"]);
$this->token("request_token_secret", $tokens["oauth_token_secret"]);
# redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$oauth_token = (array_key_exists('oauth_token', $_REQUEST)) ? $_REQUEST['oauth_token'] : "";
$oauth_verifier = (array_key_exists('oauth_verifier', $_REQUEST)) ? $_REQUEST['oauth_verifier'] : "";
if (!$oauth_token || !$oauth_verifier) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5);
}
// request an access token
$tokens = $this->api->accessToken($oauth_verifier);
// access tokens as received from provider
$this->access_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
// we should have an access_token, or else, something has gone wrong
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// we no more need to store request tokens
$this->deleteToken("request_token");
$this->deleteToken("request_token_secret");
// store access_token for later user
$this->token("access_token", $tokens['oauth_token']);
$this->token("access_token_secret", $tokens['oauth_token_secret']);
// set user as logged in to the current provider
$this->setUserConnected();
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OAuth 1 based service provider, Hybrid_Provider_Model_OAuth1
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth1 have to implement
* at least 2 methods:
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
*
* Hybrid_Provider_Model_OAuth1 use OAuth1Client v0.1 which can be found on
* Hybrid/thirdparty/OAuth/OAuth1Client.php
*/
class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model {
/**
* Provider API client
* @var OAuth1Client
*/
public $api = null;
/**
* Request_tokens as received from provider
* @var stdClas
*/
public $request_tokens_raw = null;
/**
* Access_tokens as received from provider
* @var stdClass
*/
public $access_tokens_raw = null;
/**
* Try to get the error message from provider api
*
* @param int $code Error code
* @return string
*/
function errorMessageByStatus($code = null) {
$http_status_codes = array(
200 => "OK: Success!",
304 => "Not Modified: There was no new data to return.",
400 => "Bad Request: The request was invalid.",
401 => "Unauthorized.",
403 => "Forbidden: The request is understood, but it has been refused.",
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
406 => "Not Acceptable.",
500 => "Internal Server Error: Something is broken.",
502 => "Bad Gateway.",
503 => "Service Unavailable."
);
if (!$code && $this->api) {
$code = $this->api->http_code;
}
if (isset($http_status_codes[$code])) {
return $code . " " . $http_status_codes[$code];
}
}
/**
* {@inheritdoc}
*/
function initialize() {
// 1 - check application credentials
if (!$this->config["keys"]["key"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application key and secret are required in order to connect to {$this->providerId}.", 4);
}
// 2 - include OAuth lib and client
if (! class_exists('OAuthConsumer') ) {
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
}
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
// 3.1 - setup access_token if any stored
if ($this->token("access_token")) {
$this->api = new OAuth1Client(
$this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("access_token"), $this->token("access_token_secret")
);
}
// 3.2 - setup request_token if any stored, in order to exchange with an access token
elseif ($this->token("request_token")) {
$this->api = new OAuth1Client(
$this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("request_token"), $this->token("request_token_secret")
);
}
// 3.3 - instanciate OAuth client with client credentials
else {
$this->api = new OAuth1Client($this->config["keys"]["key"], $this->config["keys"]["secret"]);
}
// Set curl proxy if exist
if (isset(Hybrid_Auth::$config["proxy"])) {
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$tokens = $this->api->requestToken($this->endpoint);
// request tokens as received from provider
$this->request_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
}
$this->token("request_token", $tokens["oauth_token"]);
$this->token("request_token_secret", $tokens["oauth_token_secret"]);
# redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$oauth_token = (array_key_exists('oauth_token', $_REQUEST)) ? $_REQUEST['oauth_token'] : "";
$oauth_verifier = (array_key_exists('oauth_verifier', $_REQUEST)) ? $_REQUEST['oauth_verifier'] : "";
if (!$oauth_token || !$oauth_verifier) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5);
}
// request an access token
$tokens = $this->api->accessToken($oauth_verifier);
// access tokens as received from provider
$this->access_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
// we should have an access_token, or else, something has gone wrong
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// we no more need to store request tokens
$this->deleteToken("request_token");
$this->deleteToken("request_token_secret");
// store access_token for later user
$this->token("access_token", $tokens['oauth_token']);
$this->token("access_token_secret", $tokens['oauth_token_secret']);
// set user as logged in to the current provider
$this->setUserConnected();
}
}

View File

@@ -1,184 +1,184 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OAuth 2 based service provider, Hybrid_Provider_Model_OAuth2
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have to implement
* at least 2 methods:
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
*
* Hybrid_Provider_Model_OAuth2 use OAuth2Client v0.1 which can be found on
* Hybrid/thirdparty/OAuth/OAuth2Client.php
*/
class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model {
/**
* Default permissions
* @var string
*/
public $scope = "";
/**
* Provider API wrapper
* @var OAuth2Client
*/
public $api = null;
/**
* Try to get the error message from provider api
*
* @param int $code Error code
* @return string
*/
function errorMessageByStatus($code = null) {
$http_status_codes = array(
200 => "OK: Success!",
304 => "Not Modified: There was no new data to return.",
400 => "Bad Request: The request was invalid.",
401 => "Unauthorized.",
403 => "Forbidden: The request is understood, but it has been refused.",
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
406 => "Not Acceptable.",
500 => "Internal Server Error: Something is broken.",
502 => "Bad Gateway.",
503 => "Service Unavailable."
);
if (!$code && $this->api) {
$code = $this->api->http_code;
}
if (isset($http_status_codes[$code])) {
return $code . " " . $http_status_codes[$code];
}
}
/**
* Adapter initializer
*/
function initialize() {
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
// override requested scope
if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
$this->scope = $this->config["scope"];
}
// include OAuth2 client
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth2Client.php";
// create a new OAuth2 client instance
$this->api = new OAuth2Client($this->config["keys"]["id"], $this->config["keys"]["secret"], $this->endpoint, $this->compressed);
// If we have an access token, set it
if ($this->token("access_token")) {
$this->api->access_token = $this->token("access_token");
$this->api->refresh_token = $this->token("refresh_token");
$this->api->access_token_expires_in = $this->token("expires_in");
$this->api->access_token_expires_at = $this->token("expires_at");
}
// Set curl proxy if exist
if (isset(Hybrid_Auth::$config["proxy"])) {
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
// redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl(array("scope" => $this->scope)));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$error = (array_key_exists('error', $_REQUEST)) ? $_REQUEST['error'] : "";
// check for errors
if ($error) {
throw new Exception("Authentication failed! {$this->providerId} returned an error: $error", 5);
}
// try to authenticate user
$code = (array_key_exists('code', $_REQUEST)) ? $_REQUEST['code'] : "";
try {
$this->api->authenticate($code);
} catch (Exception $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: " . $e->getMessage(), 6);
}
// check if authenticated
if (!$this->api->access_token) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// store tokens
$this->token("access_token", $this->api->access_token);
$this->token("refresh_token", $this->api->refresh_token);
$this->token("expires_in", $this->api->access_token_expires_in);
$this->token("expires_at", $this->api->access_token_expires_at);
// set user connected locally
$this->setUserConnected();
}
/**
* {@inheritdoc}
*/
function refreshToken() {
// have an access token?
if ($this->api->access_token) {
// have to refresh?
if ($this->api->refresh_token && $this->api->access_token_expires_at) {
// expired?
if ($this->api->access_token_expires_at <= time()) {
$response = $this->api->refreshToken(array("refresh_token" => $this->api->refresh_token));
if (!isset($response->access_token) || !$response->access_token) {
// set the user as disconnected at this point and throw an exception
$this->setUserUnconnected();
throw new Exception("The Authorization Service has return an invalid response while requesting a new access token. " . (string) $response->error);
}
// set new access_token
$this->api->access_token = $response->access_token;
if (isset($response->refresh_token))
$this->api->refresh_token = $response->refresh_token;
if (isset($response->expires_in)) {
$this->api->access_token_expires_in = $response->expires_in;
// even given by some idp, we should calculate this
$this->api->access_token_expires_at = time() + $response->expires_in;
}
}
}
// re store tokens
$this->token("access_token", $this->api->access_token);
$this->token("refresh_token", $this->api->refresh_token);
$this->token("expires_in", $this->api->access_token_expires_in);
$this->token("expires_at", $this->api->access_token_expires_at);
}
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OAuth 2 based service provider, Hybrid_Provider_Model_OAuth2
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have to implement
* at least 2 methods:
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
*
* Hybrid_Provider_Model_OAuth2 use OAuth2Client v0.1 which can be found on
* Hybrid/thirdparty/OAuth/OAuth2Client.php
*/
class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model {
/**
* Default permissions
* @var string
*/
public $scope = "";
/**
* Provider API wrapper
* @var OAuth2Client
*/
public $api = null;
/**
* Try to get the error message from provider api
*
* @param int $code Error code
* @return string
*/
function errorMessageByStatus($code = null) {
$http_status_codes = array(
200 => "OK: Success!",
304 => "Not Modified: There was no new data to return.",
400 => "Bad Request: The request was invalid.",
401 => "Unauthorized.",
403 => "Forbidden: The request is understood, but it has been refused.",
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
406 => "Not Acceptable.",
500 => "Internal Server Error: Something is broken.",
502 => "Bad Gateway.",
503 => "Service Unavailable."
);
if (!$code && $this->api) {
$code = $this->api->http_code;
}
if (isset($http_status_codes[$code])) {
return $code . " " . $http_status_codes[$code];
}
}
/**
* Adapter initializer
*/
function initialize() {
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
// override requested scope
if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
$this->scope = $this->config["scope"];
}
// include OAuth2 client
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth2Client.php";
// create a new OAuth2 client instance
$this->api = new OAuth2Client($this->config["keys"]["id"], $this->config["keys"]["secret"], $this->endpoint, $this->compressed);
// If we have an access token, set it
if ($this->token("access_token")) {
$this->api->access_token = $this->token("access_token");
$this->api->refresh_token = $this->token("refresh_token");
$this->api->access_token_expires_in = $this->token("expires_in");
$this->api->access_token_expires_at = $this->token("expires_at");
}
// Set curl proxy if exist
if (isset(Hybrid_Auth::$config["proxy"])) {
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
// redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl(array("scope" => $this->scope)));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$error = (array_key_exists('error', $_REQUEST)) ? $_REQUEST['error'] : "";
// check for errors
if ($error) {
throw new Exception("Authentication failed! {$this->providerId} returned an error: $error", 5);
}
// try to authenticate user
$code = (array_key_exists('code', $_REQUEST)) ? $_REQUEST['code'] : "";
try {
$this->api->authenticate($code);
} catch (Exception $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: " . $e->getMessage(), 6);
}
// check if authenticated
if (!$this->api->access_token) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// store tokens
$this->token("access_token", $this->api->access_token);
$this->token("refresh_token", $this->api->refresh_token);
$this->token("expires_in", $this->api->access_token_expires_in);
$this->token("expires_at", $this->api->access_token_expires_at);
// set user connected locally
$this->setUserConnected();
}
/**
* {@inheritdoc}
*/
function refreshToken() {
// have an access token?
if ($this->api->access_token) {
// have to refresh?
if ($this->api->refresh_token && $this->api->access_token_expires_at) {
// expired?
if ($this->api->access_token_expires_at <= time()) {
$response = $this->api->refreshToken(array("refresh_token" => $this->api->refresh_token));
if (!isset($response->access_token) || !$response->access_token) {
// set the user as disconnected at this point and throw an exception
$this->setUserUnconnected();
throw new Exception("The Authorization Service has return an invalid response while requesting a new access token. " . (string) $response->error);
}
// set new access_token
$this->api->access_token = $response->access_token;
if (isset($response->refresh_token))
$this->api->refresh_token = $response->refresh_token;
if (isset($response->expires_in)) {
$this->api->access_token_expires_in = $response->expires_in;
// even given by some idp, we should calculate this
$this->api->access_token_expires_at = time() + $response->expires_in;
}
}
}
// re store tokens
$this->token("access_token", $this->api->access_token);
$this->token("refresh_token", $this->api->refresh_token);
$this->token("expires_in", $this->api->access_token_expires_in);
$this->token("expires_at", $this->api->access_token_expires_at);
}
}
}

View File

@@ -1,170 +1,170 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OpenID based service provider, Hybrid_Provider_Model_OpenID
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have only to define
* the provider identifier : <code>public $openidIdentifier = ""; </code>
*
* Hybrid_Provider_Model_OpenID use LightOpenID lib which can be found on
* Hybrid/thirdparty/OpenID/LightOpenID.php
*/
class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model {
/**
* Provider API client
* @var LightOpenID
*/
public $api = null;
/**
* Openid provider identifier
* @var string
*/
public $openidIdentifier = "";
/**
* {@inheritdoc}
*/
function initialize() {
if (isset($this->params["openid_identifier"])) {
$this->openidIdentifier = $this->params["openid_identifier"];
}
// include LightOpenID lib
require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
// An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy']) ? Hybrid_Auth::$config['proxy'] : '';
$hostPort = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_PORT);
$hostUrl = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_HOST);
// Check for port on url
if ($hostPort) {
$hostUrl .= ':' . $hostPort;
}
$this->api = new LightOpenID($hostUrl, Hybrid_Auth::$config["proxy"]);
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (empty($this->openidIdentifier)) {
throw new Exception("OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4);
}
$this->api->identity = $this->openidIdentifier;
$this->api->returnUrl = $this->endpoint;
$this->api->required = array(
'namePerson/first',
'namePerson/last',
'namePerson/friendly',
'namePerson',
'contact/email',
'birthDate',
'birthDate/birthDay',
'birthDate/birthMonth',
'birthDate/birthYear',
'person/gender',
'pref/language',
'contact/postalCode/home',
'contact/city/home',
'contact/country/home',
'media/image/default',
);
# redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authUrl());
}
/**
* {@inheritdoc}
*/
function loginFinish() {
# if user don't grant access of their data to your site, halt with an Exception
if ($this->api->mode == 'cancel') {
throw new Exception("Authentication failed! User has canceled authentication!", 5);
}
# if something goes wrong
if (!$this->api->validate()) {
throw new Exception("Authentication failed. Invalid request received!", 5);
}
# fetch received user data
$response = $this->api->getAttributes();
# store the user profile
$this->user->profile->identifier = $this->api->identity;
$this->user->profile->firstName = (array_key_exists("namePerson/first", $response)) ? $response["namePerson/first"] : "";
$this->user->profile->lastName = (array_key_exists("namePerson/last", $response)) ? $response["namePerson/last"] : "";
$this->user->profile->displayName = (array_key_exists("namePerson", $response)) ? $response["namePerson"] : "";
$this->user->profile->email = (array_key_exists("contact/email", $response)) ? $response["contact/email"] : "";
$this->user->profile->language = (array_key_exists("pref/language", $response)) ? $response["pref/language"] : "";
$this->user->profile->country = (array_key_exists("contact/country/home", $response)) ? $response["contact/country/home"] : "";
$this->user->profile->zip = (array_key_exists("contact/postalCode/home", $response)) ? $response["contact/postalCode/home"] : "";
$this->user->profile->gender = (array_key_exists("person/gender", $response)) ? $response["person/gender"] : "";
$this->user->profile->photoURL = (array_key_exists("media/image/default", $response)) ? $response["media/image/default"] : "";
$this->user->profile->birthDay = (array_key_exists("birthDate/birthDay", $response)) ? $response["birthDate/birthDay"] : "";
$this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth", $response)) ? $response["birthDate/birthMonth"] : "";
$this->user->profile->birthYear = (array_key_exists("birthDate/birthDate", $response)) ? $response["birthDate/birthDate"] : "";
if (isset($response['namePerson/friendly']) && !empty($response['namePerson/friendly']) && !$this->user->profile->displayName) {
$this->user->profile->displayName = $response["namePerson/friendly"];
}
if (isset($response['birthDate']) && !empty($response['birthDate']) && !$this->user->profile->birthDay) {
list( $birthday_year, $birthday_month, $birthday_day ) = $response['birthDate'];
$this->user->profile->birthDay = (int) $birthday_day;
$this->user->profile->birthMonth = (int) $birthday_month;
$this->user->profile->birthYear = (int) $birthday_year;
}
if (!$this->user->profile->displayName) {
$this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
}
if ($this->user->profile->gender == "f") {
$this->user->profile->gender = "female";
}
if ($this->user->profile->gender == "m") {
$this->user->profile->gender = "male";
}
// set user as logged in
$this->setUserConnected();
// with openid providers we get the user profile only once, so store it
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
// try to get the user profile from stored data
$this->user = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user");
// if not found
if (!is_object($this->user)) {
throw new Exception("User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6);
}
return $this->user->profile;
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* To implement an OpenID based service provider, Hybrid_Provider_Model_OpenID
* can be used to save the hassle of the authentication flow.
*
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have only to define
* the provider identifier : <code>public $openidIdentifier = ""; </code>
*
* Hybrid_Provider_Model_OpenID use LightOpenID lib which can be found on
* Hybrid/thirdparty/OpenID/LightOpenID.php
*/
class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model {
/**
* Provider API client
* @var LightOpenID
*/
public $api = null;
/**
* Openid provider identifier
* @var string
*/
public $openidIdentifier = "";
/**
* {@inheritdoc}
*/
function initialize() {
if (isset($this->params["openid_identifier"])) {
$this->openidIdentifier = $this->params["openid_identifier"];
}
// include LightOpenID lib
require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
// An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy']) ? Hybrid_Auth::$config['proxy'] : '';
$hostPort = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_PORT);
$hostUrl = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_HOST);
// Check for port on url
if ($hostPort) {
$hostUrl .= ':' . $hostPort;
}
$this->api = new LightOpenID($hostUrl, Hybrid_Auth::$config["proxy"]);
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (empty($this->openidIdentifier)) {
throw new Exception("OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4);
}
$this->api->identity = $this->openidIdentifier;
$this->api->returnUrl = $this->endpoint;
$this->api->required = array(
'namePerson/first',
'namePerson/last',
'namePerson/friendly',
'namePerson',
'contact/email',
'birthDate',
'birthDate/birthDay',
'birthDate/birthMonth',
'birthDate/birthYear',
'person/gender',
'pref/language',
'contact/postalCode/home',
'contact/city/home',
'contact/country/home',
'media/image/default',
);
# redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authUrl());
}
/**
* {@inheritdoc}
*/
function loginFinish() {
# if user don't grant access of their data to your site, halt with an Exception
if ($this->api->mode == 'cancel') {
throw new Exception("Authentication failed! User has canceled authentication!", 5);
}
# if something goes wrong
if (!$this->api->validate()) {
throw new Exception("Authentication failed. Invalid request received!", 5);
}
# fetch received user data
$response = $this->api->getAttributes();
# store the user profile
$this->user->profile->identifier = $this->api->identity;
$this->user->profile->firstName = (array_key_exists("namePerson/first", $response)) ? $response["namePerson/first"] : "";
$this->user->profile->lastName = (array_key_exists("namePerson/last", $response)) ? $response["namePerson/last"] : "";
$this->user->profile->displayName = (array_key_exists("namePerson", $response)) ? $response["namePerson"] : "";
$this->user->profile->email = (array_key_exists("contact/email", $response)) ? $response["contact/email"] : "";
$this->user->profile->language = (array_key_exists("pref/language", $response)) ? $response["pref/language"] : "";
$this->user->profile->country = (array_key_exists("contact/country/home", $response)) ? $response["contact/country/home"] : "";
$this->user->profile->zip = (array_key_exists("contact/postalCode/home", $response)) ? $response["contact/postalCode/home"] : "";
$this->user->profile->gender = (array_key_exists("person/gender", $response)) ? $response["person/gender"] : "";
$this->user->profile->photoURL = (array_key_exists("media/image/default", $response)) ? $response["media/image/default"] : "";
$this->user->profile->birthDay = (array_key_exists("birthDate/birthDay", $response)) ? $response["birthDate/birthDay"] : "";
$this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth", $response)) ? $response["birthDate/birthMonth"] : "";
$this->user->profile->birthYear = (array_key_exists("birthDate/birthDate", $response)) ? $response["birthDate/birthDate"] : "";
if (isset($response['namePerson/friendly']) && !empty($response['namePerson/friendly']) && !$this->user->profile->displayName) {
$this->user->profile->displayName = $response["namePerson/friendly"];
}
if (isset($response['birthDate']) && !empty($response['birthDate']) && !$this->user->profile->birthDay) {
list( $birthday_year, $birthday_month, $birthday_day ) = $response['birthDate'];
$this->user->profile->birthDay = (int) $birthday_day;
$this->user->profile->birthMonth = (int) $birthday_month;
$this->user->profile->birthYear = (int) $birthday_year;
}
if (!$this->user->profile->displayName) {
$this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
}
if ($this->user->profile->gender == "f") {
$this->user->profile->gender = "female";
}
if ($this->user->profile->gender == "m") {
$this->user->profile->gender = "male";
}
// set user as logged in
$this->setUserConnected();
// with openid providers we get the user profile only once, so store it
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
// try to get the user profile from stored data
$this->user = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user");
// if not found
if (!is_object($this->user)) {
throw new Exception("User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6);
}
return $this->user->profile;
}
}

View File

@@ -1,18 +1,18 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_AOL provider adapter based on OpenID protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_AOL.html
*/
class Hybrid_Providers_AOL extends Hybrid_Provider_Model_OpenID {
var $openidIdentifier = "http://openid.aol.com/";
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_AOL provider adapter based on OpenID protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_AOL.html
*/
class Hybrid_Providers_AOL extends Hybrid_Provider_Model_OpenID {
var $openidIdentifier = "http://openid.aol.com/";
}

View File

@@ -1,406 +1,406 @@
<?php
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook as FacebookSDK;
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Facebook provider adapter based on OAuth2 protocol
* Hybrid_Providers_Facebook use the Facebook PHP SDK created by Facebook
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html
*/
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
/**
* Default permissions, and a lot of them. You can change them from the configuration by setting the scope to what you want/need.
* For a complete list see: https://developers.facebook.com/docs/facebook-login/permissions
*
* @link https://developers.facebook.com/docs/facebook-login/permissions
* @var array $scope
*/
public $scope = ['email', 'user_about_me', 'user_birthday', 'user_hometown', 'user_location', 'user_website', 'publish_actions', 'read_custom_friendlists'];
/**
* Provider API client
*
* @var \Facebook\Facebook
*/
public $api;
public $useSafeUrls = true;
/**
* {@inheritdoc}
*/
function initialize() {
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
if (isset($this->config['scope'])) {
$scope = $this->config['scope'];
if (is_string($scope)) {
$scope = explode(",", $scope);
}
$scope = array_map('trim', $scope);
$this->scope = $scope;
}
$trustForwarded = isset($this->config['trustForwarded']) ? (bool)$this->config['trustForwarded'] : false;
// Check if there is Graph SDK in thirdparty/Facebook.
if (file_exists(Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php")) {
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php";
}
else {
// If Composer install was executed, try to find autoload.php.
$vendorDir = dirname(Hybrid_Auth::$config['path_base']);
do {
if (file_exists($vendorDir . "/vendor/autoload.php")) {
require_once $vendorDir . "/vendor/autoload.php";
break;
}
} while (($vendorDir = dirname($vendorDir)) !== '/');
}
$this->api = new FacebookSDK([
'app_id' => $this->config["keys"]["id"],
'app_secret' => $this->config["keys"]["secret"],
'default_graph_version' => 'v2.8',
'trustForwarded' => $trustForwarded,
]);
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$this->endpoint = $this->params['login_done'];
$helper = $this->api->getRedirectLoginHelper();
// Use re-request, because this will trigger permissions window if not all permissions are granted.
$url = $helper->getReRequestUrl($this->endpoint, $this->scope);
// Redirect to Facebook
Hybrid_Auth::redirect($url);
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$helper = $this->api->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken($this->params['login_done']);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
throw new Hybrid_Exception('Facebook Graph returned an error: ' . $e->getMessage());
} catch (Facebook\Exceptions\FacebookSDKException $e) {
throw new Hybrid_Exception('Facebook SDK returned an error: ' . $e->getMessage());
}
if (!isset($accessToken)) {
if ($helper->getError()) {
throw new Hybrid_Exception(sprintf("Could not authorize user, reason: %s (%d)", $helper->getErrorDescription(), $helper->getErrorCode()));
} else {
throw new Hybrid_Exception("Could not authorize user. Bad request");
}
}
try {
// Validate token
$oAuth2Client = $this->api->getOAuth2Client();
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
$tokenMetadata->validateAppId($this->config["keys"]["id"]);
$tokenMetadata->validateExpiration();
// Exchanges a short-lived access token for a long-lived one
if (!$accessToken->isLongLived()) {
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
}
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception($e->getMessage(), 0, $e);
}
$this->setUserConnected();
$this->token("access_token", $accessToken->getValue());
}
/**
* {@inheritdoc}
*/
function logout() {
parent::logout();
}
/**
* Update user status
*
* @param mixed $status An array describing the status, or string
* @param string $pageid (optional) User page id
* @return array
* @throw Exception
*/
function setUserStatus($status, $pageid = null) {
if (!is_array($status)) {
$status = array('message' => $status);
}
$access_token = null;
if (is_null($pageid)) {
$pageid = 'me';
$access_token = $this->token('access_token');
// if post on page, get access_token page
} else {
foreach ($this->getUserPages(true) as $p) {
if (isset($p['id']) && intval($p['id']) == intval($pageid)) {
$access_token = $p['access_token'];
break;
}
}
if (is_null($access_token)) {
throw new Exception("Update user page failed, page not found or not writable!");
}
}
try {
$response = $this->api->post('/' . $pageid . '/feed', $status, $access_token);
} catch (FacebookSDKException $e) {
throw new Exception("Update user status failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
}
return $response;
}
/**
* {@inheridoc}
*/
function getUserPages($writableonly = false) {
if (( isset($this->config['scope']) && strpos($this->config['scope'], 'manage_pages') === false ) || (!isset($this->config['scope']) && strpos($this->scope, 'manage_pages') === false ))
throw new Exception("User status requires manage_page permission!");
try {
$pages = $this->api->get("/me/accounts", $this->token('access_token'));
$pages = $pages->getDecodedBody();
} catch (FacebookApiException $e) {
throw new Exception("Cannot retrieve user pages! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!isset($pages['data'])) {
return array();
}
if (!$writableonly) {
return $pages['data'];
}
$wrpages = array();
foreach ($pages['data'] as $p) {
if (isset($p['perms']) && in_array('CREATE_CONTENT', $p['perms'])) {
$wrpages[] = $p;
}
}
return $wrpages;
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
try {
$fields = [
'id',
'name',
'first_name',
'last_name',
'link',
'website',
'gender',
'locale',
'about',
'email',
'hometown',
'location',
'birthday'
];
$response = $this->api->get('/me?fields=' . implode(',', $fields), $this->token('access_token'));
$data = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
}
// Store the user profile.
$this->user->profile->identifier = (array_key_exists('id', $data)) ? $data['id'] : "";
$this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->firstName = (array_key_exists('first_name', $data)) ? $data['first_name'] : "";
$this->user->profile->lastName = (array_key_exists('last_name', $data)) ? $data['last_name'] : "";
$this->user->profile->photoURL = $this->getUserPhoto($this->user->profile->identifier);
$this->user->profile->profileURL = (array_key_exists('link', $data)) ? $data['link'] : "";
$this->user->profile->webSiteURL = (array_key_exists('website', $data)) ? $data['website'] : "";
$this->user->profile->gender = (array_key_exists('gender', $data)) ? $data['gender'] : "";
$this->user->profile->language = (array_key_exists('locale', $data)) ? $data['locale'] : "";
$this->user->profile->description = (array_key_exists('about', $data)) ? $data['about'] : "";
$this->user->profile->email = (array_key_exists('email', $data)) ? $data['email'] : "";
$this->user->profile->emailVerified = (array_key_exists('email', $data)) ? $data['email'] : "";
$this->user->profile->region = (array_key_exists("location", $data) && array_key_exists("name", $data['location'])) ? $data['location']["name"] : "";
if (!empty($this->user->profile->region)) {
$regionArr = explode(',', $this->user->profile->region);
if (count($regionArr) > 1) {
$this->user->profile->city = trim($regionArr[0]);
$this->user->profile->country = trim(end($regionArr));
}
}
if (array_key_exists('birthday', $data)) {
$birtydayPieces = explode('/', $data['birthday']);
if (count($birtydayPieces) == 1) {
$this->user->profile->birthYear = (int)$birtydayPieces[0];
} elseif (count($birtydayPieces) == 2) {
$this->user->profile->birthMonth = (int)$birtydayPieces[0];
$this->user->profile->birthDay = (int)$birtydayPieces[1];
} elseif (count($birtydayPieces) == 3) {
$this->user->profile->birthMonth = (int)$birtydayPieces[0];
$this->user->profile->birthDay = (int)$birtydayPieces[1];
$this->user->profile->birthYear = (int)$birtydayPieces[2];
}
}
return $this->user->profile;
}
/**
* Since the Graph API 2.0, the /friends endpoint only returns friend that also use your Facebook app.
* {@inheritdoc}
*/
function getUserContacts() {
$apiCall = '?fields=link,name';
$returnedContacts = [];
$pagedList = true;
while ($pagedList) {
try {
$response = $this->api->get('/me/friends' . $apiCall, $this->token('access_token'));
$response = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception("User contacts request failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
}
// Prepare the next call if paging links have been returned
if (array_key_exists('paging', $response) && array_key_exists('next', $response['paging'])) {
$pagedList = true;
$next_page = explode('friends', $response['paging']['next']);
$apiCall = $next_page[1];
} else {
$pagedList = false;
}
// Add the new page contacts
$returnedContacts = array_merge($returnedContacts, $response['data']);
}
$contacts = [];
foreach ($returnedContacts as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (array_key_exists("id", $item)) ? $item["id"] : "";
$uc->displayName = (array_key_exists("name", $item)) ? $item["name"] : "";
$uc->profileURL = (array_key_exists("link", $item)) ? $item["link"] : "https://www.facebook.com/profile.php?id=" . $uc->identifier;
$uc->photoURL = $this->getUserPhoto($uc->identifier);
$contacts[] = $uc;
}
return $contacts;
}
/**
* Load the user latest activity, needs 'read_stream' permission
*
* @param string $stream Which activity to fetch:
* - timeline : all the stream
* - me : the user activity only
* {@inheritdoc}
*/
function getUserActivity($stream = 'timeline') {
try {
if ($stream == "me") {
$response = $this->api->get('/me/feed', $this->token('access_token'));
} else {
$response = $this->api->get('/me/home', $this->token('access_token'));
}
$response = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception("User activity stream request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!$response || !count($response['data'])) {
return [];
}
$activities = [];
foreach ($response['data'] as $item) {
$ua = new Hybrid_User_Activity();
$ua->id = (array_key_exists("id", $item)) ? $item["id"] : "";
$ua->date = (array_key_exists("created_time", $item)) ? strtotime($item["created_time"]) : "";
if ($item["type"] == "video") {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if ($item["type"] == "link") {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if (empty($ua->text) && isset($item["story"])) {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if (empty($ua->text) && isset($item["message"])) {
$ua->text = (array_key_exists("message", $item)) ? $item["message"] : "";
}
if (!empty($ua->text)) {
$ua->user->identifier = (array_key_exists("id", $item["from"])) ? $item["from"]["id"] : "";
$ua->user->displayName = (array_key_exists("name", $item["from"])) ? $item["from"]["name"] : "";
$ua->user->profileURL = "https://www.facebook.com/profile.php?id=" . $ua->user->identifier;
$ua->user->photoURL = $this->getUserPhoto($ua->user->identifier);
$activities[] = $ua;
}
}
return $activities;
}
/**
* Returns a photo URL for give user.
*
* @param string $id
* The User ID.
*
* @return string
* A photo URL.
*/
function getUserPhoto($id) {
$photo_size = isset($this->config['photo_size']) ? $this->config['photo_size'] : 150;
return "https://graph.facebook.com/{$id}/picture?width={$photo_size}&height={$photo_size}";
}
}
<?php
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Facebook as FacebookSDK;
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Facebook provider adapter based on OAuth2 protocol
* Hybrid_Providers_Facebook use the Facebook PHP SDK created by Facebook
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html
*/
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
/**
* Default permissions, and a lot of them. You can change them from the configuration by setting the scope to what you want/need.
* For a complete list see: https://developers.facebook.com/docs/facebook-login/permissions
*
* @link https://developers.facebook.com/docs/facebook-login/permissions
* @var array $scope
*/
public $scope = ['email', 'user_about_me', 'user_birthday', 'user_hometown', 'user_location', 'user_website', 'publish_actions', 'read_custom_friendlists'];
/**
* Provider API client
*
* @var \Facebook\Facebook
*/
public $api;
public $useSafeUrls = true;
/**
* {@inheritdoc}
*/
function initialize() {
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
if (isset($this->config['scope'])) {
$scope = $this->config['scope'];
if (is_string($scope)) {
$scope = explode(",", $scope);
}
$scope = array_map('trim', $scope);
$this->scope = $scope;
}
$trustForwarded = isset($this->config['trustForwarded']) ? (bool)$this->config['trustForwarded'] : false;
// Check if there is Graph SDK in thirdparty/Facebook.
if (file_exists(Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php")) {
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php";
}
else {
// If Composer install was executed, try to find autoload.php.
$vendorDir = dirname(Hybrid_Auth::$config['path_base']);
do {
if (file_exists($vendorDir . "/vendor/autoload.php")) {
require_once $vendorDir . "/vendor/autoload.php";
break;
}
} while (($vendorDir = dirname($vendorDir)) !== '/');
}
$this->api = new FacebookSDK([
'app_id' => $this->config["keys"]["id"],
'app_secret' => $this->config["keys"]["secret"],
'default_graph_version' => 'v2.8',
'trustForwarded' => $trustForwarded,
]);
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$this->endpoint = $this->params['login_done'];
$helper = $this->api->getRedirectLoginHelper();
// Use re-request, because this will trigger permissions window if not all permissions are granted.
$url = $helper->getReRequestUrl($this->endpoint, $this->scope);
// Redirect to Facebook
Hybrid_Auth::redirect($url);
}
/**
* {@inheritdoc}
*/
function loginFinish() {
$helper = $this->api->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken($this->params['login_done']);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
throw new Hybrid_Exception('Facebook Graph returned an error: ' . $e->getMessage());
} catch (Facebook\Exceptions\FacebookSDKException $e) {
throw new Hybrid_Exception('Facebook SDK returned an error: ' . $e->getMessage());
}
if (!isset($accessToken)) {
if ($helper->getError()) {
throw new Hybrid_Exception(sprintf("Could not authorize user, reason: %s (%d)", $helper->getErrorDescription(), $helper->getErrorCode()));
} else {
throw new Hybrid_Exception("Could not authorize user. Bad request");
}
}
try {
// Validate token
$oAuth2Client = $this->api->getOAuth2Client();
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
$tokenMetadata->validateAppId($this->config["keys"]["id"]);
$tokenMetadata->validateExpiration();
// Exchanges a short-lived access token for a long-lived one
if (!$accessToken->isLongLived()) {
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
}
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception($e->getMessage(), 0, $e);
}
$this->setUserConnected();
$this->token("access_token", $accessToken->getValue());
}
/**
* {@inheritdoc}
*/
function logout() {
parent::logout();
}
/**
* Update user status
*
* @param mixed $status An array describing the status, or string
* @param string $pageid (optional) User page id
* @return array
* @throw Exception
*/
function setUserStatus($status, $pageid = null) {
if (!is_array($status)) {
$status = array('message' => $status);
}
$access_token = null;
if (is_null($pageid)) {
$pageid = 'me';
$access_token = $this->token('access_token');
// if post on page, get access_token page
} else {
foreach ($this->getUserPages(true) as $p) {
if (isset($p['id']) && intval($p['id']) == intval($pageid)) {
$access_token = $p['access_token'];
break;
}
}
if (is_null($access_token)) {
throw new Exception("Update user page failed, page not found or not writable!");
}
}
try {
$response = $this->api->post('/' . $pageid . '/feed', $status, $access_token);
} catch (FacebookSDKException $e) {
throw new Exception("Update user status failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
}
return $response;
}
/**
* {@inheridoc}
*/
function getUserPages($writableonly = false) {
if (( isset($this->config['scope']) && strpos($this->config['scope'], 'manage_pages') === false ) || (!isset($this->config['scope']) && strpos($this->scope, 'manage_pages') === false ))
throw new Exception("User status requires manage_page permission!");
try {
$pages = $this->api->get("/me/accounts", $this->token('access_token'));
$pages = $pages->getDecodedBody();
} catch (FacebookApiException $e) {
throw new Exception("Cannot retrieve user pages! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!isset($pages['data'])) {
return array();
}
if (!$writableonly) {
return $pages['data'];
}
$wrpages = array();
foreach ($pages['data'] as $p) {
if (isset($p['perms']) && in_array('CREATE_CONTENT', $p['perms'])) {
$wrpages[] = $p;
}
}
return $wrpages;
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
try {
$fields = [
'id',
'name',
'first_name',
'last_name',
'link',
'website',
'gender',
'locale',
'about',
'email',
'hometown',
'location',
'birthday'
];
$response = $this->api->get('/me?fields=' . implode(',', $fields), $this->token('access_token'));
$data = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
}
// Store the user profile.
$this->user->profile->identifier = (array_key_exists('id', $data)) ? $data['id'] : "";
$this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->firstName = (array_key_exists('first_name', $data)) ? $data['first_name'] : "";
$this->user->profile->lastName = (array_key_exists('last_name', $data)) ? $data['last_name'] : "";
$this->user->profile->photoURL = $this->getUserPhoto($this->user->profile->identifier);
$this->user->profile->profileURL = (array_key_exists('link', $data)) ? $data['link'] : "";
$this->user->profile->webSiteURL = (array_key_exists('website', $data)) ? $data['website'] : "";
$this->user->profile->gender = (array_key_exists('gender', $data)) ? $data['gender'] : "";
$this->user->profile->language = (array_key_exists('locale', $data)) ? $data['locale'] : "";
$this->user->profile->description = (array_key_exists('about', $data)) ? $data['about'] : "";
$this->user->profile->email = (array_key_exists('email', $data)) ? $data['email'] : "";
$this->user->profile->emailVerified = (array_key_exists('email', $data)) ? $data['email'] : "";
$this->user->profile->region = (array_key_exists("location", $data) && array_key_exists("name", $data['location'])) ? $data['location']["name"] : "";
if (!empty($this->user->profile->region)) {
$regionArr = explode(',', $this->user->profile->region);
if (count($regionArr) > 1) {
$this->user->profile->city = trim($regionArr[0]);
$this->user->profile->country = trim(end($regionArr));
}
}
if (array_key_exists('birthday', $data)) {
$birtydayPieces = explode('/', $data['birthday']);
if (count($birtydayPieces) == 1) {
$this->user->profile->birthYear = (int)$birtydayPieces[0];
} elseif (count($birtydayPieces) == 2) {
$this->user->profile->birthMonth = (int)$birtydayPieces[0];
$this->user->profile->birthDay = (int)$birtydayPieces[1];
} elseif (count($birtydayPieces) == 3) {
$this->user->profile->birthMonth = (int)$birtydayPieces[0];
$this->user->profile->birthDay = (int)$birtydayPieces[1];
$this->user->profile->birthYear = (int)$birtydayPieces[2];
}
}
return $this->user->profile;
}
/**
* Since the Graph API 2.0, the /friends endpoint only returns friend that also use your Facebook app.
* {@inheritdoc}
*/
function getUserContacts() {
$apiCall = '?fields=link,name';
$returnedContacts = [];
$pagedList = true;
while ($pagedList) {
try {
$response = $this->api->get('/me/friends' . $apiCall, $this->token('access_token'));
$response = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception("User contacts request failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
}
// Prepare the next call if paging links have been returned
if (array_key_exists('paging', $response) && array_key_exists('next', $response['paging'])) {
$pagedList = true;
$next_page = explode('friends', $response['paging']['next']);
$apiCall = $next_page[1];
} else {
$pagedList = false;
}
// Add the new page contacts
$returnedContacts = array_merge($returnedContacts, $response['data']);
}
$contacts = [];
foreach ($returnedContacts as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (array_key_exists("id", $item)) ? $item["id"] : "";
$uc->displayName = (array_key_exists("name", $item)) ? $item["name"] : "";
$uc->profileURL = (array_key_exists("link", $item)) ? $item["link"] : "https://www.facebook.com/profile.php?id=" . $uc->identifier;
$uc->photoURL = $this->getUserPhoto($uc->identifier);
$contacts[] = $uc;
}
return $contacts;
}
/**
* Load the user latest activity, needs 'read_stream' permission
*
* @param string $stream Which activity to fetch:
* - timeline : all the stream
* - me : the user activity only
* {@inheritdoc}
*/
function getUserActivity($stream = 'timeline') {
try {
if ($stream == "me") {
$response = $this->api->get('/me/feed', $this->token('access_token'));
} else {
$response = $this->api->get('/me/home', $this->token('access_token'));
}
$response = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
throw new Hybrid_Exception("User activity stream request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!$response || !count($response['data'])) {
return [];
}
$activities = [];
foreach ($response['data'] as $item) {
$ua = new Hybrid_User_Activity();
$ua->id = (array_key_exists("id", $item)) ? $item["id"] : "";
$ua->date = (array_key_exists("created_time", $item)) ? strtotime($item["created_time"]) : "";
if ($item["type"] == "video") {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if ($item["type"] == "link") {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if (empty($ua->text) && isset($item["story"])) {
$ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
}
if (empty($ua->text) && isset($item["message"])) {
$ua->text = (array_key_exists("message", $item)) ? $item["message"] : "";
}
if (!empty($ua->text)) {
$ua->user->identifier = (array_key_exists("id", $item["from"])) ? $item["from"]["id"] : "";
$ua->user->displayName = (array_key_exists("name", $item["from"])) ? $item["from"]["name"] : "";
$ua->user->profileURL = "https://www.facebook.com/profile.php?id=" . $ua->user->identifier;
$ua->user->photoURL = $this->getUserPhoto($ua->user->identifier);
$activities[] = $ua;
}
}
return $activities;
}
/**
* Returns a photo URL for give user.
*
* @param string $id
* The User ID.
*
* @return string
* A photo URL.
*/
function getUserPhoto($id) {
$photo_size = isset($this->config['photo_size']) ? $this->config['photo_size'] : 150;
return "https://graph.facebook.com/{$id}/picture?width={$photo_size}&height={$photo_size}";
}
}

View File

@@ -1,121 +1,121 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Foursquare provider adapter based on OAuth2 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Foursquare.html
*/
/**
* Howto define profile photo size:
* - add params key into hybridauth config
* ...
* "Foursquare" => array (
* "enabled" => true,
* "keys" => ...,
* "params" => array( "photo_size" => "16x16" )
* ),
* ...
* - list of valid photo_size values is described here https://developer.foursquare.com/docs/responses/photo.html
* - default photo_size is 100x100
*/
class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2 {
private static $apiVersion = array("v" => "20120610");
private static $defPhotoSize = "100x100";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider apis end-points
$this->api->api_base_url = "https://api.foursquare.com/v2/";
$this->api->authorize_url = "https://foursquare.com/oauth2/authenticate";
$this->api->token_url = "https://foursquare.com/oauth2/access_token";
$this->api->sign_token_name = "oauth_token";
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$data = $this->api->api("users/self", "GET", Hybrid_Providers_Foursquare::$apiVersion);
if (!isset($data->response->user->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $data ), 6);
}
$data = $data->response->user;
$this->user->profile->identifier = $data->id;
$this->user->profile->firstName = $data->firstName;
$this->user->profile->lastName = $data->lastName;
$this->user->profile->displayName = $this->buildDisplayName($this->user->profile->firstName, $this->user->profile->lastName);
$this->user->profile->photoURL = $this->buildPhotoURL($data->photo->prefix, $data->photo->suffix);
$this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id;
$this->user->profile->gender = $data->gender;
$this->user->profile->city = $data->homeCity;
$this->user->profile->email = $data->contact->email;
$this->user->profile->emailVerified = $data->contact->email;
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
// refresh tokens if needed
$this->refreshToken();
//
$response = array();
$contacts = array();
try {
$response = $this->api->api("users/self/friends", "GET", Hybrid_Providers_Foursquare::$apiVersion);
} catch (Exception $e) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (isset($response) && $response->meta->code == 200) {
foreach ($response->response->friends->items as $contact) {
$uc = new Hybrid_User_Contact();
//
$uc->identifier = $contact->id;
//$uc->profileURL = ;
//$uc->webSiteURL = ;
$uc->photoURL = $this->buildPhotoURL($contact->photo->prefix, $contact->photo->suffix);
$uc->displayName = $this->buildDisplayName((isset($contact->firstName) ? ($contact->firstName) : ("")), (isset($contact->lastName) ? ($contact->lastName) : ("")));
//$uc->description = ;
$uc->email = (isset($contact->contact->email) ? ($contact->contact->email) : (""));
//
$contacts[] = $uc;
}
}
return $contacts;
}
/**
* {@inheritdoc}
*/
private function buildDisplayName($firstName, $lastName) {
return trim($firstName . " " . $lastName);
}
private function buildPhotoURL($prefix, $suffix) {
if (isset($prefix) && isset($suffix)) {
return $prefix . ((isset($this->config["params"]["photo_size"])) ? ($this->config["params"]["photo_size"]) : (Hybrid_Providers_Foursquare::$defPhotoSize)) . $suffix;
}
return ("");
}
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Foursquare provider adapter based on OAuth2 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Foursquare.html
*/
/**
* Howto define profile photo size:
* - add params key into hybridauth config
* ...
* "Foursquare" => array (
* "enabled" => true,
* "keys" => ...,
* "params" => array( "photo_size" => "16x16" )
* ),
* ...
* - list of valid photo_size values is described here https://developer.foursquare.com/docs/responses/photo.html
* - default photo_size is 100x100
*/
class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2 {
private static $apiVersion = array("v" => "20120610");
private static $defPhotoSize = "100x100";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider apis end-points
$this->api->api_base_url = "https://api.foursquare.com/v2/";
$this->api->authorize_url = "https://foursquare.com/oauth2/authenticate";
$this->api->token_url = "https://foursquare.com/oauth2/access_token";
$this->api->sign_token_name = "oauth_token";
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$data = $this->api->api("users/self", "GET", Hybrid_Providers_Foursquare::$apiVersion);
if (!isset($data->response->user->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $data ), 6);
}
$data = $data->response->user;
$this->user->profile->identifier = $data->id;
$this->user->profile->firstName = $data->firstName;
$this->user->profile->lastName = $data->lastName;
$this->user->profile->displayName = $this->buildDisplayName($this->user->profile->firstName, $this->user->profile->lastName);
$this->user->profile->photoURL = $this->buildPhotoURL($data->photo->prefix, $data->photo->suffix);
$this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id;
$this->user->profile->gender = $data->gender;
$this->user->profile->city = $data->homeCity;
$this->user->profile->email = $data->contact->email;
$this->user->profile->emailVerified = $data->contact->email;
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
// refresh tokens if needed
$this->refreshToken();
//
$response = array();
$contacts = array();
try {
$response = $this->api->api("users/self/friends", "GET", Hybrid_Providers_Foursquare::$apiVersion);
} catch (Exception $e) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (isset($response) && $response->meta->code == 200) {
foreach ($response->response->friends->items as $contact) {
$uc = new Hybrid_User_Contact();
//
$uc->identifier = $contact->id;
//$uc->profileURL = ;
//$uc->webSiteURL = ;
$uc->photoURL = $this->buildPhotoURL($contact->photo->prefix, $contact->photo->suffix);
$uc->displayName = $this->buildDisplayName((isset($contact->firstName) ? ($contact->firstName) : ("")), (isset($contact->lastName) ? ($contact->lastName) : ("")));
//$uc->description = ;
$uc->email = (isset($contact->contact->email) ? ($contact->contact->email) : (""));
//
$contacts[] = $uc;
}
}
return $contacts;
}
/**
* {@inheritdoc}
*/
private function buildDisplayName($firstName, $lastName) {
return trim($firstName . " " . $lastName);
}
private function buildPhotoURL($prefix, $suffix) {
if (isset($prefix) && isset($suffix)) {
return $prefix . ((isset($this->config["params"]["photo_size"])) ? ($this->config["params"]["photo_size"]) : (Hybrid_Providers_Foursquare::$defPhotoSize)) . $suffix;
}
return ("");
}
}

View File

@@ -1,306 +1,306 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Google provider adapter based on OAuth2 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html
*/
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
/**
* > more infos on google APIs: http://developer.google.com (official site)
* or here: http://discovery-check.appspot.com/ (unofficial but up to date)
* default permissions
* {@inheritdoc}
*/
public $scope = "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.emails.read https://www.google.com/m8/feeds/";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->authorize_url = "https://accounts.google.com/o/oauth2/auth";
$this->api->token_url = "https://accounts.google.com/o/oauth2/token";
$this->api->token_info_url = "https://www.googleapis.com/oauth2/v2/tokeninfo";
// Google POST methods require an access_token in the header
$this->api->curl_header = array("Authorization: OAuth " . $this->api->access_token);
// Override the redirect uri when it's set in the config parameters. This way we prevent
// redirect uri mismatches when authenticating with Google.
if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
$this->api->redirect_uri = $this->config['redirect_uri'];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$parameters = array("scope" => $this->scope, "access_type" => "offline");
$optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd", "state");
foreach ($optionals as $parameter) {
if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
$parameters[$parameter] = $this->config[$parameter];
}
if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
$this->scope = $this->config["scope"];
}
}
if (isset($this->config['force']) && $this->config['force'] === true) {
$parameters['approval_prompt'] = 'force';
}
Hybrid_Auth::redirect($this->api->authorizeUrl($parameters));
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
// refresh tokens if needed
$this->refreshToken();
// ask google api for user infos
if (strpos($this->scope, '/auth/plus.profile.emails.read') !== false) {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($verified->id) || isset($verified->error))
$verified = new stdClass();
} else {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me/openIdConnect");
if (!isset($verified->sub) || isset($verified->error))
$verified = new stdClass();
}
$response = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($response->id) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $response ), 6);
}
$this->user->profile->identifier = (property_exists($verified, 'id')) ? $verified->id : ((property_exists($response, 'id')) ? $response->id : "");
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name->givenName : "";
$this->user->profile->lastName = (property_exists($response, 'name')) ? $response->name->familyName : "";
$this->user->profile->displayName = (property_exists($response, 'displayName')) ? $response->displayName : "";
$this->user->profile->photoURL = (property_exists($response, 'image')) ? ((property_exists($response->image, 'url')) ? substr($response->image->url, 0, -2) . "200" : '') : '';
$this->user->profile->profileURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->description = (property_exists($response, 'aboutMe')) ? $response->aboutMe : "";
$this->user->profile->gender = (property_exists($response, 'gender')) ? $response->gender : "";
$this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : ((property_exists($verified, 'locale')) ? $verified->locale : "");
$this->user->profile->email = (property_exists($response, 'email')) ? $response->email : ((property_exists($verified, 'email')) ? $verified->email : "");
$this->user->profile->emailVerified = (property_exists($verified, 'email')) ? $verified->email : "";
if (property_exists($response, 'emails')) {
if (count($response->emails) == 1) {
$this->user->profile->email = $response->emails[0]->value;
} else {
foreach ($response->emails as $email) {
if ($email->type == 'account') {
$this->user->profile->email = $email->value;
break;
}
}
}
if (property_exists($verified, 'emails')) {
if (count($verified->emails) == 1) {
$this->user->profile->emailVerified = $verified->emails[0]->value;
} else {
foreach ($verified->emails as $email) {
if ($email->type == 'account') {
$this->user->profile->emailVerified = $email->value;
break;
}
}
}
}
}
$this->user->profile->phone = (property_exists($response, 'phone')) ? $response->phone : "";
$this->user->profile->country = (property_exists($response, 'country')) ? $response->country : "";
$this->user->profile->region = (property_exists($response, 'region')) ? $response->region : "";
$this->user->profile->zip = (property_exists($response, 'zip')) ? $response->zip : "";
if (property_exists($response, 'placesLived')) {
$this->user->profile->city = "";
$this->user->profile->address = "";
foreach ($response->placesLived as $c) {
if (property_exists($c, 'primary')) {
if ($c->primary == true) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
break;
}
} else {
if (property_exists($c, 'value')) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
}
}
}
}
// google API returns multiple urls, but a "website" only if it is verified
// see http://support.google.com/plus/answer/1713826?hl=en
if (property_exists($response, 'urls')) {
foreach ($response->urls as $u) {
if (property_exists($u, 'primary') && $u->primary == true)
$this->user->profile->webSiteURL = $u->value;
}
} else {
$this->user->profile->webSiteURL = '';
}
// google API returns age ranges min and/or max as of https://developers.google.com/+/web/api/rest/latest/people#resource
if (property_exists($response, 'ageRange')) {
if (property_exists($response->ageRange, 'min') && property_exists($response->ageRange, 'max')) {
$this->user->profile->age = $response->ageRange->min . ' - ' . $response->ageRange->max;
} else {
if (property_exists($response->ageRange, 'min')) {
$this->user->profile->age = '>= ' . $response->ageRange->min;
} else {
if (property_exists($response->ageRange, 'max')) {
$this->user->profile->age = '<= ' . $response->ageRange->max;
} else {
$this->user->profile->age = '';
}
}
}
} else {
$this->user->profile->age = '';
}
// google API returns birthdays only if a user set 'show in my account'
if (property_exists($response, 'birthday')) {
list($birthday_year, $birthday_month, $birthday_day) = explode('-', $response->birthday);
$this->user->profile->birthDay = (int) $birthday_day;
$this->user->profile->birthMonth = (int) $birthday_month;
$this->user->profile->birthYear = (int) $birthday_year;
} else {
$this->user->profile->birthDay = 0;
$this->user->profile->birthMonth = 0;
$this->user->profile->birthYear = 0;
}
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
// refresh tokens if needed
$this->refreshToken();
$contacts = array();
if (!isset($this->config['contacts_param'])) {
$this->config['contacts_param'] = array("max-results" => 500);
}
// Google Gmail and Android contacts
if (strpos($this->scope, '/m8/feeds/') !== false) {
$response = $this->api->api("https://www.google.com/m8/feeds/contacts/default/full?"
. http_build_query(array_merge(array('alt' => 'json'), $this->config['contacts_param'])));
if (!$response) {
return array();
}
if (isset($response->feed->entry)) {
foreach ($response->feed->entry as $idx => $entry) {
$uc = new Hybrid_User_Contact();
$uc->email = isset($entry->{'gd$email'}[0]->address) ? (string) $entry->{'gd$email'}[0]->address : '';
$uc->displayName = isset($entry->title->{'$t'}) ? (string) $entry->title->{'$t'} : '';
$uc->identifier = ($uc->email != '') ? $uc->email : '';
$uc->description = '';
if (property_exists($entry, 'link')) {
/**
* sign links with access_token
*/
if (is_array($entry->link)) {
foreach ($entry->link as $l) {
if (property_exists($l, 'gd$etag') && $l->type == "image/*") {
$uc->photoURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
} else if ($l->type == "self") {
$uc->profileURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
}
}
}
} else {
$uc->profileURL = '';
}
if (property_exists($response, 'website')) {
if (is_array($response->website)) {
foreach ($response->website as $w) {
if ($w->primary == true)
$uc->webSiteURL = $w->value;
}
} else {
$uc->webSiteURL = $response->website->value;
}
} else {
$uc->webSiteURL = '';
}
$contacts[] = $uc;
}
}
}
// Google social contacts
if (strpos($this->scope, '/auth/plus.login') !== false) {
$response = $this->api->api("https://www.googleapis.com/plus/v1/people/me/people/visible?"
. http_build_query($this->config['contacts_param']));
if (!$response) {
return array();
}
foreach ($response->items as $idx => $item) {
$uc = new Hybrid_User_Contact();
$uc->email = (property_exists($item, 'email')) ? $item->email : '';
$uc->displayName = (property_exists($item, 'displayName')) ? $item->displayName : '';
$uc->identifier = (property_exists($item, 'id')) ? $item->id : '';
$uc->description = (property_exists($item, 'objectType')) ? $item->objectType : '';
$uc->photoURL = (property_exists($item, 'image')) ? ((property_exists($item->image, 'url')) ? $item->image->url : '') : '';
$uc->profileURL = (property_exists($item, 'url')) ? $item->url : '';
$uc->webSiteURL = '';
$contacts[] = $uc;
}
}
return $contacts;
}
/**
* Add query parameters to the $url
*
* @param string $url URL
* @param array $params Parameters to add
* @return string
*/
function addUrlParam($url, array $params){
$query = parse_url($url, PHP_URL_QUERY);
// Returns the URL string with new parameters
if ($query) {
$url .= '&' . http_build_query($params);
} else {
$url .= '?' . http_build_query($params);
}
return $url;
}
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Google provider adapter based on OAuth2 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html
*/
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
/**
* > more infos on google APIs: http://developer.google.com (official site)
* or here: http://discovery-check.appspot.com/ (unofficial but up to date)
* default permissions
* {@inheritdoc}
*/
public $scope = "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.emails.read https://www.google.com/m8/feeds/";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->authorize_url = "https://accounts.google.com/o/oauth2/auth";
$this->api->token_url = "https://accounts.google.com/o/oauth2/token";
$this->api->token_info_url = "https://www.googleapis.com/oauth2/v2/tokeninfo";
// Google POST methods require an access_token in the header
$this->api->curl_header = array("Authorization: OAuth " . $this->api->access_token);
// Override the redirect uri when it's set in the config parameters. This way we prevent
// redirect uri mismatches when authenticating with Google.
if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
$this->api->redirect_uri = $this->config['redirect_uri'];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$parameters = array("scope" => $this->scope, "access_type" => "offline");
$optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd", "state");
foreach ($optionals as $parameter) {
if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
$parameters[$parameter] = $this->config[$parameter];
}
if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
$this->scope = $this->config["scope"];
}
}
if (isset($this->config['force']) && $this->config['force'] === true) {
$parameters['approval_prompt'] = 'force';
}
Hybrid_Auth::redirect($this->api->authorizeUrl($parameters));
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
// refresh tokens if needed
$this->refreshToken();
// ask google api for user infos
if (strpos($this->scope, '/auth/plus.profile.emails.read') !== false) {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($verified->id) || isset($verified->error))
$verified = new stdClass();
} else {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me/openIdConnect");
if (!isset($verified->sub) || isset($verified->error))
$verified = new stdClass();
}
$response = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($response->id) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $response ), 6);
}
$this->user->profile->identifier = (property_exists($verified, 'id')) ? $verified->id : ((property_exists($response, 'id')) ? $response->id : "");
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name->givenName : "";
$this->user->profile->lastName = (property_exists($response, 'name')) ? $response->name->familyName : "";
$this->user->profile->displayName = (property_exists($response, 'displayName')) ? $response->displayName : "";
$this->user->profile->photoURL = (property_exists($response, 'image')) ? ((property_exists($response->image, 'url')) ? substr($response->image->url, 0, -2) . "200" : '') : '';
$this->user->profile->profileURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->description = (property_exists($response, 'aboutMe')) ? $response->aboutMe : "";
$this->user->profile->gender = (property_exists($response, 'gender')) ? $response->gender : "";
$this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : ((property_exists($verified, 'locale')) ? $verified->locale : "");
$this->user->profile->email = (property_exists($response, 'email')) ? $response->email : ((property_exists($verified, 'email')) ? $verified->email : "");
$this->user->profile->emailVerified = (property_exists($verified, 'email')) ? $verified->email : "";
if (property_exists($response, 'emails')) {
if (count($response->emails) == 1) {
$this->user->profile->email = $response->emails[0]->value;
} else {
foreach ($response->emails as $email) {
if ($email->type == 'account') {
$this->user->profile->email = $email->value;
break;
}
}
}
if (property_exists($verified, 'emails')) {
if (count($verified->emails) == 1) {
$this->user->profile->emailVerified = $verified->emails[0]->value;
} else {
foreach ($verified->emails as $email) {
if ($email->type == 'account') {
$this->user->profile->emailVerified = $email->value;
break;
}
}
}
}
}
$this->user->profile->phone = (property_exists($response, 'phone')) ? $response->phone : "";
$this->user->profile->country = (property_exists($response, 'country')) ? $response->country : "";
$this->user->profile->region = (property_exists($response, 'region')) ? $response->region : "";
$this->user->profile->zip = (property_exists($response, 'zip')) ? $response->zip : "";
if (property_exists($response, 'placesLived')) {
$this->user->profile->city = "";
$this->user->profile->address = "";
foreach ($response->placesLived as $c) {
if (property_exists($c, 'primary')) {
if ($c->primary == true) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
break;
}
} else {
if (property_exists($c, 'value')) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
}
}
}
}
// google API returns multiple urls, but a "website" only if it is verified
// see http://support.google.com/plus/answer/1713826?hl=en
if (property_exists($response, 'urls')) {
foreach ($response->urls as $u) {
if (property_exists($u, 'primary') && $u->primary == true)
$this->user->profile->webSiteURL = $u->value;
}
} else {
$this->user->profile->webSiteURL = '';
}
// google API returns age ranges min and/or max as of https://developers.google.com/+/web/api/rest/latest/people#resource
if (property_exists($response, 'ageRange')) {
if (property_exists($response->ageRange, 'min') && property_exists($response->ageRange, 'max')) {
$this->user->profile->age = $response->ageRange->min . ' - ' . $response->ageRange->max;
} else {
if (property_exists($response->ageRange, 'min')) {
$this->user->profile->age = '>= ' . $response->ageRange->min;
} else {
if (property_exists($response->ageRange, 'max')) {
$this->user->profile->age = '<= ' . $response->ageRange->max;
} else {
$this->user->profile->age = '';
}
}
}
} else {
$this->user->profile->age = '';
}
// google API returns birthdays only if a user set 'show in my account'
if (property_exists($response, 'birthday')) {
list($birthday_year, $birthday_month, $birthday_day) = explode('-', $response->birthday);
$this->user->profile->birthDay = (int) $birthday_day;
$this->user->profile->birthMonth = (int) $birthday_month;
$this->user->profile->birthYear = (int) $birthday_year;
} else {
$this->user->profile->birthDay = 0;
$this->user->profile->birthMonth = 0;
$this->user->profile->birthYear = 0;
}
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
// refresh tokens if needed
$this->refreshToken();
$contacts = array();
if (!isset($this->config['contacts_param'])) {
$this->config['contacts_param'] = array("max-results" => 500);
}
// Google Gmail and Android contacts
if (strpos($this->scope, '/m8/feeds/') !== false) {
$response = $this->api->api("https://www.google.com/m8/feeds/contacts/default/full?"
. http_build_query(array_merge(array('alt' => 'json'), $this->config['contacts_param'])));
if (!$response) {
return array();
}
if (isset($response->feed->entry)) {
foreach ($response->feed->entry as $idx => $entry) {
$uc = new Hybrid_User_Contact();
$uc->email = isset($entry->{'gd$email'}[0]->address) ? (string) $entry->{'gd$email'}[0]->address : '';
$uc->displayName = isset($entry->title->{'$t'}) ? (string) $entry->title->{'$t'} : '';
$uc->identifier = ($uc->email != '') ? $uc->email : '';
$uc->description = '';
if (property_exists($entry, 'link')) {
/**
* sign links with access_token
*/
if (is_array($entry->link)) {
foreach ($entry->link as $l) {
if (property_exists($l, 'gd$etag') && $l->type == "image/*") {
$uc->photoURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
} else if ($l->type == "self") {
$uc->profileURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
}
}
}
} else {
$uc->profileURL = '';
}
if (property_exists($response, 'website')) {
if (is_array($response->website)) {
foreach ($response->website as $w) {
if ($w->primary == true)
$uc->webSiteURL = $w->value;
}
} else {
$uc->webSiteURL = $response->website->value;
}
} else {
$uc->webSiteURL = '';
}
$contacts[] = $uc;
}
}
}
// Google social contacts
if (strpos($this->scope, '/auth/plus.login') !== false) {
$response = $this->api->api("https://www.googleapis.com/plus/v1/people/me/people/visible?"
. http_build_query($this->config['contacts_param']));
if (!$response) {
return array();
}
foreach ($response->items as $idx => $item) {
$uc = new Hybrid_User_Contact();
$uc->email = (property_exists($item, 'email')) ? $item->email : '';
$uc->displayName = (property_exists($item, 'displayName')) ? $item->displayName : '';
$uc->identifier = (property_exists($item, 'id')) ? $item->id : '';
$uc->description = (property_exists($item, 'objectType')) ? $item->objectType : '';
$uc->photoURL = (property_exists($item, 'image')) ? ((property_exists($item->image, 'url')) ? $item->image->url : '') : '';
$uc->profileURL = (property_exists($item, 'url')) ? $item->url : '';
$uc->webSiteURL = '';
$contacts[] = $uc;
}
}
return $contacts;
}
/**
* Add query parameters to the $url
*
* @param string $url URL
* @param array $params Parameters to add
* @return string
*/
function addUrlParam($url, array $params){
$query = parse_url($url, PHP_URL_QUERY);
// Returns the URL string with new parameters
if ($query) {
$url .= '&' . http_build_query($params);
} else {
$url .= '?' . http_build_query($params);
}
return $url;
}
}

View File

@@ -1,40 +1,40 @@
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Google OpenID based
*
* Provided as a way to keep backward compatibility for Google OpenID based on HybridAuth <= 2.0.8
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html
*/
/**
* To replace the default google adapter, we should use this config instead:
*
* "Google" => array (
* "enabled" => true,
* "wrapper" => array( "path" => "Providers/GoogleOpenID.php", "class" => "Hybrid_Providers_Google" )
* )
*/
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OpenID
{
var $openidIdentifier = "https://www.google.com/accounts/o8/id";
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$this->user->profile->emailVerified = $this->user->profile->email;
// restore the user profile
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
}
}
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Google OpenID based
*
* Provided as a way to keep backward compatibility for Google OpenID based on HybridAuth <= 2.0.8
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html
*/
/**
* To replace the default google adapter, we should use this config instead:
*
* "Google" => array (
* "enabled" => true,
* "wrapper" => array( "path" => "Providers/GoogleOpenID.php", "class" => "Hybrid_Providers_Google" )
* )
*/
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OpenID
{
var $openidIdentifier = "https://www.google.com/accounts/o8/id";
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$this->user->profile->emailVerified = $this->user->profile->email;
// restore the user profile
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
}
}

View File

@@ -1,170 +1,170 @@
<?php
/* !
* Hybridauth
* https://hybridauth.github.io/hybridauth | https://github.com/hybridauth/hybridauth
* (c) 2017 Hybridauth authors | https://hybridauth.github.io/license.html
*/
/**
* Hybrid_Providers_LinkedIn OAuth2 provider adapter.
*/
class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
/**
* {@inheritdoc}
*/
public $scope = "r_basicprofile r_emailaddress";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points.
$this->api->api_base_url = "https://api.linkedin.com/v1/";
$this->api->authorize_url = "https://www.linkedin.com/oauth/v2/authorization";
$this->api->token_url = "https://www.linkedin.com/oauth/v2/accessToken";
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (is_array($this->scope)) {
$this->scope = implode(" ", $this->scope);
}
parent::loginBegin();
}
/**
* {@inheritdoc}
*
* @see https://developer.linkedin.com/docs/rest-api
*/
function getUserProfile() {
// Refresh tokens if needed.
$this->setHeaders("token");
$this->refreshToken();
// https://developer.linkedin.com/docs/fields.
$fields = isset($this->config["fields"]) ? $this->config["fields"] : [
"id",
"email-address",
"first-name",
"last-name",
"headline",
"location",
"industry",
"picture-url",
"public-profile-url",
];
$this->setHeaders();
$response = $this->api->get(
"people/~:(" . implode(",", $fields) . ")",
array(
"format" => "json",
)
);
if (!isset($response->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
}
$this->user->profile->identifier = isset($response->id) ? $response->id : "";
$this->user->profile->firstName = isset($response->firstName) ? $response->firstName : "";
$this->user->profile->lastName = isset($response->lastName) ? $response->lastName : "";
$this->user->profile->photoURL = isset($response->pictureUrl) ? $response->pictureUrl : "";
$this->user->profile->profileURL = isset($response->publicProfileUrl) ? $response->publicProfileUrl : "";
$this->user->profile->email = isset($response->emailAddress) ? $response->emailAddress : "";
$this->user->profile->description = isset($response->headline) ? $response->headline : "";
$this->user->profile->country = isset($response->location) ? $response->location->name : "";
$this->user->profile->emailVerified = $this->user->profile->email;
$this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
return $this->user->profile;
}
/**
* {@inheritdoc}
*
* @param array $status
* An associative array containing:
* - content: A collection of fields describing the shared content.
* - comment: A comment by the member to associated with the share.
* - visibility: A collection of visibility information about the share.
*
* @return object
* An object containing:
* - updateKey - A unique ID for the shared content posting that was just created.
* - updateUrl - A direct link to the newly shared content on LinkedIn.com that you can direct the user's web browser to.
* @throws Exception
* @see https://developer.linkedin.com/docs/share-on-linkedin
*/
function setUserStatus($status) {
// Refresh tokens if needed.
$this->setHeaders("token");
$this->refreshToken();
try {
// Define default visibility.
if (!isset($status["visibility"])) {
$status["visibility"]["code"] = "anyone";
}
$this->setHeaders("share");
$response = $this->api->post(
"people/~/shares?format=json",
array(
"body" => $status,
)
);
} catch (Exception $e) {
throw new Exception("Update user status failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!isset($response->updateKey)) {
throw new Exception("Update user status failed! {$this->providerId} returned an error: {$response->message}", $response->errorCode);
}
return $response;
}
/**
* Set correct request headers.
*
* @param string $api_type
* (optional) Specify api type.
*
* @return void
*/
private function setHeaders($api_type = null) {
$this->api->curl_header = array(
"Authorization: Bearer {$this->api->access_token}",
);
switch ($api_type) {
case "share":
$this->api->curl_header = array_merge(
$this->api->curl_header,
array(
"Content-Type: application/json",
"x-li-format: json",
)
);
break;
case "token":
$this->api->curl_header = array_merge(
$this->api->curl_header,
array(
"Content-Type: application/x-www-form-urlencoded",
)
);
break;
}
}
}
<?php
/* !
* Hybridauth
* https://hybridauth.github.io/hybridauth | https://github.com/hybridauth/hybridauth
* (c) 2017 Hybridauth authors | https://hybridauth.github.io/license.html
*/
/**
* Hybrid_Providers_LinkedIn OAuth2 provider adapter.
*/
class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
/**
* {@inheritdoc}
*/
public $scope = "r_basicprofile r_emailaddress";
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points.
$this->api->api_base_url = "https://api.linkedin.com/v1/";
$this->api->authorize_url = "https://www.linkedin.com/oauth/v2/authorization";
$this->api->token_url = "https://www.linkedin.com/oauth/v2/accessToken";
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (is_array($this->scope)) {
$this->scope = implode(" ", $this->scope);
}
parent::loginBegin();
}
/**
* {@inheritdoc}
*
* @see https://developer.linkedin.com/docs/rest-api
*/
function getUserProfile() {
// Refresh tokens if needed.
$this->setHeaders("token");
$this->refreshToken();
// https://developer.linkedin.com/docs/fields.
$fields = isset($this->config["fields"]) ? $this->config["fields"] : [
"id",
"email-address",
"first-name",
"last-name",
"headline",
"location",
"industry",
"picture-url",
"public-profile-url",
];
$this->setHeaders();
$response = $this->api->get(
"people/~:(" . implode(",", $fields) . ")",
array(
"format" => "json",
)
);
if (!isset($response->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
}
$this->user->profile->identifier = isset($response->id) ? $response->id : "";
$this->user->profile->firstName = isset($response->firstName) ? $response->firstName : "";
$this->user->profile->lastName = isset($response->lastName) ? $response->lastName : "";
$this->user->profile->photoURL = isset($response->pictureUrl) ? $response->pictureUrl : "";
$this->user->profile->profileURL = isset($response->publicProfileUrl) ? $response->publicProfileUrl : "";
$this->user->profile->email = isset($response->emailAddress) ? $response->emailAddress : "";
$this->user->profile->description = isset($response->headline) ? $response->headline : "";
$this->user->profile->country = isset($response->location) ? $response->location->name : "";
$this->user->profile->emailVerified = $this->user->profile->email;
$this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
return $this->user->profile;
}
/**
* {@inheritdoc}
*
* @param array $status
* An associative array containing:
* - content: A collection of fields describing the shared content.
* - comment: A comment by the member to associated with the share.
* - visibility: A collection of visibility information about the share.
*
* @return object
* An object containing:
* - updateKey - A unique ID for the shared content posting that was just created.
* - updateUrl - A direct link to the newly shared content on LinkedIn.com that you can direct the user's web browser to.
* @throws Exception
* @see https://developer.linkedin.com/docs/share-on-linkedin
*/
function setUserStatus($status) {
// Refresh tokens if needed.
$this->setHeaders("token");
$this->refreshToken();
try {
// Define default visibility.
if (!isset($status["visibility"])) {
$status["visibility"]["code"] = "anyone";
}
$this->setHeaders("share");
$response = $this->api->post(
"people/~/shares?format=json",
array(
"body" => $status,
)
);
} catch (Exception $e) {
throw new Exception("Update user status failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
}
if (!isset($response->updateKey)) {
throw new Exception("Update user status failed! {$this->providerId} returned an error: {$response->message}", $response->errorCode);
}
return $response;
}
/**
* Set correct request headers.
*
* @param string $api_type
* (optional) Specify api type.
*
* @return void
*/
private function setHeaders($api_type = null) {
$this->api->curl_header = array(
"Authorization: Bearer {$this->api->access_token}",
);
switch ($api_type) {
case "share":
$this->api->curl_header = array_merge(
$this->api->curl_header,
array(
"Content-Type: application/json",
"x-li-format: json",
)
);
break;
case "token":
$this->api->curl_header = array_merge(
$this->api->curl_header,
array(
"Content-Type: application/x-www-form-urlencoded",
)
);
break;
}
}
}

View File

@@ -1,100 +1,100 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Windows Live OAuth2 Class
*
* @package HybridAuth providers package
* @author Lukasz Koprowski <azram19@gmail.com>
* @version 0.2
* @license BSD License
*/
/**
* Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol
*/
class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
/**
* {@inheritdoc}
*/
public $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday';
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->api_base_url = 'https://apis.live.net/v5.0/';
$this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf';
$this->api->token_url = 'https://login.live.com/oauth20_token.srf';
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$data = $this->api->get("me");
if (!isset($data->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData( $data ), 6);
}
$this->user->profile->identifier = (property_exists($data, 'id')) ? $data->id : "";
$this->user->profile->firstName = (property_exists($data, 'first_name')) ? $data->first_name : "";
$this->user->profile->lastName = (property_exists($data, 'last_name')) ? $data->last_name : "";
$this->user->profile->displayName = (property_exists($data, 'name')) ? trim($data->name) : "";
$this->user->profile->gender = (property_exists($data, 'gender')) ? $data->gender : "";
//wl.basic
$this->user->profile->profileURL = (property_exists($data, 'link')) ? $data->link : "";
//wl.emails
$this->user->profile->email = (property_exists($data, 'emails')) ? $data->emails->preferred : "";
$this->user->profile->emailVerified = (property_exists($data, 'emails')) ? $data->emails->account : "";
//wl.birthday
$this->user->profile->birthDay = (property_exists($data, 'birth_day')) ? $data->birth_day : "";
$this->user->profile->birthMonth = (property_exists($data, 'birth_month')) ? $data->birth_month : "";
$this->user->profile->birthYear = (property_exists($data, 'birth_year')) ? $data->birth_year : "";
return $this->user->profile;
}
/**
* Windows Live api does not support retrieval of email addresses (only hashes :/)
* {@inheritdoc}
*/
function getUserContacts() {
$response = $this->api->get('me/contacts');
if ($this->api->http_code != 200) {
throw new Exception('User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus($this->api->http_code));
}
if (!isset($response->data) || ( isset($response->errcode) && $response->errcode != 0 )) {
return array();
}
$contacts = array();
foreach ($response->data as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
$uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
$uc->email = (property_exists($item, 'emails')) ? $item->emails->preferred : "";
$contacts[] = $uc;
}
return $contacts;
}
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Windows Live OAuth2 Class
*
* @package HybridAuth providers package
* @author Lukasz Koprowski <azram19@gmail.com>
* @version 0.2
* @license BSD License
*/
/**
* Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol
*/
class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
/**
* {@inheritdoc}
*/
public $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday';
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->api_base_url = 'https://apis.live.net/v5.0/';
$this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf';
$this->api->token_url = 'https://login.live.com/oauth20_token.srf';
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$data = $this->api->get("me");
if (!isset($data->id)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData( $data ), 6);
}
$this->user->profile->identifier = (property_exists($data, 'id')) ? $data->id : "";
$this->user->profile->firstName = (property_exists($data, 'first_name')) ? $data->first_name : "";
$this->user->profile->lastName = (property_exists($data, 'last_name')) ? $data->last_name : "";
$this->user->profile->displayName = (property_exists($data, 'name')) ? trim($data->name) : "";
$this->user->profile->gender = (property_exists($data, 'gender')) ? $data->gender : "";
//wl.basic
$this->user->profile->profileURL = (property_exists($data, 'link')) ? $data->link : "";
//wl.emails
$this->user->profile->email = (property_exists($data, 'emails')) ? $data->emails->preferred : "";
$this->user->profile->emailVerified = (property_exists($data, 'emails')) ? $data->emails->account : "";
//wl.birthday
$this->user->profile->birthDay = (property_exists($data, 'birth_day')) ? $data->birth_day : "";
$this->user->profile->birthMonth = (property_exists($data, 'birth_month')) ? $data->birth_month : "";
$this->user->profile->birthYear = (property_exists($data, 'birth_year')) ? $data->birth_year : "";
return $this->user->profile;
}
/**
* Windows Live api does not support retrieval of email addresses (only hashes :/)
* {@inheritdoc}
*/
function getUserContacts() {
$response = $this->api->get('me/contacts');
if ($this->api->http_code != 200) {
throw new Exception('User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus($this->api->http_code));
}
if (!isset($response->data) || ( isset($response->errcode) && $response->errcode != 0 )) {
return array();
}
$contacts = array();
foreach ($response->data as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
$uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
$uc->email = (property_exists($item, 'emails')) ? $item->emails->preferred : "";
$contacts[] = $uc;
}
return $contacts;
}
}

View File

@@ -1,164 +1,164 @@
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_MySpace provider adapter based on OAuth1 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_MySpace.html
*/
class Hybrid_Providers_MySpace extends Hybrid_Provider_Model_OAuth1
{
/**
* IDp wrappers initializer
*/
function initialize()
{
parent::initialize();
// Provider api end-points
$this->api->api_endpoint_url = "http://api.myspace.com/v1/";
$this->api->authorize_url = "http://api.myspace.com/authorize";
$this->api->request_token_url = "http://api.myspace.com/request_token";
$this->api->access_token_url = "http://api.myspace.com/access_token";
}
/**
* get the connected uid from myspace api
*/
public function getCurrentUserId()
{
$response = $this->api->get( 'http://api.myspace.com/v1/user.json' );
if ( ! isset( $response->userId ) ){
throw new Exception( "User id request failed! {$this->providerId} returned an invalid response." );
}
return $response->userId;
}
/**
* load the user profile from the IDp api client
*/
function getUserProfile()
{
$userId = $this->getCurrentUserId();
$data = $this->api->get( 'http://api.myspace.com/v1/users/' . $userId . '/profile.json' );
if ( ! is_object( $data ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$this->user->profile->identifier = $userId;
$this->user->profile->displayName = $data->basicprofile->name;
$this->user->profile->description = $data->aboutme;
$this->user->profile->gender = $data->basicprofile->gender;
$this->user->profile->photoURL = $data->basicprofile->image;
$this->user->profile->profileURL = $data->basicprofile->webUri;
$this->user->profile->age = $data->age;
$this->user->profile->country = $data->country;
$this->user->profile->region = $data->region;
$this->user->profile->city = $data->city;
$this->user->profile->zip = $data->postalcode;
return $this->user->profile;
}
/**
* load the user contacts
*/
function getUserContacts()
{
$userId = $this->getCurrentUserId();
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends.json" );
if ( ! is_object( $response ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$contacts = ARRAY();
foreach( $response->Friends as $item ){
$uc = new Hybrid_User_Contact();
$uc->identifier = $item->userId;
$uc->displayName = $item->name;
$uc->profileURL = $item->webUri;
$uc->photoURL = $item->image;
$uc->description = $item->status;
$contacts[] = $uc;
}
return $contacts;
}
/**
* update user status
*/
function setUserStatus( $status )
{
// crappy myspace... gonna see this asaic
$userId = $this->getCurrentUserId();
$parameters = array( 'status' => $status );
$response = $this->api->api( "http://api.myspace.com/v1/users/" . $userId . "/status", 'PUT', $parameters );
// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}
}
/**
* load the user latest activity
* - timeline : all the stream
* - me : the user activity only
*/
function getUserActivity( $stream )
{
$userId = $this->getCurrentUserId();
if( $stream == "me" ){
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/status.json" );
}
else{
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends/status.json" );
}
if ( ! is_object( $response ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$activities = ARRAY();
if( $stream == "me" ){
// todo
}
else{
foreach( $response->FriendsStatus as $item ){
$ua = new Hybrid_User_Activity();
$ua->id = $item->statusId;
$ua->date = NULL; // to find out!!
$ua->text = $item->status;
$ua->user->identifier = $item->user->userId;
$ua->user->displayName = $item->user->name;
$ua->user->profileURL = $item->user->uri;
$ua->user->photoURL = $item->user->image;
$activities[] = $ua;
}
}
return $activities;
}
}
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_MySpace provider adapter based on OAuth1 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_MySpace.html
*/
class Hybrid_Providers_MySpace extends Hybrid_Provider_Model_OAuth1
{
/**
* IDp wrappers initializer
*/
function initialize()
{
parent::initialize();
// Provider api end-points
$this->api->api_endpoint_url = "http://api.myspace.com/v1/";
$this->api->authorize_url = "http://api.myspace.com/authorize";
$this->api->request_token_url = "http://api.myspace.com/request_token";
$this->api->access_token_url = "http://api.myspace.com/access_token";
}
/**
* get the connected uid from myspace api
*/
public function getCurrentUserId()
{
$response = $this->api->get( 'http://api.myspace.com/v1/user.json' );
if ( ! isset( $response->userId ) ){
throw new Exception( "User id request failed! {$this->providerId} returned an invalid response." );
}
return $response->userId;
}
/**
* load the user profile from the IDp api client
*/
function getUserProfile()
{
$userId = $this->getCurrentUserId();
$data = $this->api->get( 'http://api.myspace.com/v1/users/' . $userId . '/profile.json' );
if ( ! is_object( $data ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$this->user->profile->identifier = $userId;
$this->user->profile->displayName = $data->basicprofile->name;
$this->user->profile->description = $data->aboutme;
$this->user->profile->gender = $data->basicprofile->gender;
$this->user->profile->photoURL = $data->basicprofile->image;
$this->user->profile->profileURL = $data->basicprofile->webUri;
$this->user->profile->age = $data->age;
$this->user->profile->country = $data->country;
$this->user->profile->region = $data->region;
$this->user->profile->city = $data->city;
$this->user->profile->zip = $data->postalcode;
return $this->user->profile;
}
/**
* load the user contacts
*/
function getUserContacts()
{
$userId = $this->getCurrentUserId();
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends.json" );
if ( ! is_object( $response ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$contacts = ARRAY();
foreach( $response->Friends as $item ){
$uc = new Hybrid_User_Contact();
$uc->identifier = $item->userId;
$uc->displayName = $item->name;
$uc->profileURL = $item->webUri;
$uc->photoURL = $item->image;
$uc->description = $item->status;
$contacts[] = $uc;
}
return $contacts;
}
/**
* update user status
*/
function setUserStatus( $status )
{
// crappy myspace... gonna see this asaic
$userId = $this->getCurrentUserId();
$parameters = array( 'status' => $status );
$response = $this->api->api( "http://api.myspace.com/v1/users/" . $userId . "/status", 'PUT', $parameters );
// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}
}
/**
* load the user latest activity
* - timeline : all the stream
* - me : the user activity only
*/
function getUserActivity( $stream )
{
$userId = $this->getCurrentUserId();
if( $stream == "me" ){
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/status.json" );
}
else{
$response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends/status.json" );
}
if ( ! is_object( $response ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$activities = ARRAY();
if( $stream == "me" ){
// todo
}
else{
foreach( $response->FriendsStatus as $item ){
$ua = new Hybrid_User_Activity();
$ua->id = $item->statusId;
$ua->date = NULL; // to find out!!
$ua->text = $item->status;
$ua->user->identifier = $item->user->userId;
$ua->user->displayName = $item->user->name;
$ua->user->profileURL = $item->user->uri;
$ua->user->photoURL = $item->user->image;
$activities[] = $ua;
}
}
return $activities;
}
}

View File

@@ -1,16 +1,16 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_OpenID provider adapter for any idp openid based
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html
*/
class Hybrid_Providers_OpenID extends Hybrid_Provider_Model_OpenID {
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_OpenID provider adapter for any idp openid based
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html
*/
class Hybrid_Providers_OpenID extends Hybrid_Provider_Model_OpenID {
}

View File

@@ -1,264 +1,264 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Twitter provider adapter based on OAuth1 protocol
*/
class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1 {
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->api_base_url = "https://api.twitter.com/1.1/";
$this->api->authorize_url = "https://api.twitter.com/oauth/authenticate";
$this->api->request_token_url = "https://api.twitter.com/oauth/request_token";
$this->api->access_token_url = "https://api.twitter.com/oauth/access_token";
if (isset($this->config['api_version']) && $this->config['api_version']) {
$this->api->api_base_url = "https://api.twitter.com/{$this->config['api_version']}/";
}
if (isset($this->config['authorize']) && $this->config['authorize']) {
$this->api->authorize_url = "https://api.twitter.com/oauth/authorize";
}
$this->api->curl_auth_header = false;
}
/**
* {@inheritdoc}
*/
function loginBegin() {
// Initiate the Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
if (isset($_REQUEST['reverse_auth']) && ($_REQUEST['reverse_auth'] == 'yes')) {
$stage1 = $this->api->signedRequest($this->api->request_token_url, 'POST', array('x_auth_mode' => 'reverse_auth'));
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
$responseObj = array('x_reverse_auth_parameters' => $stage1, 'x_reverse_auth_target' => $this->config["keys"]["key"]);
$response = json_encode($responseObj);
header("Content-Type: application/json", true, 200);
echo $response;
die();
}
$tokens = $this->api->requestToken($this->endpoint);
// request tokens as received from provider
$this->request_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
}
$this->token("request_token", $tokens["oauth_token"]);
$this->token("request_token_secret", $tokens["oauth_token_secret"]);
// redirect the user to the provider authentication url with force_login
if (( isset($this->config['force_login']) && $this->config['force_login'] ) || ( isset($this->config['force']) && $this->config['force'] === true )) {
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens, array('force_login' => true)));
}
// else, redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
// in case we are completing a Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
if (isset($_REQUEST['oauth_token_secret'])) {
$tokens = $_REQUEST;
$this->access_tokens_raw = $tokens;
// we should have an access_token unless something has gone wrong
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// Get rid of tokens we don't need
$this->deleteToken("request_token");
$this->deleteToken("request_token_secret");
// Store access_token and secret for later use
$this->token("access_token", $tokens['oauth_token']);
$this->token("access_token_secret", $tokens['oauth_token_secret']);
// set user as logged in to the current provider
$this->setUserConnected();
return;
}
parent::loginFinish();
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$includeEmail = isset($this->config['includeEmail']) ? (bool) $this->config['includeEmail'] : false;
$response = $this->api->get('account/verify_credentials.json'. ($includeEmail ? '?include_email=true' : ''));
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User profile request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 6);
}
if (!is_object($response) || !isset($response->id)) {
throw new Exception("User profile request failed! {$this->providerId} api returned an invalid response: " . Hybrid_Logger::dumpData( $response ), 6);
}
# store the user profile.
$this->user->profile->identifier = (property_exists($response, 'id')) ? $response->id : "";
$this->user->profile->displayName = (property_exists($response, 'screen_name')) ? $response->screen_name : "";
$this->user->profile->description = (property_exists($response, 'description')) ? $response->description : "";
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name : "";
$this->user->profile->photoURL = (property_exists($response, 'profile_image_url')) ? (str_replace('_normal', '', $response->profile_image_url)) : "";
$this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("http://twitter.com/" . $response->screen_name) : "";
$this->user->profile->webSiteURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->region = (property_exists($response, 'location')) ? $response->location : "";
if($includeEmail) $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
if($includeEmail) $this->user->profile->emailVerified = (property_exists($response, 'email')) ? $response->email : "";
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
$parameters = array('cursor' => '-1');
$response = $this->api->get('friends/ids.json', $parameters);
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if (!$response || !count($response->ids)) {
return array();
}
// 75 id per time should be okey
$contactsids = array_chunk($response->ids, 75);
$contacts = array();
foreach ($contactsids as $chunk) {
$parameters = array('user_id' => implode(",", $chunk));
$response = $this->api->get('users/lookup.json', $parameters);
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if ($response && count($response)) {
foreach ($response as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
$uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
$uc->profileURL = (property_exists($item, 'screen_name')) ? ("http://twitter.com/" . $item->screen_name) : "";
$uc->photoURL = (property_exists($item, 'profile_image_url')) ? $item->profile_image_url : "";
$uc->description = (property_exists($item, 'description')) ? $item->description : "";
$contacts[] = $uc;
}
}
}
return $contacts;
}
/**
* {@inheritdoc}
*/
function setUserStatus($status) {
if (is_array($status) && isset($status['message']) && isset($status['picture'])) {
$response = $this->api->post('statuses/update_with_media.json', array('status' => $status['message'], 'media[]' => file_get_contents($status['picture'])), null, null, true);
} else {
$response = $this->api->post('statuses/update.json', array('status' => $status));
}
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
return $response;
}
/**
* {@inheritdoc}
*/
function getUserStatus($tweetid) {
$info = $this->api->get('statuses/show.json?id=' . $tweetid . '&include_entities=true');
// check the last HTTP status code returned
if ($this->api->http_code != 200 || !isset($info->id)) {
throw new Exception("Cannot retrieve user status! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
return $info;
}
/**
* load the user latest activity
* - timeline : all the stream
* - me : the user activity only
*
* by default return the timeline
* {@inheritdoc}
*/
function getUserActivity($stream) {
if ($stream == "me") {
$response = $this->api->get('statuses/user_timeline.json');
} else {
$response = $this->api->get('statuses/home_timeline.json');
}
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User activity stream request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if (!$response) {
return array();
}
$activities = array();
foreach ($response as $item) {
$ua = new Hybrid_User_Activity();
$ua->id = (property_exists($item, 'id')) ? $item->id : "";
$ua->date = (property_exists($item, 'created_at')) ? strtotime($item->created_at) : "";
$ua->text = (property_exists($item, 'text')) ? $item->text : "";
$ua->user->identifier = (property_exists($item->user, 'id')) ? $item->user->id : "";
$ua->user->displayName = (property_exists($item->user, 'name')) ? $item->user->name : "";
$ua->user->profileURL = (property_exists($item->user, 'screen_name')) ? ("http://twitter.com/" . $item->user->screen_name) : "";
$ua->user->photoURL = (property_exists($item->user, 'profile_image_url')) ? $item->user->profile_image_url : "";
$activities[] = $ua;
}
return $activities;
}
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_Providers_Twitter provider adapter based on OAuth1 protocol
*/
class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1 {
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points
$this->api->api_base_url = "https://api.twitter.com/1.1/";
$this->api->authorize_url = "https://api.twitter.com/oauth/authenticate";
$this->api->request_token_url = "https://api.twitter.com/oauth/request_token";
$this->api->access_token_url = "https://api.twitter.com/oauth/access_token";
if (isset($this->config['api_version']) && $this->config['api_version']) {
$this->api->api_base_url = "https://api.twitter.com/{$this->config['api_version']}/";
}
if (isset($this->config['authorize']) && $this->config['authorize']) {
$this->api->authorize_url = "https://api.twitter.com/oauth/authorize";
}
$this->api->curl_auth_header = false;
}
/**
* {@inheritdoc}
*/
function loginBegin() {
// Initiate the Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
if (isset($_REQUEST['reverse_auth']) && ($_REQUEST['reverse_auth'] == 'yes')) {
$stage1 = $this->api->signedRequest($this->api->request_token_url, 'POST', array('x_auth_mode' => 'reverse_auth'));
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
$responseObj = array('x_reverse_auth_parameters' => $stage1, 'x_reverse_auth_target' => $this->config["keys"]["key"]);
$response = json_encode($responseObj);
header("Content-Type: application/json", true, 200);
echo $response;
die();
}
$tokens = $this->api->requestToken($this->endpoint);
// request tokens as received from provider
$this->request_tokens_raw = $tokens;
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
}
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
}
$this->token("request_token", $tokens["oauth_token"]);
$this->token("request_token_secret", $tokens["oauth_token_secret"]);
// redirect the user to the provider authentication url with force_login
if (( isset($this->config['force_login']) && $this->config['force_login'] ) || ( isset($this->config['force']) && $this->config['force'] === true )) {
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens, array('force_login' => true)));
}
// else, redirect the user to the provider authentication url
Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
}
/**
* {@inheritdoc}
*/
function loginFinish() {
// in case we are completing a Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
if (isset($_REQUEST['oauth_token_secret'])) {
$tokens = $_REQUEST;
$this->access_tokens_raw = $tokens;
// we should have an access_token unless something has gone wrong
if (!isset($tokens["oauth_token"])) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
}
// Get rid of tokens we don't need
$this->deleteToken("request_token");
$this->deleteToken("request_token_secret");
// Store access_token and secret for later use
$this->token("access_token", $tokens['oauth_token']);
$this->token("access_token_secret", $tokens['oauth_token_secret']);
// set user as logged in to the current provider
$this->setUserConnected();
return;
}
parent::loginFinish();
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$includeEmail = isset($this->config['includeEmail']) ? (bool) $this->config['includeEmail'] : false;
$response = $this->api->get('account/verify_credentials.json'. ($includeEmail ? '?include_email=true' : ''));
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User profile request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 6);
}
if (!is_object($response) || !isset($response->id)) {
throw new Exception("User profile request failed! {$this->providerId} api returned an invalid response: " . Hybrid_Logger::dumpData( $response ), 6);
}
# store the user profile.
$this->user->profile->identifier = (property_exists($response, 'id')) ? $response->id : "";
$this->user->profile->displayName = (property_exists($response, 'screen_name')) ? $response->screen_name : "";
$this->user->profile->description = (property_exists($response, 'description')) ? $response->description : "";
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name : "";
$this->user->profile->photoURL = (property_exists($response, 'profile_image_url')) ? (str_replace('_normal', '', $response->profile_image_url)) : "";
$this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("http://twitter.com/" . $response->screen_name) : "";
$this->user->profile->webSiteURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->region = (property_exists($response, 'location')) ? $response->location : "";
if($includeEmail) $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
if($includeEmail) $this->user->profile->emailVerified = (property_exists($response, 'email')) ? $response->email : "";
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
$parameters = array('cursor' => '-1');
$response = $this->api->get('friends/ids.json', $parameters);
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if (!$response || !count($response->ids)) {
return array();
}
// 75 id per time should be okey
$contactsids = array_chunk($response->ids, 75);
$contacts = array();
foreach ($contactsids as $chunk) {
$parameters = array('user_id' => implode(",", $chunk));
$response = $this->api->get('users/lookup.json', $parameters);
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if ($response && count($response)) {
foreach ($response as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
$uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
$uc->profileURL = (property_exists($item, 'screen_name')) ? ("http://twitter.com/" . $item->screen_name) : "";
$uc->photoURL = (property_exists($item, 'profile_image_url')) ? $item->profile_image_url : "";
$uc->description = (property_exists($item, 'description')) ? $item->description : "";
$contacts[] = $uc;
}
}
}
return $contacts;
}
/**
* {@inheritdoc}
*/
function setUserStatus($status) {
if (is_array($status) && isset($status['message']) && isset($status['picture'])) {
$response = $this->api->post('statuses/update_with_media.json', array('status' => $status['message'], 'media[]' => file_get_contents($status['picture'])), null, null, true);
} else {
$response = $this->api->post('statuses/update.json', array('status' => $status));
}
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
return $response;
}
/**
* {@inheritdoc}
*/
function getUserStatus($tweetid) {
$info = $this->api->get('statuses/show.json?id=' . $tweetid . '&include_entities=true');
// check the last HTTP status code returned
if ($this->api->http_code != 200 || !isset($info->id)) {
throw new Exception("Cannot retrieve user status! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
return $info;
}
/**
* load the user latest activity
* - timeline : all the stream
* - me : the user activity only
*
* by default return the timeline
* {@inheritdoc}
*/
function getUserActivity($stream) {
if ($stream == "me") {
$response = $this->api->get('statuses/user_timeline.json');
} else {
$response = $this->api->get('statuses/home_timeline.json');
}
// check the last HTTP status code returned
if ($this->api->http_code != 200) {
throw new Exception("User activity stream request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
}
if (!$response) {
return array();
}
$activities = array();
foreach ($response as $item) {
$ua = new Hybrid_User_Activity();
$ua->id = (property_exists($item, 'id')) ? $item->id : "";
$ua->date = (property_exists($item, 'created_at')) ? strtotime($item->created_at) : "";
$ua->text = (property_exists($item, 'text')) ? $item->text : "";
$ua->user->identifier = (property_exists($item->user, 'id')) ? $item->user->id : "";
$ua->user->displayName = (property_exists($item->user, 'name')) ? $item->user->name : "";
$ua->user->profileURL = (property_exists($item->user, 'screen_name')) ? ("http://twitter.com/" . $item->user->screen_name) : "";
$ua->user->photoURL = (property_exists($item->user, 'profile_image_url')) ? $item->user->profile_image_url : "";
$activities[] = $ua;
}
return $activities;
}
}

View File

@@ -1,269 +1,269 @@
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Yahoo OAuth Class.
*
* @package HybridAuth providers package
* @author Lukasz Koprowski <azram19@gmail.com>
* @author Oleg Kuzava <olegkuzava@gmail.com>
* @version 1.0
* @license BSD License
*/
/**
* Hybrid_Providers_Yahoo - Yahoo provider adapter based on OAuth2 protocol.
*/
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OAuth2 {
/**
* Define Yahoo scopes.
*
* @var array $scope
* If empty will be used YDN App scopes.
* @see https://developer.yahoo.com/oauth2/guide/yahoo_scopes.
*/
public $scope = [];
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points.
$this->api->api_base_url = "https://social.yahooapis.com/v1/";
$this->api->authorize_url = "https://api.login.yahoo.com/oauth2/request_auth";
$this->api->token_url = "https://api.login.yahoo.com/oauth2/get_token";
// Set token headers.
$this->setAuthorizationHeaders("basic");
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (is_array($this->scope)) {
$this->scope = implode(",", $this->scope);
}
parent::loginBegin();
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$userId = $this->getCurrentUserId();
$response = $this->api->get("user/{$userId}/profile", array(
"format" => "json",
));
if (!isset($response->profile)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
}
$data = $response->profile;
$this->user->profile->identifier = isset($data->guid) ? $data->guid : "";
$this->user->profile->firstName = isset($data->givenName) ? $data->givenName : "";
$this->user->profile->lastName = isset($data->familyName) ? $data->familyName : "";
$this->user->profile->displayName = isset($data->nickname) ? trim($data->nickname) : "";
$this->user->profile->profileURL = isset($data->profileUrl) ? $data->profileUrl : "";
$this->user->profile->gender = isset($data->gender) ? $data->gender : "";
if ($this->user->profile->gender === "F") {
$this->user->profile->gender = "female";
}
elseif ($this->user->profile->gender === "M") {
$this->user->profile->gender = "male";
}
if (isset($data->emails)) {
$email = "";
foreach ($data->emails as $v) {
if (isset($v->primary) && $v->primary) {
$email = isset($v->handle) ? $v->handle : "";
break;
}
}
$this->user->profile->email = $email;
$this->user->profile->emailVerified = $email;
}
$this->user->profile->age = isset($data->displayAge) ? $data->displayAge : "";
$this->user->profile->photoURL = isset($data->image) ? $data->image->imageUrl : "";
$this->user->profile->address = isset($data->location) ? $data->location : "";
$this->user->profile->language = isset($data->lang) ? $data->lang : "";
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
$userId = $this->getCurrentUserId();
$response = $this->api->get("user/{$userId}/contacts", array(
"format" => "json",
"count" => "max",
));
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error: " . $this->errorMessageByStatus());
}
if (!isset($response->contacts) || !isset($response->contacts->contact) || (isset($response->errcode) && $response->errcode != 0)) {
return array();
}
$contacts = array();
foreach ($response->contacts->contact as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = isset($item->id) ? $item->id : "";
$uc->email = $this->selectEmail($item->fields);
$uc->displayName = $this->selectName($item->fields);
$uc->photoURL = $this->selectPhoto($item->fields);
$contacts[] = $uc;
}
return $contacts;
}
/**
* Returns current user id.
*
* @return string
* Current user ID.
* @throws Exception
*/
function getCurrentUserId() {
// Set headers to get refresh token.
$this->setAuthorizationHeaders("basic");
// Refresh tokens if needed.
$this->refreshToken();
// Set headers to make api call.
$this->setAuthorizationHeaders("bearer");
$response = $this->api->get("me/guid", array(
"format" => "json",
));
if (!isset($response->guid->value)) {
throw new Exception("User id request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response));
}
return $response->guid->value;
}
/**
* Utility function for returning values from XML-like objects.
*
* @param stdClass $vs
* Object.
* @param string $t
* Property name.
* @return mixed
*/
private function select($vs, $t) {
foreach ($vs as $v) {
if ($v->type == $t) {
return $v;
}
}
return null;
}
/**
* Parses user name.
*
* @param stdClass $v
* Object.
* @return string
* User name.
*/
private function selectName($v) {
$s = $this->select($v, "name");
if (!$s) {
$s = $this->select($v, "nickname");
return isset($s->value) ? $s->value : "";
}
return isset($s->value) ? "{$s->value->givenName} {$s->value->familyName}" : "";
}
/**
* Parses photo URL.
*
* @param stdClass $v
* Object.
* @return string
* Photo URL.
*/
private function selectPhoto($v) {
$s = $this->select($v, "image");
return isset($s->value) ? $s->value->imageUrl : "";
}
/**
* Parses email.
*
* @param stdClass $v
* Object
* @return string
* An email address.
*/
private function selectEmail($v) {
$s = $this->select($v, "email");
if (empty($s)) {
$s = $this->select($v, "yahooid");
if (isset($s->value) && strpos($s->value, "@") === FALSE) {
$s->value .= "@yahoo.com";
}
}
return isset($s->value) ? $s->value : "";
}
/**
* Set correct Authorization headers.
*
* @param string $token_type
* Specify token type.
*
* @return void
*/
private function setAuthorizationHeaders($token_type) {
switch ($token_type) {
case "basic":
// The /get_token requires authorization header.
$token = base64_encode("{$this->config["keys"]["id"]}:{$this->config["keys"]["secret"]}");
$this->api->curl_header = array(
"Authorization: Basic {$token}",
"Content-Type: application/x-www-form-urlencoded",
);
break;
case "bearer":
// Yahoo API requires the token to be passed as a Bearer within the authorization header.
$this->api->curl_header = array(
"Authorization: Bearer {$this->api->access_token}",
);
break;
}
}
}
<?php
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Yahoo OAuth Class.
*
* @package HybridAuth providers package
* @author Lukasz Koprowski <azram19@gmail.com>
* @author Oleg Kuzava <olegkuzava@gmail.com>
* @version 1.0
* @license BSD License
*/
/**
* Hybrid_Providers_Yahoo - Yahoo provider adapter based on OAuth2 protocol.
*/
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OAuth2 {
/**
* Define Yahoo scopes.
*
* @var array $scope
* If empty will be used YDN App scopes.
* @see https://developer.yahoo.com/oauth2/guide/yahoo_scopes.
*/
public $scope = [];
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider api end-points.
$this->api->api_base_url = "https://social.yahooapis.com/v1/";
$this->api->authorize_url = "https://api.login.yahoo.com/oauth2/request_auth";
$this->api->token_url = "https://api.login.yahoo.com/oauth2/get_token";
// Set token headers.
$this->setAuthorizationHeaders("basic");
}
/**
* {@inheritdoc}
*/
function loginBegin() {
if (is_array($this->scope)) {
$this->scope = implode(",", $this->scope);
}
parent::loginBegin();
}
/**
* {@inheritdoc}
*/
function getUserProfile() {
$userId = $this->getCurrentUserId();
$response = $this->api->get("user/{$userId}/profile", array(
"format" => "json",
));
if (!isset($response->profile)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
}
$data = $response->profile;
$this->user->profile->identifier = isset($data->guid) ? $data->guid : "";
$this->user->profile->firstName = isset($data->givenName) ? $data->givenName : "";
$this->user->profile->lastName = isset($data->familyName) ? $data->familyName : "";
$this->user->profile->displayName = isset($data->nickname) ? trim($data->nickname) : "";
$this->user->profile->profileURL = isset($data->profileUrl) ? $data->profileUrl : "";
$this->user->profile->gender = isset($data->gender) ? $data->gender : "";
if ($this->user->profile->gender === "F") {
$this->user->profile->gender = "female";
}
elseif ($this->user->profile->gender === "M") {
$this->user->profile->gender = "male";
}
if (isset($data->emails)) {
$email = "";
foreach ($data->emails as $v) {
if (isset($v->primary) && $v->primary) {
$email = isset($v->handle) ? $v->handle : "";
break;
}
}
$this->user->profile->email = $email;
$this->user->profile->emailVerified = $email;
}
$this->user->profile->age = isset($data->displayAge) ? $data->displayAge : "";
$this->user->profile->photoURL = isset($data->image) ? $data->image->imageUrl : "";
$this->user->profile->address = isset($data->location) ? $data->location : "";
$this->user->profile->language = isset($data->lang) ? $data->lang : "";
return $this->user->profile;
}
/**
* {@inheritdoc}
*/
function getUserContacts() {
$userId = $this->getCurrentUserId();
$response = $this->api->get("user/{$userId}/contacts", array(
"format" => "json",
"count" => "max",
));
if ($this->api->http_code != 200) {
throw new Exception("User contacts request failed! {$this->providerId} returned an error: " . $this->errorMessageByStatus());
}
if (!isset($response->contacts) || !isset($response->contacts->contact) || (isset($response->errcode) && $response->errcode != 0)) {
return array();
}
$contacts = array();
foreach ($response->contacts->contact as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = isset($item->id) ? $item->id : "";
$uc->email = $this->selectEmail($item->fields);
$uc->displayName = $this->selectName($item->fields);
$uc->photoURL = $this->selectPhoto($item->fields);
$contacts[] = $uc;
}
return $contacts;
}
/**
* Returns current user id.
*
* @return string
* Current user ID.
* @throws Exception
*/
function getCurrentUserId() {
// Set headers to get refresh token.
$this->setAuthorizationHeaders("basic");
// Refresh tokens if needed.
$this->refreshToken();
// Set headers to make api call.
$this->setAuthorizationHeaders("bearer");
$response = $this->api->get("me/guid", array(
"format" => "json",
));
if (!isset($response->guid->value)) {
throw new Exception("User id request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response));
}
return $response->guid->value;
}
/**
* Utility function for returning values from XML-like objects.
*
* @param stdClass $vs
* Object.
* @param string $t
* Property name.
* @return mixed
*/
private function select($vs, $t) {
foreach ($vs as $v) {
if ($v->type == $t) {
return $v;
}
}
return null;
}
/**
* Parses user name.
*
* @param stdClass $v
* Object.
* @return string
* User name.
*/
private function selectName($v) {
$s = $this->select($v, "name");
if (!$s) {
$s = $this->select($v, "nickname");
return isset($s->value) ? $s->value : "";
}
return isset($s->value) ? "{$s->value->givenName} {$s->value->familyName}" : "";
}
/**
* Parses photo URL.
*
* @param stdClass $v
* Object.
* @return string
* Photo URL.
*/
private function selectPhoto($v) {
$s = $this->select($v, "image");
return isset($s->value) ? $s->value->imageUrl : "";
}
/**
* Parses email.
*
* @param stdClass $v
* Object
* @return string
* An email address.
*/
private function selectEmail($v) {
$s = $this->select($v, "email");
if (empty($s)) {
$s = $this->select($v, "yahooid");
if (isset($s->value) && strpos($s->value, "@") === FALSE) {
$s->value .= "@yahoo.com";
}
}
return isset($s->value) ? $s->value : "";
}
/**
* Set correct Authorization headers.
*
* @param string $token_type
* Specify token type.
*
* @return void
*/
private function setAuthorizationHeaders($token_type) {
switch ($token_type) {
case "basic":
// The /get_token requires authorization header.
$token = base64_encode("{$this->config["keys"]["id"]}:{$this->config["keys"]["secret"]}");
$this->api->curl_header = array(
"Authorization: Basic {$token}",
"Content-Type: application/x-www-form-urlencoded",
);
break;
case "bearer":
// Yahoo API requires the token to be passed as a Bearer within the authorization header.
$this->api->curl_header = array(
"Authorization: Bearer {$this->api->access_token}",
);
break;
}
}
}

View File

@@ -1,141 +1,141 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
require_once realpath(dirname(__FILE__)) . "/StorageInterface.php";
/**
* HybridAuth storage manager
*/
class Hybrid_Storage implements Hybrid_Storage_Interface {
/**
* Constructor
*/
function __construct() {
if (!session_id()) {
if (!session_start()) {
throw new Exception("Hybridauth requires the use of 'session_start()' at the start of your script, which appears to be disabled.", 1);
}
}
$this->config("php_session_id", session_id());
$this->config("version", Hybrid_Auth::$version);
}
/**
* Saves a value in the config storage, or returns config if value is null
*
* @param string $key Config name
* @param string $value Config value
* @return array|null
*/
public function config($key, $value = null) {
$key = strtolower($key);
if ($value) {
$_SESSION["HA::CONFIG"][$key] = serialize($value);
} elseif (isset($_SESSION["HA::CONFIG"][$key])) {
return unserialize($_SESSION["HA::CONFIG"][$key]);
}
return null;
}
/**
* Returns value from session storage
*
* @param string $key Key
* @return string|null
*/
public function get($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key])) {
return unserialize($_SESSION["HA::STORE"][$key]);
}
return null;
}
/**
* Saves a key value pair to the session storage
*
* @param string $key Key
* @param string $value Value
* @return void
*/
public function set($key, $value) {
$key = strtolower($key);
$_SESSION["HA::STORE"][$key] = serialize($value);
}
/**
* Clear session storage
* @return void
*/
function clear() {
$_SESSION["HA::STORE"] = array();
}
/**
* Delete a specific key from session storage
*
* @param string $key Key
* @return void
*/
function delete($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key])) {
$f = $_SESSION['HA::STORE'];
unset($f[$key]);
$_SESSION["HA::STORE"] = $f;
}
}
/**
* Delete all keys recursively from session storage
*
* @param string $key Key
* @retun void
*/
function deleteMatch($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"]) && count($_SESSION["HA::STORE"])) {
$f = $_SESSION['HA::STORE'];
foreach ($f as $k => $v) {
if (strstr($k, $key)) {
unset($f[$k]);
}
}
$_SESSION["HA::STORE"] = $f;
}
}
/**
* Returns session storage as a serialized string
* @return string|null
*/
function getSessionData() {
if (isset($_SESSION["HA::STORE"])) {
return serialize($_SESSION["HA::STORE"]);
}
return null;
}
/**
* Restores the session from serialized session data
*
* @param string $sessiondata Serialized session data
* @return void
*/
function restoreSessionData($sessiondata = null) {
$_SESSION["HA::STORE"] = unserialize($sessiondata);
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
require_once realpath(dirname(__FILE__)) . "/StorageInterface.php";
/**
* HybridAuth storage manager
*/
class Hybrid_Storage implements Hybrid_Storage_Interface {
/**
* Constructor
*/
function __construct() {
if (!session_id()) {
if (!session_start()) {
throw new Exception("Hybridauth requires the use of 'session_start()' at the start of your script, which appears to be disabled.", 1);
}
}
$this->config("php_session_id", session_id());
$this->config("version", Hybrid_Auth::$version);
}
/**
* Saves a value in the config storage, or returns config if value is null
*
* @param string $key Config name
* @param string $value Config value
* @return array|null
*/
public function config($key, $value = null) {
$key = strtolower($key);
if ($value) {
$_SESSION["HA::CONFIG"][$key] = serialize($value);
} elseif (isset($_SESSION["HA::CONFIG"][$key])) {
return unserialize($_SESSION["HA::CONFIG"][$key]);
}
return null;
}
/**
* Returns value from session storage
*
* @param string $key Key
* @return string|null
*/
public function get($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key])) {
return unserialize($_SESSION["HA::STORE"][$key]);
}
return null;
}
/**
* Saves a key value pair to the session storage
*
* @param string $key Key
* @param string $value Value
* @return void
*/
public function set($key, $value) {
$key = strtolower($key);
$_SESSION["HA::STORE"][$key] = serialize($value);
}
/**
* Clear session storage
* @return void
*/
function clear() {
$_SESSION["HA::STORE"] = array();
}
/**
* Delete a specific key from session storage
*
* @param string $key Key
* @return void
*/
function delete($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key])) {
$f = $_SESSION['HA::STORE'];
unset($f[$key]);
$_SESSION["HA::STORE"] = $f;
}
}
/**
* Delete all keys recursively from session storage
*
* @param string $key Key
* @retun void
*/
function deleteMatch($key) {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"]) && count($_SESSION["HA::STORE"])) {
$f = $_SESSION['HA::STORE'];
foreach ($f as $k => $v) {
if (strstr($k, $key)) {
unset($f[$k]);
}
}
$_SESSION["HA::STORE"] = $f;
}
}
/**
* Returns session storage as a serialized string
* @return string|null
*/
function getSessionData() {
if (isset($_SESSION["HA::STORE"])) {
return serialize($_SESSION["HA::STORE"]);
}
return null;
}
/**
* Restores the session from serialized session data
*
* @param string $sessiondata Serialized session data
* @return void
*/
function restoreSessionData($sessiondata = null) {
$_SESSION["HA::STORE"] = unserialize($sessiondata);
}
}

View File

@@ -1,40 +1,40 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* The Hybrid_User class represents the current logged in user
*/
class Hybrid_User {
/**
* The ID (name) of the connected provider
* @var mixed
*/
public $providerId = null;
/**
* Timestamp connection to the provider
* @var int
*/
public $timestamp = null;
/**
* User profile, contains the list of fields available in the normalized user profile structure used by HybridAuth
* @var Hybrid_User_Profile
*/
public $profile = null;
/**
* Initialize the user object
*/
function __construct() {
$this->timestamp = time();
$this->profile = new Hybrid_User_Profile();
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* The Hybrid_User class represents the current logged in user
*/
class Hybrid_User {
/**
* The ID (name) of the connected provider
* @var mixed
*/
public $providerId = null;
/**
* Timestamp connection to the provider
* @var int
*/
public $timestamp = null;
/**
* User profile, contains the list of fields available in the normalized user profile structure used by HybridAuth
* @var Hybrid_User_Profile
*/
public $profile = null;
/**
* Initialize the user object
*/
function __construct() {
$this->timestamp = time();
$this->profile = new Hybrid_User_Profile();
}
}

View File

@@ -1,55 +1,55 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Activity
*
* used to provider the connected user activity stream on a standardized structure across supported social apis.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Activity.html
*/
class Hybrid_User_Activity {
/**
* Activity id on the provider side, usually given as integer
* @var mixed
*/
public $id = null;
/**
* Activity date of creation
* @var int
*/
public $date = null;
/**
* Activity content as a string
* @var string
*/
public $text = null;
/**
* User who created the activity
* @var stdClass
*/
public $user = null;
/**
* Constructor
*/
public function __construct() {
$this->user = new stdClass();
// typically, we should have a few information about the user who created the event from social apis
$this->user->identifier = null;
$this->user->displayName = null;
$this->user->profileURL = null;
$this->user->photoURL = null;
}
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Activity
*
* used to provider the connected user activity stream on a standardized structure across supported social apis.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Activity.html
*/
class Hybrid_User_Activity {
/**
* Activity id on the provider side, usually given as integer
* @var mixed
*/
public $id = null;
/**
* Activity date of creation
* @var int
*/
public $date = null;
/**
* Activity content as a string
* @var string
*/
public $text = null;
/**
* User who created the activity
* @var stdClass
*/
public $user = null;
/**
* Constructor
*/
public function __construct() {
$this->user = new stdClass();
// typically, we should have a few information about the user who created the event from social apis
$this->user->identifier = null;
$this->user->displayName = null;
$this->user->profileURL = null;
$this->user->photoURL = null;
}
}

View File

@@ -1,60 +1,60 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Contact
*
* used to provider the connected user contacts list on a standardized structure across supported social apis.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Contacts.html
*/
class Hybrid_User_Contact {
/**
* The Unique contact user ID
* @var mixed
*/
public $identifier = null;
/**
* User website, blog, web page
* @var string
*/
public $webSiteURL = null;
/**
* URL link to profile page on the IDp web site
* @var string
*/
public $profileURL = null;
/**
* URL link to user photo or avatar
* @var string
*/
public $photoURL = null;
/**
* User displayName provided by the IDp or a concatenation of first and last name
* @var string
*/
public $displayName = null;
/**
* A short about_me
* @var string
*/
public $description = null;
/**
* User email. Not all of IDp grant access to the user email
* @var string
*/
public $email = null;
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Contact
*
* used to provider the connected user contacts list on a standardized structure across supported social apis.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Contacts.html
*/
class Hybrid_User_Contact {
/**
* The Unique contact user ID
* @var mixed
*/
public $identifier = null;
/**
* User website, blog, web page
* @var string
*/
public $webSiteURL = null;
/**
* URL link to profile page on the IDp web site
* @var string
*/
public $profileURL = null;
/**
* URL link to user photo or avatar
* @var string
*/
public $photoURL = null;
/**
* User displayName provided by the IDp or a concatenation of first and last name
* @var string
*/
public $displayName = null;
/**
* A short about_me
* @var string
*/
public $description = null;
/**
* User email. Not all of IDp grant access to the user email
* @var string
*/
public $email = null;
}

View File

@@ -1,163 +1,163 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Profile object represents the current logged in user profile.
* The list of fields available in the normalized user profile structure used by HybridAuth.
*
* The Hybrid_User_Profile object is populated with as much information about the user as
* HybridAuth was able to pull from the given API or authentication provider.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html
*/
class Hybrid_User_Profile {
/**
* The Unique user's ID on the connected provider
* @var mixed
*/
public $identifier = null;
/**
* User website, blog, web page
* @var string
*/
public $webSiteURL = null;
/**
* URL link to profile page on the IDp web site
* @var string
*/
public $profileURL = null;
/**
* URL link to user photo or avatar
* @var string
*/
public $photoURL = null;
/**
* User displayName provided by the IDp or a concatenation of first and last name.
* @var string
*/
public $displayName = null;
/**
* A short about_me
* @var string
*/
public $description = null;
/**
* User's first name
* @var string
*/
public $firstName = null;
/**
* User's last name
* @var string
*/
public $lastName = null;
/**
* Male or female
* @var string
*/
public $gender = null;
/**
* Language
* @var string
*/
public $language = null;
/**
* User age, we don't calculate it. we return it as is if the IDp provide it.
* @var int
*/
public $age = null;
/**
* User birth Day
* @var int
*/
public $birthDay = null;
/**
* User birth Month
* @var int
*/
public $birthMonth = null;
/**
* User birth Year
* @var int
*/
public $birthYear = null;
/**
* User email. Note: not all of IDp grant access to the user email
* @var string
*/
public $email = null;
/**
* Verified user email. Note: not all of IDp grant access to verified user email
* @var string
*/
public $emailVerified = null;
/**
* Phone number
* @var string
*/
public $phone = null;
/**
* Complete user address
* @var string
*/
public $address = null;
/**
* User country
* @var string
*/
public $country = null;
/**
* Region
* @var string
*/
public $region = null;
/**
* City
* @var string
*/
public $city = null;
/**
* Postal code
* @var string
*/
public $zip = null;
/**
* Job title
* @var string
*/
public $job_title = null;
/**
* Organization name
* @var string
*/
public $organization_name = null;
}
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
* Hybrid_User_Profile object represents the current logged in user profile.
* The list of fields available in the normalized user profile structure used by HybridAuth.
*
* The Hybrid_User_Profile object is populated with as much information about the user as
* HybridAuth was able to pull from the given API or authentication provider.
*
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html
*/
class Hybrid_User_Profile {
/**
* The Unique user's ID on the connected provider
* @var mixed
*/
public $identifier = null;
/**
* User website, blog, web page
* @var string
*/
public $webSiteURL = null;
/**
* URL link to profile page on the IDp web site
* @var string
*/
public $profileURL = null;
/**
* URL link to user photo or avatar
* @var string
*/
public $photoURL = null;
/**
* User displayName provided by the IDp or a concatenation of first and last name.
* @var string
*/
public $displayName = null;
/**
* A short about_me
* @var string
*/
public $description = null;
/**
* User's first name
* @var string
*/
public $firstName = null;
/**
* User's last name
* @var string
*/
public $lastName = null;
/**
* Male or female
* @var string
*/
public $gender = null;
/**
* Language
* @var string
*/
public $language = null;
/**
* User age, we don't calculate it. we return it as is if the IDp provide it.
* @var int
*/
public $age = null;
/**
* User birth Day
* @var int
*/
public $birthDay = null;
/**
* User birth Month
* @var int
*/
public $birthMonth = null;
/**
* User birth Year
* @var int
*/
public $birthYear = null;
/**
* User email. Note: not all of IDp grant access to the user email
* @var string
*/
public $email = null;
/**
* Verified user email. Note: not all of IDp grant access to verified user email
* @var string
*/
public $emailVerified = null;
/**
* Phone number
* @var string
*/
public $phone = null;
/**
* Complete user address
* @var string
*/
public $address = null;
/**
* User country
* @var string
*/
public $country = null;
/**
* Region
* @var string
*/
public $region = null;
/**
* City
* @var string
*/
public $city = null;
/**
* Postal code
* @var string
*/
public $zip = null;
/**
* Job title
* @var string
*/
public $job_title = null;
/**
* Organization name
* @var string
*/
public $organization_name = null;
}

View File

@@ -1,10 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -1,72 +1,72 @@
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
// ----------------------------------------------------------------------------------------
// HybridAuth Config file: http://hybridauth.sourceforge.net/userguide/Configuration.html
// ----------------------------------------------------------------------------------------
return
array(
"base_url" => "#GLOBAL_HYBRID_AUTH_URL_BASE#",
"providers" => array (
// openid providers
"OpenID" => array (
"enabled" => #OPENID_ADAPTER_STATUS#
),
"AOL" => array (
"enabled" => #AOL_ADAPTER_STATUS#
),
"Yahoo" => array (
"enabled" => #YAHOO_ADAPTER_STATUS#,
"keys" => array ( "id" => "#YAHOO_APPLICATION_APP_ID#", "secret" => "#YAHOO_APPLICATION_SECRET#" )
),
"Google" => array (
"enabled" => #GOOGLE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" )
),
"Facebook" => array (
"enabled" => #FACEBOOK_ADAPTER_STATUS#,
"keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_SECRET#" )
),
"Twitter" => array (
"enabled" => #TWITTER_ADAPTER_STATUS#,
"keys" => array ( "key" => "#TWITTER_APPLICATION_KEY#", "secret" => "#TWITTER_APPLICATION_SECRET#" )
),
// windows live
"Live" => array (
"enabled" => #LIVE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#LIVE_APPLICATION_APP_ID#", "secret" => "#LIVE_APPLICATION_SECRET#" )
),
"MySpace" => array (
"enabled" => #MYSPACE_ADAPTER_STATUS#,
"keys" => array ( "key" => "#MYSPACE_APPLICATION_KEY#", "secret" => "#MYSPACE_APPLICATION_SECRET#" )
),
"LinkedIn" => array (
"enabled" => #LINKEDIN_ADAPTER_STATUS#,
"keys" => array ( "key" => "#LINKEDIN_APPLICATION_KEY#", "secret" => "#LINKEDIN_APPLICATION_SECRET#" )
),
"Foursquare" => array (
"enabled" => #FOURSQUARE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#FOURSQUARE_APPLICATION_APP_ID#", "secret" => "#FOURSQUARE_APPLICATION_SECRET#" )
),
),
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
"debug_mode" => false,
"debug_file" => ""
);
<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
// ----------------------------------------------------------------------------------------
// HybridAuth Config file: http://hybridauth.sourceforge.net/userguide/Configuration.html
// ----------------------------------------------------------------------------------------
return
array(
"base_url" => "#GLOBAL_HYBRID_AUTH_URL_BASE#",
"providers" => array (
// openid providers
"OpenID" => array (
"enabled" => #OPENID_ADAPTER_STATUS#
),
"AOL" => array (
"enabled" => #AOL_ADAPTER_STATUS#
),
"Yahoo" => array (
"enabled" => #YAHOO_ADAPTER_STATUS#,
"keys" => array ( "id" => "#YAHOO_APPLICATION_APP_ID#", "secret" => "#YAHOO_APPLICATION_SECRET#" )
),
"Google" => array (
"enabled" => #GOOGLE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" )
),
"Facebook" => array (
"enabled" => #FACEBOOK_ADAPTER_STATUS#,
"keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_SECRET#" )
),
"Twitter" => array (
"enabled" => #TWITTER_ADAPTER_STATUS#,
"keys" => array ( "key" => "#TWITTER_APPLICATION_KEY#", "secret" => "#TWITTER_APPLICATION_SECRET#" )
),
// windows live
"Live" => array (
"enabled" => #LIVE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#LIVE_APPLICATION_APP_ID#", "secret" => "#LIVE_APPLICATION_SECRET#" )
),
"MySpace" => array (
"enabled" => #MYSPACE_ADAPTER_STATUS#,
"keys" => array ( "key" => "#MYSPACE_APPLICATION_KEY#", "secret" => "#MYSPACE_APPLICATION_SECRET#" )
),
"LinkedIn" => array (
"enabled" => #LINKEDIN_ADAPTER_STATUS#,
"keys" => array ( "key" => "#LINKEDIN_APPLICATION_KEY#", "secret" => "#LINKEDIN_APPLICATION_SECRET#" )
),
"Foursquare" => array (
"enabled" => #FOURSQUARE_ADAPTER_STATUS#,
"keys" => array ( "id" => "#FOURSQUARE_APPLICATION_APP_ID#", "secret" => "#FOURSQUARE_APPLICATION_SECRET#" )
),
),
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
"debug_mode" => false,
"debug_file" => ""
);

View File

@@ -1,10 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -1,10 +1,10 @@
<html>
<head>
<title>OpenID Policy</title>
</head>
<body>
<!--
Set here your OpenID Policy,
-->
</body>
<html>
<head>
<title>OpenID Policy</title>
</head>
<body>
<!--
Set here your OpenID Policy,
-->
</body>
</html>

View File

@@ -1,13 +1,13 @@
<html>
<head>
<title>HybridAuth Endpoint</title>
<meta name="robots" content="NOINDEX, NOFOLLOW">
<meta http-equiv="X-XRDS-Location" content="{X_XRDS_LOCATION}" />
</head>
<body>
<h3 style="margin-bottom: 2px;">HybridAuth</h3>
Open Source Social Sign On PHP Library.
<br />
<a href="http://hybridauth.sourceforge.net/" style="color:green;text-decoration:none;">hybridauth.sourceforge.net/</a>
</body>
</html>
<html>
<head>
<title>HybridAuth Endpoint</title>
<meta name="robots" content="NOINDEX, NOFOLLOW">
<meta http-equiv="X-XRDS-Location" content="{X_XRDS_LOCATION}" />
</head>
<body>
<h3 style="margin-bottom: 2px;">HybridAuth</h3>
Open Source Social Sign On PHP Library.
<br />
<a href="http://hybridauth.sourceforge.net/" style="color:green;text-decoration:none;">hybridauth.sourceforge.net/</a>
</body>
</html>

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
xmlns:xrds="xri://$xrds"
xmlns:openid="http://openid.net/xmlns/1.0"
xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="1">
<Type>http://specs.openid.net/auth/2.0/return_to</Type>
<URI>{RETURN_TO_URL}</URI>
</Service>
</XRD>
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
xmlns:xrds="xri://$xrds"
xmlns:openid="http://openid.net/xmlns/1.0"
xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="1">
<Type>http://specs.openid.net/auth/2.0/return_to</Type>
<URI>{RETURN_TO_URL}</URI>
</Service>
</XRD>
</xrds:XRDS>

View File

@@ -1,37 +1,37 @@
<html>
<head>
<meta name="ROBOTS" content="NONE" />
<script type="text/javascript">
function parseIsLiveUserResponse(e) {
var b = "isLiveUser";
if (!e) return false;
for (var d = e.substring(1).split("&"), a = [], c = 0; c < d.length; c++) {
parm = d[c].split("=");
a[unescape(parm[0])] = unescape(parm[1])
}
if (a[b] !== undefined && a[b].length != 0 && window.parent && window.parent.parent && window.parent.parent.Microsoft !== undefined) {
var f = a[b] == "true";
window.parent.parent.Microsoft.Live.App.get_auth().set_isLiveUser(f);
return true
}
return false
}
function onLoad() {
try {
var c = window.location.hash.substr(1),
d = window.location.search;
if (window.location.replace == null) window.location.replace = window.location.assign;
window.location.replace("about:blank");
if (parseIsLiveUserResponse(d)) return;
var b = c.split("/")[0],
a = null;
if (b && b != ".parent") a = window.parent.frames[b];
else a = window.parent.parent;
a.Microsoft && a.Microsoft.Live.Channels.Mux._recv_chunk(c)
} catch (e) {}
}
< /script>
</head>
<body onload="onLoad();">
</body>
<html>
<head>
<meta name="ROBOTS" content="NONE" />
<script type="text/javascript">
function parseIsLiveUserResponse(e) {
var b = "isLiveUser";
if (!e) return false;
for (var d = e.substring(1).split("&"), a = [], c = 0; c < d.length; c++) {
parm = d[c].split("=");
a[unescape(parm[0])] = unescape(parm[1])
}
if (a[b] !== undefined && a[b].length != 0 && window.parent && window.parent.parent && window.parent.parent.Microsoft !== undefined) {
var f = a[b] == "true";
window.parent.parent.Microsoft.Live.App.get_auth().set_isLiveUser(f);
return true
}
return false
}
function onLoad() {
try {
var c = window.location.hash.substr(1),
d = window.location.search;
if (window.location.replace == null) window.location.replace = window.location.assign;
window.location.replace("about:blank");
if (parseIsLiveUserResponse(d)) return;
var b = c.split("/")[0],
a = null;
if (b && b != ".parent") a = window.parent.frames[b];
else a = window.parent.parent;
a.Microsoft && a.Microsoft.Live.Channels.Mux._recv_chunk(c)
} catch (e) {}
}
< /script>
</head>
<body onload="onLoad();">
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,194 +1,194 @@
<?php
// OAuthWrapHandler.php 1.1
/**
* FILE: OAuthWrapHandler.php
*
* DESCRIPTION: Sample implementation of OAuth WRAP Authentication protocol.
*
* VERSION: 1.1
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*
* OAuthWrapHandler
* This handler is used to both process the raw HTTP requests that generate the
* required cookies for the Windows Live javascript control to work within a
* php applicaiton.
*/
class OAuthWrapHandler
{
public function ProcessRequest()
{
$this->ExpireCookies();
$cookies_setup = $this->convertParamsToCookies($_REQUEST);
if(isset($cookies_setup['verification_code']))
{
$auth_params = $this->getAuthorizationToken(
WRAP_ACCESS_URL
, WRAP_CLIENT_ID
, WRAP_CLIENT_SECRET
, WRAP_CALLBACK
, $cookies_setup['verification_code']
);
unset($cookies_setup['verification_code']);
}
else
{
throw new Exception("No verification Code returned from Windows Live Services.");
}
$cookies_auth = $this->convertParamsToCookies($auth_params);
$cookies = array_merge($cookies_setup, $cookies_auth);
$this->setAuthCookies($cookies);
return $cookies;
}
public function ExpireCookies()
{
setcookie ("c_accessToken", "", time() - 3600);
setcookie ("c_clientId", "", time() - 3600);
setcookie ("c_clientState", "", time() - 3600);
setcookie ("c_scope", "", time() - 3600);
setcookie ("c_error", "", time() - 3600);
setcookie ("c_uid", "", time() - 3600);
setcookie ("c_expiry", "", time() - 3600);
setcookie ("lca", "", time() - 3600);
}
private function setAuthCookies($cookies)
{
foreach($cookies as $key => $value)
{
setcookie ($key, $value, time() + 36000);
}
setcookie ('c_clientId', WRAP_CLIENT_ID, time() + 36000); //clientID == appId
setcookie ('lca', 'done', time() + 36000); //lca //done
}
private function convertParamsToCookies($array)
{
$cookies = array();
foreach(array_keys($array) as $getParam)
{
$getParam = urldecode($getParam);
switch($getParam)
{
case 'wrap_client_state':
$cookies['c_clientState'] = $array['wrap_client_state'];
break;
case 'wrap_verification_code':
$cookies['verification_code'] = $array['wrap_verification_code'];
break;
case 'exp': //scope
$cookies['c_scope'] = str_replace(';', ',',$array['exp']);
break;
case 'error_code':
$cookies['c_error'] = ' ' . $array['error_code'];
break;
case 'wrap_error_reason':
$cookies['c_error'] = ' ' . $array['wrap_error_reason'];
break;
case 'wrap_access_token':
$cookies['c_accessToken']= $array['wrap_access_token'];
break;
case 'wrap_access_token_expires_in':
$cookies['c_expiry']= date('j/m/Y g:i:s A', $array['wrap_access_token_expires_in']);
break;
case 'uid':
$cookies['c_uid']= $array['uid'];
break;
}
}
return $cookies;
}
private function getAuthorizationToken($authUrl, $appId, $appSecret, $callbackUrl, $verificationCode)
{
$tokenRequest = 'wrap_client_id=' . urlencode($appId)
. '&wrap_client_secret=' . urlencode($appSecret)
. '&wrap_callback=' . urlencode($callbackUrl)
. '&wrap_verification_code=' . urlencode($verificationCode);
$response = $this->postWRAPRequest($authUrl, $tokenRequest);
return $this->parseWRAPResponse($response);
}
private function postWRAPRequest($posturl, $postvars)
{
$ch = curl_init($posturl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
@ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$Rec_Data = curl_exec($ch);
curl_close($ch);
return urldecode($Rec_Data);
}
private function parseWRAPResponse($response)
{
$pos = strpos($response, 'wrap_access_token=');
if ($pos === false)
{
$pos = strpos($response, 'wrap_error_reason=');
}
$codes = '?' . substr($response, $pos, strlen($response));
if (preg_match_all('/[?&]([^&=]+)=([^&=]+)/', $codes, $matches))
{
for($i =0; $i < count($matches[1]); $i++)
{
$contents[$matches[1][$i]] = $matches[2][$i];
}
}
else
{
throw new Exception('No matches for regular expression.');
}
return $contents;
}
public function GET($url,$params=false,$auth=false){
$url = $this->MakeUrl($url,$params);
// borrowed from Andy Langton: http://andylangton.co.uk/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array (
"Authorization: WRAP access_token=$auth",
"Content-Type: application/json",
"Accept: application/json"
));
if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
}else {
// Handle the useragent like we are Google Chrome
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13.');
}
curl_setopt($ch , CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result=curl_exec($ch);
$info=curl_getinfo($ch);
curl_close($ch);
return $result;
}
public function MakeUrl($url,$params){
if(!empty($params) && $params){
foreach($params as $k=>$v) $kv[] = "$k=$v";
$url_params = str_replace(" ","+",implode('&',$kv));
$url = trim($url) . '?' . $url_params;
}
return $url;
}
}
<?php
// OAuthWrapHandler.php 1.1
/**
* FILE: OAuthWrapHandler.php
*
* DESCRIPTION: Sample implementation of OAuth WRAP Authentication protocol.
*
* VERSION: 1.1
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*
* OAuthWrapHandler
* This handler is used to both process the raw HTTP requests that generate the
* required cookies for the Windows Live javascript control to work within a
* php applicaiton.
*/
class OAuthWrapHandler
{
public function ProcessRequest()
{
$this->ExpireCookies();
$cookies_setup = $this->convertParamsToCookies($_REQUEST);
if(isset($cookies_setup['verification_code']))
{
$auth_params = $this->getAuthorizationToken(
WRAP_ACCESS_URL
, WRAP_CLIENT_ID
, WRAP_CLIENT_SECRET
, WRAP_CALLBACK
, $cookies_setup['verification_code']
);
unset($cookies_setup['verification_code']);
}
else
{
throw new Exception("No verification Code returned from Windows Live Services.");
}
$cookies_auth = $this->convertParamsToCookies($auth_params);
$cookies = array_merge($cookies_setup, $cookies_auth);
$this->setAuthCookies($cookies);
return $cookies;
}
public function ExpireCookies()
{
setcookie ("c_accessToken", "", time() - 3600);
setcookie ("c_clientId", "", time() - 3600);
setcookie ("c_clientState", "", time() - 3600);
setcookie ("c_scope", "", time() - 3600);
setcookie ("c_error", "", time() - 3600);
setcookie ("c_uid", "", time() - 3600);
setcookie ("c_expiry", "", time() - 3600);
setcookie ("lca", "", time() - 3600);
}
private function setAuthCookies($cookies)
{
foreach($cookies as $key => $value)
{
setcookie ($key, $value, time() + 36000);
}
setcookie ('c_clientId', WRAP_CLIENT_ID, time() + 36000); //clientID == appId
setcookie ('lca', 'done', time() + 36000); //lca //done
}
private function convertParamsToCookies($array)
{
$cookies = array();
foreach(array_keys($array) as $getParam)
{
$getParam = urldecode($getParam);
switch($getParam)
{
case 'wrap_client_state':
$cookies['c_clientState'] = $array['wrap_client_state'];
break;
case 'wrap_verification_code':
$cookies['verification_code'] = $array['wrap_verification_code'];
break;
case 'exp': //scope
$cookies['c_scope'] = str_replace(';', ',',$array['exp']);
break;
case 'error_code':
$cookies['c_error'] = ' ' . $array['error_code'];
break;
case 'wrap_error_reason':
$cookies['c_error'] = ' ' . $array['wrap_error_reason'];
break;
case 'wrap_access_token':
$cookies['c_accessToken']= $array['wrap_access_token'];
break;
case 'wrap_access_token_expires_in':
$cookies['c_expiry']= date('j/m/Y g:i:s A', $array['wrap_access_token_expires_in']);
break;
case 'uid':
$cookies['c_uid']= $array['uid'];
break;
}
}
return $cookies;
}
private function getAuthorizationToken($authUrl, $appId, $appSecret, $callbackUrl, $verificationCode)
{
$tokenRequest = 'wrap_client_id=' . urlencode($appId)
. '&wrap_client_secret=' . urlencode($appSecret)
. '&wrap_callback=' . urlencode($callbackUrl)
. '&wrap_verification_code=' . urlencode($verificationCode);
$response = $this->postWRAPRequest($authUrl, $tokenRequest);
return $this->parseWRAPResponse($response);
}
private function postWRAPRequest($posturl, $postvars)
{
$ch = curl_init($posturl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
@ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$Rec_Data = curl_exec($ch);
curl_close($ch);
return urldecode($Rec_Data);
}
private function parseWRAPResponse($response)
{
$pos = strpos($response, 'wrap_access_token=');
if ($pos === false)
{
$pos = strpos($response, 'wrap_error_reason=');
}
$codes = '?' . substr($response, $pos, strlen($response));
if (preg_match_all('/[?&]([^&=]+)=([^&=]+)/', $codes, $matches))
{
for($i =0; $i < count($matches[1]); $i++)
{
$contents[$matches[1][$i]] = $matches[2][$i];
}
}
else
{
throw new Exception('No matches for regular expression.');
}
return $contents;
}
public function GET($url,$params=false,$auth=false){
$url = $this->MakeUrl($url,$params);
// borrowed from Andy Langton: http://andylangton.co.uk/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array (
"Authorization: WRAP access_token=$auth",
"Content-Type: application/json",
"Accept: application/json"
));
if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
}else {
// Handle the useragent like we are Google Chrome
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13.');
}
curl_setopt($ch , CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result=curl_exec($ch);
$info=curl_getinfo($ch);
curl_close($ch);
return $result;
}
public function MakeUrl($url,$params){
if(!empty($params) && $params){
foreach($params as $k=>$v) $kv[] = "$k=$v";
$url_params = str_replace(" ","+",implode('&',$kv));
$url = trim($url) . '?' . $url_params;
}
return $url;
}
}

View File

@@ -1,10 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -1,16 +1,16 @@
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
// ------------------------------------------------------------------------
// HybridAuth End Point
// ------------------------------------------------------------------------
require_once("../../class2.php");
require_once( "Hybrid/Auth.php" );
require_once( "Hybrid/Endpoint.php" );
require_once("vendor/autoload.php");
Hybrid_Endpoint::process();
<?php
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
// ------------------------------------------------------------------------
// HybridAuth End Point
// ------------------------------------------------------------------------
require_once("../../class2.php");
require_once( "Hybrid/Auth.php" );
require_once( "Hybrid/Endpoint.php" );
require_once("vendor/autoload.php");
Hybrid_Endpoint::process();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,276 +1,276 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Mailout - template-related functions
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/redirection_class.php $
* $Id: redirection_class.php 11922 2010-10-27 11:31:18Z secretr $
* $Revision: 11315 $
*
*/
/**
* Various template-related mailout functions
*
* @package e107
* @subpackage e107_handlers
* @version $Id: mailout_admin_class.php 11315 2010-02-10 18:18:01Z secretr $;
*
* Handles common aspects of template-based emails
*/
class e107MailTemplate
{
public $lastTemplateData = FALSE; // Mailer template info - cache
public $mainBodyText = FALSE; // Cache for body text
public $altBodyText = FALSE; // Cache for alternate body text
/**
* Empty our template cache
*
* @return none
*/
public function clearTemplateCache()
{
$this->lastTemplateData = FALSE;
}
/**
* Set a template to be used.
* Clears any cached data
*
* @param array|string $newTemplate - if a string, the name of a template. (The internal name of the variable, not the associated name)
* If an array, an existing template - must be in the correct format - no checking done
*
* @return boolean TRUE if accepted, FALSE if rejected
*/
public function setNewTemplate($newTemplate)
{
$this->mainBodyText = FALSE;
$this->altBodyText = FALSE;
if (is_array($newTemplate))
{
$this->lastTemplateData = $newTemplate;
return TRUE;
}
return $this->loadTemplateInfo($newTemplate);
}
/**
* Given a template name, assembles the array of data required by sendTemplated() and saves in our cache
*
* Template file name is 'email_template.php'
* The template is first sought in the template file of the current theme directory, and data read as available.
* If $extraFile is specified, that is searched next
* Gaps are then filled in from the core template file.
*
* @param string $templateName - name of required template
* @param string $extraFile - optional path to additional template file (intended for plugins)
* (This is read between the theme-specific file and the defaults)
*
* @return boolean TRUE - template found and loaded. FALSE if not found.
* If successful, we store an array in $lastTemplateData, with exactly six elements:
* 'template_name'
* 'email_overrides' - any override information (often an empty array)
* 'email_header' - any header information (usually loaded from the default)
* 'email_body'
* 'email_footer'
* 'email_plainText' - optional template for plain text part of email
*/
public function loadTemplateInfo($templateName, $extraFile = FALSE)
{
static $requiredFields = array ('email_overrides', 'email_header', 'email_body', 'email_footer', 'email_plainText');
if (is_array($this->lastTemplateData))
{
if ($this->lastTemplateData['template_name'] == $templateName)
{
return $this->lastTemplateData;
}
$this->lastTemplateData = FALSE; // Obviously a new template
}
$ret = array('email_overrides' => '', 'email_header' => '', 'email_body' => '', 'email_footer' => '', 'email_plainText' => '');
if (!in_array($templateName, array('textonly', 'texthtml', 'texttheme')))
{
$found = 0; // Count number of field definitions we've found
$fileList = array(THEME.'templates/email_template.php');
if ($extraFile)
{
$fileList[] = $extraFile;
}
$fileList[] = e_CORE.'templates/email_template.php';
foreach ($fileList as $templateFileName ) // Override file, optional plugin file then defaults
{
if (($found < count($requiredFields)) && is_readable($templateFileName))
{
require_once($templateFileName);
//$tVars = get_defined_vars();
//if (isset($tVars['GLOBALS'])) unset($tVars['GLOBALS']);
//print_a($tVars);
if (isset($$templateName))
{
if (is_array($$templateName))
{
foreach ($requiredFields as $k)
{
if (!$ret[$k] && isset(${$templateName}[$k]))
{
$ret[$k] = ${$templateName}[$k];
$found++;
}
}
}
else
{
$ret['email_body'] = $$templateName; // Non-array just defines body of email
$found++;
}
}
}
}
// Now fill in the gaps from the defaults
if ($found < count($requiredFields))
{
foreach ($requiredFields as $k)
{
$override = strtoupper($k);
if (!$ret[$k] && isset($$override))
{
$ret[$k] = $$override;
$found++;
}
}
}
if (($found == 0) || !$ret['email_body']) // Pointless if we haven't defined a body
{
return FALSE;
}
}
$this->lastTemplateData = $ret;
$this->lastTemplateData['template_name'] = $templateName; // Cache template
return $this->lastTemplateData; // Return this rather than $ret, so return is consistent with cached data
}
/**
* Creates email body text according to options, using the cached template information.
* Caches body, and potentially alternate body
*
* @param $text string - text to process
* @param boolean $incImages - valid only with HTML and templated output:
* if true any 'absolute' format images are embedded in the source of the email.
* if FALSE, absolute links are converted to URLs on the local server
*
* @return boolean TRUE for success, FALSE on error (no template defined)
*/
public function makeEmailBody($text, $incImages = TRUE)
{
if (!is_array( $this->lastTemplateData)) return FALSE;
if (!isset($this->lastTemplateData['template_name'])) return FALSE;
$tp = e107::getParser();
// textonly - generate plain text email
// texthtml - HTML format email, no theme info
// texttheme - HTML format email, including current theme stylesheet etc
$format = $this->lastTemplateData['template_name'];
if (!$format)
{
echo 'No format specified!';
return FALSE;
}
if ($format == 'textonly')
{ // Plain text email - strip bbcodes etc
$temp = $tp->toHTML($text, TRUE, 'E_BODY_PLAIN'); // Decode bbcodes into HTML, plain text as far as possible etc
$temp = stripslashes(strip_tags($temp)); // Have to do strip_tags() again in case bbcode added some
$this->mainBodyText = $temp;
$this->altBodyText = '';
return TRUE;
}
$consts = $incImages ? ',consts_abs' : 'consts_full'; // If inline images, absolute constants so we can change them
if (($format != 'texthtml') && ($format != 'texttheme'))
{ // Specific theme - loaded already
$mailHeader = $tp->parseTemplate($this->lastTemplateData['email_header'], TRUE);
$mailBody = $tp->parseTemplate(str_replace('{BODY}', $text, $this->lastTemplateData['email_body']), TRUE);
$mailFooter = $tp->parseTemplate($this->lastTemplateData['email_footer'], TRUE);
$mailBody = $mailHeader.$mailBody.$mailFooter;
}
if (($format == 'texthtml') || ($format == 'texttheme'))
{
// HTML format email here, using hard-coded defaults
$mailHeader = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
$mailHeader .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n";
$mailHeader .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
if ($format == 'texttheme')
{
$styleFile = THEME.'emailstyle.css';
if (!is_readable($styleFile)) { $styleFile = THEME."/style.css"; }
$style_css = file_get_contents($styleFile);
$mailHeader .= "<style>\n".$style_css."\n</style>";
}
$mailHeader .= "</head>\n";
$mailBody = $mailHeader."<body>\n";
if ($format == 'texttheme')
{
$mailBody .= "<div style='padding:10px;width:97%'><div class='forumheader3'>\n";
$mailBody .= $tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</div></div></body></html>";
}
else
{
$mailBody .= $tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</body></html>";
$mailBody = str_replace("&quot;", '"', $mailBody);
}
$mailBody = stripslashes($mailBody);
}
if (!$incImages)
{
// Handle internally generated 'absolute' links - they need the full URL
$mailBody = str_replace("src='".e_HTTP, "src='".SITEURL, $mailBody);
$mailBody = str_replace('src="'.e_HTTP, 'src="'.SITEURL, $mailBody);
$mailBody = str_replace("href='".e_HTTP, "src='".SITEURL, $mailBody);
$mailBody = str_replace('href="'.e_HTTP, 'src="'.SITEURL, $mailBody);
}
// print_a($mailBody);
$this->mainBodyText = $mailBody;
$this->altBodyText = '';
if ($this->lastTemplateData['email_plainText'])
{
$this->altBodyText = $tp->parseTemplate(str_replace('{BODY}', $text, $this->lastTemplateData['email_plainText']), TRUE);
}
return TRUE;
}
}
?>
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Mailout - template-related functions
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/redirection_class.php $
* $Id: redirection_class.php 11922 2010-10-27 11:31:18Z secretr $
* $Revision: 11315 $
*
*/
/**
* Various template-related mailout functions
*
* @package e107
* @subpackage e107_handlers
* @version $Id: mailout_admin_class.php 11315 2010-02-10 18:18:01Z secretr $;
*
* Handles common aspects of template-based emails
*/
class e107MailTemplate
{
public $lastTemplateData = FALSE; // Mailer template info - cache
public $mainBodyText = FALSE; // Cache for body text
public $altBodyText = FALSE; // Cache for alternate body text
/**
* Empty our template cache
*
* @return none
*/
public function clearTemplateCache()
{
$this->lastTemplateData = FALSE;
}
/**
* Set a template to be used.
* Clears any cached data
*
* @param array|string $newTemplate - if a string, the name of a template. (The internal name of the variable, not the associated name)
* If an array, an existing template - must be in the correct format - no checking done
*
* @return boolean TRUE if accepted, FALSE if rejected
*/
public function setNewTemplate($newTemplate)
{
$this->mainBodyText = FALSE;
$this->altBodyText = FALSE;
if (is_array($newTemplate))
{
$this->lastTemplateData = $newTemplate;
return TRUE;
}
return $this->loadTemplateInfo($newTemplate);
}
/**
* Given a template name, assembles the array of data required by sendTemplated() and saves in our cache
*
* Template file name is 'email_template.php'
* The template is first sought in the template file of the current theme directory, and data read as available.
* If $extraFile is specified, that is searched next
* Gaps are then filled in from the core template file.
*
* @param string $templateName - name of required template
* @param string $extraFile - optional path to additional template file (intended for plugins)
* (This is read between the theme-specific file and the defaults)
*
* @return boolean TRUE - template found and loaded. FALSE if not found.
* If successful, we store an array in $lastTemplateData, with exactly six elements:
* 'template_name'
* 'email_overrides' - any override information (often an empty array)
* 'email_header' - any header information (usually loaded from the default)
* 'email_body'
* 'email_footer'
* 'email_plainText' - optional template for plain text part of email
*/
public function loadTemplateInfo($templateName, $extraFile = FALSE)
{
static $requiredFields = array ('email_overrides', 'email_header', 'email_body', 'email_footer', 'email_plainText');
if (is_array($this->lastTemplateData))
{
if ($this->lastTemplateData['template_name'] == $templateName)
{
return $this->lastTemplateData;
}
$this->lastTemplateData = FALSE; // Obviously a new template
}
$ret = array('email_overrides' => '', 'email_header' => '', 'email_body' => '', 'email_footer' => '', 'email_plainText' => '');
if (!in_array($templateName, array('textonly', 'texthtml', 'texttheme')))
{
$found = 0; // Count number of field definitions we've found
$fileList = array(THEME.'templates/email_template.php');
if ($extraFile)
{
$fileList[] = $extraFile;
}
$fileList[] = e_CORE.'templates/email_template.php';
foreach ($fileList as $templateFileName ) // Override file, optional plugin file then defaults
{
if (($found < count($requiredFields)) && is_readable($templateFileName))
{
require_once($templateFileName);
//$tVars = get_defined_vars();
//if (isset($tVars['GLOBALS'])) unset($tVars['GLOBALS']);
//print_a($tVars);
if (isset($$templateName))
{
if (is_array($$templateName))
{
foreach ($requiredFields as $k)
{
if (!$ret[$k] && isset(${$templateName}[$k]))
{
$ret[$k] = ${$templateName}[$k];
$found++;
}
}
}
else
{
$ret['email_body'] = $$templateName; // Non-array just defines body of email
$found++;
}
}
}
}
// Now fill in the gaps from the defaults
if ($found < count($requiredFields))
{
foreach ($requiredFields as $k)
{
$override = strtoupper($k);
if (!$ret[$k] && isset($$override))
{
$ret[$k] = $$override;
$found++;
}
}
}
if (($found == 0) || !$ret['email_body']) // Pointless if we haven't defined a body
{
return FALSE;
}
}
$this->lastTemplateData = $ret;
$this->lastTemplateData['template_name'] = $templateName; // Cache template
return $this->lastTemplateData; // Return this rather than $ret, so return is consistent with cached data
}
/**
* Creates email body text according to options, using the cached template information.
* Caches body, and potentially alternate body
*
* @param $text string - text to process
* @param boolean $incImages - valid only with HTML and templated output:
* if true any 'absolute' format images are embedded in the source of the email.
* if FALSE, absolute links are converted to URLs on the local server
*
* @return boolean TRUE for success, FALSE on error (no template defined)
*/
public function makeEmailBody($text, $incImages = TRUE)
{
if (!is_array( $this->lastTemplateData)) return FALSE;
if (!isset($this->lastTemplateData['template_name'])) return FALSE;
$tp = e107::getParser();
// textonly - generate plain text email
// texthtml - HTML format email, no theme info
// texttheme - HTML format email, including current theme stylesheet etc
$format = $this->lastTemplateData['template_name'];
if (!$format)
{
echo 'No format specified!';
return FALSE;
}
if ($format == 'textonly')
{ // Plain text email - strip bbcodes etc
$temp = $tp->toHTML($text, TRUE, 'E_BODY_PLAIN'); // Decode bbcodes into HTML, plain text as far as possible etc
$temp = stripslashes(strip_tags($temp)); // Have to do strip_tags() again in case bbcode added some
$this->mainBodyText = $temp;
$this->altBodyText = '';
return TRUE;
}
$consts = $incImages ? ',consts_abs' : 'consts_full'; // If inline images, absolute constants so we can change them
if (($format != 'texthtml') && ($format != 'texttheme'))
{ // Specific theme - loaded already
$mailHeader = $tp->parseTemplate($this->lastTemplateData['email_header'], TRUE);
$mailBody = $tp->parseTemplate(str_replace('{BODY}', $text, $this->lastTemplateData['email_body']), TRUE);
$mailFooter = $tp->parseTemplate($this->lastTemplateData['email_footer'], TRUE);
$mailBody = $mailHeader.$mailBody.$mailFooter;
}
if (($format == 'texthtml') || ($format == 'texttheme'))
{
// HTML format email here, using hard-coded defaults
$mailHeader = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
$mailHeader .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n";
$mailHeader .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
if ($format == 'texttheme')
{
$styleFile = THEME.'emailstyle.css';
if (!is_readable($styleFile)) { $styleFile = THEME."/style.css"; }
$style_css = file_get_contents($styleFile);
$mailHeader .= "<style>\n".$style_css."\n</style>";
}
$mailHeader .= "</head>\n";
$mailBody = $mailHeader."<body>\n";
if ($format == 'texttheme')
{
$mailBody .= "<div style='padding:10px;width:97%'><div class='forumheader3'>\n";
$mailBody .= $tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</div></div></body></html>";
}
else
{
$mailBody .= $tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</body></html>";
$mailBody = str_replace("&quot;", '"', $mailBody);
}
$mailBody = stripslashes($mailBody);
}
if (!$incImages)
{
// Handle internally generated 'absolute' links - they need the full URL
$mailBody = str_replace("src='".e_HTTP, "src='".SITEURL, $mailBody);
$mailBody = str_replace('src="'.e_HTTP, 'src="'.SITEURL, $mailBody);
$mailBody = str_replace("href='".e_HTTP, "src='".SITEURL, $mailBody);
$mailBody = str_replace('href="'.e_HTTP, 'src="'.SITEURL, $mailBody);
}
// print_a($mailBody);
$this->mainBodyText = $mailBody;
$this->altBodyText = '';
if ($this->lastTemplateData['email_plainText'])
{
$this->altBodyText = $tp->parseTemplate(str_replace('{BODY}', $text, $this->lastTemplateData['email_plainText']), TRUE);
}
return TRUE;
}
}
?>

File diff suppressed because one or more lines are too long

View File

@@ -1,441 +1,441 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
/**
* @package e107
* @subpackage e107_handlers
*
* Handler for 'notify' events - sends email notifications to the appropriate user groups
*/
if (!defined('e107_INIT')) { exit; }
class notify
{
public $notify_prefs;
function __construct()
{
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php');
if(empty($this->notify_prefs))
{
$this->notify_prefs = e107::getConfig('notify')->getPref();
}
}
/**
* Register core and plugin notification events.
*/
public function registerEvents()
{
$active = e107::getConfig()->get('notify');
if(empty($active) && defset('e_PAGE') == 'notify.php')
{
e107::getMessage()->addDebug('Notify is disabled!');
return false;
}
$e_event = e107::getEvent();
if(varset($this->notify_prefs['event']))
{
foreach ($this->notify_prefs['event'] as $id => $status)
{
$include = null;
if ($status['class'] != e_UC_NOBODY) // 255;
{
if(varset($status['include'])) // Plugin
{
$include = e_PLUGIN.$status['include']."/e_notify.php";
if(varset($status['legacy']) != 1)
{
$class = $status['include']."_notify";
$method = $id;
$e_event->register($id, array($class, $method), $include);
}
else
{
$e_event->register($id, 'notify_'.$id, $include);
}
}
else // core
{
if(method_exists($this, 'notify_'.$id)) // as found below.
{
$e_event->register($id, array('notify', 'notify_'.$id));
}
else
{
$e_event->register($id, array('notify', 'generic')); // use generic notification.
}
}
}
}
}
// e107::getEvent()->debug();
}
/**
* Generic Notification method when none defined.
*/
function generic($data,$id)
{
$message = print_a($data,true);
$this->send($id, 'Event Triggered: '.$id, $message);
}
/**
* Send an email notification following an event.
*
* The email is sent via a common interface, which will send immediately for small numbers of recipients, and queue for larger.
*
* @param string $id - identifies event actions
* @param string $subject - subject for email
* @param string $message - email message body
* @return void
*
* @todo handle 'everyone except' clauses (email address filter done)
* @todo set up pref to not notify originator of event which caused notify (see $blockOriginator)
*/
function send($id, $subject, $message, $media=array())
{
$tp = e107::getParser();
$sql = e107::getDb();
$subject = $tp->toEmail($subject);
$message = $tp->replaceConstants($message, "full");
// $message = $tp->toEmail($message);
$emailFilter = '';
$notifyTarget = $this->notify_prefs['event'][$id]['class'];
if ($notifyTarget == '-email')
{
$emailFilter = $this->notify_prefs['event'][$id]['email'];
}
$blockOriginator = FALSE; // TODO: set this using a pref
$recipients = array();
if ($notifyTarget == 'email') // Single email address - that can always go immediately
{
if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL))
{
$recipients[] = array(
'mail_recipient_email' => $this->notify_prefs['event'][$id]['email'],
'mail_target_info' => array(
'SUBJECT' => $subject,
'DATE_SHORT' => $tp->toDate(time(),'short'),
'DATE_LONG' => $tp->toDate(time(),'long'),
)
);
}
}
elseif (is_numeric($notifyTarget))
{
switch ($notifyTarget)
{
case e_UC_MAINADMIN :
$qry = "`user_admin` = 1 AND `user_perms` = '0' AND `user_ban` = 0";
break;
case e_UC_ADMIN :
$qry = "`user_admin` = 1 AND `user_ban` = 0";
break;
case e_UC_MEMBER :
$qry = "`user_ban` = 0";
break;
default :
$qry = "user_ban = 0 AND user_class REGEXP '(^|,)(".$notifyTarget.")(,|$)'";
break;
}
$qry = 'SELECT user_id,user_name,user_email,user_join,user_lastvisit FROM `#user` WHERE '.$qry;
if ($blockOriginator)
{
$qry .= ' AND `user_id` != '.USERID;
}
if (false !== ($count = $sql->gen($qry)))
{
// Now add email addresses to the list
while ($row = $sql->fetch())
{
if ($row['user_email'] != $emailFilter)
{
$unsubscribe = array('date'=>$row['user_join'],'email'=>$row['user_email'],'id'=>$row['user_id'], 'plugin'=>'user', 'userclass'=>$notifyTarget);
$urlQuery = http_build_query($unsubscribe,null,'&');
$exclude = array(e_UC_MEMBER,e_UC_ADMIN, e_UC_MAINADMIN); // no unsubscribing from these classes.
$unsubUrl = SITEURL."unsubscribe.php?id=".base64_encode($urlQuery);
$unsubMessage = "This message was sent to ".$row['user_email'].". If you don't want to receive these emails in the future, please <a href='".$unsubUrl."'>unsubscribe</a>.";
$recipients[] = array(
'mail_recipient_id' => $row['user_id'],
'mail_recipient_name' => $row['user_name'], // Should this use realname?
'mail_recipient_email' => $row['user_email'],
'mail_target_info' => array(
'USERID' => $row['user_id'],
'DISPLAYNAME' => $row['user_name'],
'SUBJECT' => $subject,
'USERNAME' => $row['user_name'],
'USERLASTVISIT' => $row['user_lastvisit'],
'UNSUBSCRIBE' => (!in_array($notifyTarget, $exclude)) ? $unsubUrl : '',
'UNSUBSCRIBE_MESSAGE' => (!in_array($notifyTarget, $exclude)) ? $unsubMessage : '',
'USERCLASS' => $notifyTarget,
'DATE_SHORT' => $tp->toDate(time(),'short'),
'DATE_LONG' => $tp->toDate(time(),'long'),
)
);
}
}
}
}
if(E107_DEBUG_LEVEL > 0 || deftrue('e_DEBUG_NOTIFY'))
{
$data = array('id'=>$id, 'subject'=>$subject, 'recipients'=> $recipients, 'prefs'=>$this->notify_prefs['event'][$id], 'message'=>$message);
e107::getMessage()->addDebug("<b>Mailing is simulated only while in DEBUG mode.</b>");
e107::getMessage()->addDebug(print_a($data,true));
e107::getLog()->add('Notify Debug', $data, E_LOG_INFORMATIVE, "NOTIFY_DBG");
return;
}
$siteadminemail = e107::getPref('siteadminemail');
$siteadmin = e107::getPref('siteadmin');
if (count($recipients))
{
require_once(e_HANDLER.'mail_manager_class.php');
$mailer = new e107MailManager;
// Create the mail body
$mailData = array(
'mail_total_count' => count($recipients),
'mail_content_status' => MAIL_STATUS_TEMP,
'mail_create_app' => 'core',
'mail_title' => 'NOTIFY',
'mail_subject' => $subject,
'mail_sender_email' => e107::getPref('replyto_email',$siteadminemail),
'mail_sender_name' => e107::getPref('replyto_name',$siteadmin),
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
'mail_body' => $message,
'template' => 'notify',
'mail_send_style' => 'notify'
);
if(!empty($media) && is_array($media))
{
foreach($media as $k=>$v)
{
$mailData['mail_media'][$k] = array('path'=>$v);
}
}
$result = $mailer->sendEmails('notify', $mailData, $recipients);
e107::getLog()->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING);
}
else
{
$data = array('qry'=>$qry, 'error'=>'No recipients');
e107::getLog()->add('Notify Debug', $data, E_LOG_WARNING_, "NOTIFY_DBG");
}
}
// ---------------------------------------
function notify_usersup($data)
{
$message = "";
foreach ($data as $key => $value)
{
if($key != "password1" && $key != "password2" && $key != "email_confirm" && $key != "register")
{
if(is_array($value)) // show user-extended values.
{
foreach($value as $k => $v)
{
$message .= str_replace("user_","",$k).': '.$v.'<br />';
}
}
else
{
$message .= $key.': '.$value.'<br />';
}
}
}
$this->send('usersup', NT_LAN_US_1, $message);
}
/**
* @param $data
*/
function notify_userveri($data)
{
$msgtext = NT_LAN_UV_2.$data['user_id']."\n";
$msgtext .= NT_LAN_UV_3.$data['user_loginname']."\n";
$msgtext .= NT_LAN_UV_4.e107::getIPHandler()->getIP(FALSE);
$this->send('userveri', NT_LAN_UV_1, $msgtext);
}
function notify_login($data)
{
$message = "";
foreach ($data as $key => $value)
{
$message .= $key.': '.$value.'<br />';
}
$this->send('login', NT_LAN_LI_1, $message);
}
function notify_logout()
{
$this->send('logout', NT_LAN_LO_1, USERID.'. '.USERNAME.' '.NT_LAN_LO_2);
}
function notify_flood($data)
{
$this->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.e107::getIPHandler()->ipDecode($data, TRUE));
}
function notify_subnews($data)
{
$message = "";
foreach ($data as $key => $value)
{
$message .= $key.': '.$value.'<br />';
}
$this->send('subnews', NT_LAN_SN_1, $message);
}
function notify_newspost($data)
{
$message = '<b>'.$data['news_title'].'</b>';
if (vartrue($data['news_summary'])) $message .= '<br /><br />'.$data['news_summary'];
if (vartrue($data['news_body'])) $message .= '<br /><br />'.$data['news_body'];
if (vartrue($data['news_extended'])) $message.= '<br /><br />'.$data['news_extended'];
$this->send('newspost', $data['news_title'], e107::getParser()->text_truncate(e107::getParser()->toDB($message), 400, '...'));
}
function notify_newsupd($data)
{
$message = '<b>'.$data['news_title'].'</b>';
if (vartrue($data['news_summary'])) $message .= '<br /><br />'.$data['news_summary'];
if (vartrue($data['news_body'])) $message .= '<br /><br />'.$data['news_body'];
if (vartrue($data['news_extended'])) $message.= '<br /><br />'.$data['news_extended'];
$this->send('newsupd', NT_LAN_NU_1.': '.$data['news_title'], e107::getParser()->text_truncate(e107::getParser()->toDB($message), 400, '...'));
}
function notify_newsdel($data)
{
$this->send('newsdel', NT_LAN_ND_1, NT_LAN_ND_2.': '.$data);
}
function notify_maildone($data)
{
$message = '<b>'.$data['mail_subject'].'</b><br /><br />'.$data['mail_body'];
$this->send('maildone', NT_LAN_ML_1.': '.$data['mail_subject'], $message);
}
function notify_fileupload($data)
{
$message = '<b>'.$data['upload_name'].'</b><br /><br />'.$data['upload_description'].'<br /><br />'.$data['upload_size'].'<br /><br />'.$data['upload_user'];
$this->send('fileupload', $data['upload_name'], $message);
}
function notify_admin_news_created($data)
{
$this->notify_newspost($data);
}
function notify_admin_news_notify($data)
{
$tp = e107::getParser();
$sql = e107::getDb();
$author = $sql->retrieve('user','user_name','user_id = '.intval($data['news_author'])." LIMIT 1");
$template = "<h4><a href='{NEWS_URL}'>{NEWS_TITLE}</a></h4>
<div class='summary'>{NEWS_SUMMARY}</div>
<div class='author'>".LAN_POSTED_BY.": {NEWS_AUTHOR}</div>
<div><a class='btn btn-primary' href='{NEWS_URL}'>".LAN_CLICK_TO_VIEW."</a></div>
";
$shortcodes = array(
'NEWS_URL' => e107::getUrl()->create('news/view/item', $data,'full=1&encode=0'),
'NEWS_TITLE' => $tp->toHTML($data['news_title']),
'NEWS_SUMMARY' => $tp->toEmail($data['news_summary']),
'NEWS_AUTHOR' => $tp->toHTML($author)
);
$img = explode(",",$data['news_thumbnail']);
$message = $tp->simpleParse($template, $shortcodes);
$this->send('admin_news_notify', $data['news_title'], $message, $img);
// print_a($message);
}
}
/*
if (isset($nt->notify_prefs['plugins']) && e_PAGE != 'notify.php')
{
foreach ($nt->notify_prefs['plugins'] as $plugin_id => $plugin_settings)
{
if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php'))
{
require_once(e_PLUGIN.$plugin_id.'/e_notify.php');
}
}
}
*/
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
/**
* @package e107
* @subpackage e107_handlers
*
* Handler for 'notify' events - sends email notifications to the appropriate user groups
*/
if (!defined('e107_INIT')) { exit; }
class notify
{
public $notify_prefs;
function __construct()
{
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php');
if(empty($this->notify_prefs))
{
$this->notify_prefs = e107::getConfig('notify')->getPref();
}
}
/**
* Register core and plugin notification events.
*/
public function registerEvents()
{
$active = e107::getConfig()->get('notify');
if(empty($active) && defset('e_PAGE') == 'notify.php')
{
e107::getMessage()->addDebug('Notify is disabled!');
return false;
}
$e_event = e107::getEvent();
if(varset($this->notify_prefs['event']))
{
foreach ($this->notify_prefs['event'] as $id => $status)
{
$include = null;
if ($status['class'] != e_UC_NOBODY) // 255;
{
if(varset($status['include'])) // Plugin
{
$include = e_PLUGIN.$status['include']."/e_notify.php";
if(varset($status['legacy']) != 1)
{
$class = $status['include']."_notify";
$method = $id;
$e_event->register($id, array($class, $method), $include);
}
else
{
$e_event->register($id, 'notify_'.$id, $include);
}
}
else // core
{
if(method_exists($this, 'notify_'.$id)) // as found below.
{
$e_event->register($id, array('notify', 'notify_'.$id));
}
else
{
$e_event->register($id, array('notify', 'generic')); // use generic notification.
}
}
}
}
}
// e107::getEvent()->debug();
}
/**
* Generic Notification method when none defined.
*/
function generic($data,$id)
{
$message = print_a($data,true);
$this->send($id, 'Event Triggered: '.$id, $message);
}
/**
* Send an email notification following an event.
*
* The email is sent via a common interface, which will send immediately for small numbers of recipients, and queue for larger.
*
* @param string $id - identifies event actions
* @param string $subject - subject for email
* @param string $message - email message body
* @return void
*
* @todo handle 'everyone except' clauses (email address filter done)
* @todo set up pref to not notify originator of event which caused notify (see $blockOriginator)
*/
function send($id, $subject, $message, $media=array())
{
$tp = e107::getParser();
$sql = e107::getDb();
$subject = $tp->toEmail($subject);
$message = $tp->replaceConstants($message, "full");
// $message = $tp->toEmail($message);
$emailFilter = '';
$notifyTarget = $this->notify_prefs['event'][$id]['class'];
if ($notifyTarget == '-email')
{
$emailFilter = $this->notify_prefs['event'][$id]['email'];
}
$blockOriginator = FALSE; // TODO: set this using a pref
$recipients = array();
if ($notifyTarget == 'email') // Single email address - that can always go immediately
{
if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL))
{
$recipients[] = array(
'mail_recipient_email' => $this->notify_prefs['event'][$id]['email'],
'mail_target_info' => array(
'SUBJECT' => $subject,
'DATE_SHORT' => $tp->toDate(time(),'short'),
'DATE_LONG' => $tp->toDate(time(),'long'),
)
);
}
}
elseif (is_numeric($notifyTarget))
{
switch ($notifyTarget)
{
case e_UC_MAINADMIN :
$qry = "`user_admin` = 1 AND `user_perms` = '0' AND `user_ban` = 0";
break;
case e_UC_ADMIN :
$qry = "`user_admin` = 1 AND `user_ban` = 0";
break;
case e_UC_MEMBER :
$qry = "`user_ban` = 0";
break;
default :
$qry = "user_ban = 0 AND user_class REGEXP '(^|,)(".$notifyTarget.")(,|$)'";
break;
}
$qry = 'SELECT user_id,user_name,user_email,user_join,user_lastvisit FROM `#user` WHERE '.$qry;
if ($blockOriginator)
{
$qry .= ' AND `user_id` != '.USERID;
}
if (false !== ($count = $sql->gen($qry)))
{
// Now add email addresses to the list
while ($row = $sql->fetch())
{
if ($row['user_email'] != $emailFilter)
{
$unsubscribe = array('date'=>$row['user_join'],'email'=>$row['user_email'],'id'=>$row['user_id'], 'plugin'=>'user', 'userclass'=>$notifyTarget);
$urlQuery = http_build_query($unsubscribe,null,'&');
$exclude = array(e_UC_MEMBER,e_UC_ADMIN, e_UC_MAINADMIN); // no unsubscribing from these classes.
$unsubUrl = SITEURL."unsubscribe.php?id=".base64_encode($urlQuery);
$unsubMessage = "This message was sent to ".$row['user_email'].". If you don't want to receive these emails in the future, please <a href='".$unsubUrl."'>unsubscribe</a>.";
$recipients[] = array(
'mail_recipient_id' => $row['user_id'],
'mail_recipient_name' => $row['user_name'], // Should this use realname?
'mail_recipient_email' => $row['user_email'],
'mail_target_info' => array(
'USERID' => $row['user_id'],
'DISPLAYNAME' => $row['user_name'],
'SUBJECT' => $subject,
'USERNAME' => $row['user_name'],
'USERLASTVISIT' => $row['user_lastvisit'],
'UNSUBSCRIBE' => (!in_array($notifyTarget, $exclude)) ? $unsubUrl : '',
'UNSUBSCRIBE_MESSAGE' => (!in_array($notifyTarget, $exclude)) ? $unsubMessage : '',
'USERCLASS' => $notifyTarget,
'DATE_SHORT' => $tp->toDate(time(),'short'),
'DATE_LONG' => $tp->toDate(time(),'long'),
)
);
}
}
}
}
if(E107_DEBUG_LEVEL > 0 || deftrue('e_DEBUG_NOTIFY'))
{
$data = array('id'=>$id, 'subject'=>$subject, 'recipients'=> $recipients, 'prefs'=>$this->notify_prefs['event'][$id], 'message'=>$message);
e107::getMessage()->addDebug("<b>Mailing is simulated only while in DEBUG mode.</b>");
e107::getMessage()->addDebug(print_a($data,true));
e107::getLog()->add('Notify Debug', $data, E_LOG_INFORMATIVE, "NOTIFY_DBG");
return;
}
$siteadminemail = e107::getPref('siteadminemail');
$siteadmin = e107::getPref('siteadmin');
if (count($recipients))
{
require_once(e_HANDLER.'mail_manager_class.php');
$mailer = new e107MailManager;
// Create the mail body
$mailData = array(
'mail_total_count' => count($recipients),
'mail_content_status' => MAIL_STATUS_TEMP,
'mail_create_app' => 'core',
'mail_title' => 'NOTIFY',
'mail_subject' => $subject,
'mail_sender_email' => e107::getPref('replyto_email',$siteadminemail),
'mail_sender_name' => e107::getPref('replyto_name',$siteadmin),
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
'mail_body' => $message,
'template' => 'notify',
'mail_send_style' => 'notify'
);
if(!empty($media) && is_array($media))
{
foreach($media as $k=>$v)
{
$mailData['mail_media'][$k] = array('path'=>$v);
}
}
$result = $mailer->sendEmails('notify', $mailData, $recipients);
e107::getLog()->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING);
}
else
{
$data = array('qry'=>$qry, 'error'=>'No recipients');
e107::getLog()->add('Notify Debug', $data, E_LOG_WARNING_, "NOTIFY_DBG");
}
}
// ---------------------------------------
function notify_usersup($data)
{
$message = "";
foreach ($data as $key => $value)
{
if($key != "password1" && $key != "password2" && $key != "email_confirm" && $key != "register")
{
if(is_array($value)) // show user-extended values.
{
foreach($value as $k => $v)
{
$message .= str_replace("user_","",$k).': '.$v.'<br />';
}
}
else
{
$message .= $key.': '.$value.'<br />';
}
}
}
$this->send('usersup', NT_LAN_US_1, $message);
}
/**
* @param $data
*/
function notify_userveri($data)
{
$msgtext = NT_LAN_UV_2.$data['user_id']."\n";
$msgtext .= NT_LAN_UV_3.$data['user_loginname']."\n";
$msgtext .= NT_LAN_UV_4.e107::getIPHandler()->getIP(FALSE);
$this->send('userveri', NT_LAN_UV_1, $msgtext);
}
function notify_login($data)
{
$message = "";
foreach ($data as $key => $value)
{
$message .= $key.': '.$value.'<br />';
}
$this->send('login', NT_LAN_LI_1, $message);
}
function notify_logout()
{
$this->send('logout', NT_LAN_LO_1, USERID.'. '.USERNAME.' '.NT_LAN_LO_2);
}
function notify_flood($data)
{
$this->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.e107::getIPHandler()->ipDecode($data, TRUE));
}
function notify_subnews($data)
{
$message = "";
foreach ($data as $key => $value)
{
$message .= $key.': '.$value.'<br />';
}
$this->send('subnews', NT_LAN_SN_1, $message);
}
function notify_newspost($data)
{
$message = '<b>'.$data['news_title'].'</b>';
if (vartrue($data['news_summary'])) $message .= '<br /><br />'.$data['news_summary'];
if (vartrue($data['news_body'])) $message .= '<br /><br />'.$data['news_body'];
if (vartrue($data['news_extended'])) $message.= '<br /><br />'.$data['news_extended'];
$this->send('newspost', $data['news_title'], e107::getParser()->text_truncate(e107::getParser()->toDB($message), 400, '...'));
}
function notify_newsupd($data)
{
$message = '<b>'.$data['news_title'].'</b>';
if (vartrue($data['news_summary'])) $message .= '<br /><br />'.$data['news_summary'];
if (vartrue($data['news_body'])) $message .= '<br /><br />'.$data['news_body'];
if (vartrue($data['news_extended'])) $message.= '<br /><br />'.$data['news_extended'];
$this->send('newsupd', NT_LAN_NU_1.': '.$data['news_title'], e107::getParser()->text_truncate(e107::getParser()->toDB($message), 400, '...'));
}
function notify_newsdel($data)
{
$this->send('newsdel', NT_LAN_ND_1, NT_LAN_ND_2.': '.$data);
}
function notify_maildone($data)
{
$message = '<b>'.$data['mail_subject'].'</b><br /><br />'.$data['mail_body'];
$this->send('maildone', NT_LAN_ML_1.': '.$data['mail_subject'], $message);
}
function notify_fileupload($data)
{
$message = '<b>'.$data['upload_name'].'</b><br /><br />'.$data['upload_description'].'<br /><br />'.$data['upload_size'].'<br /><br />'.$data['upload_user'];
$this->send('fileupload', $data['upload_name'], $message);
}
function notify_admin_news_created($data)
{
$this->notify_newspost($data);
}
function notify_admin_news_notify($data)
{
$tp = e107::getParser();
$sql = e107::getDb();
$author = $sql->retrieve('user','user_name','user_id = '.intval($data['news_author'])." LIMIT 1");
$template = "<h4><a href='{NEWS_URL}'>{NEWS_TITLE}</a></h4>
<div class='summary'>{NEWS_SUMMARY}</div>
<div class='author'>".LAN_POSTED_BY.": {NEWS_AUTHOR}</div>
<div><a class='btn btn-primary' href='{NEWS_URL}'>".LAN_CLICK_TO_VIEW."</a></div>
";
$shortcodes = array(
'NEWS_URL' => e107::getUrl()->create('news/view/item', $data,'full=1&encode=0'),
'NEWS_TITLE' => $tp->toHTML($data['news_title']),
'NEWS_SUMMARY' => $tp->toEmail($data['news_summary']),
'NEWS_AUTHOR' => $tp->toHTML($author)
);
$img = explode(",",$data['news_thumbnail']);
$message = $tp->simpleParse($template, $shortcodes);
$this->send('admin_news_notify', $data['news_title'], $message, $img);
// print_a($message);
}
}
/*
if (isset($nt->notify_prefs['plugins']) && e_PAGE != 'notify.php')
{
foreach ($nt->notify_prefs['plugins'] as $plugin_id => $plugin_settings)
{
if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php'))
{
require_once(e_PLUGIN.$plugin_id.'/e_notify.php');
}
}
}
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,80 +1,80 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if (!defined('e107_INIT')) { exit; }
$e107 = e107::getInstance();
$action = e107::getParser()->toDB(varset($_GET['mode'],'makemail'));
switch ($action)
{
case 'justone' :
$text = 'Send mail with constraints specified by an optional plugin';
break;
case 'debug' :
$text = 'For devs only. Not used at present';
break;
case 'saved' :
$text = 'Select and use a saved email template to send a mailshot. Delete any template no longer required';
break;
case 'pending' :
$text = 'List of mailshots released for sending, together with current status. The mail scheduler task will process these emails as it is able, taking account of
the earliest and latest sending dates you set';
break;
case 'held' :
$text = 'List of emails which have been prepared for sending, but not yet released';
break;
case 'sent' :
$text = 'List of completed mailshots. Allows you to see the sending results.<br />';
break;
case 'savedmail' :
case 'makemail' :
case 'main' :
$text = 'Create an email, give it a meaningful title, and select the list of recipients. You can save everything as a template for later, or send immediately.<br />';
$text .= 'Email addresses may be contributed by plugins (such as newsletter), and duplicates are removed when the mail is sent<br />';
$text .= 'Any attachment is selected from the list of valid downloads.<br />';
$text .= 'Mail may be sent as plain text (most universal, and least at risk of being classed as spam), or as HTML (in which case a plain text alternative is automatically generated). The theme style
may optionally be added to the email. Alternatively a predefined template can be selected.';
break;
case 'recipients' :
$text = 'Shows all recipients or potential recipients of an email, together with current status';
break;
case 'prefs' :
$text = '<b>Configure mailshot options.</b><br />
A test email is sent using the current method and settings. If you are having problems with emails bouncing, try sending a test email to: <i>check-auth@verifier.port25.com</i> to ensure your server MX records are correct. Of course, be sure your site email address is correct before doing so.<br /><br />';
$text .= '<b>Emailing Method</b><br />
Use SMTP to send mail if possible. The settings will depend on your host\'s mail server.<br /><br />';
$text .= '<b>Default email format</b><br />
Emails may be sent either in plain text only, or in HTML format. The latter generally gives a better appearance, but is more prone to being filtered by various
security measures. If you select HTML, a separate plain text part is added.<br /><br />';
$text .= '<b>Bulk mail controls</b><br />
The values you set here will depend on your host, and on the number of emails you send; it may be possible to set all values to zero so that the
mail queue is emptied virtually instantly. Typically it is best to send less than 500 emails per hour.<br /><br />';
$text .= '<b>Bounced Emails</b><br />
You can specify an email address to receive the return response when an email is undeliverable. If you have control over your server, you can specify the
separate scheduler-driven auto-processing script; this receives bounce messages as they arrive, and updates status instantly. Otherwise you can specify a separate email account,
which can be checked either periodically (using the scheduler), or manually via the user options menu. Normally this will be a standard
POP3 account; use the TLS-related options only if specifically required by your host<br /><br />';
$text .= '<b>Email Address Sources</b><br />
If you have additional mail-related plugins, you can select which of them may contribute email addresses to the list.<br /><br />';
$text .= '<b>Logging</b><br />
The logging option creates a text file in the system log directory. This must be deleted periodically. The \'logging
only\' options allow you to see exactly who would receive emails if actually sent. The \'with errors\' option fails every
7th email, primarily for testing';
break;
case 'maint' :
$text = 'Maintenance functions for the mail database';
break;
default :
$text = 'Undocumented option';
}
$ns->tablerender('Mail Help', $text);
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if (!defined('e107_INIT')) { exit; }
$e107 = e107::getInstance();
$action = e107::getParser()->toDB(varset($_GET['mode'],'makemail'));
switch ($action)
{
case 'justone' :
$text = 'Send mail with constraints specified by an optional plugin';
break;
case 'debug' :
$text = 'For devs only. Not used at present';
break;
case 'saved' :
$text = 'Select and use a saved email template to send a mailshot. Delete any template no longer required';
break;
case 'pending' :
$text = 'List of mailshots released for sending, together with current status. The mail scheduler task will process these emails as it is able, taking account of
the earliest and latest sending dates you set';
break;
case 'held' :
$text = 'List of emails which have been prepared for sending, but not yet released';
break;
case 'sent' :
$text = 'List of completed mailshots. Allows you to see the sending results.<br />';
break;
case 'savedmail' :
case 'makemail' :
case 'main' :
$text = 'Create an email, give it a meaningful title, and select the list of recipients. You can save everything as a template for later, or send immediately.<br />';
$text .= 'Email addresses may be contributed by plugins (such as newsletter), and duplicates are removed when the mail is sent<br />';
$text .= 'Any attachment is selected from the list of valid downloads.<br />';
$text .= 'Mail may be sent as plain text (most universal, and least at risk of being classed as spam), or as HTML (in which case a plain text alternative is automatically generated). The theme style
may optionally be added to the email. Alternatively a predefined template can be selected.';
break;
case 'recipients' :
$text = 'Shows all recipients or potential recipients of an email, together with current status';
break;
case 'prefs' :
$text = '<b>Configure mailshot options.</b><br />
A test email is sent using the current method and settings. If you are having problems with emails bouncing, try sending a test email to: <i>check-auth@verifier.port25.com</i> to ensure your server MX records are correct. Of course, be sure your site email address is correct before doing so.<br /><br />';
$text .= '<b>Emailing Method</b><br />
Use SMTP to send mail if possible. The settings will depend on your host\'s mail server.<br /><br />';
$text .= '<b>Default email format</b><br />
Emails may be sent either in plain text only, or in HTML format. The latter generally gives a better appearance, but is more prone to being filtered by various
security measures. If you select HTML, a separate plain text part is added.<br /><br />';
$text .= '<b>Bulk mail controls</b><br />
The values you set here will depend on your host, and on the number of emails you send; it may be possible to set all values to zero so that the
mail queue is emptied virtually instantly. Typically it is best to send less than 500 emails per hour.<br /><br />';
$text .= '<b>Bounced Emails</b><br />
You can specify an email address to receive the return response when an email is undeliverable. If you have control over your server, you can specify the
separate scheduler-driven auto-processing script; this receives bounce messages as they arrive, and updates status instantly. Otherwise you can specify a separate email account,
which can be checked either periodically (using the scheduler), or manually via the user options menu. Normally this will be a standard
POP3 account; use the TLS-related options only if specifically required by your host<br /><br />';
$text .= '<b>Email Address Sources</b><br />
If you have additional mail-related plugins, you can select which of them may contribute email addresses to the list.<br /><br />';
$text .= '<b>Logging</b><br />
The logging option creates a text file in the system log directory. This must be deleted periodically. The \'logging
only\' options allow you to see exactly who would receive emails if actually sent. The \'with errors\' option fails every
7th email, primarily for testing';
break;
case 'maint' :
$text = 'Maintenance functions for the mail database';
break;
default :
$text = 'Undocumented option';
}
$ns->tablerender('Mail Help', $text);

View File

@@ -1,133 +1,133 @@
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
//define("RL_LAN_001", "System Logs");
define("RL_LAN_002", "Rolling Log");
// define("RL_LAN_003", "User Audit Trail Maintenance");
//define("RL_LAN_004", "Admin/Rolling Log Upgraded");
define("RL_LAN_005", "Configure/View system logs");
//define("RL_LAN_006", "Options Updated");
// define("RL_LAN_007", "User Audit Trail Options");
define("RL_LAN_008", "Rolling Log is active:");
define("RL_LAN_009", "Rolling Log History length in days");
// define("RL_LAN_010", "Update Options");
// define("RL_LAN_011", "Rolling Log Configuration");
define("RL_LAN_012", "Filter Options");
define("RL_LAN_013", "Start date/time");
define("RL_LAN_014", "End date/time");
define("RL_LAN_015", "User ID filter");
define("RL_LAN_016", "Blank for none, zero for guest");
define("RL_LAN_017", "No log entries, or none match filter");
define("RL_LAN_018", "Refresh log");
define("RL_LAN_019", "yy-mm-dd hh:mm:ss");
define("RL_LAN_020", "IP");
//define("RL_LAN_021", "ID");
//define("RL_LAN_022", "User");
define("RL_LAN_023", "Event Type");
define("RL_LAN_024", "From");
define("RL_LAN_025", "Event Title");
define("RL_LAN_026", "Class for which user actions logged");
// define("RL_LAN_027", "Options");
define("RL_LAN_028", "Update Filters");
define("RL_LAN_029", "Event type filter");
define("RL_LAN_030", "Admin Log");
define("RL_LAN_031", "Actions to log");
define("RL_LAN_032", "Pri"); // Event importance
define("RL_LAN_033", "Further Information");
define("RL_LAN_044", "Log events to display per page");
define("RL_LAN_045", "Delete admin log events older than ");
define("RL_LAN_046", "days");
define("RL_LAN_047", "Confirm delete admin log events older than ");
// define("RL_LAN_048", "Admin log maintenance");
define("RL_LAN_049", "Delete old entries");
define("RL_LAN_050", "Parameter error - nothing deleted");
// define("RL_LAN_051", "Confirm Delete");
define("RL_LAN_052", "Admin log");
define("RL_LAN_053", "User Audit Log");
define("RL_LAN_054", "Nothing to delete, or database error");
// define("RL_LAN_055", "Cancel");
//define("RL_LAN_056", "Nothing deleted");
define("RL_LAN_057", " - events older than [x] ([y] entries) deleted");
define("RL_LAN_058", "Priority Filter:");
define("RL_LAN_059", "Caller Filter:");
define("RL_LAN_060", "IP Address Filter:");
define("RL_LAN_061", "Wildcard (*) at end acceptable");
define("RL_LAN_062", "User Audit Log");
// define("RL_LAN_063", "User audit settings updated");
define("RL_LAN_064", "Applicable to all logs");
define("RL_LAN_065", "Confirm delete user audit log events older than ");
define("RL_LAN_066", "Delete user audit trail log events older than ");
define("RL_LAN_067", "Download History");
define("RL_LAN_068", "D/L ID");
define("RL_LAN_069", "Download Name");
// Messages for checkbox options in audit log - correspond to audit log event codes (20 consecutive values reserved)
define("RL_LAN_071", "User registration (ignores class setting above)");
define("RL_LAN_072", "Signup email acknowledgement (ignores class setting above)");
define("RL_LAN_073", "Login/Logout");
define("RL_LAN_075", "Change display name");
define("RL_LAN_076", "Change password");
define("RL_LAN_077", "Change email address");
define("RL_LAN_078", "Password Reset");
define("RL_LAN_079", "Change other user settings");
define("RL_LAN_080", "Admin quick add user");
define("RL_LAN_081", "Mail bounces");
define("RL_LAN_082", "User bans");
define("RL_LAN_083", "Mail bounce resets");
define("RL_LAN_084", "Temporary accounts");
define("RL_LAN_087", "Details");
// Intentional gap
define("RL_LAN_090", "Download ID");
define("RL_LAN_091", "Detailed timings");
define("RL_LAN_092", "Time period");
define("RL_LAN_093", "(mins)");
define("RL_LAN_094", "Detailed timing analysis");
// define("RL_LAN_095", "Logs to include");
define("RL_LAN_096", "Diff (s)");
// define("RL_LAN_097", "Time");
//define("RL_LAN_098", "Source"); // Moved to lan_admin.php
// define("RL_LAN_099", "Comments");
define("RL_LAN_100", "CID"); // Comment ID field
define("RL_LAN_101", "PID");
//define("RL_LAN_102", "ID");//LAN_ID
define("RL_LAN_103", "Subject");
define("RL_LAN_104", "UID");
// define("RL_LAN_105", "Author");
define("RL_LAN_106", "Type");
define("RL_LAN_107", "Comment");
define("RL_LAN_108", "BK"); // Comment blocked
define("RL_LAN_109", "LK"); // Comment locked
define("RL_LAN_110", "Del"); // Delete column
define("RL_LAN_111", "Delete checked items");
define("RL_LAN_112", "Deleted --NUMBER-- comments");
define("RL_LAN_113", "Error deleting comments!");
define("RL_LAN_114", "Clear Filters");
define("RL_LAN_115", "Users Admin");
define("RL_LAN_116", "Location");
define("RL_LAN_117", "PgCnt");
define("RL_LAN_118", "Flag");
// define("RL_LAN_119", "Active");
define("RL_LAN_120", "Users on-line");
//define("RL_LAN_121", "System Logs Options");
define("RL_LAN_122", "System Logs Configuration");
define("RL_LAN_123", "User audit trail class");
define("RL_LAN_124", "User audit trail actions");
define("RL_LAN_125", "System Logs Maintenance");
define("RL_LAN_126", "Total [x] entries matching search condition");
define("RL_LAN_132", "Informative");
define("RL_LAN_133", "Notice");
define("RL_LAN_134", "Warning");
define("RL_LAN_135", "Fatal");
// define("RL_LAN_JS_CONFIRM", "Are you sure?");
?>
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
//define("RL_LAN_001", "System Logs");
define("RL_LAN_002", "Rolling Log");
// define("RL_LAN_003", "User Audit Trail Maintenance");
//define("RL_LAN_004", "Admin/Rolling Log Upgraded");
define("RL_LAN_005", "Configure/View system logs");
//define("RL_LAN_006", "Options Updated");
// define("RL_LAN_007", "User Audit Trail Options");
define("RL_LAN_008", "Rolling Log is active:");
define("RL_LAN_009", "Rolling Log History length in days");
// define("RL_LAN_010", "Update Options");
// define("RL_LAN_011", "Rolling Log Configuration");
define("RL_LAN_012", "Filter Options");
define("RL_LAN_013", "Start date/time");
define("RL_LAN_014", "End date/time");
define("RL_LAN_015", "User ID filter");
define("RL_LAN_016", "Blank for none, zero for guest");
define("RL_LAN_017", "No log entries, or none match filter");
define("RL_LAN_018", "Refresh log");
define("RL_LAN_019", "yy-mm-dd hh:mm:ss");
define("RL_LAN_020", "IP");
//define("RL_LAN_021", "ID");
//define("RL_LAN_022", "User");
define("RL_LAN_023", "Event Type");
define("RL_LAN_024", "From");
define("RL_LAN_025", "Event Title");
define("RL_LAN_026", "Class for which user actions logged");
// define("RL_LAN_027", "Options");
define("RL_LAN_028", "Update Filters");
define("RL_LAN_029", "Event type filter");
define("RL_LAN_030", "Admin Log");
define("RL_LAN_031", "Actions to log");
define("RL_LAN_032", "Pri"); // Event importance
define("RL_LAN_033", "Further Information");
define("RL_LAN_044", "Log events to display per page");
define("RL_LAN_045", "Delete admin log events older than ");
define("RL_LAN_046", "days");
define("RL_LAN_047", "Confirm delete admin log events older than ");
// define("RL_LAN_048", "Admin log maintenance");
define("RL_LAN_049", "Delete old entries");
define("RL_LAN_050", "Parameter error - nothing deleted");
// define("RL_LAN_051", "Confirm Delete");
define("RL_LAN_052", "Admin log");
define("RL_LAN_053", "User Audit Log");
define("RL_LAN_054", "Nothing to delete, or database error");
// define("RL_LAN_055", "Cancel");
//define("RL_LAN_056", "Nothing deleted");
define("RL_LAN_057", " - events older than [x] ([y] entries) deleted");
define("RL_LAN_058", "Priority Filter:");
define("RL_LAN_059", "Caller Filter:");
define("RL_LAN_060", "IP Address Filter:");
define("RL_LAN_061", "Wildcard (*) at end acceptable");
define("RL_LAN_062", "User Audit Log");
// define("RL_LAN_063", "User audit settings updated");
define("RL_LAN_064", "Applicable to all logs");
define("RL_LAN_065", "Confirm delete user audit log events older than ");
define("RL_LAN_066", "Delete user audit trail log events older than ");
define("RL_LAN_067", "Download History");
define("RL_LAN_068", "D/L ID");
define("RL_LAN_069", "Download Name");
// Messages for checkbox options in audit log - correspond to audit log event codes (20 consecutive values reserved)
define("RL_LAN_071", "User registration (ignores class setting above)");
define("RL_LAN_072", "Signup email acknowledgement (ignores class setting above)");
define("RL_LAN_073", "Login/Logout");
define("RL_LAN_075", "Change display name");
define("RL_LAN_076", "Change password");
define("RL_LAN_077", "Change email address");
define("RL_LAN_078", "Password Reset");
define("RL_LAN_079", "Change other user settings");
define("RL_LAN_080", "Admin quick add user");
define("RL_LAN_081", "Mail bounces");
define("RL_LAN_082", "User bans");
define("RL_LAN_083", "Mail bounce resets");
define("RL_LAN_084", "Temporary accounts");
define("RL_LAN_087", "Details");
// Intentional gap
define("RL_LAN_090", "Download ID");
define("RL_LAN_091", "Detailed timings");
define("RL_LAN_092", "Time period");
define("RL_LAN_093", "(mins)");
define("RL_LAN_094", "Detailed timing analysis");
// define("RL_LAN_095", "Logs to include");
define("RL_LAN_096", "Diff (s)");
// define("RL_LAN_097", "Time");
//define("RL_LAN_098", "Source"); // Moved to lan_admin.php
// define("RL_LAN_099", "Comments");
define("RL_LAN_100", "CID"); // Comment ID field
define("RL_LAN_101", "PID");
//define("RL_LAN_102", "ID");//LAN_ID
define("RL_LAN_103", "Subject");
define("RL_LAN_104", "UID");
// define("RL_LAN_105", "Author");
define("RL_LAN_106", "Type");
define("RL_LAN_107", "Comment");
define("RL_LAN_108", "BK"); // Comment blocked
define("RL_LAN_109", "LK"); // Comment locked
define("RL_LAN_110", "Del"); // Delete column
define("RL_LAN_111", "Delete checked items");
define("RL_LAN_112", "Deleted --NUMBER-- comments");
define("RL_LAN_113", "Error deleting comments!");
define("RL_LAN_114", "Clear Filters");
define("RL_LAN_115", "Users Admin");
define("RL_LAN_116", "Location");
define("RL_LAN_117", "PgCnt");
define("RL_LAN_118", "Flag");
// define("RL_LAN_119", "Active");
define("RL_LAN_120", "Users on-line");
//define("RL_LAN_121", "System Logs Options");
define("RL_LAN_122", "System Logs Configuration");
define("RL_LAN_123", "User audit trail class");
define("RL_LAN_124", "User audit trail actions");
define("RL_LAN_125", "System Logs Maintenance");
define("RL_LAN_126", "Total [x] entries matching search condition");
define("RL_LAN_132", "Informative");
define("RL_LAN_133", "Notice");
define("RL_LAN_134", "Warning");
define("RL_LAN_135", "Fatal");
// define("RL_LAN_JS_CONFIRM", "Are you sure?");
?>

View File

@@ -1,106 +1,106 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if (!defined("PAGE_NAME")) { define("PAGE_NAME", "Schedule Tasks"); }
// Menu
define("LAN_CRON_M_02", "Refresh");
// Table heading
define("LAN_CRON_2", "Function");
define("LAN_CRON_3", "Tab");
define("LAN_CRON_4", "Last-run");
// Default crons
define("LAN_CRON_01_1", "Test Email");
define("LAN_CRON_01_2", "Send a test email to [eml]."); // [eml] is automatically replaced by head admin e-mail address.
define("LAN_CRON_01_3", "Recommended to test the scheduling system.");
define("LAN_CRON_02_1", "Mail Queue");
define("LAN_CRON_02_2", "Process mail queue.");
define("LAN_CRON_03_1", "Mail Bounce Check");
define("LAN_CRON_03_2", "Check for bounced emails.");
define("LAN_CRON_04_1", "Ban Retrigger Check");
define("LAN_CRON_04_2", "Process bounce retriggers.");
define("LAN_CRON_04_3", "Only needed if retriggering of bans enabled.");
define("LAN_CRON_05_1", "Database Backup");
define("LAN_CRON_05_2", "Backup the system database to");
// Error and info messages
define("LAN_CRON_6", "Couldn't Import Prefs");
define("LAN_CRON_7", "Couldn't Import Timing Settings");
define("LAN_CRON_8", "Imported Timing Settings for");
define("LAN_CRON_9", "[x] minutes and [y] seconds ago."); // [x] and [y] are automatically replaced.
define("LAN_CRON_10", "[y] seconds ago.");
define("LAN_CRON_11", "Active Crons");
define("LAN_CRON_12", "Last cron refresh");
define("LAN_CRON_13", "Please be sure cron.php is executable.");
define("LAN_CRON_14", "Please CHMOD /cron.php to 755.");
define("LAN_CRON_15", "Use the following Cron Command");
define("LAN_CRON_16", "Using your server control panel (eg. cPanel, DirectAdmin, Plesk etc.) please create a crontab to run this command on your server every minute.");
// leave some room for additions/changes
// Info for checkCoreUpdate cron
define("LAN_CRON_20_1", "Check for e107 Update");
define("LAN_CRON_20_2", "Check e107.org for Core updates"); // [eml] is automatically replaced by head admin e-mail address.
define("LAN_CRON_20_3", "Recommended to keep system up to date.");
define("LAN_CRON_20_4", "Update this Git repository");
define("LAN_CRON_20_5", "Update this e107 installation with the very latest files from github.");
define("LAN_CRON_20_6", "Recommended for developers only.");
//define("LAN_CRON_20_7", "Warning!");//LAN_WARNING
define("LAN_CRON_20_8", "May cause site instability!");
define("LAN_CRON_30", "Every Minute");
define("LAN_CRON_31", "Every Other Minute");
define("LAN_CRON_32", "Every 5 Minutes");
define("LAN_CRON_33", "Every 10 minutes");
define("LAN_CRON_34", "Every 15 minutes");
define("LAN_CRON_35", "Every 30 minutes");
define("LAN_CRON_36", "Every Hour");
define("LAN_CRON_37", "Every Other Hour");
define("LAN_CRON_38", "Every 3 Hours");
define("LAN_CRON_39", "Every 6 Hours");
define("LAN_CRON_40", "Every Day");
define("LAN_CRON_41", "Every Month");
define("LAN_CRON_42", "Every Week Day");
define("LAN_CRON_50", "Minute(s):");
define("LAN_CRON_51", "Hour(s):");
define("LAN_CRON_52", "Day(s):");
define("LAN_CRON_53", "Month(s):");
define("LAN_CRON_54", "Weekday(s):");
define("LAN_CRON_55", "Database Backup Failed");
define("LAN_CRON_56", "Database Backup Complete");
define("LAN_CRON_60", "Go to cPanel");
define("LAN_CRON_61", "Generate new cron password");
define("LAN_CRON_62", "Executing config function [b][x][/b]");
define("LAN_CRON_63", "Config function [b][x][/b] NOT found.");
define("LAN_CRON_64", "An administrator can automate tasks using e107 Schedule Tasks. [br]
In the Manage Tab, you can edit, delete and run tasks. [br]
When you edit a task you can set the minutes, hours, days, month or day of the week you want the task to run. Use * to run for each period. Use the Active property to Enabled the Task.[br]
Note: You are advised not to delete standard jobs.[br]
");
define("LAN_CRON_BACKUP", "Backup");
define("LAN_CRON_LOGGING", "Logging");
define("LAN_CRON_RUNNING", "Running");
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if (!defined("PAGE_NAME")) { define("PAGE_NAME", "Schedule Tasks"); }
// Menu
define("LAN_CRON_M_02", "Refresh");
// Table heading
define("LAN_CRON_2", "Function");
define("LAN_CRON_3", "Tab");
define("LAN_CRON_4", "Last-run");
// Default crons
define("LAN_CRON_01_1", "Test Email");
define("LAN_CRON_01_2", "Send a test email to [eml]."); // [eml] is automatically replaced by head admin e-mail address.
define("LAN_CRON_01_3", "Recommended to test the scheduling system.");
define("LAN_CRON_02_1", "Mail Queue");
define("LAN_CRON_02_2", "Process mail queue.");
define("LAN_CRON_03_1", "Mail Bounce Check");
define("LAN_CRON_03_2", "Check for bounced emails.");
define("LAN_CRON_04_1", "Ban Retrigger Check");
define("LAN_CRON_04_2", "Process bounce retriggers.");
define("LAN_CRON_04_3", "Only needed if retriggering of bans enabled.");
define("LAN_CRON_05_1", "Database Backup");
define("LAN_CRON_05_2", "Backup the system database to");
// Error and info messages
define("LAN_CRON_6", "Couldn't Import Prefs");
define("LAN_CRON_7", "Couldn't Import Timing Settings");
define("LAN_CRON_8", "Imported Timing Settings for");
define("LAN_CRON_9", "[x] minutes and [y] seconds ago."); // [x] and [y] are automatically replaced.
define("LAN_CRON_10", "[y] seconds ago.");
define("LAN_CRON_11", "Active Crons");
define("LAN_CRON_12", "Last cron refresh");
define("LAN_CRON_13", "Please be sure cron.php is executable.");
define("LAN_CRON_14", "Please CHMOD /cron.php to 755.");
define("LAN_CRON_15", "Use the following Cron Command");
define("LAN_CRON_16", "Using your server control panel (eg. cPanel, DirectAdmin, Plesk etc.) please create a crontab to run this command on your server every minute.");
// leave some room for additions/changes
// Info for checkCoreUpdate cron
define("LAN_CRON_20_1", "Check for e107 Update");
define("LAN_CRON_20_2", "Check e107.org for Core updates"); // [eml] is automatically replaced by head admin e-mail address.
define("LAN_CRON_20_3", "Recommended to keep system up to date.");
define("LAN_CRON_20_4", "Update this Git repository");
define("LAN_CRON_20_5", "Update this e107 installation with the very latest files from github.");
define("LAN_CRON_20_6", "Recommended for developers only.");
//define("LAN_CRON_20_7", "Warning!");//LAN_WARNING
define("LAN_CRON_20_8", "May cause site instability!");
define("LAN_CRON_30", "Every Minute");
define("LAN_CRON_31", "Every Other Minute");
define("LAN_CRON_32", "Every 5 Minutes");
define("LAN_CRON_33", "Every 10 minutes");
define("LAN_CRON_34", "Every 15 minutes");
define("LAN_CRON_35", "Every 30 minutes");
define("LAN_CRON_36", "Every Hour");
define("LAN_CRON_37", "Every Other Hour");
define("LAN_CRON_38", "Every 3 Hours");
define("LAN_CRON_39", "Every 6 Hours");
define("LAN_CRON_40", "Every Day");
define("LAN_CRON_41", "Every Month");
define("LAN_CRON_42", "Every Week Day");
define("LAN_CRON_50", "Minute(s):");
define("LAN_CRON_51", "Hour(s):");
define("LAN_CRON_52", "Day(s):");
define("LAN_CRON_53", "Month(s):");
define("LAN_CRON_54", "Weekday(s):");
define("LAN_CRON_55", "Database Backup Failed");
define("LAN_CRON_56", "Database Backup Complete");
define("LAN_CRON_60", "Go to cPanel");
define("LAN_CRON_61", "Generate new cron password");
define("LAN_CRON_62", "Executing config function [b][x][/b]");
define("LAN_CRON_63", "Config function [b][x][/b] NOT found.");
define("LAN_CRON_64", "An administrator can automate tasks using e107 Schedule Tasks. [br]
In the Manage Tab, you can edit, delete and run tasks. [br]
When you edit a task you can set the minutes, hours, days, month or day of the week you want the task to run. Use * to run for each period. Use the Active property to Enabled the Task.[br]
Note: You are advised not to delete standard jobs.[br]
");
define("LAN_CRON_BACKUP", "Backup");
define("LAN_CRON_LOGGING", "Logging");
define("LAN_CRON_RUNNING", "Running");

View File

@@ -1,44 +1,44 @@
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
define("FRTLAN_13", "Current Front Page Settings");
define("FRTLAN_30", "Custom Page");
define("FRTLAN_35", "Post-login page");
define("FRTLAN_42", "Add new rule");
define("FRTLAN_43", "Class");
define("FRTLAN_46", "Edit existing rule");
define("FRTLAN_49", "Home Page");
define("FRTLAN_51", "Other");
define("FRTLAN_PAGE_TITLE", "Front Page");
define("FRTLAN_56", "duplicate definition for class:");
define("FRTLAN_57", "Software error");
define("FRTLAN_61", "Selection");
// define("FRTLAN_53", "User Class");
//define("FRTLAN_1", "Front Page settings updated.");
//define("FRTLAN_12", "Update Front Page Settings");
// define("FRTLAN_15", "Other (enter url)");
//define("FRTLAN_33", "Current Settings");
// New language defs for 0.8
//define("FRTLAN_38", "The rules are searched in order, to find the first where the current user belongs to the class specified in the rule. That rule then determines the front (home) page and any specific post-login page.");
//define("FRTLAN_39", "If no rule matches, news.php is set as the home page");
//define("FRTLAN_41", "The user is sent to the specified &quot;Post-login page&quot; (if specified) immediately following a login");
//define("FRTLAN_40", "Order");
// define("FRTLAN_47", "Move up");
// define("FRTLAN_48", "Move down");
// define("FRTLAN_50", "(To disable, select &quot;Other&quot; with a blank URL)");
//define("FRTLAN_52", "None");
// define("FRTLAN_60", "Front");
// define("FRTLAN_44", "Go to this page after login");
//define("FRTLAN_45", "Values not changed");
//define("FRTLAN_54", "Are you sure?");
//define("FRTLAN_55", "Confirm delete rule?");
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
define("FRTLAN_13", "Current Front Page Settings");
define("FRTLAN_30", "Custom Page");
define("FRTLAN_35", "Post-login page");
define("FRTLAN_42", "Add new rule");
define("FRTLAN_43", "Class");
define("FRTLAN_46", "Edit existing rule");
define("FRTLAN_49", "Home Page");
define("FRTLAN_51", "Other");
define("FRTLAN_PAGE_TITLE", "Front Page");
define("FRTLAN_56", "duplicate definition for class:");
define("FRTLAN_57", "Software error");
define("FRTLAN_61", "Selection");
// define("FRTLAN_53", "User Class");
//define("FRTLAN_1", "Front Page settings updated.");
//define("FRTLAN_12", "Update Front Page Settings");
// define("FRTLAN_15", "Other (enter url)");
//define("FRTLAN_33", "Current Settings");
// New language defs for 0.8
//define("FRTLAN_38", "The rules are searched in order, to find the first where the current user belongs to the class specified in the rule. That rule then determines the front (home) page and any specific post-login page.");
//define("FRTLAN_39", "If no rule matches, news.php is set as the home page");
//define("FRTLAN_41", "The user is sent to the specified &quot;Post-login page&quot; (if specified) immediately following a login");
//define("FRTLAN_40", "Order");
// define("FRTLAN_47", "Move up");
// define("FRTLAN_48", "Move down");
// define("FRTLAN_50", "(To disable, select &quot;Other&quot; with a blank URL)");
//define("FRTLAN_52", "None");
// define("FRTLAN_60", "Front");
// define("FRTLAN_44", "Go to this page after login");
//define("FRTLAN_45", "Values not changed");
//define("FRTLAN_54", "Are you sure?");
//define("FRTLAN_55", "Confirm delete rule?");
?>

View File

@@ -1,390 +1,390 @@
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
/*
The definitions in this file are for standard "explanatory" messages which might be entered
into any of the system logs. They are in three groups with different prefixes:
LAN_ADMIN_LOG_nnn - the admin log (records intentional actions by admins)
LAN_AUDIT_LOG_nnn - the audit log (records actions, generally intentional, by users)
LAN_ROLL_LOG_nnn - the rolling log (records extraneous events, debugging etc)
*/
// User audit trail events. For messages 11-30, the last 2 digits must match the define for the event type in the admin log class file
define("LAN_AUDIT_LOG_001", "Access by banned user");
define("LAN_AUDIT_LOG_002", "Flood protection activated");
define("LAN_AUDIT_LOG_003", "Access from banned IP Address");
define("LAN_AUDIT_LOG_004", "");
define("LAN_AUDIT_LOG_005", "");
define("LAN_AUDIT_LOG_006", "User changed password");
define("LAN_AUDIT_LOG_007", "User changed email address");
define("LAN_AUDIT_LOG_008", "");
define("LAN_AUDIT_LOG_009", "");
define("LAN_AUDIT_LOG_010", "User data changed by admin");
define("LAN_AUDIT_LOG_011", "User signed up");
define("LAN_AUDIT_LOG_012", "User confirmed registration");
define("LAN_AUDIT_LOG_013", "User login");
define("LAN_AUDIT_LOG_014", "User logout");
define("LAN_AUDIT_LOG_015", "User changed display name");
define("LAN_AUDIT_LOG_016", "User changed password");
define("LAN_AUDIT_LOG_017", "User changed email address");
define("LAN_AUDIT_LOG_018", "User password reset");
define("LAN_AUDIT_LOG_019", "User changed settings");
define("LAN_AUDIT_LOG_020", "User added by admin");
define("LAN_AUDIT_LOG_021", "User email bounce");
define("LAN_AUDIT_LOG_022", "User banned");
define("LAN_AUDIT_LOG_023", "User bounce reset");
define("LAN_AUDIT_LOG_024", "User temporary status");
// Admin log events
//-----------------
define("LAN_AL_ADLOG_01", "Admin log - prefs updated");
define("LAN_AL_ADLOG_02", "Admin log - delete old data");
define("LAN_AL_ADLOG_03", "User Audit log - delete old data");
define("LAN_AL_ADLOG_04", "User audit options updated");
define("LAN_AL_ADLOG_05", "");
// User edits
//-----------
define("LAN_AL_USET_01", "Admin edited user data");
define("LAN_AL_USET_02", "User added by Admin");
define("LAN_AL_USET_03", "User options updated");
define("LAN_AL_USET_04", "Users pruned");
define("LAN_AL_USET_05", "User banned");
define("LAN_AL_USET_06", "User unbanned");
define("LAN_AL_USET_07", "User deleted");
define("LAN_AL_USET_08", "User made admin");
define("LAN_AL_USET_09", "User admin status revoked");
define("LAN_AL_USET_10", "User approved");
define("LAN_AL_USET_11", "Resend validation email");
define("LAN_AL_USET_12", "Resend all validation emails");
define("LAN_AL_USET_13", "Bounced emails deleted");
define("LAN_AL_USET_14", "Class membership updated");
define("LAN_AL_USET_15", "Signup refused"); // Too many users at same IP address
// Userclass events
//------------------
define("LAN_AL_UCLASS_00", "Unknown userclass-related event");
define("LAN_AL_UCLASS_01", "Userclass created");
define("LAN_AL_UCLASS_02", "Userclass deleted");
define("LAN_AL_UCLASS_03", "Userclass edited");
define("LAN_AL_UCLASS_04", "Class membership updated");
define("LAN_AL_UCLASS_05", "Initial userclass settings edited");
define("LAN_AL_UCLASS_06", "Class membership emptied");
// Banlist events
//----------------
define("LAN_AL_BANLIST_00", "Unknown ban-related event");
define("LAN_AL_BANLIST_01", "Manual ban added");
define("LAN_AL_BANLIST_02", "Ban deleted");
define("LAN_AL_BANLIST_03", "Ban time changed");
define("LAN_AL_BANLIST_04", "Whitelist entry added");
define("LAN_AL_BANLIST_05", "Whitelist entry deleted");
define("LAN_AL_BANLIST_06", "Banlist exported");
define("LAN_AL_BANLIST_07", "Banlist imported");
define("LAN_AL_BANLIST_08", "Banlist options updated");
define("LAN_AL_BANLIST_09", "Banlist entry edited");
define("LAN_AL_BANLIST_10", "Whitelist entry edited");
define("LAN_AL_BANLIST_11", "Whitelist hit for ban entry");
define("LAN_AL_BANLIST_12", "Expired bans cleared");
// Comment-related events
//-----------------------
define("LAN_AL_COMMENT_01", "Comment(s) deleted");
// Rolling log events
//-------------------
define("LAN_ROLL_LOG_01", "Empty username and/or password");
define("LAN_ROLL_LOG_02", "Incorrect image code entered");
define("LAN_ROLL_LOG_03", "Invalid username/password combination");
define("LAN_ROLL_LOG_04", "Invalid username entered");
define("LAN_ROLL_LOG_05", "Login attempt by user not fully signed up");
define("LAN_ROLL_LOG_06", "Login blocked by event trigger handler");
define("LAN_ROLL_LOG_07", "Multiple logins from same address");
define("LAN_ROLL_LOG_08", "Excessive username length");
define("LAN_ROLL_LOG_09", "Banned user attempted login");
define("LAN_ROLL_LOG_10", "Login fail - reason unknown");
define("LAN_ROLL_LOG_11", "Admin login fail");
// Prefs events
//-------------
define("LAN_AL_PREFS_01", "Preferences changed");
define("LAN_AL_PREFS_02", "New Preferences created");
define("LAN_AL_PREFS_03", "Error saving prefs");
// Front Page events
//------------------
define("LAN_AL_FRONTPG_00", "Unknown front page-related event");
define("LAN_AL_FRONTPG_01", "Rules order changed");
define("LAN_AL_FRONTPG_02", "Rule added");
define("LAN_AL_FRONTPG_03", "Rule edited");
define("LAN_AL_FRONTPG_04", "Rule deleted");
define("LAN_AL_FRONTPG_05", "");
define("LAN_AL_FRONTPG_06", "");
// User theme admin
//-----------------
define("LAN_AL_UTHEME_00", "Unknown user theme related event");
define("LAN_AL_UTHEME_01", "User theme settings changed");
define("LAN_AL_UTHEME_02", "");
// Update routines
//----------------
define("LAN_AL_UPDATE_00", "Unknown software update related event");
define("LAN_AL_UPDATE_01", "Update from 1.0 to 2.0 executed");
define("LAN_AL_UPDATE_02", "Update from 0.7.x to 0.7.6 executed");
define("LAN_AL_UPDATE_03", "Missing prefs added");
// Administrator routines
//-----------------------
define("LAN_AL_ADMIN_00", "Unknown administrator event");
define("LAN_AL_ADMIN_01", "Update admin permissions");
define("LAN_AL_ADMIN_02", "Admin rights removed");
define("LAN_AL_ADMIN_03", "");
// Maintenance mode
//-----------------
define("LAN_AL_MAINT_00", "Unknown maintenance message");
define("LAN_AL_MAINT_01", "Maintenance mode set");
define("LAN_AL_MAINT_02", "Maintenance mode cleared");
// Sitelinks routines
//-------------------
define("LAN_AL_SLINKS_00", "Unknown sitelinks message");
define("LAN_AL_SLINKS_01", "Sublinks generated");
define("LAN_AL_SLINKS_02", "Sitelink moved up");
define("LAN_AL_SLINKS_03", "Sitelink moved down");
define("LAN_AL_SLINKS_04", "Sitelink order updated");
define("LAN_AL_SLINKS_05", "Sitelinks options updated");
define("LAN_AL_SLINKS_06", "Sitelink deleted");
define("LAN_AL_SLINKS_07", "Sitelink submitted");
define("LAN_AL_SLINKS_08", "Sitelink updated");
// Theme manager routines
//-----------------------
define("LAN_AL_THEME_00", "Unknown theme-related message");
define("LAN_AL_THEME_01", "Site theme updated");
define("LAN_AL_THEME_02", "Admin theme updated");
define("LAN_AL_THEME_03", "Image preload/site CSS updated");
define("LAN_AL_THEME_04", "Admin style/CSS updated");
define("LAN_AL_THEME_05", "");
// Cache control routines
//-----------------------
define("LAN_AL_CACHE_00", "Unknown cache-control message");
define("LAN_AL_CACHE_01", "Cache settings updated");
define("LAN_AL_CACHE_02", "System cache emptied");
define("LAN_AL_CACHE_03", "Content cache emptied");
define("LAN_AL_CACHE_04", "");
// Emote admin
//------------
define("LAN_AL_EMOTE_00", "Unknown emote-related message");
define("LAN_AL_EMOTE_01", "Active emote pack changed");
define("LAN_AL_EMOTE_02", "Emotes activated");
define("LAN_AL_EMOTE_03", "Emotes deactivated");
// Welcome message
//----------------
define("LAN_AL_WELCOME_00", "Unknown welcome-related message");
define("LAN_AL_WELCOME_01", "Welcome message created");
define("LAN_AL_WELCOME_02", "Welcome message updated");
define("LAN_AL_WELCOME_03", "Welcome message deleted");
define("LAN_AL_WELCOME_04", "Welcome message options changed");
define("LAN_AL_WELCOME_05", "");
// Admin Password
//---------------
define("LAN_AL_ADMINPW_01", "Admin password changed");
// Banners Admin
//--------------
define("LAN_AL_BANNER_00", "Unknown banner-related message");
define("LAN_AL_BANNER_01", "Banner menu update");
define("LAN_AL_BANNER_02", "Banner created");
define("LAN_AL_BANNER_03", "Banner updated");
define("LAN_AL_BANNER_04", "Banner deleted");
define("LAN_AL_BANNER_05", "Banner configuration updated");
define("LAN_AL_BANNER_06", "");
// Image management
//-----------------
define("LAN_AL_IMALAN_00", "Unknown image-related message");
define("LAN_AL_IMALAN_01", "Avatar deleted");
define("LAN_AL_IMALAN_02", "All avatars and photos deleted");
define("LAN_AL_IMALAN_03", "Avatar deleted");
define("LAN_AL_IMALAN_04", "Settings updated");
define("LAN_AL_IMALAN_05", "");
define("LAN_AL_IMALAN_06", "");
// Language management
//--------------------
define("LAN_AL_LANG_00", "Unknown language-related message");
define("LAN_AL_LANG_01", "Language prefs changed");
define("LAN_AL_LANG_02", "Language tables deleted");
define("LAN_AL_LANG_03", "Language tables created");
define("LAN_AL_LANG_04", "Language zip created");
define("LAN_AL_LANG_05", "");
// Meta Tags
//----------
define("LAN_AL_META_01", "Meta tags updated");
// Downloads
//----------
define("LAN_AL_DOWNL_01", "Download options changed");
define("LAN_AL_DOWNL_02", "Download category created");
define("LAN_AL_DOWNL_03", "Download category updated");
define("LAN_AL_DOWNL_04", "Download category deleted");
define("LAN_AL_DOWNL_05", "Download created");
define("LAN_AL_DOWNL_06", "Download updated");
define("LAN_AL_DOWNL_07", "Download deleted");
define("LAN_AL_DOWNL_08", "Download category order updated");
define("LAN_AL_DOWNL_09", "Download limit added");
define("LAN_AL_DOWNL_10", "Download limit edited");
define("LAN_AL_DOWNL_11", "Download limit deleted");
define("LAN_AL_DOWNL_12", "Download mirror added");
define("LAN_AL_DOWNL_13", "Download mirror updated");
define("LAN_AL_DOWNL_14", "Download mirror deleted");
define("LAN_AL_DOWNL_15", "");
// Custom Pages/Menus
//-------------------
define("LAN_AL_CPAGE_01", "Custom page/menu added");
define("LAN_AL_CPAGE_02", "Custom page/menu updated");
define("LAN_AL_CPAGE_03", "Custom page/menu deleted");
define("LAN_AL_CPAGE_04", "Custom page/menu settings updated");
// Extended User Fields
//---------------------
define("LAN_AL_EUF_01", "EUF moved up");
define("LAN_AL_EUF_02", "EUF moved down");
define("LAN_AL_EUF_03", "EUF category moved up");
define("LAN_AL_EUF_04", "EUF category moved down");
define("LAN_AL_EUF_05", "Extended User Field added");
define("LAN_AL_EUF_06", "Extended User Field updated");
define("LAN_AL_EUF_07", "Extended User Field deleted");
define("LAN_AL_EUF_08", "EUF category added");
define("LAN_AL_EUF_09", "EUF category updated");
define("LAN_AL_EUF_10", "EUF category deleted");
define("LAN_AL_EUF_11", "Extended user fields activated");
define("LAN_AL_EUF_12", "Extended user fields deactivated");
// Menus
//------
define("LAN_AL_MENU_01", "Menu activated");
define("LAN_AL_MENU_02", "Menu - set visibility");
define("LAN_AL_MENU_03", "Menu - change area");
define("LAN_AL_MENU_04", "Menu deactivated");
define("LAN_AL_MENU_05", "Menu - move to top");
define("LAN_AL_MENU_06", "Menu - move to bottom");
define("LAN_AL_MENU_07", "Menu - move up");
define("LAN_AL_MENU_08", "Menu - move down");
define("LAN_AL_MENU_09", "");
// Public Uploads
//---------------
define("LAN_AL_UPLOAD_01", "Uploaded file deleted");
define("LAN_AL_UPLOAD_02", "Upload prefs changed");
// Search
//-------
define("LAN_AL_SEARCH_01", "Search settings updated");
define("LAN_AL_SEARCH_02", "Search prefs updated");
define("LAN_AL_SEARCH_03", "Search params auto-update");
define("LAN_AL_SEARCH_04", "Searchable areas updated");
define("LAN_AL_SEARCH_05", "Search handler settings updated");
define("LAN_AL_SEARCH_06", "");
// Notify
//-------
define("LAN_AL_NOTIFY_01", "Notify settings updated");
// News
//-----
define("LAN_AL_NEWS_01", "News item deleted");
define("LAN_AL_NEWS_02", "News category deleted");
define("LAN_AL_NEWS_03", "Submitted news deleted");
define("LAN_AL_NEWS_04", "News category created");
define("LAN_AL_NEWS_05", "News category updated");
define("LAN_AL_NEWS_06", "News preferences updated");
define("LAN_AL_NEWS_07", "Submitted news authorised");
define("LAN_AL_NEWS_08", "News item added");
define("LAN_AL_NEWS_09", "News item updated");
define("LAN_AL_NEWS_10", "News category rewrite changed");
define("LAN_AL_NEWS_11", "News category rewrite deleted");
define("LAN_AL_NEWS_12", "News rewrite changed");
define("LAN_AL_NEWS_13", "News rewrite deleted");
// File Manager
//-------------
define("LAN_AL_FILEMAN_01", "File(s) deleted");
define("LAN_AL_FILEMAN_02", "File(s) moved");
define("LAN_AL_FILEMAN_03", "File(s) uploaded");
define("LAN_AL_FILEMAN_04", "");
// Mail
//-----
define("LAN_AL_MAIL_01", "Test email sent");
define("LAN_AL_MAIL_02", "Mailshot created");
define("LAN_AL_MAIL_03", "Mail settings updated");
define("LAN_AL_MAIL_04", "Mailshot details deleted");
define("LAN_AL_MAIL_05", "Mail Database tidy");
define("LAN_AL_MAIL_06", "Mailout activated");
define("LAN_AL_MAIL_07", "");
// Plugin Manager
//---------------
define("LAN_AL_PLUGMAN_01", "Plugin installed");
define("LAN_AL_PLUGMAN_02", "Plugin updated");
define("LAN_AL_PLUGMAN_03", "Plugin uninstalled");
define("LAN_AL_PLUGMAN_04", "Plugin refreshed");
// URL Manager
//---------------
define("LAN_AL_EURL_01", "Site URL configuration changed");
// Sundry Pseudo-plugins - technically they"re plugins, but not worth the file overhead of treating them separately
//----------------------
define("LAN_AL_MISC_01", "Tree menu settings updated");
define("LAN_AL_MISC_02", "Online menu settings updated");
define("LAN_AL_MISC_03", "Login menu settings updated");
define("LAN_AL_MISC_04", "Comment menu settings updated");
define("LAN_AL_MISC_05", "Clock menu settings updated");
define("LAN_AL_MISC_06", "Blog calendar menu settings updated");
//define("LAN_AL_MISC_07", "");
define("LAN_AL_PING_01", "Ping to service");
define("LAN_AL_ADMINUI_01", "Admin-UI DB Table Insert: [x]");
define("LAN_AL_ADMINUI_02", "Admin-UI DB Table Update: [x]");
define("LAN_AL_ADMINUI_03", "Admin-UI DB Table Delete: [x]");
define("LAN_AL_ADMINUI_04", "Admin-UI DB Error: [x]");
define("LAN_AL_BACKUP", "Database backup");
define("LAN_AL_MEDIA_01", "Media Upload");
define("LAN_AL_USET_100", "Admin logged in as another user");
define("LAN_AL_USET_101", "Admin logged out as another user");
<?php
/*
* Copyright (C) 2008-2013 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Admin Language File
*
*/
/*
The definitions in this file are for standard "explanatory" messages which might be entered
into any of the system logs. They are in three groups with different prefixes:
LAN_ADMIN_LOG_nnn - the admin log (records intentional actions by admins)
LAN_AUDIT_LOG_nnn - the audit log (records actions, generally intentional, by users)
LAN_ROLL_LOG_nnn - the rolling log (records extraneous events, debugging etc)
*/
// User audit trail events. For messages 11-30, the last 2 digits must match the define for the event type in the admin log class file
define("LAN_AUDIT_LOG_001", "Access by banned user");
define("LAN_AUDIT_LOG_002", "Flood protection activated");
define("LAN_AUDIT_LOG_003", "Access from banned IP Address");
define("LAN_AUDIT_LOG_004", "");
define("LAN_AUDIT_LOG_005", "");
define("LAN_AUDIT_LOG_006", "User changed password");
define("LAN_AUDIT_LOG_007", "User changed email address");
define("LAN_AUDIT_LOG_008", "");
define("LAN_AUDIT_LOG_009", "");
define("LAN_AUDIT_LOG_010", "User data changed by admin");
define("LAN_AUDIT_LOG_011", "User signed up");
define("LAN_AUDIT_LOG_012", "User confirmed registration");
define("LAN_AUDIT_LOG_013", "User login");
define("LAN_AUDIT_LOG_014", "User logout");
define("LAN_AUDIT_LOG_015", "User changed display name");
define("LAN_AUDIT_LOG_016", "User changed password");
define("LAN_AUDIT_LOG_017", "User changed email address");
define("LAN_AUDIT_LOG_018", "User password reset");
define("LAN_AUDIT_LOG_019", "User changed settings");
define("LAN_AUDIT_LOG_020", "User added by admin");
define("LAN_AUDIT_LOG_021", "User email bounce");
define("LAN_AUDIT_LOG_022", "User banned");
define("LAN_AUDIT_LOG_023", "User bounce reset");
define("LAN_AUDIT_LOG_024", "User temporary status");
// Admin log events
//-----------------
define("LAN_AL_ADLOG_01", "Admin log - prefs updated");
define("LAN_AL_ADLOG_02", "Admin log - delete old data");
define("LAN_AL_ADLOG_03", "User Audit log - delete old data");
define("LAN_AL_ADLOG_04", "User audit options updated");
define("LAN_AL_ADLOG_05", "");
// User edits
//-----------
define("LAN_AL_USET_01", "Admin edited user data");
define("LAN_AL_USET_02", "User added by Admin");
define("LAN_AL_USET_03", "User options updated");
define("LAN_AL_USET_04", "Users pruned");
define("LAN_AL_USET_05", "User banned");
define("LAN_AL_USET_06", "User unbanned");
define("LAN_AL_USET_07", "User deleted");
define("LAN_AL_USET_08", "User made admin");
define("LAN_AL_USET_09", "User admin status revoked");
define("LAN_AL_USET_10", "User approved");
define("LAN_AL_USET_11", "Resend validation email");
define("LAN_AL_USET_12", "Resend all validation emails");
define("LAN_AL_USET_13", "Bounced emails deleted");
define("LAN_AL_USET_14", "Class membership updated");
define("LAN_AL_USET_15", "Signup refused"); // Too many users at same IP address
// Userclass events
//------------------
define("LAN_AL_UCLASS_00", "Unknown userclass-related event");
define("LAN_AL_UCLASS_01", "Userclass created");
define("LAN_AL_UCLASS_02", "Userclass deleted");
define("LAN_AL_UCLASS_03", "Userclass edited");
define("LAN_AL_UCLASS_04", "Class membership updated");
define("LAN_AL_UCLASS_05", "Initial userclass settings edited");
define("LAN_AL_UCLASS_06", "Class membership emptied");
// Banlist events
//----------------
define("LAN_AL_BANLIST_00", "Unknown ban-related event");
define("LAN_AL_BANLIST_01", "Manual ban added");
define("LAN_AL_BANLIST_02", "Ban deleted");
define("LAN_AL_BANLIST_03", "Ban time changed");
define("LAN_AL_BANLIST_04", "Whitelist entry added");
define("LAN_AL_BANLIST_05", "Whitelist entry deleted");
define("LAN_AL_BANLIST_06", "Banlist exported");
define("LAN_AL_BANLIST_07", "Banlist imported");
define("LAN_AL_BANLIST_08", "Banlist options updated");
define("LAN_AL_BANLIST_09", "Banlist entry edited");
define("LAN_AL_BANLIST_10", "Whitelist entry edited");
define("LAN_AL_BANLIST_11", "Whitelist hit for ban entry");
define("LAN_AL_BANLIST_12", "Expired bans cleared");
// Comment-related events
//-----------------------
define("LAN_AL_COMMENT_01", "Comment(s) deleted");
// Rolling log events
//-------------------
define("LAN_ROLL_LOG_01", "Empty username and/or password");
define("LAN_ROLL_LOG_02", "Incorrect image code entered");
define("LAN_ROLL_LOG_03", "Invalid username/password combination");
define("LAN_ROLL_LOG_04", "Invalid username entered");
define("LAN_ROLL_LOG_05", "Login attempt by user not fully signed up");
define("LAN_ROLL_LOG_06", "Login blocked by event trigger handler");
define("LAN_ROLL_LOG_07", "Multiple logins from same address");
define("LAN_ROLL_LOG_08", "Excessive username length");
define("LAN_ROLL_LOG_09", "Banned user attempted login");
define("LAN_ROLL_LOG_10", "Login fail - reason unknown");
define("LAN_ROLL_LOG_11", "Admin login fail");
// Prefs events
//-------------
define("LAN_AL_PREFS_01", "Preferences changed");
define("LAN_AL_PREFS_02", "New Preferences created");
define("LAN_AL_PREFS_03", "Error saving prefs");
// Front Page events
//------------------
define("LAN_AL_FRONTPG_00", "Unknown front page-related event");
define("LAN_AL_FRONTPG_01", "Rules order changed");
define("LAN_AL_FRONTPG_02", "Rule added");
define("LAN_AL_FRONTPG_03", "Rule edited");
define("LAN_AL_FRONTPG_04", "Rule deleted");
define("LAN_AL_FRONTPG_05", "");
define("LAN_AL_FRONTPG_06", "");
// User theme admin
//-----------------
define("LAN_AL_UTHEME_00", "Unknown user theme related event");
define("LAN_AL_UTHEME_01", "User theme settings changed");
define("LAN_AL_UTHEME_02", "");
// Update routines
//----------------
define("LAN_AL_UPDATE_00", "Unknown software update related event");
define("LAN_AL_UPDATE_01", "Update from 1.0 to 2.0 executed");
define("LAN_AL_UPDATE_02", "Update from 0.7.x to 0.7.6 executed");
define("LAN_AL_UPDATE_03", "Missing prefs added");
// Administrator routines
//-----------------------
define("LAN_AL_ADMIN_00", "Unknown administrator event");
define("LAN_AL_ADMIN_01", "Update admin permissions");
define("LAN_AL_ADMIN_02", "Admin rights removed");
define("LAN_AL_ADMIN_03", "");
// Maintenance mode
//-----------------
define("LAN_AL_MAINT_00", "Unknown maintenance message");
define("LAN_AL_MAINT_01", "Maintenance mode set");
define("LAN_AL_MAINT_02", "Maintenance mode cleared");
// Sitelinks routines
//-------------------
define("LAN_AL_SLINKS_00", "Unknown sitelinks message");
define("LAN_AL_SLINKS_01", "Sublinks generated");
define("LAN_AL_SLINKS_02", "Sitelink moved up");
define("LAN_AL_SLINKS_03", "Sitelink moved down");
define("LAN_AL_SLINKS_04", "Sitelink order updated");
define("LAN_AL_SLINKS_05", "Sitelinks options updated");
define("LAN_AL_SLINKS_06", "Sitelink deleted");
define("LAN_AL_SLINKS_07", "Sitelink submitted");
define("LAN_AL_SLINKS_08", "Sitelink updated");
// Theme manager routines
//-----------------------
define("LAN_AL_THEME_00", "Unknown theme-related message");
define("LAN_AL_THEME_01", "Site theme updated");
define("LAN_AL_THEME_02", "Admin theme updated");
define("LAN_AL_THEME_03", "Image preload/site CSS updated");
define("LAN_AL_THEME_04", "Admin style/CSS updated");
define("LAN_AL_THEME_05", "");
// Cache control routines
//-----------------------
define("LAN_AL_CACHE_00", "Unknown cache-control message");
define("LAN_AL_CACHE_01", "Cache settings updated");
define("LAN_AL_CACHE_02", "System cache emptied");
define("LAN_AL_CACHE_03", "Content cache emptied");
define("LAN_AL_CACHE_04", "");
// Emote admin
//------------
define("LAN_AL_EMOTE_00", "Unknown emote-related message");
define("LAN_AL_EMOTE_01", "Active emote pack changed");
define("LAN_AL_EMOTE_02", "Emotes activated");
define("LAN_AL_EMOTE_03", "Emotes deactivated");
// Welcome message
//----------------
define("LAN_AL_WELCOME_00", "Unknown welcome-related message");
define("LAN_AL_WELCOME_01", "Welcome message created");
define("LAN_AL_WELCOME_02", "Welcome message updated");
define("LAN_AL_WELCOME_03", "Welcome message deleted");
define("LAN_AL_WELCOME_04", "Welcome message options changed");
define("LAN_AL_WELCOME_05", "");
// Admin Password
//---------------
define("LAN_AL_ADMINPW_01", "Admin password changed");
// Banners Admin
//--------------
define("LAN_AL_BANNER_00", "Unknown banner-related message");
define("LAN_AL_BANNER_01", "Banner menu update");
define("LAN_AL_BANNER_02", "Banner created");
define("LAN_AL_BANNER_03", "Banner updated");
define("LAN_AL_BANNER_04", "Banner deleted");
define("LAN_AL_BANNER_05", "Banner configuration updated");
define("LAN_AL_BANNER_06", "");
// Image management
//-----------------
define("LAN_AL_IMALAN_00", "Unknown image-related message");
define("LAN_AL_IMALAN_01", "Avatar deleted");
define("LAN_AL_IMALAN_02", "All avatars and photos deleted");
define("LAN_AL_IMALAN_03", "Avatar deleted");
define("LAN_AL_IMALAN_04", "Settings updated");
define("LAN_AL_IMALAN_05", "");
define("LAN_AL_IMALAN_06", "");
// Language management
//--------------------
define("LAN_AL_LANG_00", "Unknown language-related message");
define("LAN_AL_LANG_01", "Language prefs changed");
define("LAN_AL_LANG_02", "Language tables deleted");
define("LAN_AL_LANG_03", "Language tables created");
define("LAN_AL_LANG_04", "Language zip created");
define("LAN_AL_LANG_05", "");
// Meta Tags
//----------
define("LAN_AL_META_01", "Meta tags updated");
// Downloads
//----------
define("LAN_AL_DOWNL_01", "Download options changed");
define("LAN_AL_DOWNL_02", "Download category created");
define("LAN_AL_DOWNL_03", "Download category updated");
define("LAN_AL_DOWNL_04", "Download category deleted");
define("LAN_AL_DOWNL_05", "Download created");
define("LAN_AL_DOWNL_06", "Download updated");
define("LAN_AL_DOWNL_07", "Download deleted");
define("LAN_AL_DOWNL_08", "Download category order updated");
define("LAN_AL_DOWNL_09", "Download limit added");
define("LAN_AL_DOWNL_10", "Download limit edited");
define("LAN_AL_DOWNL_11", "Download limit deleted");
define("LAN_AL_DOWNL_12", "Download mirror added");
define("LAN_AL_DOWNL_13", "Download mirror updated");
define("LAN_AL_DOWNL_14", "Download mirror deleted");
define("LAN_AL_DOWNL_15", "");
// Custom Pages/Menus
//-------------------
define("LAN_AL_CPAGE_01", "Custom page/menu added");
define("LAN_AL_CPAGE_02", "Custom page/menu updated");
define("LAN_AL_CPAGE_03", "Custom page/menu deleted");
define("LAN_AL_CPAGE_04", "Custom page/menu settings updated");
// Extended User Fields
//---------------------
define("LAN_AL_EUF_01", "EUF moved up");
define("LAN_AL_EUF_02", "EUF moved down");
define("LAN_AL_EUF_03", "EUF category moved up");
define("LAN_AL_EUF_04", "EUF category moved down");
define("LAN_AL_EUF_05", "Extended User Field added");
define("LAN_AL_EUF_06", "Extended User Field updated");
define("LAN_AL_EUF_07", "Extended User Field deleted");
define("LAN_AL_EUF_08", "EUF category added");
define("LAN_AL_EUF_09", "EUF category updated");
define("LAN_AL_EUF_10", "EUF category deleted");
define("LAN_AL_EUF_11", "Extended user fields activated");
define("LAN_AL_EUF_12", "Extended user fields deactivated");
// Menus
//------
define("LAN_AL_MENU_01", "Menu activated");
define("LAN_AL_MENU_02", "Menu - set visibility");
define("LAN_AL_MENU_03", "Menu - change area");
define("LAN_AL_MENU_04", "Menu deactivated");
define("LAN_AL_MENU_05", "Menu - move to top");
define("LAN_AL_MENU_06", "Menu - move to bottom");
define("LAN_AL_MENU_07", "Menu - move up");
define("LAN_AL_MENU_08", "Menu - move down");
define("LAN_AL_MENU_09", "");
// Public Uploads
//---------------
define("LAN_AL_UPLOAD_01", "Uploaded file deleted");
define("LAN_AL_UPLOAD_02", "Upload prefs changed");
// Search
//-------
define("LAN_AL_SEARCH_01", "Search settings updated");
define("LAN_AL_SEARCH_02", "Search prefs updated");
define("LAN_AL_SEARCH_03", "Search params auto-update");
define("LAN_AL_SEARCH_04", "Searchable areas updated");
define("LAN_AL_SEARCH_05", "Search handler settings updated");
define("LAN_AL_SEARCH_06", "");
// Notify
//-------
define("LAN_AL_NOTIFY_01", "Notify settings updated");
// News
//-----
define("LAN_AL_NEWS_01", "News item deleted");
define("LAN_AL_NEWS_02", "News category deleted");
define("LAN_AL_NEWS_03", "Submitted news deleted");
define("LAN_AL_NEWS_04", "News category created");
define("LAN_AL_NEWS_05", "News category updated");
define("LAN_AL_NEWS_06", "News preferences updated");
define("LAN_AL_NEWS_07", "Submitted news authorised");
define("LAN_AL_NEWS_08", "News item added");
define("LAN_AL_NEWS_09", "News item updated");
define("LAN_AL_NEWS_10", "News category rewrite changed");
define("LAN_AL_NEWS_11", "News category rewrite deleted");
define("LAN_AL_NEWS_12", "News rewrite changed");
define("LAN_AL_NEWS_13", "News rewrite deleted");
// File Manager
//-------------
define("LAN_AL_FILEMAN_01", "File(s) deleted");
define("LAN_AL_FILEMAN_02", "File(s) moved");
define("LAN_AL_FILEMAN_03", "File(s) uploaded");
define("LAN_AL_FILEMAN_04", "");
// Mail
//-----
define("LAN_AL_MAIL_01", "Test email sent");
define("LAN_AL_MAIL_02", "Mailshot created");
define("LAN_AL_MAIL_03", "Mail settings updated");
define("LAN_AL_MAIL_04", "Mailshot details deleted");
define("LAN_AL_MAIL_05", "Mail Database tidy");
define("LAN_AL_MAIL_06", "Mailout activated");
define("LAN_AL_MAIL_07", "");
// Plugin Manager
//---------------
define("LAN_AL_PLUGMAN_01", "Plugin installed");
define("LAN_AL_PLUGMAN_02", "Plugin updated");
define("LAN_AL_PLUGMAN_03", "Plugin uninstalled");
define("LAN_AL_PLUGMAN_04", "Plugin refreshed");
// URL Manager
//---------------
define("LAN_AL_EURL_01", "Site URL configuration changed");
// Sundry Pseudo-plugins - technically they"re plugins, but not worth the file overhead of treating them separately
//----------------------
define("LAN_AL_MISC_01", "Tree menu settings updated");
define("LAN_AL_MISC_02", "Online menu settings updated");
define("LAN_AL_MISC_03", "Login menu settings updated");
define("LAN_AL_MISC_04", "Comment menu settings updated");
define("LAN_AL_MISC_05", "Clock menu settings updated");
define("LAN_AL_MISC_06", "Blog calendar menu settings updated");
//define("LAN_AL_MISC_07", "");
define("LAN_AL_PING_01", "Ping to service");
define("LAN_AL_ADMINUI_01", "Admin-UI DB Table Insert: [x]");
define("LAN_AL_ADMINUI_02", "Admin-UI DB Table Update: [x]");
define("LAN_AL_ADMINUI_03", "Admin-UI DB Table Delete: [x]");
define("LAN_AL_ADMINUI_04", "Admin-UI DB Error: [x]");
define("LAN_AL_BACKUP", "Database backup");
define("LAN_AL_MEDIA_01", "Media Upload");
define("LAN_AL_USET_100", "Admin logged in as another user");
define("LAN_AL_USET_101", "Admin logged out as another user");

View File

@@ -1,298 +1,298 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
// TODO - LANS - MAJOR LAN REWRITE NEEDED
define("CORE_DATE_ORDER", "dmy"); // Temporary until we find somewhere better to put it.
// Defines order of field entry/display in date boxes
// Acceptable values: dmy, mdy, ymd
define("LAN_MAILOUT_01", "From Name");
define("LAN_MAILOUT_02", "From Email");
define("LAN_MAILOUT_03", "To");
define("LAN_MAILOUT_04", "Cc");
define("LAN_MAILOUT_05", "Bcc");
define("LAN_MAILOUT_06", "Subject");
define("LAN_MAILOUT_07", "Attachment");
define("LAN_MAILOUT_08", "Send Email");
define("LAN_MAILOUT_09", "Send format");
define("LAN_MAILOUT_10", "User Subscribed");
define("LAN_MAILOUT_11", "Insert Variables");
define("LAN_MAILOUT_12", "All Users");
define("LAN_MAILOUT_13", "All Unverified Users ");
define("LAN_MAILOUT_14", "Display Name");
define("LAN_MAILOUT_15", "Mailout");
define("LAN_MAILOUT_16", "Username");
define("LAN_MAILOUT_17", "Signup link");
define("LAN_MAILOUT_18", "User ID");
define("LAN_MAILOUT_19", "No target email address specified");
define("LAN_MAILOUT_20", "Sendmail-path");
define("LAN_MAILOUT_21", "Bulk mailing Entries");
define("LAN_MAILOUT_22", "There are currently no saved entries");
define("LAN_MAILOUT_23", "userclass: ");
define("LAN_MAILOUT_24", "email(s) are ready to be sent");
define("LAN_MAILOUT_25", "Bulk mailing controls");
define("LAN_MAILOUT_26", "Pause bulk mailing every");
define("LAN_MAILOUT_27", "emails for ");
define("LAN_MAILOUT_28", "Save Changes");
define("LAN_MAILOUT_29", "seconds");
define("LAN_MAILOUT_30", "Used mostly with SMTP keepalive. A pause of more than 30 seconds may cause the browser to time-out");
define("LAN_MAILOUT_31", "Bounced Email Processing");
// define("LAN_MAILOUT_32", "Email address");
define("LAN_MAILOUT_33", "Incoming Mail server");
define("LAN_MAILOUT_34", "Account (user) Name");
// define("LAN_MAILOUT_35", "Password");
define("LAN_MAILOUT_36", "Delete Bounced Mails after checking");
define("LAN_MAILOUT_37", "Proceed");
define("LAN_MAILOUT_38", "Cancel");
define("LAN_MAILOUT_39", "Emailing");
// define("LAN_MAILOUT_40", "You need to rename <b>e107.htaccess</b> to <b>.htaccess</b> in");
define("LAN_MAILOUT_41", "before sending mail from this page.");
//define("LAN_MAILOUT_42", "Warning");//NOT_USED
define("LAN_MAILOUT_43", "Username");
define("LAN_MAILOUT_44", "User Login");
define("LAN_MAILOUT_45", "User Email");
define("LAN_MAILOUT_46", "User-Match");
define("LAN_MAILOUT_47", "contains");
define("LAN_MAILOUT_48", "equals");
//define("LAN_MAILOUT_49", "Id");//LAN_ID
//define("LAN_MAILOUT_50", "Author");//LAN_AUTHOR
define("LAN_MAILOUT_51", "Subject");
define("LAN_MAILOUT_52", "Last mod");
define("LAN_MAILOUT_53", "Admins");
define("LAN_MAILOUT_54", "Self");
define("LAN_MAILOUT_55", "Userclass");
define("LAN_MAILOUT_56", "Last Visit");
define("LAN_MAILOUT_57", "Send bulk SMTP emails in blocks"); // SMTP KeepAlive option
//define("LAN_MAILOUT_58", "There is a problem with the attachment:");
//define("LAN_MAILOUT_59", "Mailing Progress");
//define("LAN_MAILOUT_60", "Sending...");
//define("LAN_MAILOUT_61", "There are no remaining emails to be sent.");
//define("LAN_MAILOUT_62", "Emails sent:");
//define("LAN_MAILOUT_63", "Emails failed:");
//define("LAN_MAILOUT_64", "Total time elapsed:");
//define("LAN_MAILOUT_65", "seconds");
//define("LAN_MAILOUT_66", "Cancelled Successfully");
define("LAN_MAILOUT_67", "The email could not be sent. Please review your SMTP settings, or select another mailing method and try again.");
define("LAN_MAILOUT_68", "Registered Users");
define("LAN_MAILOUT_69", "matches, after ");
define("LAN_MAILOUT_70", " duplicates stripped.");
define("LAN_MAILOUT_71", "Total emails to send");
define("LAN_MAILOUT_72", "Mailshot logging");
define("LAN_MAILOUT_73", "No logging");
define("LAN_MAILOUT_74", "Logging only (no send)");
define("LAN_MAILOUT_75", "Log and send");
define("LAN_MAILOUT_76", "Include email info in log");
define("LAN_MAILOUT_77", "Email address sources");
define("LAN_MAILOUT_78", "Mailshot Status");
define("LAN_MAILOUT_79", "No mailshots to display");
//define("LAN_MAILOUT_80", "Date");//LAN_DATE
define("LAN_MAILOUT_81", "The email has been successfully sent, please check your inbox.");
define("LAN_MAILOUT_82", "Mails sent");
define("LAN_MAILOUT_83", "Mails to go");
define("LAN_MAILOUT_84", "Mail ID");
define("LAN_MAILOUT_85", "Originator");
define("LAN_MAILOUT_86", "Re-send");
define("LAN_MAILOUT_87", "SMTP Server");
define("LAN_MAILOUT_88", "SMTP Username");
define("LAN_MAILOUT_89", "SMTP Password");
define("LAN_MAILOUT_90", "SMTP Features");
define("LAN_MAILOUT_91", "POP before SMTP");
define("LAN_MAILOUT_92", "SSL");
define("LAN_MAILOUT_93", "TLS");
define("LAN_MAILOUT_94", "(Use SSL for gmail/googlemail)");
define("LAN_MAILOUT_95", "Use VERP for bulk mailing");
//define("LAN_MAILOUT_96", "none");//LAN_NONE
define("LAN_MAILOUT_97", "Mailer Results");
define("LAN_MAILOUT_98", "Orphaned entries");
define("LAN_MAILOUT_99", "Confirm retry mailshot");
define("LAN_MAILOUT_100", "Message");
define("LAN_MAILOUT_101", "Email Detail");
define("LAN_MAILOUT_102", "Detail of mailshot");
define("LAN_MAILOUT_103", "Results of attempts to send");
define("LAN_MAILOUT_104", "No attempt to send, or error saving result");
define("LAN_MAILOUT_105", "Details of up to 10 failures");
define("LAN_MAILOUT_106", "The email could not be sent. It appears that your server is not correctly configured to send emails, please try again using SMTP, or contact your hosts and ask them to check their sendmail / email server settings.");
define("LAN_MAILOUT_107", "at");
define("LAN_MAILOUT_108", "Result");
define("LAN_MAILOUT_109", "Show detail");
define("LAN_MAILOUT_110", "Send test email");
define("LAN_MAILOUT_111", "Email Title (not sent)");
define("LAN_MAILOUT_112", "Send test email to");
define("LAN_MAILOUT_113", "Test email from");
define("LAN_MAILOUT_114", "This is a test email, it appears that your email settings are working ok! [br][br] Regards [br] from the e107 website system.");
define("LAN_MAILOUT_115", "Bulk Emailing method");
define("LAN_MAILOUT_116", "If unsure, leave as php");
define("LAN_MAILOUT_117", "complete");
define("LAN_MAILOUT_118", "Click on proceed' to start sending emails. Click on 'cancel' to stop the run. Once complete, select another page. Unsent emails cal be viewed through the 'Mailshot status' screen");
define("LAN_MAILOUT_119", "Logging only, with errors");
define("LAN_MAILOUT_120", "Account type");
define("LAN_MAILOUT_121", "Standard POP3");
define("LAN_MAILOUT_122", "POP3, TLS disabled");
define("LAN_MAILOUT_123", "POP3 with TLS");
define("LAN_MAILOUT_124", "IMAP");
define("LAN_MAILOUT_125", "Text only");
define("LAN_MAILOUT_126", "Text and HTML");
define("LAN_MAILOUT_127", "Include theme");
define("LAN_MAILOUT_128", "Send Error");
define("LAN_MAILOUT_129", "Expiry Date");
define("LAN_MAILOUT_130", "Creation Date");
define("LAN_MAILOUT_131", "Sending Started");
define("LAN_MAILOUT_132", "Sending Complete");
//define("LAN_MAILOUT_133", "Source"); // Moved to lan_admin.php
define("LAN_MAILOUT_134", "Priority");
//define("LAN_MAILOUT_135", "Title");//LAN_TITLE
define("LAN_MAILOUT_136", "Mailout Status");
define("LAN_MAILOUT_137", "Mail Ref");
define("LAN_MAILOUT_138", "Email status");
define("LAN_MAILOUT_139", "Date active");
define("LAN_MAILOUT_140", "Recipient Email");
define("LAN_MAILOUT_141", "Recipient Name");
define("LAN_MAILOUT_142", "Recipient User ID");
define("LAN_MAILOUT_143", "Recipient ref.");
define("LAN_MAILOUT_144", "Bounced");
define("LAN_MAILOUT_145", "New email saved");
define("LAN_MAILOUT_146", "Error saving email");
define("LAN_MAILOUT_147", "Email updated");
define("LAN_MAILOUT_148", "User values");
define("LAN_MAILOUT_149", "Sender Email");
define("LAN_MAILOUT_150", "Sender Name");
define("LAN_MAILOUT_151", "Copy to");
define("LAN_MAILOUT_152", "Blind copy to");
define("LAN_MAILOUT_153", "Attachments");
define("LAN_MAILOUT_154", "Send Format");
define("LAN_MAILOUT_155", "Selectors");
define("LAN_MAILOUT_156", "Maximum number of emails to send per scheduler tick");
define("LAN_MAILOUT_157", "Value will depend on a number of factors, including how often your mail queue scheduler job is triggered and the rate at which your ISP will accept outgoing mail. Zero to clear queue each time");
define("LAN_MAILOUT_158", "Send now");
define("LAN_MAILOUT_159", "Hold email");
define("LAN_MAILOUT_160", "Cancel send");
define("LAN_MAILOUT_161", "IMPORTANT! This file appears to not exist");
define("LAN_MAILOUT_162", "IMPORTANT! You need to make this file executable");
define("LAN_MAILOUT_163", "Edit/Send Mail");
define("LAN_MAILOUT_164", "Email information not found");
define("LAN_MAILOUT_165", "Confirm delete the following stored email, including any recipient records");
define("LAN_MAILOUT_166", "General error deleting mail ref: [x]");
define("LAN_MAILOUT_167", "Error deleting mail content ref: [x]");
define("LAN_MAILOUT_168", "Mail content deleted ref: [x]");
define("LAN_MAILOUT_169", "Error deleting mail recipients ref: [x]");
define("LAN_MAILOUT_170", "Deleted [y] recipients for mail ref: [x]");
define("LAN_MAILOUT_171", "Confirm email delete");
define("LAN_MAILOUT_172", "Mail Type/Status");
define("LAN_MAILOUT_173", "Recipients");
define("LAN_MAILOUT_174", "Security check fail: [x] [z]");
define("LAN_MAILOUT_175", "Before");
define("LAN_MAILOUT_176", "Equal to");
define("LAN_MAILOUT_177", "After");
define("LAN_MAILOUT_178", "Last site visit");
define("LAN_MAILOUT_179", "Confirm email send");
define("LAN_MAILOUT_180", "Selection criteria:");
define("LAN_MAILOUT_181", "Show recipients");
define("LAN_MAILOUT_182", "Tidy database tables");
define("LAN_MAILOUT_183", "Error tidying database");
define("LAN_MAILOUT_184", "Database tidied");
define("LAN_MAILOUT_185", "Emails added to send queue");
define("LAN_MAILOUT_186", "General error putting mail ref: [x] on hold");
define("LAN_MAILOUT_187", "Email [x] put on hold");
define("LAN_MAILOUT_188", "General error sending mail ref: [x]");
define("LAN_MAILOUT_189", "Test address");
// Admin menu text
define("LAN_MAILOUT_190", "Create/Send Mail");
define("LAN_MAILOUT_191", "Saved emails");
define("LAN_MAILOUT_192", "Completed Mailshots");
define("LAN_MAILOUT_193", "Pending Mailshots");
define("LAN_MAILOUT_194", "Held Mailshots");
// define("LAN_MAILOUT_195", "");
// define("LAN_MAILOUT_196", "");
// Block of error messages kept together
define("LAN_MAILOUT_200", "No subject specified");
define("LAN_MAILOUT_201", "No meaningful data for email");
define("LAN_MAILOUT_202", "No text in email body");
define("LAN_MAILOUT_203", "No sender name specified");
define("LAN_MAILOUT_204", "No sender email address specified");
define("LAN_MAILOUT_205", "Email send format error");
define("LAN_MAILOUT_206", "Invalid mail ID ([x]) specified");
define("LAN_MAILOUT_207", "Template load error");
define("LAN_MAILOUT_208", "Template conversion error");
// Block of status messages kept together
define("LAN_MAILOUT_211", "Sent");
define("LAN_MAILOUT_212", "Failed");
define("LAN_MAILOUT_213", "Bounced");
define("LAN_MAILOUT_214", "To send");
define("LAN_MAILOUT_215", "Saved");
define("LAN_MAILOUT_216", "Code error");
define("LAN_MAILOUT_217", "Held");
define("LAN_MAILOUT_218", "Cancelled");
define("LAN_MAILOUT_219", "Partial");
// General messages continued
define("LAN_MAILOUT_220", "Email ID [x] cancelled");
define("LAN_MAILOUT_221", "Error cancelling email with ID [x]");
define("LAN_MAILOUT_222", "Default email format");
define("LAN_MAILOUT_223", "(Used for some system-generated emails)");
define("LAN_MAILOUT_224", "Inc. Images");
define("LAN_MAILOUT_225", "Include images in email");
define("LAN_MAILOUT_226", "[x] orphaned recipient record(s) removed");
define("LAN_MAILOUT_227", "Deleted [x] records from [y]");
define("LAN_MAILOUT_228", "[x] anomalies in mail_content corrected; records: [y]");
define("LAN_MAILOUT_229", "Email ID [x] put on hold");
define("LAN_MAILOUT_230", "Error holding email with ID [x]");
define("LAN_MAILOUT_231", "Bounced emails - Processing method");
define("LAN_MAILOUT_232", "None");
define("LAN_MAILOUT_233", "Auto-process script");
define("LAN_MAILOUT_234", "Mail account");
define("LAN_MAILOUT_235", "(Your server must forward or 'pipe' from the email address above to the script path above.)");
define("LAN_MAILOUT_236", "Last Bounce Processed");
define("LAN_MAILOUT_237", "Summary counters updated on [x] emails");
define("LAN_MAILOUT_238", "Earliest time to send");
define("LAN_MAILOUT_239", "Latest time to send");
define("LAN_MAILOUT_240", "Notify me when run complete");
define("LAN_MAILOUT_241", " (This is in addition to the standard e107 notify options)");
define("LAN_MAILOUT_242", "Additional options (only when sending)");
define("LAN_MAILOUT_243", "Notify");
define("LAN_MAILOUT_244", "Email sent: ");
define("LAN_MAILOUT_245", "Check for bounces automatically");
define("LAN_MAILOUT_246", "If checked, you will need to activate the task in the scheduler");
define("LAN_MAILOUT_247", "Email information:");
define("LAN_MAILOUT_248", "Completion status: ");
define("LAN_MAILOUT_249", "Send results:");
define("LAN_MAILOUT_250", "--- End of notification ---");
define("LAN_MAILOUT_251", "Copy and edit");
define("LAN_MAILOUT_252", "Does various consistency checks on the data, corrects counts, deletes temporary data");
define("LAN_MAILOUT_253", "No recipients found - check for database corruption");
define("LAN_MAILOUT_254", "View templated email");
define("LAN_MAILOUT_255", "Templated Email, ID: ");
define("LAN_MAILOUT_256", "Return");
define("LAN_MAILOUT_257", "Generated template");
//define("LAN_MAILOUT_258", "Template: ");//LAN_TEMPLATE
define("LAN_SEND", "Send");
define("LAN_HOLD", "Hold");
define("LAN_MAILOUT_260", "User-Type");
define("LAN_MAILOUT_261", "SMTP Port");
define("LAN_MAILOUT_262", "Template Preview");
define("LAN_MAILOUT_263", "Total Recipients");
define("LAN_MAILOUT_264", "Embed Media");
define("LAN_MAILOUT_265", "Pending");
define("LAN_MAILOUT_266", "Max Active");
define("LAN_MAILOUT_267", "Generate Public/Private keys");
define("LAN_MAILOUT_268", "Developer Mode Only");
define("LAN_MAILOUT_269", "Send Later");
define("LAN_MAILOUT_270", "Test SMTP Connection");
define("LAN_MAILOUT_271", "Authentication failed with username ([x]) and password ([y]):");
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
// TODO - LANS - MAJOR LAN REWRITE NEEDED
define("CORE_DATE_ORDER", "dmy"); // Temporary until we find somewhere better to put it.
// Defines order of field entry/display in date boxes
// Acceptable values: dmy, mdy, ymd
define("LAN_MAILOUT_01", "From Name");
define("LAN_MAILOUT_02", "From Email");
define("LAN_MAILOUT_03", "To");
define("LAN_MAILOUT_04", "Cc");
define("LAN_MAILOUT_05", "Bcc");
define("LAN_MAILOUT_06", "Subject");
define("LAN_MAILOUT_07", "Attachment");
define("LAN_MAILOUT_08", "Send Email");
define("LAN_MAILOUT_09", "Send format");
define("LAN_MAILOUT_10", "User Subscribed");
define("LAN_MAILOUT_11", "Insert Variables");
define("LAN_MAILOUT_12", "All Users");
define("LAN_MAILOUT_13", "All Unverified Users ");
define("LAN_MAILOUT_14", "Display Name");
define("LAN_MAILOUT_15", "Mailout");
define("LAN_MAILOUT_16", "Username");
define("LAN_MAILOUT_17", "Signup link");
define("LAN_MAILOUT_18", "User ID");
define("LAN_MAILOUT_19", "No target email address specified");
define("LAN_MAILOUT_20", "Sendmail-path");
define("LAN_MAILOUT_21", "Bulk mailing Entries");
define("LAN_MAILOUT_22", "There are currently no saved entries");
define("LAN_MAILOUT_23", "userclass: ");
define("LAN_MAILOUT_24", "email(s) are ready to be sent");
define("LAN_MAILOUT_25", "Bulk mailing controls");
define("LAN_MAILOUT_26", "Pause bulk mailing every");
define("LAN_MAILOUT_27", "emails for ");
define("LAN_MAILOUT_28", "Save Changes");
define("LAN_MAILOUT_29", "seconds");
define("LAN_MAILOUT_30", "Used mostly with SMTP keepalive. A pause of more than 30 seconds may cause the browser to time-out");
define("LAN_MAILOUT_31", "Bounced Email Processing");
// define("LAN_MAILOUT_32", "Email address");
define("LAN_MAILOUT_33", "Incoming Mail server");
define("LAN_MAILOUT_34", "Account (user) Name");
// define("LAN_MAILOUT_35", "Password");
define("LAN_MAILOUT_36", "Delete Bounced Mails after checking");
define("LAN_MAILOUT_37", "Proceed");
define("LAN_MAILOUT_38", "Cancel");
define("LAN_MAILOUT_39", "Emailing");
// define("LAN_MAILOUT_40", "You need to rename <b>e107.htaccess</b> to <b>.htaccess</b> in");
define("LAN_MAILOUT_41", "before sending mail from this page.");
//define("LAN_MAILOUT_42", "Warning");//NOT_USED
define("LAN_MAILOUT_43", "Username");
define("LAN_MAILOUT_44", "User Login");
define("LAN_MAILOUT_45", "User Email");
define("LAN_MAILOUT_46", "User-Match");
define("LAN_MAILOUT_47", "contains");
define("LAN_MAILOUT_48", "equals");
//define("LAN_MAILOUT_49", "Id");//LAN_ID
//define("LAN_MAILOUT_50", "Author");//LAN_AUTHOR
define("LAN_MAILOUT_51", "Subject");
define("LAN_MAILOUT_52", "Last mod");
define("LAN_MAILOUT_53", "Admins");
define("LAN_MAILOUT_54", "Self");
define("LAN_MAILOUT_55", "Userclass");
define("LAN_MAILOUT_56", "Last Visit");
define("LAN_MAILOUT_57", "Send bulk SMTP emails in blocks"); // SMTP KeepAlive option
//define("LAN_MAILOUT_58", "There is a problem with the attachment:");
//define("LAN_MAILOUT_59", "Mailing Progress");
//define("LAN_MAILOUT_60", "Sending...");
//define("LAN_MAILOUT_61", "There are no remaining emails to be sent.");
//define("LAN_MAILOUT_62", "Emails sent:");
//define("LAN_MAILOUT_63", "Emails failed:");
//define("LAN_MAILOUT_64", "Total time elapsed:");
//define("LAN_MAILOUT_65", "seconds");
//define("LAN_MAILOUT_66", "Cancelled Successfully");
define("LAN_MAILOUT_67", "The email could not be sent. Please review your SMTP settings, or select another mailing method and try again.");
define("LAN_MAILOUT_68", "Registered Users");
define("LAN_MAILOUT_69", "matches, after ");
define("LAN_MAILOUT_70", " duplicates stripped.");
define("LAN_MAILOUT_71", "Total emails to send");
define("LAN_MAILOUT_72", "Mailshot logging");
define("LAN_MAILOUT_73", "No logging");
define("LAN_MAILOUT_74", "Logging only (no send)");
define("LAN_MAILOUT_75", "Log and send");
define("LAN_MAILOUT_76", "Include email info in log");
define("LAN_MAILOUT_77", "Email address sources");
define("LAN_MAILOUT_78", "Mailshot Status");
define("LAN_MAILOUT_79", "No mailshots to display");
//define("LAN_MAILOUT_80", "Date");//LAN_DATE
define("LAN_MAILOUT_81", "The email has been successfully sent, please check your inbox.");
define("LAN_MAILOUT_82", "Mails sent");
define("LAN_MAILOUT_83", "Mails to go");
define("LAN_MAILOUT_84", "Mail ID");
define("LAN_MAILOUT_85", "Originator");
define("LAN_MAILOUT_86", "Re-send");
define("LAN_MAILOUT_87", "SMTP Server");
define("LAN_MAILOUT_88", "SMTP Username");
define("LAN_MAILOUT_89", "SMTP Password");
define("LAN_MAILOUT_90", "SMTP Features");
define("LAN_MAILOUT_91", "POP before SMTP");
define("LAN_MAILOUT_92", "SSL");
define("LAN_MAILOUT_93", "TLS");
define("LAN_MAILOUT_94", "(Use SSL for gmail/googlemail)");
define("LAN_MAILOUT_95", "Use VERP for bulk mailing");
//define("LAN_MAILOUT_96", "none");//LAN_NONE
define("LAN_MAILOUT_97", "Mailer Results");
define("LAN_MAILOUT_98", "Orphaned entries");
define("LAN_MAILOUT_99", "Confirm retry mailshot");
define("LAN_MAILOUT_100", "Message");
define("LAN_MAILOUT_101", "Email Detail");
define("LAN_MAILOUT_102", "Detail of mailshot");
define("LAN_MAILOUT_103", "Results of attempts to send");
define("LAN_MAILOUT_104", "No attempt to send, or error saving result");
define("LAN_MAILOUT_105", "Details of up to 10 failures");
define("LAN_MAILOUT_106", "The email could not be sent. It appears that your server is not correctly configured to send emails, please try again using SMTP, or contact your hosts and ask them to check their sendmail / email server settings.");
define("LAN_MAILOUT_107", "at");
define("LAN_MAILOUT_108", "Result");
define("LAN_MAILOUT_109", "Show detail");
define("LAN_MAILOUT_110", "Send test email");
define("LAN_MAILOUT_111", "Email Title (not sent)");
define("LAN_MAILOUT_112", "Send test email to");
define("LAN_MAILOUT_113", "Test email from");
define("LAN_MAILOUT_114", "This is a test email, it appears that your email settings are working ok! [br][br] Regards [br] from the e107 website system.");
define("LAN_MAILOUT_115", "Bulk Emailing method");
define("LAN_MAILOUT_116", "If unsure, leave as php");
define("LAN_MAILOUT_117", "complete");
define("LAN_MAILOUT_118", "Click on proceed' to start sending emails. Click on 'cancel' to stop the run. Once complete, select another page. Unsent emails cal be viewed through the 'Mailshot status' screen");
define("LAN_MAILOUT_119", "Logging only, with errors");
define("LAN_MAILOUT_120", "Account type");
define("LAN_MAILOUT_121", "Standard POP3");
define("LAN_MAILOUT_122", "POP3, TLS disabled");
define("LAN_MAILOUT_123", "POP3 with TLS");
define("LAN_MAILOUT_124", "IMAP");
define("LAN_MAILOUT_125", "Text only");
define("LAN_MAILOUT_126", "Text and HTML");
define("LAN_MAILOUT_127", "Include theme");
define("LAN_MAILOUT_128", "Send Error");
define("LAN_MAILOUT_129", "Expiry Date");
define("LAN_MAILOUT_130", "Creation Date");
define("LAN_MAILOUT_131", "Sending Started");
define("LAN_MAILOUT_132", "Sending Complete");
//define("LAN_MAILOUT_133", "Source"); // Moved to lan_admin.php
define("LAN_MAILOUT_134", "Priority");
//define("LAN_MAILOUT_135", "Title");//LAN_TITLE
define("LAN_MAILOUT_136", "Mailout Status");
define("LAN_MAILOUT_137", "Mail Ref");
define("LAN_MAILOUT_138", "Email status");
define("LAN_MAILOUT_139", "Date active");
define("LAN_MAILOUT_140", "Recipient Email");
define("LAN_MAILOUT_141", "Recipient Name");
define("LAN_MAILOUT_142", "Recipient User ID");
define("LAN_MAILOUT_143", "Recipient ref.");
define("LAN_MAILOUT_144", "Bounced");
define("LAN_MAILOUT_145", "New email saved");
define("LAN_MAILOUT_146", "Error saving email");
define("LAN_MAILOUT_147", "Email updated");
define("LAN_MAILOUT_148", "User values");
define("LAN_MAILOUT_149", "Sender Email");
define("LAN_MAILOUT_150", "Sender Name");
define("LAN_MAILOUT_151", "Copy to");
define("LAN_MAILOUT_152", "Blind copy to");
define("LAN_MAILOUT_153", "Attachments");
define("LAN_MAILOUT_154", "Send Format");
define("LAN_MAILOUT_155", "Selectors");
define("LAN_MAILOUT_156", "Maximum number of emails to send per scheduler tick");
define("LAN_MAILOUT_157", "Value will depend on a number of factors, including how often your mail queue scheduler job is triggered and the rate at which your ISP will accept outgoing mail. Zero to clear queue each time");
define("LAN_MAILOUT_158", "Send now");
define("LAN_MAILOUT_159", "Hold email");
define("LAN_MAILOUT_160", "Cancel send");
define("LAN_MAILOUT_161", "IMPORTANT! This file appears to not exist");
define("LAN_MAILOUT_162", "IMPORTANT! You need to make this file executable");
define("LAN_MAILOUT_163", "Edit/Send Mail");
define("LAN_MAILOUT_164", "Email information not found");
define("LAN_MAILOUT_165", "Confirm delete the following stored email, including any recipient records");
define("LAN_MAILOUT_166", "General error deleting mail ref: [x]");
define("LAN_MAILOUT_167", "Error deleting mail content ref: [x]");
define("LAN_MAILOUT_168", "Mail content deleted ref: [x]");
define("LAN_MAILOUT_169", "Error deleting mail recipients ref: [x]");
define("LAN_MAILOUT_170", "Deleted [y] recipients for mail ref: [x]");
define("LAN_MAILOUT_171", "Confirm email delete");
define("LAN_MAILOUT_172", "Mail Type/Status");
define("LAN_MAILOUT_173", "Recipients");
define("LAN_MAILOUT_174", "Security check fail: [x] [z]");
define("LAN_MAILOUT_175", "Before");
define("LAN_MAILOUT_176", "Equal to");
define("LAN_MAILOUT_177", "After");
define("LAN_MAILOUT_178", "Last site visit");
define("LAN_MAILOUT_179", "Confirm email send");
define("LAN_MAILOUT_180", "Selection criteria:");
define("LAN_MAILOUT_181", "Show recipients");
define("LAN_MAILOUT_182", "Tidy database tables");
define("LAN_MAILOUT_183", "Error tidying database");
define("LAN_MAILOUT_184", "Database tidied");
define("LAN_MAILOUT_185", "Emails added to send queue");
define("LAN_MAILOUT_186", "General error putting mail ref: [x] on hold");
define("LAN_MAILOUT_187", "Email [x] put on hold");
define("LAN_MAILOUT_188", "General error sending mail ref: [x]");
define("LAN_MAILOUT_189", "Test address");
// Admin menu text
define("LAN_MAILOUT_190", "Create/Send Mail");
define("LAN_MAILOUT_191", "Saved emails");
define("LAN_MAILOUT_192", "Completed Mailshots");
define("LAN_MAILOUT_193", "Pending Mailshots");
define("LAN_MAILOUT_194", "Held Mailshots");
// define("LAN_MAILOUT_195", "");
// define("LAN_MAILOUT_196", "");
// Block of error messages kept together
define("LAN_MAILOUT_200", "No subject specified");
define("LAN_MAILOUT_201", "No meaningful data for email");
define("LAN_MAILOUT_202", "No text in email body");
define("LAN_MAILOUT_203", "No sender name specified");
define("LAN_MAILOUT_204", "No sender email address specified");
define("LAN_MAILOUT_205", "Email send format error");
define("LAN_MAILOUT_206", "Invalid mail ID ([x]) specified");
define("LAN_MAILOUT_207", "Template load error");
define("LAN_MAILOUT_208", "Template conversion error");
// Block of status messages kept together
define("LAN_MAILOUT_211", "Sent");
define("LAN_MAILOUT_212", "Failed");
define("LAN_MAILOUT_213", "Bounced");
define("LAN_MAILOUT_214", "To send");
define("LAN_MAILOUT_215", "Saved");
define("LAN_MAILOUT_216", "Code error");
define("LAN_MAILOUT_217", "Held");
define("LAN_MAILOUT_218", "Cancelled");
define("LAN_MAILOUT_219", "Partial");
// General messages continued
define("LAN_MAILOUT_220", "Email ID [x] cancelled");
define("LAN_MAILOUT_221", "Error cancelling email with ID [x]");
define("LAN_MAILOUT_222", "Default email format");
define("LAN_MAILOUT_223", "(Used for some system-generated emails)");
define("LAN_MAILOUT_224", "Inc. Images");
define("LAN_MAILOUT_225", "Include images in email");
define("LAN_MAILOUT_226", "[x] orphaned recipient record(s) removed");
define("LAN_MAILOUT_227", "Deleted [x] records from [y]");
define("LAN_MAILOUT_228", "[x] anomalies in mail_content corrected; records: [y]");
define("LAN_MAILOUT_229", "Email ID [x] put on hold");
define("LAN_MAILOUT_230", "Error holding email with ID [x]");
define("LAN_MAILOUT_231", "Bounced emails - Processing method");
define("LAN_MAILOUT_232", "None");
define("LAN_MAILOUT_233", "Auto-process script");
define("LAN_MAILOUT_234", "Mail account");
define("LAN_MAILOUT_235", "(Your server must forward or 'pipe' from the email address above to the script path above.)");
define("LAN_MAILOUT_236", "Last Bounce Processed");
define("LAN_MAILOUT_237", "Summary counters updated on [x] emails");
define("LAN_MAILOUT_238", "Earliest time to send");
define("LAN_MAILOUT_239", "Latest time to send");
define("LAN_MAILOUT_240", "Notify me when run complete");
define("LAN_MAILOUT_241", " (This is in addition to the standard e107 notify options)");
define("LAN_MAILOUT_242", "Additional options (only when sending)");
define("LAN_MAILOUT_243", "Notify");
define("LAN_MAILOUT_244", "Email sent: ");
define("LAN_MAILOUT_245", "Check for bounces automatically");
define("LAN_MAILOUT_246", "If checked, you will need to activate the task in the scheduler");
define("LAN_MAILOUT_247", "Email information:");
define("LAN_MAILOUT_248", "Completion status: ");
define("LAN_MAILOUT_249", "Send results:");
define("LAN_MAILOUT_250", "--- End of notification ---");
define("LAN_MAILOUT_251", "Copy and edit");
define("LAN_MAILOUT_252", "Does various consistency checks on the data, corrects counts, deletes temporary data");
define("LAN_MAILOUT_253", "No recipients found - check for database corruption");
define("LAN_MAILOUT_254", "View templated email");
define("LAN_MAILOUT_255", "Templated Email, ID: ");
define("LAN_MAILOUT_256", "Return");
define("LAN_MAILOUT_257", "Generated template");
//define("LAN_MAILOUT_258", "Template: ");//LAN_TEMPLATE
define("LAN_SEND", "Send");
define("LAN_HOLD", "Hold");
define("LAN_MAILOUT_260", "User-Type");
define("LAN_MAILOUT_261", "SMTP Port");
define("LAN_MAILOUT_262", "Template Preview");
define("LAN_MAILOUT_263", "Total Recipients");
define("LAN_MAILOUT_264", "Embed Media");
define("LAN_MAILOUT_265", "Pending");
define("LAN_MAILOUT_266", "Max Active");
define("LAN_MAILOUT_267", "Generate Public/Private keys");
define("LAN_MAILOUT_268", "Developer Mode Only");
define("LAN_MAILOUT_269", "Send Later");
define("LAN_MAILOUT_270", "Test SMTP Connection");
define("LAN_MAILOUT_271", "Authentication failed with username ([x]) and password ([y]):");

View File

@@ -1,111 +1,111 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Administration Area - User classes
*
*/
//define("UCSLAN_1", "Cleared all users from class.");
//define("UCSLAN_2", "Class users updated.");
//define("UCSLAN_3", "Class deleted.");//NOT USED
//define("UCSLAN_4", "Please tick the confirm box to delete this user class"); currently not in use
//define("UCSLAN_5", "Class updated.");//LAN_UPDATED.': '.LAN_USERCLASS
//define("UCSLAN_6", "Class saved to database.");//LAN_UPDATED.': '.LAN_USERCLASS
//define("UCSLAN_7", "No user classes yet.");//LAN_NO_RECORDS_FOUND
//define("UCSLAN_8", "Existing Classes");//NOT USED
//define("UCSLAN_9", "No Icon");//NOT USED
define("UCSLAN_10", "Class not deleted - it is a core class, or is used in the definition of another class, as either parent or edit class");
//define("UCSLAN_11", "tick to confirm");//NOT USED
//define("UCSLAN_12", "Class Name");//LAN_NAME
//define("UCSLAN_13", "Class Description");//LAN_DESCRIPTION
//define("UCSLAN_14", "Update User Class");//LAN_UPDATE
//define("UCSLAN_15", "Create New Class");//LAN_CREATE
//define("UCSLAN_16", "Assign users to class");
//define("UCSLAN_17", "Remove");
//define("UCSLAN_18", "Clear Class");//NOT USED
//define("UCSLAN_19", "Assign users to");
//define("UCSLAN_20", "class");//NOT USED
//define("UCSLAN_21", "User Class Settings");//LAN_SETTINGS
//define("UCSLAN_22", "Users - click to move ...");
//define("UCSLAN_23", "Users in this class ...");
//define("UCSLAN_24", "Class Manager");//LAN_MANAGER
//define("UCSLAN_25", "Create/Edit Classes");//NOT USED
//define("UCSLAN_26", "Class Membership");//NOT USED
//define("UCSLAN_27", "Debug Help");//NOT USED
//define("UCSLAN_28", "Modify Class Membership");
//define("UCSLAN_29", "That class must not be deleted");//NOT USED
define("UCSLAN_30", "Short name displayed in selectors");
define("UCSLAN_31", "Information about applicability of class");
define("UCSLAN_32", "Users in this class can add/remove themselves from the class being edited");
define("UCSLAN_33", "Determines which users can see this class in drop-down lists");
//define("UCSLAN_34", "Class Visibility");//LAN_VISIBILITY
//define("UCSLAN_35", "Class Parent");//LAN_PARENT
define("UCSLAN_36", "If the top of the tree is 'No One', permissions increase towards the top of the tree<br />If the top of the tree is 'Everyone', permissions increase as you go down the tree");
define("UCSLAN_37", "You must enter a name for the class");
define("UCSLAN_38", "Initial User Class");
define("UCSLAN_39", "No classes which can be set");
define("UCSLAN_40", "Set initial classes");
define("UCSLAN_41", "Settings updated");
//define("UCSLAN_42", "Nothing changed - not updated");//LAN_NOCHANGE_NOTSAVED
define("UCSLAN_43", "Existing classes: ");
//define("UCSLAN_44", "None");//LAN_NONE
define("UCSLAN_45", "Point at which classes set:");
define("UCSLAN_46", "(ignored if no verification)");
define("UCSLAN_47", "Initial Signup");
define("UCSLAN_48", "Verification by email or admin");
define("UCSLAN_49", "These classes are set for any newly signed up user - either immediately, or once their site membership has been verified");
//define("UCSLAN_50", "Options/Setup");//NOT USED
//define("UCSLAN_51", "User Class Functions");//NOT USED
//define("UCSLAN_52", "Setup Options");//LAN_OPTIONS
define("UCSLAN_53", "Caution! Only use these options when requested by support.");
define("UCSLAN_54", "Set a default user hierarchy");
define("UCSLAN_55", "Clear the user hierarchy");
define("UCSLAN_56", "(this sets a 'flat' user class structure)");
define("UCSLAN_57", "(the hierarchy can be modified later)");
define("UCSLAN_58", "Execute");
//define("UCSLAN_59", "Enable admin logging of user class edits");//NOT USED
//define("UCSLAN_60", "User Class Configuration options");//NOT USED
//define("UCSLAN_61", "User class setup");//NOT USED
define("UCSLAN_62", "Create default class tree: ");
define("UCSLAN_63", "That class name already exists - please choose another");
define("UCSLAN_64", "completed");
define("UCSLAN_65", "Flatten user class hierarchy: ");
//define("UCSLAN_66", "Confirm flatten user class hierarchy");
//define("UCSLAN_67", "Confirm set default user class hierarchy");
//define("UCSLAN_68", "Class Icon");//LAN_ICON
define("UCSLAN_69", "Optional icon associated with class - directory ");
define("UCSLAN_70", "Rebuilding class hierarchy: ");
define("UCSLAN_71", "User Class Maintenance");
define("UCSLAN_72", "Rebuild class hierarchy ");
define("UCSLAN_73", "(This may be required if database corruption occurs)");
//userclass_class.php
define("UCSLAN_74", "Administrators and Moderators");
define("UCSLAN_75", "Registered and logged in members");
define("UCSLAN_76", "Site Administrators");
define("UCSLAN_77", "Main Site Administrators");
define("UCSLAN_78", "Moderators for Forums and other areas");
//define("UCSLAN_79", "Class Type");
define("UCSLAN_80", "Standard");
define("UCSLAN_81", "Group");
define("UCSLAN_82", "A group brings together a number of individual classes");
define("UCSLAN_83", "Classes in group");
//define("UCSLAN_84", " (Group)");//UCSLAN_81
define("UCSLAN_85", "You have assigned all available classes; please reassign one which is not in use");
define("UCSLAN_86", "Some settings not allowed for admin classes - they have been set to defaults. ");
define("UCSLAN_87", "Recently joined users");
define("UCSLAN_88", "Identified search bots");
define("UCSLAN_89", "Checked classes are members of the group");
define("UCSLAN_90", "You can't edit certain system user classes!");
define("UCSLAN_91", "Class Structure");
//define("UCSLAN_UPDATE", "Update");//NOT USED ... LAN_UPDATE
?>
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Administration Area - User classes
*
*/
//define("UCSLAN_1", "Cleared all users from class.");
//define("UCSLAN_2", "Class users updated.");
//define("UCSLAN_3", "Class deleted.");//NOT USED
//define("UCSLAN_4", "Please tick the confirm box to delete this user class"); currently not in use
//define("UCSLAN_5", "Class updated.");//LAN_UPDATED.': '.LAN_USERCLASS
//define("UCSLAN_6", "Class saved to database.");//LAN_UPDATED.': '.LAN_USERCLASS
//define("UCSLAN_7", "No user classes yet.");//LAN_NO_RECORDS_FOUND
//define("UCSLAN_8", "Existing Classes");//NOT USED
//define("UCSLAN_9", "No Icon");//NOT USED
define("UCSLAN_10", "Class not deleted - it is a core class, or is used in the definition of another class, as either parent or edit class");
//define("UCSLAN_11", "tick to confirm");//NOT USED
//define("UCSLAN_12", "Class Name");//LAN_NAME
//define("UCSLAN_13", "Class Description");//LAN_DESCRIPTION
//define("UCSLAN_14", "Update User Class");//LAN_UPDATE
//define("UCSLAN_15", "Create New Class");//LAN_CREATE
//define("UCSLAN_16", "Assign users to class");
//define("UCSLAN_17", "Remove");
//define("UCSLAN_18", "Clear Class");//NOT USED
//define("UCSLAN_19", "Assign users to");
//define("UCSLAN_20", "class");//NOT USED
//define("UCSLAN_21", "User Class Settings");//LAN_SETTINGS
//define("UCSLAN_22", "Users - click to move ...");
//define("UCSLAN_23", "Users in this class ...");
//define("UCSLAN_24", "Class Manager");//LAN_MANAGER
//define("UCSLAN_25", "Create/Edit Classes");//NOT USED
//define("UCSLAN_26", "Class Membership");//NOT USED
//define("UCSLAN_27", "Debug Help");//NOT USED
//define("UCSLAN_28", "Modify Class Membership");
//define("UCSLAN_29", "That class must not be deleted");//NOT USED
define("UCSLAN_30", "Short name displayed in selectors");
define("UCSLAN_31", "Information about applicability of class");
define("UCSLAN_32", "Users in this class can add/remove themselves from the class being edited");
define("UCSLAN_33", "Determines which users can see this class in drop-down lists");
//define("UCSLAN_34", "Class Visibility");//LAN_VISIBILITY
//define("UCSLAN_35", "Class Parent");//LAN_PARENT
define("UCSLAN_36", "If the top of the tree is 'No One', permissions increase towards the top of the tree<br />If the top of the tree is 'Everyone', permissions increase as you go down the tree");
define("UCSLAN_37", "You must enter a name for the class");
define("UCSLAN_38", "Initial User Class");
define("UCSLAN_39", "No classes which can be set");
define("UCSLAN_40", "Set initial classes");
define("UCSLAN_41", "Settings updated");
//define("UCSLAN_42", "Nothing changed - not updated");//LAN_NOCHANGE_NOTSAVED
define("UCSLAN_43", "Existing classes: ");
//define("UCSLAN_44", "None");//LAN_NONE
define("UCSLAN_45", "Point at which classes set:");
define("UCSLAN_46", "(ignored if no verification)");
define("UCSLAN_47", "Initial Signup");
define("UCSLAN_48", "Verification by email or admin");
define("UCSLAN_49", "These classes are set for any newly signed up user - either immediately, or once their site membership has been verified");
//define("UCSLAN_50", "Options/Setup");//NOT USED
//define("UCSLAN_51", "User Class Functions");//NOT USED
//define("UCSLAN_52", "Setup Options");//LAN_OPTIONS
define("UCSLAN_53", "Caution! Only use these options when requested by support.");
define("UCSLAN_54", "Set a default user hierarchy");
define("UCSLAN_55", "Clear the user hierarchy");
define("UCSLAN_56", "(this sets a 'flat' user class structure)");
define("UCSLAN_57", "(the hierarchy can be modified later)");
define("UCSLAN_58", "Execute");
//define("UCSLAN_59", "Enable admin logging of user class edits");//NOT USED
//define("UCSLAN_60", "User Class Configuration options");//NOT USED
//define("UCSLAN_61", "User class setup");//NOT USED
define("UCSLAN_62", "Create default class tree: ");
define("UCSLAN_63", "That class name already exists - please choose another");
define("UCSLAN_64", "completed");
define("UCSLAN_65", "Flatten user class hierarchy: ");
//define("UCSLAN_66", "Confirm flatten user class hierarchy");
//define("UCSLAN_67", "Confirm set default user class hierarchy");
//define("UCSLAN_68", "Class Icon");//LAN_ICON
define("UCSLAN_69", "Optional icon associated with class - directory ");
define("UCSLAN_70", "Rebuilding class hierarchy: ");
define("UCSLAN_71", "User Class Maintenance");
define("UCSLAN_72", "Rebuild class hierarchy ");
define("UCSLAN_73", "(This may be required if database corruption occurs)");
//userclass_class.php
define("UCSLAN_74", "Administrators and Moderators");
define("UCSLAN_75", "Registered and logged in members");
define("UCSLAN_76", "Site Administrators");
define("UCSLAN_77", "Main Site Administrators");
define("UCSLAN_78", "Moderators for Forums and other areas");
//define("UCSLAN_79", "Class Type");
define("UCSLAN_80", "Standard");
define("UCSLAN_81", "Group");
define("UCSLAN_82", "A group brings together a number of individual classes");
define("UCSLAN_83", "Classes in group");
//define("UCSLAN_84", " (Group)");//UCSLAN_81
define("UCSLAN_85", "You have assigned all available classes; please reassign one which is not in use");
define("UCSLAN_86", "Some settings not allowed for admin classes - they have been set to defaults. ");
define("UCSLAN_87", "Recently joined users");
define("UCSLAN_88", "Identified search bots");
define("UCSLAN_89", "Checked classes are members of the group");
define("UCSLAN_90", "You can't edit certain system user classes!");
define("UCSLAN_91", "Class Structure");
//define("UCSLAN_UPDATE", "Update");//NOT USED ... LAN_UPDATE
?>

View File

@@ -1,48 +1,48 @@
<?php
/*
* Copyright 2008-2010 e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Validator Handler - Language File
*/
/*
* Default error messages by Error code number
*/
define("LAN_VALIDATE_0", "Unknown Error");
define("LAN_VALIDATE_101", "Missing value");
define("LAN_VALIDATE_102", "Unexpected value type");
define("LAN_VALIDATE_103", "Invalid characters found");
define("LAN_VALIDATE_104", "Not a valid email address");
define("LAN_VALIDATE_105", "Fields don\"t match" );
define("LAN_VALIDATE_131", "String too short");
define("LAN_VALIDATE_132", "String too long");
define("LAN_VALIDATE_133", "Number too low");
define("LAN_VALIDATE_134", "Number too high");
define("LAN_VALIDATE_135", "Array count too low");
define("LAN_VALIDATE_136", "Array count too high");
define("LAN_VALIDATE_151", "Number of type integer expected");
define("LAN_VALIDATE_152", "Number of type float expected");
define("LAN_VALIDATE_153", "Instance type expected");
define("LAN_VALIDATE_154", "Array type expected");
define("LAN_VALIDATE_191", "Empty value");
define("LAN_VALIDATE_201", "File not exists");
define("LAN_VALIDATE_202", "File not writable");
define("LAN_VALIDATE_203", "File exceeds allowed file size");
define("LAN_VALIDATE_204", "File size lower than allowed minimal file size");
//define("LAN_VALIDATE_", "");
/*
* TRANSLATION INSTRUCTIONS:
* Don"t translate %1$s, %2$s, %3$s, etc.
*
* These are substituted by validator handler:
* %1$s - field name
* %2$d - validation error code (number)
* %3$s - validation error message (string)
*/
// define("LAN_VALIDATE_FAILMSG", "<strong>&quot;%1$s&quot;</strong> validation error: [#%2$d] %3$s.");
//FIXME - use this instead:
<?php
/*
* Copyright 2008-2010 e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Validator Handler - Language File
*/
/*
* Default error messages by Error code number
*/
define("LAN_VALIDATE_0", "Unknown Error");
define("LAN_VALIDATE_101", "Missing value");
define("LAN_VALIDATE_102", "Unexpected value type");
define("LAN_VALIDATE_103", "Invalid characters found");
define("LAN_VALIDATE_104", "Not a valid email address");
define("LAN_VALIDATE_105", "Fields don\"t match" );
define("LAN_VALIDATE_131", "String too short");
define("LAN_VALIDATE_132", "String too long");
define("LAN_VALIDATE_133", "Number too low");
define("LAN_VALIDATE_134", "Number too high");
define("LAN_VALIDATE_135", "Array count too low");
define("LAN_VALIDATE_136", "Array count too high");
define("LAN_VALIDATE_151", "Number of type integer expected");
define("LAN_VALIDATE_152", "Number of type float expected");
define("LAN_VALIDATE_153", "Instance type expected");
define("LAN_VALIDATE_154", "Array type expected");
define("LAN_VALIDATE_191", "Empty value");
define("LAN_VALIDATE_201", "File not exists");
define("LAN_VALIDATE_202", "File not writable");
define("LAN_VALIDATE_203", "File exceeds allowed file size");
define("LAN_VALIDATE_204", "File size lower than allowed minimal file size");
//define("LAN_VALIDATE_", "");
/*
* TRANSLATION INSTRUCTIONS:
* Don"t translate %1$s, %2$s, %3$s, etc.
*
* These are substituted by validator handler:
* %1$s - field name
* %2$d - validation error code (number)
* %3$s - validation error message (string)
*/
// define("LAN_VALIDATE_FAILMSG", "<strong>&quot;%1$s&quot;</strong> validation error: [#%2$d] %3$s.");
//FIXME - use this instead:
define("LAN_VALIDATE_FAILMSG", "[x] validation error: [y] [z].");

View File

@@ -1,188 +1,188 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_installer.php,v $
* $Revision$
* $Date$
* $Author$
*/
define("LANINS_001", "e107 Installation");
define("LANINS_002", "Step ");
define("LANINS_003", "1");
define("LANINS_004", "Language Selection");
define("LANINS_005", "Please choose the language to use during installation");
// define("LANINS_006", "Set Language");
define("LANINS_007", "4");
define("LANINS_008", "PHP and MySQL Versions Check / File Permissions Check");
define("LANINS_009", "Retest File Permissions");
define("LANINS_010", "File not writable: ");
define("LANINS_010a", "Folder not writable: ");
// define("LANINS_011", "Error"); new > LAN_ERROR
define("LANINS_012", "MySQL Functions don't seem to exist. This probably means that either the MySQL PHP Extension isn't installed or your PHP installation wasn't compiled with MySQL support."); // help for 012
define("LANINS_013", "Couldn't determine your MySQL version number. This is a non fatal error, so please continue installing, but be aware that e107 requires MySQL >= 3.23 to function correctly.");
define("LANINS_014", "File Permissions");
define("LANINS_015", "PHP Version");
// define("LANINS_016", "MySQL");
define("LANINS_017", "PASS");
define("LANINS_018", "Ensure all the listed files exist and are writable by the server. This normally involves CHMODing them 777, but environments vary - contact your host if you have any problems.");
define("LANINS_019", "The version of PHP installed on your server isn't capable of running e107. e107 requires a PHP version of at least ".MIN_PHP_VERSION." to run correctly. Either upgrade your PHP version, or contact your host for an upgrade.");
// define("LANINS_020", "Continue Installation"); //LAN_CONTINUE
define("LANINS_021", "2");
define("LANINS_022", "MySQL Server Details");
define("LANINS_023", "Please enter your MySQL settings here.
If you have root permissions you can create a new database by ticking the box, if not you must create a database or use a pre-existing one.
If you have only one database use a prefix so that other scripts can share the same database.
If you do not know your MySQL details contact your web host.");
define("LANINS_024", "MySQL Server:");
define("LANINS_025", "MySQL Username:");
define("LANINS_026", "MySQL Password:");
define("LANINS_027", "MySQL Database:");
define("LANINS_028", "Create Database?");
define("LANINS_029", "Table prefix:");
define("LANINS_030", "The MySQL server you would like e107 to use. It can also include a port number. e.g. 'hostname:port' or a path to a local socket e.g. \":/path/to/socket\" for the localhost.");
define("LANINS_031", "The username you wish e107 to use to connect to your MySQL server");
define("LANINS_032", "The Password for the user you just entered. Must not contain single or double quotes.");
define("LANINS_033", "The MySQL database you wish e107 to reside in, sometimes referred to as a schema. Must begin with a letter. If the user has database create permissions you can opt to create the database automatically if it doesn't already exist.");
define("LANINS_034", "The prefix you wish e107 to use when creating the e107 tables. Useful for multiple installs of e107 in one database schema.");
// define("LANINS_035", "Continue"); // LAN_CONTINUE
define("LANINS_036", "3");
define("LANINS_037", "MySQL Connection Verification");
define("LANINS_038", " and Database Creation");
define("LANINS_039", "Please make sure you fill in all fields, most importantly, MySQL Server, MySQL Username and MySQL Database (These are always required by the MySQL Server)");
define("LANINS_040", "Errors");
define("LANINS_041", "e107 was unable to establish a connection to the MySQL server using the information you entered. Please return to the last page and ensure the information is correct.");
define("LANINS_042", "Connection to the MySQL server established and verified.");
define("LANINS_043", "Unable to create database, please ensure you have the correct permissions to create databases on your server.");
define("LANINS_044", "Successfully created database.");
define("LANINS_045", "Please click on the button to proceed to next stage.");
define("LANINS_046", "5");
define("LANINS_047", "Administrator Details");
define("LANINS_048", "EXIF extension");
define("LANINS_049", "The two passwords you entered are not the same. Please go back and try again.");
define("LANINS_050", "XML extension");
define("LANINS_051", "Installed");
define("LANINS_052", "Not Installed");
// define("LANINS_053", "e107 v2.x requires the PHP XML Extension to be installed. Please contact your host or read the information at [x] before continuing");
// define("LANINS_054", "e107 v2.x requires the PHP EXIF Extension to be installed. Please contact your host or read the information at [x] before continuing");
define("LANINS_055", "Install Confirmation");
define("LANINS_056", "6");
define("LANINS_057", " e107 now has all the information it needs to complete the installation.
Please click the button to create the database tables and save all your settings.
");
define("LANINS_058", "7");
define("LANINS_060", "Unable to read the sql datafile
Please ensure the file [b]core_sql.php[/b] exists in the [b]/e107_core/sql[/b] directory.");
define("LANINS_061", "e107 was unable to create all of the required database tables.
Please clear the database and rectify any problems before trying again.");
// define("LANINS_063", "Welcome to e107");
define("LANINS_069", "e107 has been successfully installed!
For security reasons you should now set the file permissions on the [b]e107_config.php[/b] file back to 644.
Also please delete install.php from your server after you have clicked the button below.
");
define("LANINS_070", "e107 was unable to save the main config file to your server.
Please ensure the [b]e107_config.php[/b] file has the correct permissions");
define("LANINS_071", "Installation Complete");
define("LANINS_072", "Admin Username");
define("LANINS_073", "This is the name you will use to login into the site. If you wish to use this as your display name also");
define("LANINS_074", "Admin Display Name");
// define("LANINS_075", "This is the name that you wish your users to see displayed in your profile, forums and other areas. If you wish to use the same as your username then leave this blank.");
define("LANINS_076", "Admin Password");
define("LANINS_077", "Please type the admin password you wish to use here");
define("LANINS_078", "Admin Password Confirmation");
define("LANINS_079", "Please type the admin password again for confirmation");
define("LANINS_080", "Admin Email");
define("LANINS_081", "Enter your email address");
// define("LANINS_082", "user@yoursite.com");
// Better table creation error reporting
define("LANINS_083", "MySQL Reported Error:");
define("LANINS_084", "The installer could not establish a connection to the database");
define("LANINS_085", "The installer could not select database:");
define("LANINS_086", "Admin Username, Admin Password and Admin Email are required fields. Please return to the last page and ensure the information is correctly entered.");
// define("LANINS_087", "Misc");
// define("LANINS_088", "Home");
// define("LANINS_089", "Downloads");
// define("LANINS_090", "Members");
// define("LANINS_091", "Submit News");
// define("LANINS_092", "Contact Us");
// define("LANINS_093", "Grants access to private menu items");
// define("LANINS_094", "Example private forum class");
// define("LANINS_095", "Integrity Check");
// define("LANINS_096", 'Latest Comments');
// define("LANINS_097", '[more ...]');
// define("LANINS_098", 'Articles');
// define("LANINS_099", 'Articles Front Page ...');
// define("LANINS_100", 'Latest Forum Posts');
// define("LANINS_101", 'Update menu Settings');
// define("LANINS_102", 'Date / Time');
// define("LANINS_103", 'Reviews');
// define("LANINS_104", 'Review Front Page ...');
define("LANINS_105", "A database name or prefix beginning with some digits followed by 'e' or 'E' is not acceptable");
define("LANINS_106", "WARNING - e107 cannot write to the directories and/or files listed. While this will not stop e107 installing, it will mean that certain features are not available.
You will need to change the file permissions to use these features");
define("LANINS_107", "Website Name");
define("LANINS_108", "My Website");
define("LANINS_109", "Website Theme");
// define("LANINS_110", "");
define("LANINS_111", "Include Content/Configuration");
define("LANINS_112", "Quickly reproduce the look of the theme preview or demo. (If Available)");
define("LANINS_113", "Please enter a website name");
define("LANINS_114", "Please select a theme");
define("LANINS_115", "Theme Name");
define("LANINS_116", "Theme Type");
define("LANINS_117", "Website Preferences");
define("LANINS_118", "Install Plugins");
define("LANINS_119", "Install all plugins that the theme may require.");
define("LANINS_120", "8");
define("LANINS_121", "e107_config.php is not an empty file");
define("LANINS_122", "You might have an existing installation");
define("LANINS_123", "Optional: Your public name or alias. Leave blank to use the user name");
define("LANINS_124", "Please choose a password of at least 8 characters");
define("LANINS_125", "e107 has been installed successfully!");
define("LANINS_126", "For security reasons you should now set the file permissions on the e107_config.php file back to 644.");
define("LANINS_127", "The database [x] already exists. Overwrite it? (any existing data will be lost)");
define("LANINS_128", "Overwrite");
define("LANINS_129", "Database not found.");
define("LANINS_134", "Installation");
define("LANINS_135", "of"); //single time use installer only as in .1 of 8 not replacing by LAN_SEARCH_12
define("LANINS_136", "Deleted existing database");
define("LANINS_137", "Found existing database");
// define("LANINS_138", "Version");
define("LANINS_141", "Please fill in the form below with your MySQL details. If you do not know this information, please contact your hosting provider. You may hover over each field for additional information.");
define("LANINS_142", "IMPORTANT: Please rename e107.htaccess to .htaccess");
define("LANINS_144", "IMPORTANT: Please copy and paste the contents of the [b]e107.htaccess[/b] into your [b].htaccess[/b] file. Please take care NOT to overwrite any existing data that may be in it.");
define("LANINS_145", "e107 v2.x requires the PHP [x] to be installed. Please contact your host or read the information at [y] before continuing.");
define("LANINS_146", "Admin-area Skin");
define("LANINS_147", "Administration");
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_installer.php,v $
* $Revision$
* $Date$
* $Author$
*/
define("LANINS_001", "e107 Installation");
define("LANINS_002", "Step ");
define("LANINS_003", "1");
define("LANINS_004", "Language Selection");
define("LANINS_005", "Please choose the language to use during installation");
// define("LANINS_006", "Set Language");
define("LANINS_007", "4");
define("LANINS_008", "PHP and MySQL Versions Check / File Permissions Check");
define("LANINS_009", "Retest File Permissions");
define("LANINS_010", "File not writable: ");
define("LANINS_010a", "Folder not writable: ");
// define("LANINS_011", "Error"); new > LAN_ERROR
define("LANINS_012", "MySQL Functions don't seem to exist. This probably means that either the MySQL PHP Extension isn't installed or your PHP installation wasn't compiled with MySQL support."); // help for 012
define("LANINS_013", "Couldn't determine your MySQL version number. This is a non fatal error, so please continue installing, but be aware that e107 requires MySQL >= 3.23 to function correctly.");
define("LANINS_014", "File Permissions");
define("LANINS_015", "PHP Version");
// define("LANINS_016", "MySQL");
define("LANINS_017", "PASS");
define("LANINS_018", "Ensure all the listed files exist and are writable by the server. This normally involves CHMODing them 777, but environments vary - contact your host if you have any problems.");
define("LANINS_019", "The version of PHP installed on your server isn't capable of running e107. e107 requires a PHP version of at least ".MIN_PHP_VERSION." to run correctly. Either upgrade your PHP version, or contact your host for an upgrade.");
// define("LANINS_020", "Continue Installation"); //LAN_CONTINUE
define("LANINS_021", "2");
define("LANINS_022", "MySQL Server Details");
define("LANINS_023", "Please enter your MySQL settings here.
If you have root permissions you can create a new database by ticking the box, if not you must create a database or use a pre-existing one.
If you have only one database use a prefix so that other scripts can share the same database.
If you do not know your MySQL details contact your web host.");
define("LANINS_024", "MySQL Server:");
define("LANINS_025", "MySQL Username:");
define("LANINS_026", "MySQL Password:");
define("LANINS_027", "MySQL Database:");
define("LANINS_028", "Create Database?");
define("LANINS_029", "Table prefix:");
define("LANINS_030", "The MySQL server you would like e107 to use. It can also include a port number. e.g. 'hostname:port' or a path to a local socket e.g. \":/path/to/socket\" for the localhost.");
define("LANINS_031", "The username you wish e107 to use to connect to your MySQL server");
define("LANINS_032", "The Password for the user you just entered. Must not contain single or double quotes.");
define("LANINS_033", "The MySQL database you wish e107 to reside in, sometimes referred to as a schema. Must begin with a letter. If the user has database create permissions you can opt to create the database automatically if it doesn't already exist.");
define("LANINS_034", "The prefix you wish e107 to use when creating the e107 tables. Useful for multiple installs of e107 in one database schema.");
// define("LANINS_035", "Continue"); // LAN_CONTINUE
define("LANINS_036", "3");
define("LANINS_037", "MySQL Connection Verification");
define("LANINS_038", " and Database Creation");
define("LANINS_039", "Please make sure you fill in all fields, most importantly, MySQL Server, MySQL Username and MySQL Database (These are always required by the MySQL Server)");
define("LANINS_040", "Errors");
define("LANINS_041", "e107 was unable to establish a connection to the MySQL server using the information you entered. Please return to the last page and ensure the information is correct.");
define("LANINS_042", "Connection to the MySQL server established and verified.");
define("LANINS_043", "Unable to create database, please ensure you have the correct permissions to create databases on your server.");
define("LANINS_044", "Successfully created database.");
define("LANINS_045", "Please click on the button to proceed to next stage.");
define("LANINS_046", "5");
define("LANINS_047", "Administrator Details");
define("LANINS_048", "EXIF extension");
define("LANINS_049", "The two passwords you entered are not the same. Please go back and try again.");
define("LANINS_050", "XML extension");
define("LANINS_051", "Installed");
define("LANINS_052", "Not Installed");
// define("LANINS_053", "e107 v2.x requires the PHP XML Extension to be installed. Please contact your host or read the information at [x] before continuing");
// define("LANINS_054", "e107 v2.x requires the PHP EXIF Extension to be installed. Please contact your host or read the information at [x] before continuing");
define("LANINS_055", "Install Confirmation");
define("LANINS_056", "6");
define("LANINS_057", " e107 now has all the information it needs to complete the installation.
Please click the button to create the database tables and save all your settings.
");
define("LANINS_058", "7");
define("LANINS_060", "Unable to read the sql datafile
Please ensure the file [b]core_sql.php[/b] exists in the [b]/e107_core/sql[/b] directory.");
define("LANINS_061", "e107 was unable to create all of the required database tables.
Please clear the database and rectify any problems before trying again.");
// define("LANINS_063", "Welcome to e107");
define("LANINS_069", "e107 has been successfully installed!
For security reasons you should now set the file permissions on the [b]e107_config.php[/b] file back to 644.
Also please delete install.php from your server after you have clicked the button below.
");
define("LANINS_070", "e107 was unable to save the main config file to your server.
Please ensure the [b]e107_config.php[/b] file has the correct permissions");
define("LANINS_071", "Installation Complete");
define("LANINS_072", "Admin Username");
define("LANINS_073", "This is the name you will use to login into the site. If you wish to use this as your display name also");
define("LANINS_074", "Admin Display Name");
// define("LANINS_075", "This is the name that you wish your users to see displayed in your profile, forums and other areas. If you wish to use the same as your username then leave this blank.");
define("LANINS_076", "Admin Password");
define("LANINS_077", "Please type the admin password you wish to use here");
define("LANINS_078", "Admin Password Confirmation");
define("LANINS_079", "Please type the admin password again for confirmation");
define("LANINS_080", "Admin Email");
define("LANINS_081", "Enter your email address");
// define("LANINS_082", "user@yoursite.com");
// Better table creation error reporting
define("LANINS_083", "MySQL Reported Error:");
define("LANINS_084", "The installer could not establish a connection to the database");
define("LANINS_085", "The installer could not select database:");
define("LANINS_086", "Admin Username, Admin Password and Admin Email are required fields. Please return to the last page and ensure the information is correctly entered.");
// define("LANINS_087", "Misc");
// define("LANINS_088", "Home");
// define("LANINS_089", "Downloads");
// define("LANINS_090", "Members");
// define("LANINS_091", "Submit News");
// define("LANINS_092", "Contact Us");
// define("LANINS_093", "Grants access to private menu items");
// define("LANINS_094", "Example private forum class");
// define("LANINS_095", "Integrity Check");
// define("LANINS_096", 'Latest Comments');
// define("LANINS_097", '[more ...]');
// define("LANINS_098", 'Articles');
// define("LANINS_099", 'Articles Front Page ...');
// define("LANINS_100", 'Latest Forum Posts');
// define("LANINS_101", 'Update menu Settings');
// define("LANINS_102", 'Date / Time');
// define("LANINS_103", 'Reviews');
// define("LANINS_104", 'Review Front Page ...');
define("LANINS_105", "A database name or prefix beginning with some digits followed by 'e' or 'E' is not acceptable");
define("LANINS_106", "WARNING - e107 cannot write to the directories and/or files listed. While this will not stop e107 installing, it will mean that certain features are not available.
You will need to change the file permissions to use these features");
define("LANINS_107", "Website Name");
define("LANINS_108", "My Website");
define("LANINS_109", "Website Theme");
// define("LANINS_110", "");
define("LANINS_111", "Include Content/Configuration");
define("LANINS_112", "Quickly reproduce the look of the theme preview or demo. (If Available)");
define("LANINS_113", "Please enter a website name");
define("LANINS_114", "Please select a theme");
define("LANINS_115", "Theme Name");
define("LANINS_116", "Theme Type");
define("LANINS_117", "Website Preferences");
define("LANINS_118", "Install Plugins");
define("LANINS_119", "Install all plugins that the theme may require.");
define("LANINS_120", "8");
define("LANINS_121", "e107_config.php is not an empty file");
define("LANINS_122", "You might have an existing installation");
define("LANINS_123", "Optional: Your public name or alias. Leave blank to use the user name");
define("LANINS_124", "Please choose a password of at least 8 characters");
define("LANINS_125", "e107 has been installed successfully!");
define("LANINS_126", "For security reasons you should now set the file permissions on the e107_config.php file back to 644.");
define("LANINS_127", "The database [x] already exists. Overwrite it? (any existing data will be lost)");
define("LANINS_128", "Overwrite");
define("LANINS_129", "Database not found.");
define("LANINS_134", "Installation");
define("LANINS_135", "of"); //single time use installer only as in .1 of 8 not replacing by LAN_SEARCH_12
define("LANINS_136", "Deleted existing database");
define("LANINS_137", "Found existing database");
// define("LANINS_138", "Version");
define("LANINS_141", "Please fill in the form below with your MySQL details. If you do not know this information, please contact your hosting provider. You may hover over each field for additional information.");
define("LANINS_142", "IMPORTANT: Please rename e107.htaccess to .htaccess");
define("LANINS_144", "IMPORTANT: Please copy and paste the contents of the [b]e107.htaccess[/b] into your [b].htaccess[/b] file. Please take care NOT to overwrite any existing data that may be in it.");
define("LANINS_145", "e107 v2.x requires the PHP [x] to be installed. Please contact your host or read the information at [y] before continuing.");
define("LANINS_146", "Admin-area Skin");
define("LANINS_147", "Administration");

Some files were not shown because too many files have changed in this diff Show More