function getAirlines()
{
    $dbMan = new DatabaseManager();
    if (!$dbMan->establishConnection()) {
        //database connection error
        return;
    }
    $request = new Request('SELECT *', 'se_Airlines');
    $request->transformCommand();
    $users = $dbMan->executeQuery($request);
    //server error
    if ($users == null) {
        //request was unsuccessful
    } else {
        if ($users->num_rows) {
            /* Get number of rows returned */
            $rows = $users->num_rows;
            /* For each row - push the airline name
             * onto the $airlines array */
            for ($i = 0; $i < $rows; ++$i) {
                $users->data_seek($i);
                $row = $users->fetch_array(MYSQLI_NUM);
                echo "<option>" . $row[0] . "</option>";
            }
        }
    }
}
Ejemplo n.º 2
0
function contact($name, $email, $subject, $phone, $message)
{
    $database_manager = new DatabaseManager();
    $json = array();
    $body = '<p>
					Celular: ' . $phone . '.<br>
					Mensaje: ' . $message . '<br><br>
					Enviado desde: ' . $_SERVER['SERVER_NAME'] . '
				</p>';
    try {
        if (Send($email, $name, $subject, EMAIL_INFO, $body, $email, $name)) {
            $database_manager->Connect();
            if ($database_manager->ExecuteProcedure(SP_INSERTA_CONTACTO, '\'' . $name . '\',
					\'' . $email . '\',\'' . $subject . '\',\'' . $phone . '\',\'' . $message . '\', \'' . EMAIL_INFO . '\'')) {
                $json[] = array('error' => 'false', 'message' => 'Mensaje enviado con éxito.');
            } else {
                $json[] = array('error' => 'false', 'message' => 'Mensaje enviado con éxito, pero hubo un error al momento de almacenar la información 
					en la base de datos.');
            }
            $database_manager->CloseConnection();
        }
    } catch (Exception $e) {
        $json[] = array('error' => 'true', 'message' => 'Hubo un error, por favor, intente nuevamente. Definición del error: ' . $e->getMessage());
    }
    echo json_encode($json);
}
Ejemplo n.º 3
0
 public function approveRestriction($restrictionId, $restrictionTable, $approval)
 {
     //create instance of Database Manager object
     $dbMan = new DatabaseManager();
     //establish connection
     //if returns false, connection failed
     if (!$dbMan->establishConnection()) {
         //database connection error
         return false;
     }
     //if approval is true - change restriction status to active
     if ($approval) {
         /* Create new request to get all pending airline restrictions */
         $request = new Request('Approve Restriction', $restrictionTable);
         $request->addParameter('restriction_id', $restrictionId);
         $request->addParameter('status', 'ACTIVE');
     } else {
         if (!$approval) {
             /* Create new request to get all pending airline restrictions */
             $request = new Request('Delete Restriction', $restrictionTable);
             $request->addParameter('restriction_id', $restrictionId);
         }
     }
     //transform the command to sql statement
     $request->transformCommand();
     //execute command
     $results = $dbMan->executeQuery($request);
     //if results is not null, command was successfully executed.
     if ($results != null) {
         //successfully approved
         return true;
     }
     //command was not successfully executed.
     return false;
 }
 /**
  * Creates a new backup
  *
  * @param string $type Accepts 'upgrade' or 'backup'
  * @return bool
  */
 function backup($type)
 {
     if (!$this->_enabled) {
         return false;
     }
     $tmp_file = tempnam($this->_store, $type . '_');
     $sql_file = $this->_store . DIRECTORY_SEPARATOR . 'backup.sql';
     touch($tmp_file);
     if (($fh = fopen($tmp_file, 'w+b')) !== false) {
         if (flock($fh, LOCK_EX)) {
             $dbm = new DatabaseManager($this->_db);
             $dbm->backup($fh);
             fclose($fh);
             chmod($tmp_file, 0666);
             if (is_file($sql_file)) {
                 unlink($sql_file);
             }
             rename($tmp_file, $sql_file);
             $this->compress($type);
             if ($this->checkArchive()) {
                 unlink($sql_file);
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Moving participants
  */
 public function move()
 {
     if (count($this->children) > 2) {
         //teleport children
         while (count($this->children) > 2) {
             //child #1, child #2 => teleport
             //child #1 <= return
             unset($this->children[count($this->children) - 1]);
             $this->iterator += 2;
         }
     }
     //teleport adults
     foreach ($this->adults as $value) {
         //child #1, child #2 => teleport
         //child #1 <= return
         //adult => teleport
         //child #2 <= return
         $this->iterator += 4;
     }
     //child #1, child #2 => teleport
     $this->iterator++;
     //write log to database
     $db_log = new DatabaseManager();
     $db_log->writeLog($this->iterator);
 }
Ejemplo n.º 6
0
function checkBlacklist($details)
{
    if ($_GET['scope']) {
        $dbManager = new DatabaseManager();
        $room = $dbManager->getRoom($_GET['scope']);
        $whitelist = explode("\n", $room->whitelist);
        $blacklist = explode("\n", $room->blacklist);
        $artist = strtolower($details["artist"]);
        $name = strtolower($details["name"]);
        if (count($details)) {
            foreach ($whitelist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return true;
                    }
                }
            }
            foreach ($blacklist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Ejemplo n.º 7
0
 public function testBasicQuery()
 {
     TestManager::loadBasicDummyData();
     $database = new DatabaseManager();
     $resource = $database->query("SHOW TABLES");
     $this->assertNotEquals(false, $resource);
 }
Ejemplo n.º 8
0
 public function removeRestrictionRequest($restrictionId, $restrictionTable)
 {
     //create instance of Database Manager object
     $dbMan = new DatabaseManager();
     //establish connection
     //if returns false, connection failed
     if (!$dbMan->establishConnection()) {
         //database connection error
         return false;
     }
     /* Create new request to remove restriction*/
     $request = new Request('Delete Restriction', $restrictionTable);
     $request->addParameter('restriction_id', $restrictionId);
     //transform the command to sql statement
     $request->transformCommand();
     //execute command
     $results = $dbMan->executeQuery($request);
     //if results is not null, command was successfully executed.
     if ($results != null) {
         //successfully approved
         return true;
     }
     //command was not successfully executed.
     return false;
 }
Ejemplo n.º 9
0
 public function getPrice($systemID, $datetime, $priceType)
 {
     $dbMgr = new DatabaseManager(true);
     $price = $dbMgr->getPrice($this->typeID, $systemID, $datetime, $priceType);
     $dbMgr = null;
     return $price;
 }
Ejemplo n.º 10
0
 public function __construct($systemID)
 {
     $dbMgr = new DatabaseManager(true);
     $objectData = $dbMgr->getSystemData($systemID);
     $this->systemID = $objectData['systemID'];
     $this->systemName = $objectData['systemName'];
     $dbMgr = null;
 }
Ejemplo n.º 11
0
 public function setUsername($name)
 {
     if ($this->verified) {
         $database = new DatabaseManager();
         $database->query("UPDATE `users` SET `username`='" . $database->sanitize($name) . "' WHERE `email`='" . $database->sanitize($this->getEmail()) . "'");
         apc_store('userObject_' . $this->blid, $this, 600);
     }
 }
Ejemplo n.º 12
0
 function collectHourStat($store = false)
 {
     $stats = new stdClass();
     $stats->time = gmdate("Y-m-d H:00:00", time());
     $stats->duration = "hour";
     $database = new DatabaseManager();
     //Addons!
     $addons = new stdClass();
     $addonArray = AddonManager::getAll();
     $addons->count = sizeof($addonArray);
     $addons->cumulative_downloads = array();
     $addons->usage = array();
     $addons->usage_total = array();
     foreach ($addonArray as $addon) {
         $downloadData = new stdClass();
         // TODO we need to go back. I dont want total downloads, I want individual
         //$downloadData->web =
         //$downloadData->ingame =
         //$downloadData->update =
         $addons->cumulative_downloads[$addon->getId()] = $downloadData;
         $res = $database->query("SELECT `version` FROM `stats_usage` WHERE `aid`='" . $addon->getId() . "' AND `reported` > now() - INTERVAL 1 HOUR");
         $ret = $res->fetch_object();
         $usage = array();
         $total = 0;
         while ($obj = $res->fetch_object()) {
             $total++;
             if (!isset($usage[$obj->version])) {
                 $usage[$obj->version] = 1;
             } else {
                 $usage[$obj->version]++;
             }
         }
         $addons->usage[$addon->getId()] = $usage;
         $addons->usage_total[$addon->getId()] = $total;
     }
     $stats->addons = $addons;
     //Builds
     $builds = new stdClass();
     $buildArray = BuildManager::getAll();
     $builds->count = sizeof($buildArray);
     $builds->cumulative_downloads = array();
     foreach ($buildArray as $build) {
         // TODO this isn't done either...
         //$builds->cumulative_downloads[$build->getId()] = $build->getDownloads();
     }
     $stats->builds = $builds;
     //Master Server
     $stats->master = new stdClass();
     $master = CronStatManager::getMasterServerStats();
     $stats->master->users = $master[0];
     $stats->master->servers = $master[1];
     if ($store) {
         CronStatManager::verifyTable($database);
         $database->query("INSERT INTO `cron_statistics`  (`time` , `duration` , `data`) VALUES ('" . $stats->time . "',  'hour',  '" . $database->sanitize(json_encode($stats)) . "')");
     }
     return $stats;
 }
Ejemplo n.º 13
0
 function getCount()
 {
     if (!isset($numberOfAddons)) {
         $db = new DatabaseManager();
         $res = $db->query("SELECT COUNT(*) FROM `addon_addons` WHERE board='" . $db->sanitize($this->id) . "'  AND deleted=0");
         $this->numberOfAddons = $res->fetch_row()[0];
     }
     return $this->numberOfAddons;
 }
Ejemplo n.º 14
0
 public static function getHistory($blid)
 {
     $db = new DatabaseManager();
     $res = $db->query("SELECT * FROM `user_log` WHERE `blid`='" . $db->sanitize($blid) . "' ORDER BY `lastseen` DESC");
     $ret = array();
     while ($obj = $res->fetch_object()) {
         $ret[] = $obj;
     }
     return $ret;
 }
Ejemplo n.º 15
0
 public static function getAll()
 {
     $ret = array();
     $db = new DatabaseManager();
     $res = $db->query("SELECT `id` FROM `build_builds`");
     while ($obj = $res->fetch_object()) {
         $ret[$obj->id] = BuildManager::getFromId($obj->id);
     }
     $res->close();
     return $ret;
 }
Ejemplo n.º 16
0
 /**
  * Method to execute the command
  * @param  $command
  * @return mixed
  */
 public function execute($command)
 {
     try {
         $this->db->beginTransaction();
         $response = $this->decoratedBus->execute($command);
         $this->db->commit();
         return $response;
     } catch (PDOException $e) {
         $this->db->rollback();
         throw new Exceptions\InternalException($e->getMessage());
     }
 }
Ejemplo n.º 17
0
 public static function clearDatabase()
 {
     apc_clear_cache();
     $database = new DatabaseManager();
     //$resource = $database->query("SELECT DATABASE()");
     //$name = $resource->fetch_row()[0];
     //$resource->close();
     //make sure we don't accidentally load dummy data on live database
     //to do: make sure this actually works
     //if(strpos($name, "test" === false)) {
     if (!$database->debug()) {
         throw new Exception("Database may not be safe to run tests on");
     }
     //addon_addons, addon_boards, addon_tags, addon_tagmap, group_groups, group_usermap, addon_comments, addon_ratings
     if (!$database->query("SET FOREIGN_KEY_CHECKS=0")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("DROP TABLE IF EXISTS addon_tagmap, addon_tags, addon_dependency,\n\t\t\taddon_addons, addon_boards, addon_comments, addon_ratings, addon_stats,\n\t\t\tusers, build_builds, build_dependency, build_stats, tag_stats, group_groups, group_usermap,\n\t\t\tstatistics, screenshots, build_screenshotmap, addon_screenshotmap")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("SET FOREIGN_KEY_CHECKS=1")) {
         throw new Exception("Database error: " . $database->error());
     }
     apc_clear_cache();
 }
 public static function getDistribution($aid)
 {
     $db = new DatabaseManager();
     $res = $db->query("SELECT * FROM `stats_usage` WHERE `aid`='" . $db->sanitize($aid) . "' AND `reported` > now() - INTERVAL 30 DAY");
     $ret = array();
     while ($obj = $res->fetch_object()) {
         if (isset($ret[$obj->version])) {
             $ret[$obj->version]++;
         } else {
             $ret[$obj->version] = 1;
         }
     }
     return $ret;
 }
Ejemplo n.º 19
0
 public static function getAllBoards()
 {
     $ret = array();
     $db = new DatabaseManager();
     $res = $db->query("SELECT `id` FROM `addon_boards`");
     if (!$res) {
         throw new Exception("Error getting data from database: " . $db->error());
     }
     while ($obj = $res->fetch_object()) {
         $ret[$obj->id] = BoardManager::getFromId($obj->id);
     }
     //improves performance with simultaneous connections
     $res->close();
     return $ret;
 }
Ejemplo n.º 20
0
 static function loadRepeatTable($con, $repeatPath)
 {
     REDLog::writeInfoLog("Start loading RepeatMasker file into database");
     $repeatTable = "repeat_masker";
     try {
         if (!DatabaseManager::hasEstablishTable($con, $repeatTable)) {
             self::createRepeatRegionsTable($con, $repeatTable);
             DatabaseManager::setAutoCommit($con, false);
             $count = 0;
             $fp = fopen($repeatPath, 'r');
             fgets($fp);
             fgets($fp);
             fgets($fp);
             while (($line = fgets($fp)) != null) {
                 $line1 = trim($line);
                 $section = explode(" ", preg_replace("/\\s(?=\\s)/", "\\1", $line1));
                 # /[\s]+/
                 $sqlClause = "insert into {$repeatTable}(chrom,begin,end,type) values('{$section['4']}','{$section['5']}','{$section['6']}','{$section['10']}')";
                 $v = mysqli_query($con, $sqlClause);
                 if (++$count % 10000 == 0) {
                     DatabaseManager::commit($con);
                 }
             }
             DatabaseManager::commit($con);
             DatabaseManager::setAutoCommit($con, true);
             if (!$v) {
                 throw new Exception("Error execute sql clause in loadRepeatTable()\n");
             }
         }
     } catch (Exception $e) {
         REDLog::writeErrLog($e->getMessage());
     }
     fclose($fp);
     REDLog::writeInfoLog("End loading RepeatMasker file into database");
 }
Ejemplo n.º 21
0
 static function loadDbSNPTable($con, $dbSNPPath)
 {
     REDLog::writeInfoLog("Start loading dbSNP file into database");
     $dbSNPTable = "dbsnp_database";
     try {
         if (!DatabaseManager::hasEstablishTable($con, $dbSNPTable)) {
             self::createDBSNPTable($con, $dbSNPTable);
             $count = 0;
             $fp = fopen($dbSNPPath, 'r');
             while ($line = fgets($fp) != null) {
                 if (strpos($line, "#") === 0) {
                     $count++;
                 } else {
                     break;
                 }
             }
             fclose($fp);
             $sqlClause = "load data local infile '{$dbSNPPath}' into table {$dbSNPTable} IGNORE {$count} LINES";
             //fields terminated by '\t' lines terminated by '\n'
             echo $sqlClause;
             $v = mysqli_query($con, $sqlClause);
             if (!$v) {
                 throw new Exception("Error execute sql clause in loadDbSNPTable()");
             }
         }
     } catch (Exception $e) {
         REDLog::writeErrLog($e->getMessage());
     }
     REDLog::writeInfoLog("End loading dbSNP file into database");
 }
Ejemplo n.º 22
0
 public function execute()
 {
     $sql = $this->build_sql();
     $values = $this->build_sql_values();
     $db = DatabaseManager::get_database($this->dbname, $this->dbid);
     $class_name = $this->result_name;
     switch ($this->type) {
         case 'none':
             $result = $db->query($sql, $values);
             break;
         case 'one':
             $result = $class_name::build($db->query_and_fetch_one($sql, $values), false);
             break;
         case 'many':
             $result = $db->query_and_fetch($sql, function ($row) use($class_name, $db) {
                 return $class_name::build($row, false, $db);
             }, $values);
             break;
         default:
             throw new DatabaseException("Invalid Type {$this->type}");
             break;
     }
     $this->result = $result;
     return $result;
 }
Ejemplo n.º 23
0
 function generateContent()
 {
     $content = '
     <h1>' . _('Exercises list') . '</h1>
     ';
     $results = DatabaseManager::getQuery("SELECT * FROM exercises  ");
     $content .= '<table>
             <thead>
                 <th>' . _('Name') . '</th>
                 <th>' . _('Description') . '</th>
                 <th>' . _('Language') . '</th>
                 <th>' . _('Word count') . '</th>
                 <th>' . _('Action') . '</th>
                 
             </thead>
             <tbody>
         ';
     while ($result = $results->fetchArray()) {
         $content .= '<tr>';
         $content .= '<td>' . $result['name'] . '</td>';
         $content .= '<td>' . $result['description'] . '</td>';
         $content .= '<td>' . $result['language'] . '</td>';
         $content .= '<td>' . $result['word_count'] . '</td>';
         $content .= '<td>
                 <a href="' . RessourceManager::getInnerUrl('exercises/show') . '?id=' . $result['id'] . '">' . _('Details') . '</a><br/>
                 <a href="' . $result['file'] . '">' . _('Download') . '</a>
                     </td>';
         $content .= '</tr>';
     }
     $content .= '<tbody></table>';
     return $content;
 }
Ejemplo n.º 24
0
 /**
  * Dient zum Export der aktuellen Datenbank.
  * Setzt den notwendigen Inhalt (den [verschlüsselten] Datenbankdump) für die export.ctp
  * 
  * @see DatabaseManager::export()
  * @author aloeser
  * @return void
  */
 public function export()
 {
     $this->set('filename', 'Sicherung_Cafeteria_' . date('d_m_Y', time()) . '.sql');
     $this->layout = 'download';
     $dump = DatabaseManager::export();
     $this->set('dump', $dump);
 }
Ejemplo n.º 25
0
 public static function getTestCases($qId)
 {
     $db = DatabaseManager::getConnection();
     $query = 'SELECT inputCase,outputCase,isSample FROM TestCases WHERE qid=:qid';
     $bindings = array('qid' => $qId);
     return $db->select($query, $bindings);
 }
Ejemplo n.º 26
0
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new DatabaseManager("localhost", "username", "password", "database");
     }
     return self::$_instance;
 }
Ejemplo n.º 27
0
 /**
  * Construct a new database object.
  * @param $settings
  */
 public function __construct($settings)
 {
     $this->database = DatabaseManager::connect($settings["host"], $settings["port"], $settings["user"], $settings["pass"], $settings["name"], isset($settings["utf8"]) ? $settings["utf8"] : true);
     // Debug
     global $settings;
     R::debug($settings["development"]);
 }
Ejemplo n.º 28
0
 function execute()
 {
     if (LoginManager::isLogged() && LoginManager::isAdministrator()) {
         if (isset($_POST['exercise_name']) && $_SESSION['form_enabled']) {
             LoginManager::register();
             LoginManager::register();
             $group = sqlite_escape_string($_POST['exercise_group']);
             $code = sqlite_escape_string($_POST['exercise_code']);
             $name = sqlite_escape_string($_POST['exercise_name']);
             $description = sqlite_escape_string($_POST['propose_description']);
             $proposer = sqlite_escape_string($_POST['exercise_proposer']);
             $state = 'draft';
             $word_count = sqlite_escape_string($_POST['exercise_word_count']);
             $licence = sqlite_escape_string($_POST['exercise_licence']);
             $language = sqlite_escape_string($_POST['exercise_language']);
             $media_type = sqlite_escape_string($_POST['exercise_media_type']);
             $exercise_version = sqlite_escape_string($_POST['exercise_exercise_version']);
             $author = sqlite_escape_string($_POST['exercise_author']);
             $author_website = sqlite_escape_string($_POST['exercise_author_website']);
             $author_contact = sqlite_escape_string($_POST['exercise_author_contact']);
             $packager = sqlite_escape_string($_POST['exercise_packager']);
             $packager_website = sqlite_escape_string($_POST['exercise_packager_website']);
             $packager_contact = sqlite_escape_string($_POST['exercise_packager_contact']);
             $translations = sqlite_escape_string($_POST['exercise_translations']);
             $file = sqlite_escape_string($_POST['exercise_file']);
             $state = 'waiting';
             DatabaseManager::setQuery("INSERT INTO exercises VALUES(\n                        NULL,\n                        {$group},\n                        '{$proposer}',\n                        '{$state}',\n                        '{$code}',\n                        '{$name}',\n                        '{$description}',\n                        {$word_count},\n                        '{$licence}',\n                        '{$language}',\n                        '{$media_type}',\n                        '{$exercise_version}',\n                        '{$author}',\n                        '{$author_website}',\n                        '{$author_contact}',\n                        '{$packager}',\n                        '{$packager_website}',\n                        '{$packager_contact}',\n                        '{$translations}',\n                        '{$file}'\n                        );");
             $this->message = "Exercise add.";
             $_SESSION['form_enabled'] = false;
         } else {
             $_SESSION['form_enabled'] = true;
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * Installation erfolgt durch den Import eines Datenbankdumps
  * Es wird geprüft, ob die Datei korrekt hochgeladen wurde.
  * Gegebenfalls wird sie an DatabaseManager::import() weitergegeben.
  * 
  * @see DatabaseManager::import()
  * @author aloeser
  * @return void
  */
 public function import()
 {
     if ($this->request->is('post')) {
         $maxUploadSize = ini_get('upload_max_filesize');
         $maxUploadSizeString = $this->getMaxUploadSizeDisplayFormat($maxUploadSize);
         $this->set('maxUploadSizeString', $maxUploadSizeString);
         $maxUploadSizeBytes = $this->return_bytes($maxUploadSize);
         $this->set('maxUploadSizeBytes', $maxUploadSize);
         //Wurde wirklich eine Datei hochgeladen?
         if (!isset($this->request->data['User']['File']['tmp_name']) || !is_uploaded_file($this->request->data['User']['File']['tmp_name'])) {
             $this->Session->setFlash('Fehler beim Hochladen der Datei.<br/>Möglicherweise wurde die maximal erlaubte Dateigröße von ' . $maxUploadSizeString . ' überschritten.', 'alert-box', array('class' => 'alert-error'));
             return $this->redirect(array('action' => 'index'));
         }
         //Ist die hochgeladene Datei zu groß?
         if ($this->request->data['User']['File']['size'] > $maxUploadSizeBytes) {
             $this->Session->setFlash('Die Datei ist zu groß.', 'alert-box', array('class' => 'alert-error'));
             return $this->redirect(array('action' => 'index'));
         }
         $result = DatabaseManager::import($this->request->data['User']['File']['tmp_name']);
         if ($result === true) {
             //Import erfolgreich
             $this->Session->setFlash('Installation erfolgreich abgeschlossen.', 'alert-box', array('class' => 'alert-success'));
             return $this->redirect(array('controller' => 'login', 'action' => 'index'));
         } else {
             $this->Session->setFlash($result, 'alert-box', array('class' => 'alert-error'));
         }
     }
     return $this->redirect(array('controller' => 'install', 'action' => 'index'));
 }
Ejemplo n.º 30
0
    public function setValues($id, $pw, $dnr, $snr, $msg, $customer_id, $campaign_id, $delivery_receipt, $unique_msg_id)
    {
        $ActionResult = false;
        if (160 < strlen($msg)) {
            $NearestSpace = strpos($msg, ' ', 160);
            $Message = substr($msg, 0, $NearestSpace);
            $SecondMessage = substr($msg, $NearestSpace, strlen($msg));
        } else {
            $Message = $msg;
            $SecondMessage = "";
        }
        $url = "http://smsgw1.a2p.mme.syniverse.com/sms.php?" . "id={$id}" . "&pw=" . UrlEncode($pw) . "&drep=" . $delivery_receipt . "&dnr=" . UrlEncode($dnr) . "&snr=" . UrlEncode($snr) . "&dtag=" . $unique_msg_id . "&msg=" . UrlEncode($Message);
        if ($f = @fopen($url, "r")) {
            $answer = fgets($f, 255);
            if (substr($answer, 0, 1) == "+") {
                $res = "success: {$answer}";
                $ActionResult = true;
            } else {
                $res = "failure: {$answer}";
                $ActionResult = $res;
            }
        } else {
            $res = "failure: error opening URL";
        }
        if ($SecondMessage != "") {
            $url = "http://smsgw1.a2p.mme.syniverse.com/sms.php?" . "id={$id}" . "&pw=" . UrlEncode($pw) . "&drep=" . $delivery_receipt . "&dnr=" . UrlEncode($dnr) . "&snr=" . UrlEncode($snr) . "&dtag=" . $unique_msg_id . "&msg=" . UrlEncode($SecondMessage);
            if ($f = @fopen($url, "r")) {
                $answer = fgets($f, 255);
                if (substr($answer, 0, 1) == "+") {
                    $res = "success: {$answer}";
                    $ActionResult = true;
                } else {
                    $res = "failure: {$answer}";
                    $ActionResult = $res;
                }
            } else {
                $res = "failure: error opening URL";
            }
        }
        $db = new DatabaseManager(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
        $SQL = 'INSERT INTO MessagingOutGoingLog(AdminCustomerID,CampaignCampaignID,MessagingMessageTypeID,DeliveryReceipt,Destination,Message,MessageKey,Result) 
VALUES(' . $customer_id . ', ' . $campaign_id . ', 4, "' . $delivery_receipt . '", "' . $dnr . '", "' . mysql_real_escape_string($msg) . '", "' . $unique_msg_id . '", "' . mysql_real_escape_string($res) . '")';
        $db->setQuery($SQL);
        $db->Query();
        return $ActionResult;
    }