function emailListener() { $connection = establishConnection(); $dbConn = establishDBConnection(); $messagestatus = "UNSEEN"; $emails = imap_search($connection, $messagestatus); if ($emails) { rsort($emails); foreach ($emails as $email_number) { // echo "in email loop"; $header = imap_headerinfo($connection, $email_number); $message = imap_fetchbody($connection, $email_number, 1.1); if ($message == "") { $message = imap_fetchbody($connection, $email_number, 1); } $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1)); if (!detectOOOmessage($header->subject, $message, $emailaddress)) { detectBIOmessage($header->subject, $emailaddress); } imap_delete($connection, 1); //this might bug out but should delete the top message that was just parsed } } $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1"); //delete mentors that have been away for more than 24 hours from the away list }
function insertKommentar($produktid, $text) { $con = establishConnection(); //$query = "insert into kommentar values(null,".$produktid.",'".$text."');"; $query = sprintf("insert into kommentar values(null, %d, '%s')", $produktid, $text); $con->query($query) or die($con->error); $con->close(); }
function addNewType($id, $parent_id, $name, $txt, $img) { $types_table = "test_cable_types"; $types_table_desc = "id, parent_id, name, txt, img"; $conn = establishConnection(GOODS_DB); $sql = "INSERT INTO " . $types_table . "(" . $types_table_desc . ") VALUES (\"" . $id . "\", \"" . $parent_id . "\", \"" . $name . "\", \"" . $txt . "\", \"" . $img . "\")"; $result = $conn->query($sql); $conn->close(); // TODO Check returned return $result; }
function getUserData($user) { $user_table = "users"; $conn = establishConnection(USERS_DB); $sql = "SELECT * FROM " . $user_table . " WHERE name=\"" . $user . "\""; $result = $conn->query($sql); $conn->close(); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $user_data = new UserData($row["id"], $row["name"], $row["pass"], $row["privileges"]); return $user_data; } else { return NULL; } }
function emailListener() { //$output = "<script>console.log( 'just got in' );</script>"; //echo $output; $connection = establishConnection(); $dbConn = establishDBConnection(); //$output = "<script>console.log( 'set up connection' );</script>"; //$dbConn->query("INSERT INTO away_mentor (userID, tiStamp) VALUES (99897, NOW())");//test the db connection //echo $output;//develop thread/loop $messagestatus = "UNSEEN"; $countTo24 = 0; while (true) { echo "in check loop"; $emails = imap_search($connection, $messagestatus); if ($emails) { rsort($emails); foreach ($emails as $email_number) { echo "in email loop"; $header = imap_headerinfo($connection, $email_number); $message = imap_fetchbody($connection, $email_number, 1.1); if ($message == "") { $message = imap_fetchbody($connection, $email_number, 1); } $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1)); if (!detectOOOmessage($header->subject, $message, $emailaddress)) { detectB00message($header->subject, $emailaddress); } imap_delete($connection, 1); //this might bug out but should delete the top message that was just parsed } } sleep(600); //do check every 10 minutes $countTo24 = $countTo24 + 1; if ($countTo24 >= 144) { $countTo24 = 0; $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY)"); //delete mentors that have been away for more than 24 hours from the away list //$command = Yii::app()->db->createCommand(); // $command->delete('away_mentor', 'tiStamp <= DATE_ADD(CURRENT_DATE , INTERVAL -1 DAY )');//this might bug the hell out deletes mentors on the away list that were put on over 24 hours ago } if (!imap_ping($connection)) { $connection = establishConnection(); } } }
function startServer($data) { // if the content-type is json, start loading if ($_SERVER['CONTENT_TYPE'] == "application/json" || $_SERVER['CONTENT_TYPE'] == "application/json; charset=UTF-8") { // open connection to database $con = establishConnection(); $jsonObject = json_decode($data); // create JSON-String and return it to the client echo json_encode(perform($jsonObject)); // close connection to database closeConnection($con); // else send a warning } else { $error = new Statusmessage(); $error->addFailure("Wrong content-type. Content-Type: application/json expected!"); echo json_encode($error); } }
<?php require_once './Popo/Produkt.php'; require_once './Popo/Kommentar.php'; require_once './dbconnection.php'; //$produktid = $_GET['produktID']; $conn = establishConnection(); $produkt = getProduct($_GET['produktID']); if (isset($_POST['menge'])) { $produkt->setMenge($_POST['menge']); if (!isset($_SESSION['bestellung'])) { $_SESSION['bestellung'] = array($produkt); } else { $_SESSION['bestellung'][] = $produkt; } echo "<script type='text/javascript'> alert('Der Warenkorb wurde erfolgreich befüllt! \\nUm ihre Produkte anzuzeigen, sehen sie im Warenkorb nach') </script>"; } if (isset($_POST['kommentar'])) { insertKommentar($_GET['produktID'], $_POST['kommentar']); } $kommis = getKommentare($_GET['produktID']); ?> <div class="container"> <h1>Detailansicht</h1> <table class="table table-bordered"> <tbody> <tr> <td><h3> Name </h3></td> <td> <?php echo $produkt->getName();
public function transfer_end($full_path) { set_exception_handler(array(&$this, 'exception_handler')); set_error_handler(array(&$this, 'error_handler')); $starttime = time(); $incomingFilename = $full_path; $path_parts = pathinfo($incomingFilename); $client = establishConnection($this->config); $entry = findMatchingEntry($path_parts["base_name"], $client); if (!$entry) { $client->stats->reportError("Entry not found", "Cannot find matching entry for referenceId [" . $path_parts["base_name"] . "]"); throw new Exception("Cannot find matching entry for referenceId [" . $path_parts["base_name"] . "]"); } log_message('debug', "Kaltura Library transfer_end trace: EntryID: " . $entry->id); $resource = new KalturaRemoteStorageResource(); $resource->storageProfileId = $this->config["source_storage_profile_id"]; //$resource->url = $path_parts['basename']; $resource->url = $full_path; log_message('debug', "Kaltura Library transfer_end trace: URL " . $resource->url); $client->media->updateContent($entry->id, $resource); $endtime = time() - $starttime; log_message('debug', "Kaltura Library transfer_end Execution Time: " . $endtime . "s"); return true; }