Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Avoid the need to edit source files for each project using the library #14

Merged
merged 2 commits into from

2 participants

@jsotuyod

instead of having to edit the source on each application using the dependency,
as suggested by the original author, make everything customizable, making it
a much better fit for dependency management tools (such as maven).

jsotuyod added some commits
@jsotuyod jsotuyod Made all required params configurable.
instead of having to edit the source on each application using the dependency,
as suggested by the original author, make everything customizable, making it
a much better fit for dependency management tools (such as maven).
532a553
@jsotuyod jsotuyod Fixed the examples adding args to DbConnect 558d4a3
@manifestinteractive manifestinteractive merged commit 47ba01f into from
@manifestinteractive

Thanks for updating the documentation as well as making the code changes, this should make things a little easier for people ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 10, 2011
  1. @jsotuyod

    Made all required params configurable.

    jsotuyod authored
    instead of having to edit the source on each application using the dependency,
    as suggested by the original author, make everything customizable, making it
    a much better fit for dependency management tools (such as maven).
  2. @jsotuyod
This page is out of date. Refresh to see the latest.
View
6 src/php/apns.php
@@ -39,8 +39,8 @@ function __autoload($class_name){
}
}
-// CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE )
-$db = new DbConnect();
+// CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO )
+$db = new DbConnect('localhost', 'apnsuser', 'apnspassword', 'apnsdb');
$db->show_errors();
// FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS
@@ -48,4 +48,4 @@ function __autoload($class_name){
// CREATE APNS OBJECT, WITH DATABASE OBJECT AND ARGUMENTS
$apns = new APNS($db, $args);
-?>
View
25 src/php/classes/class_APNS.php
@@ -147,7 +147,7 @@ class APNS {
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* ?>
@@ -157,7 +157,7 @@ class APNS {
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db, NULL, '/usr/local/apns/alt_apns.pem', '/usr/local/apns/alt_apns-dev.pem');
* ?>
@@ -168,9 +168,12 @@ class APNS {
*
* @param object $db Database Object
* @param array $args Optional arguments passed through $argv or $_GET
+ * @param string $certificate Path to the production certificate.
+ * @param string $sandboxCertificate Path to the production certificate.
+ * @param string $logPath Path to the log file.
* @access public
*/
- function __construct($db, $args=NULL, $certificate=NULL, $sandboxCertificate=NULL) {
+ function __construct($db, $args=NULL, $certificate=NULL, $sandboxCertificate=NULL, $logPath=NULL) {
if(!empty($certificate) && file_exists($certificate))
{
@@ -555,7 +558,7 @@ private function _jsonEncode($array=false){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db); // CREATE THE OBJECT
* $apns->newMessage(1, '2010-01-01 00:00:00'); // START A MESSAGE... SECOND ARGUMENT ACCEPTS ANY DATETIME STRING
@@ -609,7 +612,7 @@ public function newMessage($fk_device=NULL, $delivery=NULL, $clientId=NULL){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* $apns->newMessage(1, '2010-01-01 00:00:00');
@@ -728,7 +731,7 @@ public function queueMessage(){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
*
@@ -793,7 +796,7 @@ public function addMessageAlert($alert=NULL, $actionlockey=NULL, $lockey=NULL, $
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* $apns->newMessage(1, '2010-01-01 00:00:00');
@@ -818,7 +821,7 @@ public function addMessageBadge($number=NULL){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* $apns->newMessage(1, '2010-01-01 00:00:00');
@@ -850,7 +853,7 @@ public function addMessageCustom($key=NULL, $value=NULL){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* $apns->newMessage(1, '2010-01-01 00:00:00');
@@ -875,7 +878,7 @@ public function addMessageSound($sound=NULL){
*
* <code>
* <?php
- * $db = new DbConnect();
+ * $db = new DbConnect('localhost','dbuser','dbpass','dbname');
* $db->show_errors();
* $apns = new APNS($db);
* $apns->newMessage(1, '2010-01-01 00:00:00');
@@ -891,4 +894,4 @@ public function processQueue(){
$this->_fetchMessages();
}
}
-?>
View
16 src/php/classes/class_DbConnect.php
@@ -124,13 +124,17 @@ class DbConnect
/**
* Constructor. Initializes a database connection and selects our database.
+ * @param string $host The host to wchich to connect.
+ * @param string $username The name of the user used to login to the database.
+ * @param string $password The password of the user to login to the database.
+ * @param string $database The name of the database to which to connect.
*/
- function __construct()
+ function __construct($host, $username, $password, $database)
{
- $this->DB_HOST = 'localhost';
- $this->DB_USERNAME = 'MYUSERNAME'; // !!! CHANGE ME
- $this->DB_PASSWORD = 'MYPASSWORD'; // !!! CHANGE ME
- $this->DB_DATABASE = 'MYDATABASE'; // !!! CHANGE ME
+ $this->DB_HOST = $host;
+ $this->DB_USERNAME = $username;
+ $this->DB_PASSWORD = $password;
+ $this->DB_DATABASE = $database;
}
/**
@@ -464,4 +468,4 @@ function raise_error($error_message = '')
}
}
-?>
View
4 src/php/samples.php
@@ -39,7 +39,7 @@ function __autoload($class_name){
}
// CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE )
-$db = new DbConnect();
+$db = new DbConnect('localhost', 'apnsuser', 'apnspassword', 'apnsdb');
$db->show_errors();
// FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS
@@ -93,4 +93,4 @@ function __autoload($class_name){
// SEND ALL MESSAGES NOW
$apns->processQueue();
-?>
Something went wrong with that request. Please try again.