This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Antoni Orfin
committed
Apr 14, 2014
0 parents
commit f94ab10
Showing
50 changed files
with
3,579 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
vendor | ||
app/properties.json | ||
composer.lock | ||
box.phar | ||
composer.phar | ||
nbproject | ||
*~ | ||
.project | ||
.settings | ||
.idea | ||
build/ | ||
web/pb |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Octivi - Yealink PhoneBook Manager | ||
============================================= | ||
|
||
Simple PHP application to manage your Yealink Remote phone book. | ||
|
||
Installation | ||
--------------------------------------------- | ||
|
||
### Using a release file (prefered way) | ||
|
||
1. Download the latest release of YealinkPhoneBookManager | ||
2. Unpack archive file under your web directory | ||
3. Modify .htaccess to allow access to your phone book manager - as described in a .htaccess password protection | ||
|
||
### Using Composer (for development) | ||
|
||
Under your host directory clone this Git repository. | ||
|
||
1. In project folder execute commands: | ||
|
||
curl -sS https://getcomposer.org/installer | php | ||
php composer.phar install | ||
|
||
2. Copy `app/properties.json.dist` to `app/properties.json` | ||
3. In `app/properties.json` you can set default path and file name of your phone book | ||
4. Set the server's document root to the web/ folder | ||
|
||
Configuration | ||
--------------------------------------------- | ||
|
||
Location of the configuration file depends on the way of the installation: | ||
|
||
* From a release file - `index.php` | ||
* Composer - `app/properties.json` | ||
|
||
In that files you will find configuration properties: | ||
|
||
* `directory` - default directory of the phone book XML files | ||
* `defaultFileName` - name of the default file, which manager will use as a primary phone book | ||
|
||
|
||
.htaccess password protection | ||
--------------------------------------------- | ||
|
||
It's possible to configure a .htaccess file to ensure Basic access authentication protection. All you have to do is to uncomment | ||
last comment block in the .htaccess file, and set the right path of your .htpasswd file. | ||
|
||
AuthUserFile /path/to/your/directory/.htpasswd | ||
|
||
Yealink phones still can't get access through basic auth, so to allow them to read your phone book files, you must edit line: | ||
|
||
Allow from 127.0.0.1 | ||
|
||
where 127.0.0.1 has to be your phone IP address. | ||
|
||
|
||
Phonebook backup | ||
--------------------------------------------- | ||
|
||
In the same directory as your orginal phonebook file is, the script will create backup files of your phonebook when clicking on the "Create Backup" button. | ||
|
||
|
||
Copyright | ||
--------------------------------------------- | ||
|
||
Copyright 2014 IMAGIN Sp. z o.o. | ||
Octivi - www.octivi.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/* | ||
* Copyright 2014 IMAGIN Sp. z o.o. - imagin.pl | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
require_once __DIR__ . '/bootstrap.php'; | ||
|
||
use Octivi\Controller\SourceController; | ||
use Octivi\Controller\ContactController; | ||
use Octivi\Controller\DefaultController; | ||
|
||
$propertiesFile = __DIR__ . '/properties.json'; | ||
|
||
// $properties can come from the index.php (Phar distribution) | ||
if (isset($properties)) { | ||
$directoryPath = $properties['directory']; | ||
$directoryName = $properties['directory']; | ||
} else { | ||
$propertiesJson = file_get_contents($propertiesFile); | ||
$properties = json_decode($propertiesJson, true); | ||
|
||
$directoryPath = __DIR__ . '/../web/' . $properties['directory']; | ||
$directoryName = $properties['directory']; | ||
} | ||
|
||
if (!isset($properties['rootDirectory'])) { | ||
$properties['rootDirectory'] = __DIR__; | ||
} | ||
|
||
$properties['rootDirectory'] = rtrim($properties['rootDirectory'], '/'). '/'; | ||
|
||
if (substr($directoryName, 0, strlen($properties['rootDirectory'])) == $properties['rootDirectory']) { | ||
$directoryName = substr($directoryName, strlen($properties['rootDirectory'])); | ||
} | ||
|
||
$defaultFileName = $properties['defaultFileName']; | ||
|
||
$app['sourceDirectory'] = $directoryPath; | ||
$app['defaultFileName'] = $defaultFileName; | ||
$app['directoryName'] = $directoryName; | ||
|
||
if (isset($properties['debug']) && $properties['debug']) { | ||
error_reporting(E_ALL); | ||
$app['debug'] = true; | ||
} | ||
|
||
$app['controller.source'] = $app->share( | ||
function () use ($app) { | ||
return new SourceController($app); | ||
} | ||
); | ||
|
||
$app['controller.contact'] = $app->share( | ||
function () use ($app) { | ||
return new ContactController($app); | ||
} | ||
); | ||
|
||
$app['controller.default'] = $app->share( | ||
function () use ($app) { | ||
return new DefaultController($app); | ||
} | ||
); | ||
|
||
$app->get('/', "controller.default:indexAction")->bind('homepage'); | ||
|
||
$app->get('/source', "controller.source:indexAction")->bind('source'); | ||
$app->match('/source/new', "controller.source:newAction")->bind('source_new'); | ||
$app->get('/source/list', "controller.source:listAction")->bind('source_list'); | ||
$app->match('/source/upload', "controller.source:uploadAction")->bind('source_upload'); | ||
|
||
$name_pregmatch = '[A-Za-z.0-9-_ ]+'; | ||
|
||
$app->get('/contact/{name}', "controller.contact:indexAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact'); | ||
|
||
$app->match('/contact/{name}/list', "controller.contact:listAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact_list'); | ||
|
||
$app->get('/contact/{name}/edit', "controller.contact:editAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact_edit'); | ||
|
||
$app->get('/contact/{name}/url', "controller.contact:urlAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact_url'); | ||
|
||
$app->post('/contact/{name}/backup', "controller.contact:backupAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact_backup'); | ||
|
||
$app->post('/contact/{name}/save', "controller.contact:saveAction") | ||
->assert('name', $name_pregmatch) | ||
->bind('contact_save'); | ||
|
||
return $app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/* | ||
* Copyright 2014 IMAGIN Sp. z o.o. - imagin.pl | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
$app = new Silex\Application(); | ||
|
||
$app->register(new Silex\Provider\ServiceControllerServiceProvider()); | ||
$app->register(new Silex\Provider\TranslationServiceProvider(), array( | ||
'translator.messages' => array(), | ||
)); | ||
$app->register(new Silex\Provider\SessionServiceProvider()); | ||
$app->register(new Silex\Provider\FormServiceProvider()); | ||
$app->register(new Silex\Provider\TwigServiceProvider(), array( | ||
'twig.path' => __DIR__ . '/../src/Octivi/views', | ||
)); | ||
$app->register(new Silex\Provider\UrlGeneratorServiceProvider()); | ||
$app->register(new Silex\Provider\ValidatorServiceProvider()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"directory": "pb", | ||
"defaultFileName": "contacts.xml", | ||
"debug": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"main": "web/index.php", | ||
"output": "build/yealink-phonebook.phar", | ||
"web": true, | ||
"files": ["index.php"], | ||
"compactors": [ | ||
"Herrera\\Box\\Compactor\\Php" | ||
], | ||
"finder": [ | ||
{ | ||
"exclude": ["Tests", "tests", "*.MD", "*.md", "properties.json", "*.dist"], | ||
"in": ["app", "vendor", "src", "web"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "octivi/yealink-phonebook", | ||
"type": "application", | ||
"description": "Yealink PhoneBook Manager", | ||
"license": "GPL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Antoni Orfin", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Piotr Cytera", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-0": { | ||
"": "src/" | ||
} | ||
}, | ||
"require": { | ||
"silex/silex": "~1.1", | ||
"symfony/form": "~2.0", | ||
"symfony/config": "~2.0", | ||
"symfony/locale": "~2.2", | ||
"symfony/twig-bridge": "~2.2", | ||
"twig/twig": ">=1.8,<2.0-dev", | ||
"symfony/validator": "~2.3" | ||
}, | ||
"require-dev": { | ||
"kherge/box": "~2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
DirectoryIndex index.php | ||
|
||
<IfModule mod_rewrite.c> | ||
RewriteEngine On | ||
|
||
|
||
# Redirect to URI without front controller to prevent duplicate content | ||
# (with and without `/app.php`). Only do this redirect on the initial | ||
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an | ||
# endless redirect loop (request -> rewrite to front controller -> | ||
# redirect -> request -> ...). | ||
# So in case you get a "too many redirects" error or you always get redirected | ||
# to the startpage because your Apache does not expose the REDIRECT_STATUS | ||
# environment variable, you have 2 choices: | ||
# - disable this feature by commenting the following 2 lines or | ||
# - use Apache >= 2.3.9 and replace all git cheL flags by END flags and remove the | ||
# following RewriteCond (best solution) | ||
RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
RewriteRule ^index\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L] | ||
|
||
# If the requested filename exists, simply serve it. | ||
# We only want to let Apache serve files and not directories. | ||
RewriteCond %{REQUEST_FILENAME} -f | ||
RewriteRule .? - [L] | ||
|
||
# The following rewrites all other queries to the front controller. The | ||
# condition ensures that if you are using Apache aliases to do mass virtual | ||
# hosting, the base path will be prepended to allow proper resolution of the | ||
# app.php file; it will work in non-aliased environments as well, providing | ||
# a safe, one-size fits all solution. | ||
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ | ||
RewriteRule ^(.*) - [E=BASE:%1] | ||
RewriteRule .? %{ENV:BASE}index.php [L] | ||
|
||
# Order deny,allow | ||
# Deny from all | ||
# AuthName "Password protected" | ||
# AuthType Basic | ||
# AuthUserFile /path/to/.htpasswd | ||
# Require valid-user | ||
# Allow from 127.0.0.1 # your yealink phone IP. | ||
# Satisfy Any | ||
</IfModule> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/* | ||
* Copyright 2014 IMAGIN Sp. z o.o. - imagin.pl | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
$properties = array( | ||
'directory' => __DIR__ . '/pb', // default directory of the XML files | ||
'defaultFileName' => 'contacts.xml', // default phonebook file | ||
'debug' => true, // debug mode | ||
); | ||
|
||
// Don't edit below this line | ||
$properties['rootDirectory'] = __DIR__; | ||
require_once 'yealink-phonebook.phar'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<YealinkIPPhoneDirectory> | ||
<DirectoryEntry> | ||
<Name>Octivi HQ <a href="http://octivi.com"><b>octivi.com</b></a></Name> | ||
<Telephone>0048717230120</Telephone> | ||
</DirectoryEntry> | ||
</YealinkIPPhoneDirectory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
require_once __DIR__. '/web/index.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/* | ||
* Copyright 2014 IMAGIN Sp. z o.o. - imagin.pl | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Octivi\Controller; | ||
|
||
use Silex\Application; | ||
|
||
abstract class BaseController | ||
{ | ||
/** | ||
* @var \Silex\Application | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* @var \Twig_Environment | ||
*/ | ||
protected $twig; | ||
|
||
/** | ||
* @param Application $app | ||
*/ | ||
public function __construct(Application $app) | ||
{ | ||
$this->app = $app; | ||
$this->twig = $app['twig']; | ||
} | ||
} |
Oops, something went wrong.