/**
  * Constructor
  * @param array $configuration	An array of the configuration options 
  * nessisary to load this manager. To use the a specific manager store, a 
  * store data source must be configured as noted in the class of said 
  * manager store.
  * manager.
  * @access public
  */
 function HarmoniRepositoryManager($configuration = NULL)
 {
     // Define the type to use as a key for Identifying repositories
     $this->repositoryKeyType = new HarmoniType("Repository", "edu.middlebury.harmoni", "Repository", "Nodes with this type are by definition Repositories.");
     // Cache any created repositories so that we can pass out references to them.
     $this->_createdRepositories = array();
     $schemaMgr = Services::getService("SchemaManager");
     $ids = Services::getService("Id");
     $recordStructureId = $ids->getId("edu.middlebury.harmoni.repository.asset_content");
     $recordDesc = "A RecordStructure for the generic content of an asset.";
     if (!$schemaMgr->schemaExists($recordStructureId->getIdString())) {
         // Create the Schema
         $schema = new Schema($recordStructureId->getIdString(), "Repository Asset Content", 1, $recordDesc);
         $schema->addField(new SchemaField("Content", "Content", "blob", "The binary content of the Asset"));
         $schemaMgr->synchronize($schema);
         // The SchemaManager only allows you to use Schemas created by it for use with Records.
         $schema = $schemaMgr->getSchemaByID($recordStructureId->getIdString());
         debug::output("RecordStructure is being created from Schema with Id: '" . $schema->getID() . "'");
         $nullRepositoryId = $ids->getId('null');
         $this->_createdRecordStructures[$schema->getID()] = new HarmoniRecordStructure($this, $schema, $nullRepositoryId);
         // Add the parts to the schema
         //			$partStructureType = new Type("Repository", "edu.middlebury.harmoni", "Blob", "");
         //			$this->_createdRecordStructures[$schema->getID()]->createPartStructure(
         //																"Content",
         //																"The binary content of the Asset",
         //																$partStructureType,
         //																FALSE,
         //																FALSE,
         //																FALSE,
         //																$ids->getId("edu.middlebury.harmoni.repository.asset_content.Content")
         //																);
     }
 }
示例#2
0
 public function __destruct()
 {
     $this->values['end'] = date('H:i:s');
     $logdb = new log_database();
     try {
         $logdb->logSMSStatus($this->values);
         //throw new dbException('PACKET OVERFLOW',1153);
     } catch (dbException $e) {
         if ($e->getCode() == 1153) {
             //max_allowed_packet
             $logf = new log_file('/packet_overflow/');
             if ($logf->packet_overflow($this->values)) {
                 $this->values['log_message'] = "LOG TEXT OVER MySQL max_packet_size, WRITTEN TO " . $logf->path;
                 $logdb->logSMSStatus($this->values);
             } else {
                 $this->values['log_message'] = "TRIED TO CREATE LOG FILE AND FAILED " . $logf->path;
             }
             $this->status(CRITICAL);
             $logdb->logSMSStatus($this->values);
         } else {
             debug::output($e->getMessage());
             $this->status(WARNING);
         }
     }
 }
示例#3
0
 public static function fopen($path, $mode)
 {
     self::$path = $path;
     if (!(self::$handle = fopen(self::$path, $mode))) {
         debug::output('Cannot write to filename: ' . self::$path);
         return false;
     } else {
         return true;
     }
 }
 /**
  * Checks the environment and returns a status value. Return value is one of STARTUP_STATUS_* defines.
  * @access public
  * @return integer
  */
 function getStatus()
 {
     debug::output("ExtensionRequirement - checking to make sure PHP loaded {$this->_extension}.", 7, "StartupCheck");
     if (!extension_loaded($this->_extension)) {
         $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '';
         if (!@dl($prefix . $this->_extension . "." . PHP_SHLIB_SUFFIX)) {
             StartupCheck::error(dgettext("polyphony", sprintf("ExtensionRequirement - PHP extension <b>%s</b> is neither loaded nor could we load it dynamically.", $this->_extension)));
             return STARTUP_STATUS_ERROR;
         }
     }
     return STARTUP_STATUS_OK;
 }
示例#5
0
 public function current()
 {
     $this->row_counter++;
     $row = fgetcsv($this->fh, $this->row_size, $this->delimiter);
     if (!empty($this->header) && !empty($row)) {
         if (count($row) == $this->column_count) {
             $row = array_combine($this->header, $row);
         } else {
             debug::output("CSV parser - row count mismatch (line: {$this->row_counter})");
         }
     }
     return $row;
 }
 /**
  * Checks the environment and returns a status value. Return value is one of STARTUP_STATUS_* defines.
  * @access public
  * @return integer
  */
 function getStatus()
 {
     $harmoniVer = $this->_harmoni->getVersionNumber();
     $harmoniVerStr = $this->_harmoni->getVersionStr();
     debug::output("HarmoniVersionRequirement - checking to make sure Harmoni (currently {$harmoniVer}) is greater than " . $this->_version, 7, "StartupCheck");
     if ($this->_version <= $harmoniVer) {
         // everything's OK!
         return STARTUP_STATUS_OK;
     } else {
         // we got trouble
         StartupCheck::error(sprintf(dgettext("polyphony", "HarmoniVersionRequirement - program execution could not proceed. I must be running under the Harmoni framework version <i>%s</i> or newer. However, we detected you only have version <i>%s</i> installed."), $this->_versionStr, $harmoniVerStr));
         return STARTUP_STATUS_ERROR;
     }
 }
示例#7
0
 /**
  * Execute this action.
  * 
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     // Set the new language
     $langLoc = Services::getService('Lang');
     $harmoni->request->startNamespace("polyphony");
     $langLoc->setLanguage($harmoni->request->get("language"));
     $harmoni->request->endNamespace();
     debug::output("Setting the language to " . $harmoni->request->get("polyphony/language"));
     debug::output("SESSION: " . printpre($_SESSION, TRUE));
     $harmoni->history->goBack("polyphony/language/change");
     $null = null;
     return $null;
 }
示例#8
0
 function search($strQuery, $context = "none")
 {
     if ($context != "none") {
         $result = $this->xpath->query($strQuery, $context);
     } else {
         //echo $strQuery."\n";
         $result = $this->xpath->query($strQuery);
     }
     if ($result->length == 0) {
         debug::output('Missing XML data for query: \'' . $strQuery . '\'');
         return false;
     }
     return $result;
 }
示例#9
0
 private function inputValidation($tag)
 {
     $okay = true;
     /*
      * Make sure tag is not empty
      */
     $okay = parent::checkHasContents($tag);
     if ($okay == false) {
         return false;
     }
     debug::output("Validated: Tag ({$tag}) is not empty.");
     /*
      * Make sure tag is in the correct format
      */
     $okay = parent::checkTagFormat($tag);
     if ($okay == false) {
         return false;
     }
     debug::output("Validated: Tag ({$tag}) is correctly formatted.");
     return true;
 }
示例#10
0
 public function database()
 {
     $sql = "SELECT clientMessageReference FROM log_outbound_sms WHERE received=false AND status='LIVE' and clientMessageReference = {$this->clientMessageReference}  \n";
     //
     $q = mysql::i()->query($sql);
     $r = mysql::i()->fetch_array($q);
     $sql = "SELECT * FROM log_http_delivery_status WHERE clientmessagereference = {$this->clientMessageReference}  order by http_delivery_status_id asc \n";
     $q = mysql::i()->query($sql);
     while ($r = mysql::i()->fetch_array($q)) {
         $deliveryStatus = $r['received'];
         debug::output("{$r['messagestatusgroup']} - {$this->clientMessageReference}");
     }
     //$deliveryStatus=false; //test
     if ($deliveryStatus == true) {
         $sql = "UPDATE log_outbound_sms SET received=true WHERE clientMessageReference = {$this->clientMessageReference} \n";
         mysql::i()->query($sql);
         $fault = false;
     } else {
         $fault = true;
     }
     //$fault = true; //test
     return $fault;
 }
示例#11
0
 private function inputValidation($tag)
 {
     $okay = true;
     /*
      * Order of validation. Order done to reduce database calls. Check formatting is correct. Then check if activated next. 
      * This cuts out 2 other DB checks as it must be in the group table if activated. 
      * Same reason to check group table next, then if logged.
      */
     /*
      * Make sure tag is in the correct format
      */
     $okay = parent::checkTagFormat($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) is correctly formatted.");
     /*
      * Make sure tag exists in database (do we need to do this check?)
      */
     $okay = $this->checkTagValidityDatabase($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) exists in database.");
     /*
      * Make sure tag exists in database
      */
     $okay = $this->checkDueForRenew($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) is due for renewal.");
     return true;
 }
示例#12
0
 /**
  * Removes the definition for field $id from the Schema.
  * @param string $id
  * @return void
  */
 function deleteField($id)
 {
     debug::output("Deleting Field: " . $id . "\n " . (isset($this->_fields[$id]) ? 'exists' : "doesn't exist"), DEBUG_SYS5, "DataManager");
     $this->_fields[$id]->delete();
 }
示例#13
0
 /**
  * Executes the given action
  * @param string $module
  * @param string $action
  * @access private
  * @return mixed
  **/
 function _execute($module, $action)
 {
     debug::output("executing action '{$module}.{$action}'...", DEBUG_SYS5, "ActionHandler");
     $_pair = "{$module}.{$action}";
     // if we've already executed this action, we're probably stuck
     // in an infinite loop. no good!
     if (in_array($_pair, $this->_actionsExecuted)) {
         throw new HarmoniException("ActionHandler::execute({$_pair}) - could not proceed: \n\t\t\t\t\t\t\t\tit seems we have already executed this action before. \n\t\t\t\t\t\t\t\tAre we in an infinite loop?");
         return false;
     }
     if ($this->requiresRequestToken($module, $action) && !$this->isRequestTokenValid()) {
         throw new PermissionDeniedException("Required request token does not match. Cannot Execute this action.");
     }
     // go through each of the ActionSources and see if they have an action to execute. if so, execute it and stop
     // cycling through them (only the first action will be executed).
     $executedAction = false;
     $result = null;
     foreach (array_keys($this->_actionSources) as $sourceID) {
         $source = $this->_actionSources[$sourceID];
         if ($source->actionExists($module, $action)) {
             $result = $source->executeAction($module, $action);
             $executedAction = true;
             break;
         }
     }
     if (!$executedAction) {
         throw new UnknownActionException("ActionHandler::execute({$module}, {$action}) - could not proceed: no action source could find an\n\t\t\t\taction to associate with this module/action pair.");
     }
     // we've now executed this action -- add it to the array
     $this->_actionsExecuted[] = $_pair;
     $this->triggerEvent("edu.middlebury.harmoni.actionhandler.action_executed", $this, array("action" => $_pair));
     // now that we have our $result, let's check if we should do anything
     // else or just return back to our caller.
     // if the action that was executing called forward(), execute that action.
     // otherwise, check if we have a thread to follow.
     if ($this->_forwardToAction) {
         $forward = $this->_forwardToAction;
         $this->_forwardToAction = false;
         return $this->_executePair($forward);
     }
     if (isset($this->_threads[$_pair])) {
         // we have a subsequent action defined...
         // if we failed and there's a fail defined
         if (!$result && ($failAction = $this->_threads[$_pair][0])) {
             return $this->_executePair($failAction);
         }
         // if we succeeded and there's a success action defined
         if ($result && ($successAction = $this->_threads[$_pair][1])) {
             return $this->_executePair($successAction);
         }
     }
     // otherwise, just return the darned result
     return $result;
     // phew!
 }
 /**
  * Create a new unique identifier.
  *	
  * @return object Id
  * 
  * @throws object IdException An exception with one of the following
  *		   messages defined in org.osid.id.IdException:	 {@link
  *		   org.osid.id.IdException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.id.IdException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.id.IdException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.id.IdException#UNIMPLEMENTED UNIMPLEMENTED}
  * 
  * @access public
  */
 function createId()
 {
     if (isset($this->createId_stmt)) {
         $this->createId_stmt->execute();
         $newID = $this->harmoni_db->lastInsertId('id', 'id_value');
         $this->deleteId_stmt->bindValue(1, $newID);
         $this->deleteId_stmt->execute();
     } else {
         debug::output("Attempting to generate new id.", 20, "IdManager");
         $dbHandler = Services::getService("DatabaseManager");
         $query = new InsertQuery();
         $query->setAutoIncrementColumn("id_value", "id_id_value_seq");
         $query->setTable("id");
         $query->addRowOfValues(array());
         $result = $dbHandler->query($query, $this->_dbIndex);
         if ($result->getNumberOfRows() != 1) {
             throwError(new Error(IdException::CONFIGURATION_ERROR(), "IdManager", true));
         }
         $newID = $result->getLastAutoIncrementValue();
         // Clear out any values smaller than our last one to keep the table from
         // exploding size.
         $query = new DeleteQuery();
         $query->setTable("id");
         $query->setWhere("id_value < '" . $newID . "'");
         $result = $dbHandler->query($query, $this->_dbIndex);
     }
     $newID = $this->_prefix . strval($newID);
     debug::output("Successfully created new id '{$newID}'.", DEBUG_SYS5, "IdManager");
     $id = new HarmoniId($newID);
     // cache the id
     //		$this->_ids[$newID] = $id;
     return $id;
 }
示例#15
0
$context = new OsidContext();
$configuration = new ConfigurationProperties();
Services::startManagerAsService("DatabaseManager");
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
$errorHandler = Services::getService("ErrorHandler", true);
$dbHandler = Services::getService("DBHandler", true);
$dbIndex = $dbHandler->addDatabase(new MySQLDatabase("devo", "doboHarmoniTest", "test", "test"));
$dbHandler->pConnect($dbIndex);
$configuration->addProperty('database_index', $dbIndex);
$configuration->addProperty('database_name', $arg0 = "doboHarmoniTest");
unset($arg0);
Services::startManagerAsService("IdManager", $context, $configuration);
$errorHandler->setDebugMode(TRUE);
$test = new GroupTest('Hierarchy Tests');
$test->addTestFile(HARMONI . '/oki2/hierarchy/tests/NodeTestCase.class.php');
$test->addTestFile(HARMONI . '/oki2/hierarchy/tests/HierarchyTestCase.class.php');
$test->addTestFile(HARMONI . '/oki2/hierarchy/tests/HierarchyManagerTestCase.class.php');
$test->attachObserver(new DoboTestHtmlDisplay());
$test->run();
$timer->end();
print "\n<br />Harmoni Load Time: " . $harmonyLoadupTimer->printTime();
print "\n<br />Overall Time: " . $timer->printTime();
print "\n</p>";
$num = $dbHandler->getTotalNumberOfQueries();
debug::output("Total # of queries: " . $num, 1, "DBHandler");
debug::printAll();
unset($dbHandler, $errorHandler, $userError);
unset($num);
//	$errorHandler->printErrors(HIGH_DETAIL);
//	print "<pre>";
//	print_r($errorHandler);
示例#16
0
 public function __construct($input, $live)
 {
     parent::__construct($input, $live);
     $sql = "TRUNCATE log_check_lost_bag_inbox_notified";
     mysql::i()->query($sql);
     $host = config::get('sita_imap_host');
     $email_address = config::get('sita_imap_email_address');
     $password = config::get('sita_imap_password');
     $connection = $host . '~' . $email_address . '~' . $password;
     imap::i($connection);
     $mc = imap::i()->check();
     $result = imap::i()->fetch_overview("1:{$mc->Nmsgs}");
     if (!empty($result)) {
         $this->old_lost_tags_notified = $this->getPreviousSITAEmailsNotified();
         $old_lost_tags_invalid = $this->getPreviousSITAEmailsInvalid();
         foreach ($result as $overview) {
             $message_body = imap::i()->fetch_body($overview->msgno);
             $message_body = utils::removeMultiSpaces($message_body);
             list($prefix, $tag, $iata, $world_tracer_ref) = explode(' ', $message_body);
             if (empty($tag)) {
                 debug::output("No tag!\n");
                 continue;
             }
             //skip any tags already handled
             if ($this->old_lost_tags_notified[$tag]) {
                 debug::output("{$tag} owner previously notified\n");
                 continue;
             }
             debug::output("Checking tag format for tag {$tag}...");
             if (parent::checkTagFormat($tag) == true) {
                 debug::output("{$tag} valid format");
                 //do one query to establish if tag exists in database and is associated with a customer
                 $tag_registered = $this->getCustomer($tag);
                 //check that the tag is registered
                 if ($tag_registered == true) {
                     //Check has user got a registered email address ?
                     if (!empty($this->customer_details['email'])) {
                         //is the account 'active'?
                         if ($this->customer_details['status'] == 'ACTIVE') {
                             debug::output("Tag Active. Notify user by email.");
                             $lostBag = utils::getAirportbyIATA($iata);
                             //Owner recieves email containing the report
                             //****This mail function is for mailing ACTIVE Tag holder email****//
                             $mail = new Mail();
                             $mail->protocol = config::get('config_mail_protocol');
                             $mail->parameter = config::get('config_mail_parameter');
                             $mail->hostname = config::get('config_smtp_host');
                             $mail->username = config::get('config_smtp_username');
                             $mail->password = config::get('config_smtp_password');
                             $mail->port = config::get('config_smtp_port');
                             $mail->timeout = config::get('config_smtp_timeout');
                             $mail->setTo($this->customer_details['email']);
                             $mail->setFrom('');
                             $mail->setSender('');
                             $mail->setSubject(html_entity_decode(sprintf('Lost Bag Report')));
                             $report_foundbag_emailtext = "Dear " . $this->customer_details['firstname'] . " <br />  \n\nA lost bag report has been completed and your tag number has been reported.<br /><br />\n\nDetails of the find<br />\n<b>Tag Number: OC </b>" . $this->customer_details['tag_no'] . "<br />\n<b>Name of Finder:</b>" . " " . $this->customer_details['firstname'] . " " . $this->customer_details['lastname'] . "<br />\n<b>Email Address of Finder:</b>" . " " . $this->customer_details['email'] . "<br />\n<b>Telephone Number of Finder:</b>" . " " . $this->customer_details['telephone'] . "<br />\n<b>Mobile Number:</b>" . " " . $this->customer_details['mobile'] . "<br />\n<b>Post Code:</b>" . " " . $this->customer_details['postcode'] . "<br />\n<b>Location of Bag:</b> {$lostBag['airport']}, {$lostBag['place']}, {$lostBag['state']}, {$lostBag['country']}<br /><br />\n\nSincerely</n>\nLost Baggage Team";
                             $mail->setText(strip_tags($report_foundbag_emailtext));
                             //                        echo "<pre>";
                             //                        print_r($mail);
                             //                        die;
                             $mail->send();
                             // End mail for ACTIVE TagNo
                             $this->logCheckLostBagTagInboxNotified($tag, $iata, $world_tracer_ref, true, 'email', $this->customer_details['email']);
                             $this->logDB->logCheckLostBagEmail($this->customer_details['customer_id'], strip_tags($report_foundbag_emailtext), $this->customer_details['email'], $status, $tag);
                         } else {
                             //not active
                             debug::output("{$tag} inactive. Notify user by email.");
                             /* Owner recieves an email to ask them to contact  
                              * who will provide them with the information once they 
                              * have paid a fee. 
                              * (Would like to automate this so email is kept in 
                              * user's acocunt until they have paid a premium of 
                              * £15.00 then they can view the report)*/
                             //****This mail function is for mailing ACTIVE Tag holder email****//
                             $mail = new Mail();
                             $mail->protocol = config::get('config_mail_protocol');
                             $mail->parameter = config::get('config_mail_parameter');
                             $mail->hostname = config::get('config_smtp_host');
                             $mail->username = config::get('config_smtp_username');
                             $mail->password = config::get('config_smtp_password');
                             $mail->port = config::get('config_smtp_port');
                             $mail->timeout = config::get('config_smtp_timeout');
                             $mail->setTo($this->customer_details['email']);
                             $mail->setFrom('');
                             $mail->setSender('');
                             $mail->setSubject(html_entity_decode(sprintf('Lost Bag Report')));
                             //print_r($this->customer_details);
                             $report_foundbag_emailtext = "Dear " . $this->customer_details['firstname'] . " <br />  \nA lost bag report has been completed and your tag number has been reported.<br /><br />                            \nBut we are sorry, your tag is not ACTIVE please call " . config::get('lost_bag_number') . " to reactivate your tag.<br /><br />\n\nSincerely</n>\nLost Baggage Team";
                             $mail->setText(strip_tags($report_foundbag_emailtext));
                             //                        echo "<pre>";
                             //                        print_r($mail);
                             //                        die;
                             $mail->send();
                             // End mail for ACTIVE TagNo
                             $this->logCheckLostBagTagInboxNotified($tag, $iata, $world_tracer_ref, true, 'email', $this->customer_details['email']);
                             $this->logDB->logCheckLostBagEmail($this->customer_details['customer_id'], strip_tags($report_foundbag_emailtext), $this->customer_details['email'], $status, $tag);
                         }
                         //else
                     } else {
                         //not registered
                         debug::output("{$tag} has no registered email address ");
                         //is the account 'active'?
                         if ($this->checkTagNoStatus($tag) == 'ACTIVE') {
                             debug::output("{$tag} active\n");
                             //Owner receives SMS to say a report is waiting for you, please text YES to receive the details, text costs £1.50 or NO to cancel
                             $this->send['destinations'] = utils::formatPhoneNumber($this->customer_details['telephone']);
                             $this->logCheckLostBagTagInboxNotified($tag, $iata, $world_tracer_ref, true, 'sms', $this->send['destinations']);
                             $this->send['body'] = 'Lost bag report available for tag ' . $tag . '. For details text PIN REPORT. Text costs £1.50 each plus standard network rate. Text PIN STOP to cancel.';
                             parent::sendSMS();
                         } else {
                             debug::output("{$tag} inactive\n");
                             //not active
                             /*user recieves text to say account not active please contact
                              * directly on [telephone number] potentially we automate this and 
                              * have them go online to pay the fee before receiving the info - 
                              * your thoughts would be helpful*/
                             $this->send['destinations'] = utils::formatPhoneNumber($this->customer_details['telephone']);
                             $this->send['body'] = 'Lost bag report available for EXPIRED tag ' . $tag . '. Please contact customer services on ' . config::get('lost_bag_number') . ' Text PIN STOP to cancel.';
                             parent::sendSMS();
                             $this->logCheckLostBagTagInboxNotified($tag, $iata, $world_tracer_ref, true, 'sms', $this->send['destinations']);
                         }
                         //else
                     }
                     //else not registered
                 } else {
                     debug::output("{$tag} not registered to customer in database");
                     if (!$old_lost_tags_invalid[$tag]) {
                         $this->logDB->logCheckLostBagInvalidTag($tag);
                         //only log the tag once
                     }
                 }
             } else {
                 debug::output("{$tag} invalid format\n");
                 $this->logDB->logCheckLostBagInvalidTag($tag, $old_lost_tags_invalid);
             }
             unset($this->send);
         }
         //for each message
     } else {
         debug::output("No messages in Inbox\n");
     }
     //empty
     imap::i()->close();
 }
示例#17
0
 private function inputValidation($tag)
 {
     $okay = true;
     /*
      * Order of validation. Order done to reduce database calls. Check formatting is correct. Then check if activated next. 
      * This cuts out 2 other DB checks as it must be in the group table if activated. 
      * Same reason to check group table next, then if logged.
      */
     /*
      * Make sure tag is in the correct format
      */
     $okay = parent::checkTagFormat($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) is correctly formatted.");
     /*
      * Make sure tag not already activated
      */
     $okay = $this->checkTagAlreadyActivated($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) not already activated.");
     /*
      *
      * Do we want to do this check? Better that the user gets a standard registration msg and continues as if it's the first time it's been registered. 
      * If logged by another user we should inform the current user that this tag is already in use
      *
      * Make sure tag not already registered to another user
      */
     $okay = $this->checkTagAlreadyLogged($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) not already registered.");
     /*
      * Make sure tag exists in database
      */
     $okay = $this->checkTagValidityDatabase($tag);
     if ($okay == false) {
         debug::output("Invalid: " . $this->errors[$tag]);
         return false;
     }
     debug::output("Validated: Tag ({$tag}) exists in database.");
     return true;
 }
示例#18
0
 public function close()
 {
     debug::output("Disconnecting...");
     if (imap_close($this->imap) === false) {
         throw new emailException(imap_last_error($this->imap), imap_errors($this->imap));
     }
 }
示例#19
0
 protected function csvresponse()
 {
     $this->csvparser($this->response);
     print_r($this->csvparser->result);
     debug::output('This function has not been developed.');
     /*
      * Not currently developed and included only if CSV functionality is required in the future
      * If developed move this function into the relevant class.
      * 
      */
 }
示例#20
0
 protected function sendErrors()
 {
     foreach ($this->errors as $tag => $message) {
         debug::output($message);
         $this->send['body'] = $message;
         $this->sendSMS();
     }
     //foreach error
     unset($this->errors);
 }
示例#21
0
 private function sendEmailtoCustomer($customer_email, $firstname, $lastname, $tag_no, $message, $msg_duration = '')
 {
     debug::output("Email: {$customer_email}, {$firstname}, {$lastname}, {$tag_no}, {$message}, {$msg_duration}");
     // multiple recipients
     $to = $customer_email . ', ';
     // note the comma
     //$to .= '*****@*****.**';
     // subject
     $subject = 'Tag Membership Team - Reminder';
     // message
     switch ($message) {
         case "INACTIVE":
             $message = $this->messageBodyInactive($firstname, $lastname, $tag_no);
             break;
         case "DURATION":
             $message = $this->messageBodyDuration($firstname, $lastname, $tag_no, $msg_duration);
             break;
         default:
     }
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     $headers .= 'To: ' . $to . "\r\n";
     $headers .= 'From: foundabag@example.com <*****@*****.**>' . "\r\n";
     // Mail it
     mail($to, $subject, $message, $headers);
 }
示例#22
0
 private function getValidTags()
 {
     debug::output("Get tags against phone number {$this->phone_number}...");
     echo $sql = "SELECT * FROM log_recognised_tags t left join group_tags g on t.tag_no = g.tag  WHERE phone_number = '{$this->phone_number}' AND activated=false \n";
     $q = mysql::i()->query($sql);
     if (mysql::i()->num_rows($q) == 0) {
         return false;
     } else {
         while ($r = mysql::i()->fetch_array($q)) {
             $this->tags[$r['tag_no']] = $r;
         }
         return true;
     }
 }
示例#23
0
文件: init.inc.php 项目: Git-Host/sms
//print "<pre>";
if (!defined("PATH_SEPARATOR")) {
    if (strpos($_ENV["OS"], "Win") !== false) {
        define("PATH_SEPARATOR", ";");
    } else {
        define("PATH_SEPARATOR", ":");
    }
}
set_include_path('classes/log' . PATH_SEPARATOR . 'classes/api/textanywhere' . PATH_SEPARATOR . 'classes/api' . PATH_SEPARATOR . 'classes/parsers' . PATH_SEPARATOR . 'classes/textanywhere' . PATH_SEPARATOR . 'classes/database' . PATH_SEPARATOR . 'classes/library' . PATH_SEPARATOR . 'classes/exceptions' . PATH_SEPARATOR . 'classes/extract' . PATH_SEPARATOR . 'classes/datadictionary' . PATH_SEPARATOR . 'classes' . PATH_SEPARATOR);
function __autoload($class)
{
    if ($fh = @fopen("{$class}.inc.php", 'r', true)) {
        fclose($fh);
        require "{$class}.inc.php";
    } else {
        require "{$class}.class.php";
    }
}
try {
    config::setup();
    mysql::i(config::get('mysql_conn'));
} catch (dbException $e) {
    debug::output($e->getMessage());
    // any errors in this block then should probably exit
    exit;
} catch (Exception $e) {
    debug::output($e->getMessage());
    // any errors in this block then should probably exit
    exit;
}
示例#24
0
 /**
  * Executes an SQL query.
  * Executes an SQL query.
  * @access private
  * @param string The SQL query string.
  * @return mixed For a SELECT statement, a resource identifier, if
  * successful; For INSERT, DELETE, UPDATE statements, TRUE if successful;
  * for all: FALSE, if not successful.
  */
 function _query($query)
 {
     // do not attempt to query, if not connected
     if (!$this->isConnected()) {
         throw new ConnectionDatabaseException("Attempted to query but there was no database connection.");
         return false;
     }
     if (is_array($query)) {
         $queries = $query;
     } else {
         if (is_string($query)) {
             $queries = array($query);
         }
     }
     // If we have a persistant connection, it might be shared with other
     // databases, so make sure our database is selected.
     if ($this->_isConnectionPersistant == true) {
         if (!mysql_select_db($this->_dbName, $this->_linkId)) {
             throw new ConnectionDatabaseException("Cannot select database, " . $this->_dbName . " : " . mysql_error($this->_linkId));
         }
     }
     foreach ($queries as $q) {
         // attempt to execute the query
         $resourceId = mysql_query($q, $this->_linkId);
         debug::output("<pre>Query: <div>" . $query . "</div>Result: {$resourceId}</pre>", 1, "DBHandler");
         if ($resourceId === false) {
             $this->_failedQueries++;
             switch (mysql_errno($this->_linkId)) {
                 // No Such Table
                 case 1146:
                 case 1177:
                     throw new NoSuchTableDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
                     // Duplicate Key
                 // Duplicate Key
                 case 1022:
                 case 1062:
                     throw new DuplicateKeyDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
                     // max_allowed_packet
                 // max_allowed_packet
                 case 1153:
                     // Got a packet bigger than 'max_allowed_packet' bytes
                 // Got a packet bigger than 'max_allowed_packet' bytes
                 case 1162:
                     // Result string is longer than 'max_allowed_packet' bytes
                 // Result string is longer than 'max_allowed_packet' bytes
                 case 1301:
                     // Result of %s() was larger than max_allowed_packet (%ld) - truncated
                     $size = ByteSize::withValue(strlen($query));
                     throw new QuerySizeDatabaseException("MySQL Error: " . mysql_error($this->_linkId) . " (Query Size: " . $size->asString() . ")", mysql_errno($this->_linkId));
                 default:
                     throw new QueryDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
             }
         } else {
             $this->_successfulQueries++;
         }
     }
     return $resourceId;
 }
示例#25
0
 /**
  * Returns a new {@link DMRecord} object that can be inserted into the database.
  * @return ref object
  * @param string $type The Schema type/ID that refers to the Schema to associate this DMRecord with.
  * @param optional bool $verControl Specifies if the DMRecord should be created with Version Control. Default=no.
  */
 function createRecord($type, $verControl = false)
 {
     $schemaManager = Services::getService("SchemaManager");
     if (!$schemaManager->schemaExists($type)) {
         throwError(new Error("could not create new DMRecord of type " . $type . " because the requested type does not seem to be registered\n\t\t\twith the SchemaManager.", "RecordManager", true));
     }
     // ok, let's make a new one.
     $schema = $schemaManager->getSchemaByID($type);
     // load from the DB
     $schema->load();
     debug::output("Creating new DMRecord of type '" . $type . "', which allows fields: " . implode(", ", $schema->getAllIDs()), DEBUG_SYS4, "DataManager");
     $newRecord = new DMRecord($schema, $verControl);
     return $newRecord;
 }
示例#26
0
<?php

/**
 * application_view_cli_debug_debug
 *
 * Darstellung der Debug-Informationen für die Kommandozeile
 *
 * @TODO: Darstellung muss noch angepasst werden!
 */
echo debug::output();
 /**
  * Sets the language to use for getting data to $language.
  * @param string $language The language code (eg, "en_US") to use.
  * @access public
  * @return void
  * @todo -cLanguageLocalizer Implement LanguageLocalizer.setLanguage - use gettext functionality.
  **/
 function setLanguage($language)
 {
     if (!preg_match("/^[a-z]{2,3}_[A-Z]{2}\$/", $language)) {
         throwError(new Error("LanguageLocalizer::setLanguage({$language}) - language must start with 'xx_XX' or 'xxx_XX' (where x/X is any letter). Example: 'en_US'.", "LanguageLocalizer", true));
         return false;
     }
     // 		foreach ($this->_applications as $application => $langDir) {
     // 			$file = $langDir . DIRECTORY_SEPARATOR
     // 					. $language . DIRECTORY_SEPARATOR
     // 					. "LC_MESSAGES" . DIRECTORY_SEPARATOR
     // 					. $application . ".mo";
     //
     // 			if (! file_exists($file) ) {
     // 				throwError(new Error("LanguageLocalizer::setLanguage($language) - could not set language. The translation file '$file' does not exist!","LanguageLocalizer", true));
     // 				return false;
     // 			}
     // 		}
     $this->_lang = $language;
     $_SESSION['__CurrentLanguage'] = $this->_lang;
     // If gettext support is availible, use it.
     if (hasGettext()) {
         // Safe-Mode will restrict usage of putenv, so suppress errros for those
         // environments
         if (!ini_get('safe_mode') || ini_get('safe_mode') && preg_match('/LANG/', ini_get('safe_mode_allowed_env_vars'))) {
             putenv("LANG=" . $this->_lang);
         } else {
             @putenv("LANG=" . $this->_lang);
         }
         $result = setlocale(LC_ALL, $this->_lang);
         debug::output("Setting Lang to " . $this->_lang . " => '{$result}'.", DEBUG_SYS5, "LanguageLocalizer");
     }
 }
示例#28
0
文件: end.inc.php 项目: Git-Host/sms
<?php

if ($lock != 'nolock') {
    $lock->release();
}
debug::output("\n\nEnding script ... {$_SERVER['SCRIPT_NAME']} : " . config::get('process_name') . " : " . date('d/m/Y H:i:s') . "\n\n");
$contents = ob_get_contents();
ob_end_clean();
if (config::get('email_reports')) {
    // 		$to_email = join(',', config::get('email_reports'));
    // 		$operator = config::get('operator');
    // 		mail($to_email, "$operator Flat File Processed", $contents);
}
//if (config::get('process_name'))	{}
$status->data('log_message', $contents);
if (config::get('log_to_file') == true) {
    $logf = new log_file('/output/');
    $logf->output_buffer($contents);
}
if (config::get('output_to_screen') == true) {
    echo $contents;
}
if (config::get('process_name')) {
    // 	$type = config::get('flat_file_type');
    // 	if (empty($type) || strpos($type, 'run_process')  !== false)
    // 	{
    // 		$type = config::get('product_type');
    // 	}
    // 	$status->data('type', $type);
    $status->save();
    unset($status);
示例#29
0
 /**
  * Show the debug output
  * 
  * @return void
  */
 public static function output_debug()
 {
     debug::output();
 }
示例#30
0
 private function sendold()
 {
     $sc = $this->soap->open($this->soapPath);
     $this->vars['method'] = $this->method;
     $method = ucfirst($this->method);
     /*echo "VARS: ";
     		print_r($this->vars);
     		echo "END VARS";*/
     validator::loadDictionaries(array(ucfirst($this->method)));
     validator::validateInput($this->vars);
     $cleanData = validator::getCleanData();
     $errors = validator::getErrors();
     /*	echo "clean:";
     			print_r($cleanData);
     			print_r($errors);
     			echo "END clean";*/
     if (empty($errors)) {
         if ($this->live == true) {
             $result = $sc->__call($method, array($this->params));
             $resultMethod = $method . 'Result';
             //Dynamic method name dependent on the class name
             $this->response = $result->{$resultMethod};
             $logf = new log_file('/api/textanywhere/');
             $logf->request($this->method, $this->vars, $this->count);
             $logf->response($this->method, $this->response, $this->count);
         }
         //if live
     } else {
         debug::output("There were errors in the data to be sent");
         $logdb->logValidationErrors($this->vars, $errors);
     }
 }