function parseDBLine($record) { $dbRecord = array(); // note that the fields start off at 0, and they are simply parsed // in order $field = 0; print_r("original record"); print_r($record); list($dbRecord["FirstName"], $dbRecord["LastName"]) = parseName($record[$field++]); $dbRecord["Email"] = parseEmail($record[$field++]); $dbRecord["Phone"] = parsePhone($record[$field++]); $dbRecord["Title"] = null; $dbRecord["CustomerCNotes"] = parseCustomerCNotes($record[$field++]); list($dbRecord["Street1"], $dbRecord["Street2"], $dbRecord["City"], $dbRecord["State"], $dbRecord["Zip"]) = parseAddress($record[$field++]); $dbRecord["Country"] = "US"; $dbRecord["AdminCNotes"] = parseAdminCNotes($record[$field++]); $dbRecord["OrderedDate"] = $dbRecord["MetDate"] = parseMetDate($record[$field++]); $dbRecord["CustomerONotes"] = parseCustomerONotes($record[$field++]); $dbRecord["AdminONotes"] = parseAdminONotes($record[$field++]); $dbRecord["Charity"] = parseCharity($record[$field++]); $dbRecord["RequestedPay"] = parsePaymentRequested($record[$field++]); $dbRecord["PaidDate"] = parsePaid($record[$field++], "10/1/2014"); $dbRecord["ReleasedToShipping"] = parseReleasedToShipping($record[$field++], "10/1/2014"); $dbRecord["ShippedDate"] = parseShipped($record[$field++], "10/1/14"); $dbRecord["IsExpedited"] = parseExpedite($record[$field++]); $dbRecord["WasCanceled"] = parseCanceled($record[$field++]); $dbRecord["InvoiceNumber"] = $dbRecord["InvoiceID"] = $dbRecord["InvoiceURL"] = null; $dbRecord["Carrier"] = $dbRecord["TrackingNum"] = $dbRecord["WasReceived"] = null; $dbRecord["Discount"] = $dbRecord["ShippingFee"] = $dbRecord["ExpediteFee"] = null; $dbRecord["Products"] = parseProducts($record[$field++]); var_dump($dbRecord); return $dbRecord; }
function sendErrorReport() { $options = getOptions(); $extra_vars = isset($options['params']) ? $options['params'] : false; $content = parseEmail($options['email'], $extra_vars); email_send($options['mailTo'], "Une erreur s'est produite sur OpenNAS", $content, $outError); exit($outError); }
function parse_viewheader($imapConnection, $id, $passed_ent_id) { $header_output = array(); $second = array(); $first = array(); if (!$passed_ent_id) { $read = sqimap_run_command($imapConnection, "FETCH {$id} BODY[HEADER]", true, $a, $b, TRUE); } else { $query = "FETCH {$id} BODY[" . $passed_ent_id . '.HEADER]'; $read = sqimap_run_command($imapConnection, $query, true, $a, $b, TRUE); } $cnum = 0; for ($i = 1; $i < count($read); $i++) { $line = sm_encode_html_special_chars($read[$i]); switch (true) { case preg_match('/^>/i', $line): $second[$i] = $line; $first[$i] = ' '; $cnum++; break; // FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does // FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does case preg_match('/^[ |\\t]/', $line): $second[$i] = $line; $first[$i] = ''; break; case preg_match('/^([^:]+):(.+)/', $line, $regs): $first[$i] = $regs[1] . ':'; $second[$i] = $regs[2]; $cnum++; break; default: $second[$i] = trim($line); $first[$i] = ''; break; } } for ($i = 0; $i < count($second); $i = $j) { $f = isset($first[$i]) ? $first[$i] : ''; $s = isset($second[$i]) ? nl2br($second[$i]) : ''; $j = $i + 1; while ($first[$j] == '' && $j < count($first)) { $s .= ' ' . nl2br($second[$j]); $j++; } $lowf = strtolower($f); /* do not mark these headers as emailaddresses */ if ($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') { parseEmail($s); } if ($f) { $header_output[] = array($f, $s); } } sqimap_logout($imapConnection); return $header_output; }
function parse_viewheader($imapConnection, $id, $passed_ent_id) { global $uid_support; $header_full = array(); $header_output = array(); $second = array(); $first = array(); if (!$passed_ent_id) { $read = sqimap_run_command($imapConnection, "FETCH {$id} BODY[HEADER]", true, $a, $b, $uid_support); } else { $query = "FETCH {$id} BODY[" . $passed_ent_id . '.HEADER]'; $read = sqimap_run_command($imapConnection, $query, true, $a, $b, $uid_support); } $cnum = 0; for ($i = 1; $i < count($read); $i++) { $line = htmlspecialchars($read[$i]); switch (true) { case eregi("^>", $line): $second[$i] = $line; $first[$i] = ' '; $cnum++; break; case eregi("^[ |\t]", $line): $second[$i] = $line; $first[$i] = ''; break; case eregi("^([^:]+):(.+)", $line, $regs): $first[$i] = $regs[1] . ':'; $second[$i] = $regs[2]; $cnum++; break; default: $second[$i] = trim($line); $first[$i] = ''; break; } } for ($i = 0; $i < count($second); $i = $j) { $f = isset($first[$i]) ? $first[$i] : ''; $s = isset($second[$i]) ? nl2br($second[$i]) : ''; $j = $i + 1; while ($first[$j] == '' && $j < count($first)) { $s .= ' ' . nl2br($second[$j]); $j++; } $lowf = strtolower($f); /* do not mark these headers as emailaddresses */ if ($lowf != 'message-id:' && $lowf != 'in-reply-to:' && $lowf != 'references:') { parseEmail($s); } if ($f) { $header_output[] = array($f, $s); } } return $header_output; }
/** * Parses a body and converts all found URLs to clickable links. * * @param string body the body to process, by ref * @return void */ function parseUrl(&$body) { global $url_parser_poss_ends, $url_parser_url_tokens; $start = 0; $blength = strlen($body); while ($start < $blength) { $target_token = ''; $target_pos = $blength; /* Find the first token to replace */ foreach ($url_parser_url_tokens as $the_token) { $pos = strpos(strtolower($body), $the_token, $start); if (is_int($pos) && $pos < $target_pos) { $target_pos = $pos; $target_token = $the_token; } } /* Look for email addresses between $start and $target_pos */ $check_str = substr($body, $start, $target_pos - $start); if (parseEmail($check_str)) { replaceBlock($body, $check_str, $start, $target_pos); $blength = strlen($body); $target_pos = strlen($check_str) + $start; } /* If there was a token to replace, replace it */ if ($target_token == 'mailto:') { // rfc 2368 (mailto URL) $target_pos += 7; //skip mailto: $end = $blength; $mailto = substr($body, $target_pos, $end - $target_pos); global $MailTo_PReg_Match; if (preg_match($MailTo_PReg_Match, $mailto, $regs) && $regs[0] != '') { //sm_print_r($regs); $mailto_before = $target_token . $regs[0]; $mailto_params = $regs[10]; if ($regs[1]) { //if there is an email addr before '?', we need to merge it with the params $to = 'to=' . $regs[1]; if (strpos($mailto_params, 'to=') > -1) { //already a 'to=' $mailto_params = str_replace('to=', $to . '%2C%20', $mailto_params); } else { if ($mailto_params) { //already some params, append to them $mailto_params .= '&' . $to; } else { $mailto_params .= '?' . $to; } } } $url_str = str_replace(array('to=', 'cc=', 'bcc='), array('send_to=', 'send_to_cc=', 'send_to_bcc='), $mailto_params); $comp_uri = makeComposeLink('src/compose.php' . $url_str, $mailto_before); replaceBlock($body, $comp_uri, $target_pos - 7, $target_pos + strlen($regs[0])); $target_pos += strlen($comp_uri) - 7; } } else { if ($target_token != '') { /* Find the end of the URL */ $end = $blength; foreach ($url_parser_poss_ends as $val) { $enda = strpos($body, $val, $target_pos); if (is_int($enda) && $enda < $end) { $end = $enda; } } /* Extract URL */ $url = substr($body, $target_pos, $end - $target_pos); /* Needed since lines are not passed with \n or \r */ while (ereg("[,\\.]\$", $url)) { $url = substr($url, 0, -1); $end--; } /* Replace URL with HyperLinked Url, requires 1 char in link */ if ($url != '' && $url != $target_token) { $url_str = "<a href=\"{$url}\" target=\"_blank\">{$url}</a>"; replaceBlock($body, $url_str, $target_pos, $end); $target_pos += strlen($url_str); } else { // Not quite a valid link, skip ahead to next chance $target_pos += strlen($target_token); } } } /* Move forward */ $start = $target_pos; $blength = strlen($body); } }
/** * Retreives breadcrumb info for sub categories. * * @version 2.0 * @since 1.0.0 * @author xLink * * @param int $threadId * @param array $thread * @param array $postInfo */ private function notify($threadId, $thread, $postInfo) { $users2Notify = array(); $uid = $this->objUser->grab('id'); //grab the watching users $watchingUsers = $this->objSQL->getTable('SELECT DISTINCT user_id, seen FROM $Pforum_watch WHERE thread_id ="%s" AND seen = 1', array($threadId)); foreach ($watchingUsers as $user) { $users2Notify[] = $user['user_id']; } //remove the current user, no point in email him about the post he just made O.o $users2Notify = array_diff($users2Notify, array($uid)); if (is_empty($users2Notify)) { return false; } //grab some info about the users $users = array(); foreach ($users2Notify as $user) { $users[] = $this->objUser->getUserInfo($user['id']); } //if we have no users then return here if (is_empty($users)) { return false; } //update forum watch unset($update); $update['seen'] = 0; $this->objSQL->updateRow('forum_watch', $update, array('thread_id ="%d" AND uid IN (%s)', $threadId, implode(', ', $users2Notify))); $vars = array('AUTHOR' => $uid, 'THREAD_NAME' => $thread['subject'], 'TIME' => $postInfo['posted'], 'THREAD_URL' => $postInfo['thread_url']); $nl = "\n"; //loop thru the users and exec the desired action :D foreach ($users as $user) { $message['title'] = langVar('L_THREAD_NOTIFY'); $message['email'] = parseEmail('E_USER_POSTED', $postInfo); $message['notify'] = langVar('L_USER_POSTED', $this->objUser->profile($uid, RAW), '[b]' . secureMe($thread['subject']) . '[/b]', $this->objTime->mk_time($postInfo['posted'], 'db', $user['timezone'])) . $nl . 'You can view the topic by visiting the following URL: ' . '[url=http://' . $_SERVER['HTTP_HOST'] . '/' . root() . 'modules/forum/thread/' . seo($thread['subject']) . '-' . $threadId . '.html?mode=last_page]Here[/url]'; doNotification($user['id'], 'forum', 'forumReplies', $message); } }
/** Fügt einen Benutzer hinzu. * * @param string $email Die E-Mail Adresse des Benutzers (zum Versenden der E-Mail benötigt) * @param integer $class ID der zugehörigen Klasse * @param integer $type Typ des Benutzers (access_level) (0: admin; 1: teacher; 2: user) * @param string $realname Der "echte" Name des Benutzers * @param float $valid Anzahl Wochen, die vergehen, bis die Registrierung abläuft * @return bool false im Fehlerfall, es wird eine Warnung oder ein Fehler erzeugt */ public function addUser($email, $class = 0, $type = 2, $realname = null, $valid = 2) { if (!$this->permitted) { return false; } // Werte validieren $type = intval($type); $valid = floatval($valid); $class = intval($class); $error = false; if ($type < 0 || $type > 2) { $this->throwWarning('The access level of the new user is invalid.'); $error = true; } if ($valid < 1 || $valid > 5) { $this->throwWarning('The user must be enabled or disabled. There was an invalid value.'); $error = true; } $email = parseEmail($email); if (!$email) { $this->throwWarning('The given e-mail address is invalid.'); $error = true; } // Prüfen ob Fehler aufgetreten if ($error) { return false; } $valid = date('Y-m-d H:i:s', time() + $valid * 630000); // Registrierungshash $hash = md5(uniqid(microtime(), true)) . '-' . uniqid(); // Benutzer in DB hinzufügen $db = getDB(); if (!$db->query('addUser', array('hash' => $hash, 'accessLevel' => $type, 'realName' => $realname, 'email' => $email, 'valid' => $valid, 'class' => $class))) { return $this->throwError('While creating the new user, a technical error occurred. The user wasn\'t created.'); } // Einladungsmail vorbereiten $link = new Template(SYS_MAIL_INVITE_LINK); $link->assign('hash', $hash); $link->assign('id', $db->insertID); $tmpl = new Template(SYS_MAIL_INVITE_MAIL); $tmpl->setTitle(SYS_MAIL_INVITE_SUBJECT); $tmpl->assign('name', $realname); $tmpl->assign('link', $link); // Einladungsmail senden if (!mail($email, SYS_MAIL_INVITE_SUBJECT, $tmpl, 'Content-Type: text/html; charset=utf-8' . PHP_EOL . 'From: ' . SYS_NOREPLY)) { return $this->throwError('A technical error occurred: The e-mail with the invitation link has not been sent. The user has not been invited.'); } return true; }