예제 #1
0
function seconds_to_time($seconds)
{
    $hours = (int) ($seconds / 3600);
    $minutes = (int) (($seconds - $hours * 3600) / 60);
    $seconds = $seconds - $minutes * 60 - $hours * 3600;
    return pad($hours, 2) . ":" . pad($minutes, 2) . ":" . pad($seconds, 2);
}
예제 #2
0
/**
 *	log a message to file
 *
 *	@param string $level can be error, warn, info or debug
 *	@param string $msg message
 *	@return bool true if successful, false if not
 */
function log_msg($level, $msg)
{
    global $logfile;
    global $loglevels;
    global $request_id;
    // open logfile
    if ($logfile === false) {
        $m = umask(0111);
        // having two processes appending to the same file should
        // work fine (at least on Linux)
        $logfile = @fopen(LOG_FILE, 'ab');
        umask($m);
    }
    if ($logfile === false) {
        return false;
    }
    foreach ($loglevels as $ll) {
        if ($ll == $level) {
            fwrite($logfile, date('Y-m-d H:i:s') . tab() . pad($_SERVER['REMOTE_ADDR'], 15) . tab() . sprintf('%05u', $request_id) . tab() . $level . tab() . $msg . nl());
            fflush($logfile);
            break;
        }
        if ($ll == LOG_LEVEL) {
            break;
        }
    }
    return true;
}
예제 #3
0
function printFunc($what, $dif)
{
    $r = realpath(dirname(__FILE__) . "/..");
    echo pad(str_replace($r, "", $what["file"]), 25);
    echo pad($what["line"]);
    echo pad($what["function"] . "(" . implode(", ", $what["args"]) . ") ");
    echo pad(round($dif, 3) . "s", 5);
    echo "\n";
}
예제 #4
0
파일: Util.php 프로젝트: ArcheonK/timings
 public static function pct($pct, $mod = 1, $pad = 8, $high = 0, $med = 0, $low = 0)
 {
     $num = round($pct * 100, 2);
     $prefix = '';
     $suffix = '';
     if ($num * $mod > $high && $high != 0) {
         $prefix = '<span style="background:black;color:red">';
         $suffix = '</span>';
     } elseif ($num * $mod > $med && $med != 0) {
         $prefix = '<span style="background:black;color:orange">';
         $suffix = '</span>';
     } else {
         if ($num * $mod > $low && $low != 0) {
             $prefix = '<span style="background:black;color:yellow">';
             $suffix = '</span>';
         }
     }
     return $prefix . pad(number_format($num, 2) . '%', $pad) . $suffix;
 }
예제 #5
0
파일: gaf.php 프로젝트: prophile/xsera
            $filedata .= $contents;
            $name = substr("{$path}{$obj}", 1);
            $files[$name] = array($offset, strlen($contents));
            unset($contents);
        }
    }
}
add_directory($base);
function pad($fp, $length, $multiple, $mod = 0)
{
    while ($length++ % $multiple != $mod) {
        fwrite($fp, chr(0));
    }
}
echo strlen($filedata) . "\n";
$out = fopen($argv[1], 'wb');
// write 8-byte magic number
fwrite($out, 'THEGAME!');
fwrite($out, pack('N', count($files)));
foreach ($files as $name => $file) {
    fwrite($out, pack('n', strlen($name)));
    fwrite($out, $name);
    fwrite($out, chr(0));
    pad($out, strlen($name) + 1, 4, 2);
    fwrite($out, pack('N', $file[0]));
    fwrite($out, pack('N', $file[1]));
}
pad($out, ftell($out), 16);
fwrite($out, $filedata);
pad($out, strlen($filedata), 4);
예제 #6
0
function send_invoice(&$_employer, $_paid_postings, $_subscription_period)
{
    if (!is_a($_employer, 'Employer')) {
        return false;
    }
    $today = date('Y-m-d');
    $branch = $_employer->getAssociatedBranch();
    $sales = 'sales.' . strtolower($branch[0]['country']) . '@yellowelevator.com';
    $branch[0]['address'] = str_replace(array("\r\n", "\r"), "\n", $branch[0]['address']);
    $branch['address_lines'] = explode("\n", $branch[0]['address']);
    $currency = Currency::getSymbolFromCountryCode($branch[0]['country']);
    if ($_paid_postings > 0) {
        // 0. get the job postings pricing and currency
        $posting_rates = $GLOBALS['postings_rates'];
        $price = $posting_rates[$currency];
        // 1. generate invoice in the system
        $data = array();
        $data['issued_on'] = $today;
        $data['type'] = 'P';
        $data['employer'] = $_POST['id'];
        $data['payable_by'] = sql_date_add($today, $_employer->getPaymentTermsInDays(), 'day');
        $invoice = Invoice::create($data);
        if ($invoice === false) {
            echo 'ko';
            exit;
        }
        $amount = $price * $_paid_postings;
        $desc = $_paid_postings . ' Job Posting(s) @ ' . $currency . ' $' . $price;
        $item_added = Invoice::addItem($invoice, $amount, '1', $desc);
        $items = array();
        $items[0]['itemdesc'] = $desc;
        $items[0]['amount'] = number_format($amount, '2', '.', ', ');
        // 2. generate the invoice as PDF file
        $pdf = new PaidPostingsInvoice();
        $pdf->AliasNbPages();
        $pdf->SetAuthor('Yellow Elevator. This invoice was automatically generated. Signature is not required.');
        $pdf->SetTitle($GLOBALS['COMPANYNAME'] . ' - Invoice ' . pad($invoice, 11, '0'));
        $pdf->SetCurrency($currency);
        $pdf->SetBranch($branch);
        $pdf->AddPage();
        $pdf->SetFont('Arial', '', 10);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->SetFillColor(54, 54, 54);
        $pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Issuance Date", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, pad($invoice, 11, '0'), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['issued_on']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['payable_by']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, number_format($amount, '2', '.', ', '), 1, 0, 'C');
        $pdf->Ln(6);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, $_employer->getId(), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, $_employer->getName(), 1, 0, 'C');
        $pdf->Ln(10);
        $table_header = array("No.", "Item", "Amount (" . $currency . ")");
        $pdf->FancyTable($table_header, $items, number_format($amount, '2', '.', ', '));
        $pdf->Ln(13);
        $pdf->SetFont('', 'I');
        $pdf->Cell(0, 0, "This invoice was automatically generated. Signature is not required.", 0, 0, 'C');
        $pdf->Ln(6);
        $pdf->Cell(0, 5, "Payment Notice", 'LTR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- Payment shall be made payable to " . $branch[0]['branch'] . ".", 'LR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- To facilitate the processing of the payment, please write down the invoice number(s) on your cheque(s)/payment slip(s)", 'LBR', 0, 'C');
        $pdf->Ln(10);
        $pdf->Cell(0, 0, "E. & O. E.", 0, 0, 'C');
        $pdf->Close();
        $pdf->Output($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf', 'F');
        // 3. sends it as an email
        $attachment = chunk_split(base64_encode(file_get_contents($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf')));
        $subject = "Subscription Invoice " . pad($invoice, 11, '0');
        $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n";
        $headers .= 'Bcc: ' . $sales . "\n";
        $headers .= 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-Type: multipart/mixed; boundary="yel_mail_sep_' . $invoice . '";' . "\n\n";
        $body = '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $invoice . '"' . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "\n";
        $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
        $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
        $mail_lines = file('../private/mail/employer_posting_invoice.txt');
        $message = '';
        foreach ($mail_lines as $line) {
            $message .= $line;
        }
        $message = str_replace('%employer%', $_employer->getName(), $message);
        $message = str_replace('%postings%', $_POST['paid_postings'], $message);
        $message = str_replace('%price%', $price, $message);
        $message = str_replace('%currency%', $currency, $message);
        $message = str_replace('%amount%', number_format($amount, 2, '.', ', '), $message);
        $issued_date = explode('-', $data['issued_on']);
        $issued_timestamp = $issued_date[0] . $issued_date[1] . $issued_date[2];
        $message = str_replace('%purchased_on%', date('j M', $issued_timestamp) . ', ' . $issued_date[0], $message);
        $body .= $message . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "--\n\n";
        $body .= '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\n";
        $body .= 'Content-Disposition: attachment' . "\n";
        $body .= $attachment . "\n";
        $body .= '--yel_mail_sep_' . $invoice . "--\n\n";
        mail($_employer->getEmailAddress(), $subject, $body, $headers);
        // $handle = fopen('/tmp/email_to_'. $_employer->getEmailAddress(). '.txt', 'w');
        // fwrite($handle, 'Subject: '. $subject. "\n\n");
        // fwrite($handle, $body);
        // fclose($handle);
        unlink($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf');
    }
    if ($_subscription_period > 0) {
        $single_subscription_prices = array('MYR' => 1000, 'SGD' => 1000);
        // 0. get the job postings pricing and currency
        $subscriptions_rates = $GLOBALS['subscriptions_rates'];
        $amount = $subscriptions_rates[$currency][$_subscription_period];
        if ($_subscription_period == 1) {
            $amount = $single_subscription_prices[$currency];
        }
        $admin_fee = 0.05 * $amount;
        $total = $admin_fee + $amount;
        // 1. generate invoice in the system
        $data = array();
        $data['issued_on'] = $today;
        $data['type'] = 'J';
        $data['employer'] = $_employer->getId();
        $data['payable_by'] = sql_date_add($today, $_employer->getPaymentTermsInDays(), 'day');
        $invoice = Invoice::create($data);
        if ($invoice === false) {
            echo 'ko';
            exit;
        }
        $desc = $_subscription_period . ' month(s) of subscription';
        $item_added = Invoice::addItem($invoice, $total, '1', $desc);
        $items = array();
        $items[0]['itemdesc'] = $desc;
        $items[0]['amount'] = number_format($amount, '2', '.', ', ');
        $items[1]['itemdesc'] = 'Administration Fee';
        $items[1]['amount'] = number_format($admin_fee, '2', '.', ', ');
        // 2. generate the PDF version to be attached to sales.xx and the employer
        $pdf = new SubscriptionInvoice();
        $pdf->AliasNbPages();
        $pdf->SetAuthor('Yellow Elevator. This invoice was automatically generated. Signature is not required.');
        $pdf->SetTitle($GLOBALS['COMPANYNAME'] . ' - Invoice ' . pad($invoice, 11, '0'));
        $pdf->SetCurrency($currency);
        $pdf->SetBranch($branch);
        $pdf->AddPage();
        $pdf->SetFont('Arial', '', 10);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->SetFillColor(54, 54, 54);
        $pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Issuance Date", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, pad($invoice, 11, '0'), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['issued_on']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(33, 5, sql_date_format($data['payable_by']), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, number_format($total, '2', '.', ', '), 1, 0, 'C');
        $pdf->Ln(6);
        $pdf->SetTextColor(255, 255, 255);
        $pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
        $pdf->Cell(1);
        $pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
        $pdf->Ln(6);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->Cell(60, 5, $_employer->getId(), 1, 0, 'C');
        $pdf->Cell(1);
        $pdf->Cell(0, 5, $_employer->getName(), 1, 0, 'C');
        $pdf->Ln(10);
        $table_header = array("No.", "Item", "Amount (" . $currency . ")");
        $pdf->FancyTable($table_header, $items, number_format($total, '2', '.', ', '));
        $pdf->Ln(13);
        $pdf->SetFont('', 'I');
        $pdf->Cell(0, 0, "This invoice was automatically generated. Signature is not required.", 0, 0, 'C');
        $pdf->Ln(6);
        $pdf->Cell(0, 5, "Payment Notice", 'LTR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- Payment shall be made payable to " . $branch[0]['branch'] . ".", 'LR', 0, 'C');
        $pdf->Ln();
        $pdf->Cell(0, 5, "- To facilitate the processing of the payment, please write down the invoice number(s) on your cheque(s)/payment slip(s)", 'LBR', 0, 'C');
        $pdf->Ln(10);
        $pdf->Cell(0, 0, "E. & O. E.", 0, 0, 'C');
        $pdf->Close();
        $pdf->Output($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf', 'F');
        // 3. attach it to email
        $attachment = chunk_split(base64_encode(file_get_contents($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf')));
        $subject = "Subscription Invoice " . pad($invoice, 11, '0');
        $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n";
        $headers .= 'Bcc: ' . $sales . "\n";
        $headers .= 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-Type: multipart/mixed; boundary="yel_mail_sep_' . $invoice . '";' . "\n\n";
        $body = '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $invoice . '"' . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "\n";
        $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
        $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
        $mail_lines = file('../private/mail/employer_subscription_invoice.txt');
        $message = '';
        foreach ($mail_lines as $line) {
            $message .= $line;
        }
        $message = str_replace('%employer%', $_employer->getName(), $message);
        $message = str_replace('%period%', $_subscription_period, $message);
        $message = str_replace('%currency%', $currency, $message);
        $message = str_replace('%amount%', number_format($total, 2, '.', ', '), $message);
        $issued_date = explode('-', $data['issued_on']);
        $issued_timestamp = $issued_date[0] . $issued_date[1] . $issued_date[2];
        $message = str_replace('%purchased_on%', date('j M', $issued_timestamp) . ', ' . $issued_date[0], $message);
        $body .= $message . "\n";
        $body .= '--yel_mail_sep_alt_' . $invoice . "--\n\n";
        $body .= '--yel_mail_sep_' . $invoice . "\n";
        $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n";
        $body .= 'Content-Transfer-Encoding: base64' . "\n";
        $body .= 'Content-Disposition: attachment' . "\n";
        $body .= $attachment . "\n";
        $body .= '--yel_mail_sep_' . $invoice . "--\n\n";
        mail($_employer->getEmailAddress(), $subject, $body, $headers);
        /*$handle = fopen('/tmp/email_to_'. $_employer->getEmailAddress(). '.txt', 'w');
          fwrite($handle, 'Subject: '. $subject. "\n\n");
          fwrite($handle, $body);
          fclose($handle);*/
        unlink($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf');
    }
    return true;
}
예제 #7
0
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFillColor(54, 54, 54);
$pdf->Cell(60, 5, "Invoice Number", 1, 0, 'C', 1);
$pdf->Cell(1);
$pdf->Cell(33, 5, "Issuance Date", 1, 0, 'C', 1);
$pdf->Cell(1);
if (is_null($invoice[0]['paid_on']) || empty($invoice[0]['paid_on'])) {
    $pdf->Cell(33, 5, "Payable By", 1, 0, 'C', 1);
} else {
    $pdf->Cell(33, 5, "Paid On", 1, 0, 'C', 1);
}
$pdf->Cell(1);
$pdf->Cell(0, 5, "Amount Payable (" . $currency . ")", 1, 0, 'C', 1);
$pdf->Ln(6);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(60, 5, pad($_GET['id'], 11, '0'), 1, 0, 'C');
$pdf->Cell(1);
$pdf->Cell(33, 5, $invoice[0]['formatted_issued_on'], 1, 0, 'C');
$pdf->Cell(1);
if (is_null($invoice[0]['paid_on']) || empty($invoice[0]['paid_on'])) {
    $pdf->Cell(33, 5, $invoice[0]['formatted_payable_by'], 1, 0, 'C');
} else {
    $pdf->Cell(33, 5, $invoice[0]['formatted_paid_on'], 1, 0, 'C');
}
$pdf->Cell(1);
$pdf->Cell(0, 5, $amount_payable, 1, 0, 'C');
$pdf->Ln(6);
$pdf->SetTextColor(255, 255, 255);
$pdf->Cell(60, 5, "User ID", 1, 0, 'C', 1);
$pdf->Cell(1);
$pdf->Cell(0, 5, "Employer Name", 1, 0, 'C', 1);
예제 #8
0
         $s_last_index = $stepcount;
     }
 }
 # Case Legend
 $def[$casecount_int] .= rrd::comment(" \\n");
 $def[$casecount_int] .= rrd::comment("Case\\:\\g");
 $def[$casecount_int] .= rrd::comment(" \\n");
 # Case graph, Case runtime on top ###########################################################
 $def[$casecount_int] .= rrd::def("case{$casecount}", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
 # not used anymore; formerly used to draw grey TICK-areas if any case is unknown to hide everything.
 $def[$casecount_int] .= rrd::cdef("case" . $casecount . "_unknown", "case{$casecount},UN,1,0,IF");
 if ($s_last_index != "") {
     $def[$casecount_int] .= rrd::cdef("case_diff{$casecount}", "case{$casecount},s_line_stackbase{$s_last_index},-");
     # invisible line to stack upon
     $def[$casecount_int] .= rrd::line1("s_line_stackbase{$s_last_index}", "#00000000");
     $def[$casecount_int] .= rrd::area("case_diff{$casecount}", $col_case_runtime_area, pad($casename, $label_max_length), 1);
     # invisible line to stack upon
     $def[$casecount_int] .= rrd::line1("s_line_stackbase{$s_last_index}", "#00000000");
     $def[$casecount_int] .= rrd::line1("case_diff{$casecount}", $col_case_runtime_line, "", 1);
 } else {
     # no steps, no stacks
     $def[$casecount_int] .= rrd::area("case{$casecount}", $col_case_runtime_area, $casename);
     $def[$casecount_int] .= rrd::line1("case{$casecount}", $col_case_runtime_line, "");
 }
 $def[$casecount_int] .= rrd::gprint("case{$casecount}", "LAST", "%3.2lf s LAST");
 $def[$casecount_int] .= rrd::gprint("case{$casecount}", "MAX", "%3.2lf s MAX ");
 $def[$casecount_int] .= rrd::gprint("case{$casecount}", "AVERAGE", "%3.2lf s AVG \\j");
 $def[0] .= rrd::comment(" \\n");
 # Case graph, Warn/Crit LINE  ##########################################################
 foreach ($this->DS as $k => $v) {
     if (preg_match('/^c_' . $casecount . '__(warning|critical)/', $v['LABEL'], $matches)) {
예제 #9
0
 public function makeMonthsView(Request $request, $param1)
 {
     $arr = [];
     for ($i = 1; $i < 13; $i++) {
         $date = $param1 . '-' . pad($i, 2) . '-01';
         $arr[$i]['month'] = date('F', strtotime($date));
         $x = $this->dtrs->countByYearMonth($request->user(), $param1, $i);
         $arr[$i]['total'] = $x['total'];
     }
     return view('dtr.months')->with('months', $arr)->with('year', $param1);
 }
예제 #10
0
$n = 0;
$skipped = array();
$errors = array();
foreach (array_reverse($posts) as $post) {
    $n++;
    $output = array();
    if (empty($post['title']) || empty($post['slug'])) {
        $errors[] = $post;
        continue;
    }
    $output[] = 'title: ' . $post['title'];
    $output[] = 'date: ' . date($dateformat, $post['date']);
    $output[] = 'text: ' . "\n\n" . trim($post['text']);
    $output[] = 'tags: ' . $post['tags'];
    $output[] = 'categories: ' . $post['cats'];
    $name = pad($n, $len) . '-' . f::safe_name($post['slug']);
    $dir = $root . '/' . $name;
    if (is_dir($dir)) {
        $skipped[] = basename($dir);
        continue;
    }
    dir::make($dir);
    $content = implode("\n\n" . '----' . "\n\n", $output);
    $file = $dir . '/' . $template;
    f::write($file, $content);
}
putmessage('Exported ' . $n . ' articles to ' . $root . '<br /><br />');
if (!empty($errors)) {
    putmessage(count($errors) . ' article(s) could not be imported<br /><br />');
}
if (!empty($skipped)) {
예제 #11
0
             pad('delete', $r['ID']);
         }
         $refer_url = 'doc/';
     }
     // actualiza info en theme
     $result = mysql_query("SELECT COUNT(ID) AS num FROM docs WHERE estado = 'ok' AND pais = '" . PAIS . "'", $link);
     while ($r = mysql_fetch_array($result)) {
         mysql_query("UPDATE " . SQL . "config SET valor = '" . $r['num'] . "' WHERE dato = 'info_documentos' LIMIT 1", $link);
     }
     break;
 case 'editar-documento':
     if ($_POST['titulo'] and $_POST['cat']) {
         $_POST['titulo'] = strip_tags($_POST['titulo']);
         $result = mysql_query("SELECT ID, pais, url, acceso_escribir, acceso_cfg_escribir FROM docs WHERE ID = '" . $_POST['doc_ID'] . "' LIMIT 1", $link);
         while ($r = mysql_fetch_array($result)) {
             $text = str_replace("'", "&#39;", pad('get', $r['ID']));
             // Prevent SSX basic
             $text = str_replace("<script", "nojs", $text);
             $text = str_replace("&lt;script", "nojs", $text);
             if (nucleo_acceso($r['acceso_escribir'], $r['acceso_cfg_escribir']) or nucleo_acceso($vp['acceso']['control_gobierno'])) {
                 // Impide fijar acceso que no tienes.
                 if (!nucleo_acceso($_POST['acceso_escribir'], $_POST['acceso_cfg_escribir']) and !nucleo_acceso($vp['acceso']['control_gobierno'])) {
                     $_POST['acceso_escribir'] = $r['acceso_escribir'];
                     $_POST['acceso_cfg_escribir'] = $r['acceso_cfg_escribir'];
                 }
                 mysql_query("UPDATE docs SET cat_ID = '" . $_POST['cat'] . "', text = '" . $text . "', title = '" . $_POST['titulo'] . "', time_last = '" . $date . "', acceso_leer = '" . $_POST['acceso_leer'] . "', acceso_escribir = '" . $_POST['acceso_escribir'] . "', acceso_cfg_leer = '" . $_POST['acceso_cfg_leer'] . "', acceso_cfg_escribir = '" . $_POST['acceso_cfg_escribir'] . "', version = version + 1 WHERE ID = '" . $r['ID'] . "' LIMIT 1", $link);
             }
             redirect('http://' . strtolower($r['pais']) . '.' . DOMAIN . '/doc/' . $r['url'] . '/editar');
         }
     }
     break;
예제 #12
0
    public function show()
    {
        $this->begin();
        $branch = $this->employee->getBranch();
        $this->top('Rewards - ' . $branch[0]['country']);
        $this->menu_employee('rewards');
        $new_rewards = $this->get_rewards();
        foreach ($new_rewards as $i => $row) {
            $new_rewards[$i]['member'] = htmlspecialchars_decode(stripslashes($row['member']));
            $new_rewards[$i]['employer'] = htmlspecialchars_decode(stripslashes($row['employer']));
            $new_rewards[$i]['title'] = htmlspecialchars_decode(stripslashes($row['title']));
            $new_rewards[$i]['padded_invoice'] = pad($row['invoice'], 11, '0');
            $new_rewards[$i]['total_reward'] = number_format($row['total_reward'], 2, '.', ', ');
            $new_rewards[$i]['paid_reward'] = number_format($row['paid_reward'], 2, '.', ', ');
        }
        $paid_rewards = $this->get_rewards(true);
        foreach ($paid_rewards as $i => $row) {
            $paid_rewards[$i]['member'] = htmlspecialchars_decode(stripslashes($row['member']));
            $paid_rewards[$i]['employer'] = htmlspecialchars_decode(stripslashes($row['employer']));
            $paid_rewards[$i]['title'] = htmlspecialchars_decode(stripslashes($row['title']));
            $paid_rewards[$i]['padded_invoice'] = pad($row['invoice'], 11, '0');
            $paid_rewards[$i]['total_reward'] = number_format($row['total_reward'], 2, '.', ', ');
            $paid_rewards[$i]['paid_reward'] = number_format($row['paid_reward'], 2, '.', ', ');
            $paid_rewards[$i]['gift'] = htmlspecialchars_decode(stripslashes($row['gift']));
        }
        ?>
        <!-- submenu -->
        <div class="menu">
            <ul class="menu">
                <li id="item_new_rewards" style="background-color: #CCCCCC;"><a class="menu" onClick="show_new_rewards();">New</a></li>
                <li id="item_paid_rewards"><a class="menu" onClick="show_paid_rewards();">Paid</a></li>
            </ul>
        </div>
        <!-- end submenu -->
        
        <!-- div class="banner">
            An administration fee of <?php 
        //echo $currency
        ?>
 2.00 will be charged to the referrers for every transfer of rewards into their bank accounts. <br/><br/>Always remember to ensure that the <?php 
        // echo $currency
        ?>
 2.00 administration fee is taken into considration when making an online bank transaction.
        </div -->
        
        <div id="div_status" class="status">
            <span id="span_status" class="status"></span>
        </div>
        
        <div id="new_rewards">
        <?php 
        if (is_null($new_rewards) || count($new_rewards) <= 0 || $new_rewards === false) {
            ?>
            <div class="empty_results">No rewards being offered at this moment.</div>
        <?php 
        } else {
            ?>
            <div id="div_new_rewards">
            <?php 
            $new_rewards_table = new HTMLTable('new_rewards_table', 'new_rewards');
            $new_rewards_table->set(0, 0, "<a class=\"sortable\" onClick=\"sort_by('new_rewards', 'referrals.employed_on');\">Employed On</a>", '', 'header');
            $new_rewards_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('new_rewards', 'jobs.title');\">Job</a>", '', 'header');
            $new_rewards_table->set(0, 2, "<a class=\"sortable\" onClick=\"sort_by('new_rewards', 'members.lastname');\">Referrer</a>", '', 'header');
            $new_rewards_table->set(0, 3, "Receipt", '', 'header');
            $new_rewards_table->set(0, 4, "Reward", '', 'header');
            $new_rewards_table->set(0, 5, 'Actions', '', 'header action');
            foreach ($new_rewards as $i => $new_reward) {
                $new_rewards_table->set($i + 1, 0, $new_reward['formatted_employed_on'], '', 'cell');
                $job = htmlspecialchars_decode(stripslashes($new_reward['title'])) . '</span>' . "\n";
                $job .= '<div class="small_contact"><span class="contact_label">Employer:</span> ' . $new_reward['employer'] . '</div>' . "\n";
                $new_rewards_table->set($i + 1, 1, $job, '', 'cell');
                $referrer_short_details = '';
                if (substr($new_reward['member_id'], 0, 5) == 'team.' && substr($new_reward['member_id'], 7) == '@yellowelevator.com') {
                    $referrer_short_details = 'Yellow Elevator';
                } else {
                    $referrer_short_details = htmlspecialchars_decode(stripslashes($new_reward['member'])) . "\n";
                    $referrer_short_details .= '<div class="small_contact"><span class="contact_label">Tel.:</span> ' . $new_reward['phone_num'] . '</div>' . "\n";
                    $referrer_short_details .= '<div class="small_contact"><span class="contact_label">Email: </span><a href="mailto:' . $new_reward['member_id'] . '">' . $new_reward['member_id'] . '</a></div>' . "\n";
                }
                $new_rewards_table->set($i + 1, 2, $referrer_short_details, '', 'cell');
                $new_rewards_table->set($i + 1, 3, '<a class="no_link" onClick="show_invoice_page(' . $new_reward['invoice'] . ');">' . $new_reward['padded_invoice'] . '</a>&nbsp;<a href="invoice_pdf.php?id=' . $new_reward['invoice'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell');
                $new_rewards_table->set($i + 1, 4, $new_reward['currency'] . '$ ' . $new_reward['total_reward'], '', 'cell');
                $actions = '<input type="button" value="Award" onClick="show_award_popup(' . $new_reward['referral'] . ');" />';
                $new_rewards_table->set($i + 1, 5, $actions, '', 'cell action');
            }
            echo $new_rewards_table->get_html();
            ?>
            </div>
        <?php 
        }
        ?>
        </div>
        
        <div id="paid_rewards">
        <?php 
        if (is_null($paid_rewards) || count($paid_rewards) <= 0 || $paid_rewards === false) {
            ?>
            <div class="empty_results">No rewards awarded at this moment.</div>
        <?php 
        } else {
            ?>
            <div id="div_paid_rewards">
            <?php 
            $paid_rewards_table = new HTMLTable('paid_rewards_table', 'paid_rewards');
            $paid_rewards_table->set(0, 0, "<a class=\"sortable\" onClick=\"sort_by('paid_rewards', 'referral_rewards.paid_on');\">Awarded On</a>", '', 'header');
            $paid_rewards_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('paid_rewards', 'jobs.title');\">Job</a>", '', 'header');
            $paid_rewards_table->set(0, 2, "<a class=\"sortable\" onClick=\"sort_by('paid_rewards', 'members.lastname');\">Referrer</a>", '', 'header');
            $paid_rewards_table->set(0, 3, "Receipt", '', 'header');
            $paid_rewards_table->set(0, 4, "Total Reward", '', 'header');
            $paid_rewards_table->set(0, 5, 'Given Reward', '', 'header');
            foreach ($paid_rewards as $i => $paid_reward) {
                $paid_rewards_table->set($i + 1, 0, $paid_reward['formatted_paid_on'], '', 'cell');
                $job = htmlspecialchars_decode(stripslashes($paid_reward['title'])) . '</span>' . "\n";
                $job .= '<div class="small_contact"><span class="contact_label">Employer:</span> ' . $paid_reward['employer'] . '</div>' . "\n";
                $paid_rewards_table->set($i + 1, 1, $job, '', 'cell');
                $referrer_short_details = '';
                if (substr($paid_reward['member_id'], 0, 5) == 'team.' && substr($paid_reward['member_id'], 7) == '@yellowelevator.com') {
                    $referrer_short_details = 'Yellow Elevator';
                } else {
                    $referrer_short_details = htmlspecialchars_decode(stripslashes($paid_reward['member'])) . "\n";
                    $referrer_short_details .= '<div class="small_contact"><span class="contact_label">Tel.:</span> ' . $paid_reward['phone_num'] . '</div>' . "\n";
                    $referrer_short_details .= '<div class="small_contact"><span class="contact_label">Email: </span><a href="mailto:' . $paid_reward['member_id'] . '">' . $paid_reward['member_id'] . '</a></div>' . "\n";
                }
                $paid_rewards_table->set($i + 1, 2, $referrer_short_details, '', 'cell');
                $paid_rewards_table->set($i + 1, 3, '<a class="no_link" onClick="show_invoice_page(' . $paid_reward['invoice'] . '">' . $paid_reward['padded_invoice'] . '</a>&nbsp;<a href="invoice_pdf.php?id=' . $paid_reward['invoice'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell');
                $paid_rewards_table->set($i + 1, 4, $paid_reward['currency'] . '$ ' . $paid_reward['total_reward'], '', 'cell');
                $rewarded = $paid_reward['currency'] . '$ ' . $paid_reward['paid_reward'];
                if ($paid_reward['paid_reward'] <= 0 && !is_null($paid_reward['gift'])) {
                    $rewarded = $paid_reward['gift'];
                }
                $paid_rewards_table->set($i + 1, 5, $rewarded, '', 'cell');
            }
            echo $paid_rewards_table->get_html();
            ?>
            </div>
        <?php 
        }
        ?>
        </div>
        
        <!-- popup windows goes here -->
        <div id="award_window" class="popup_window">
            <div class="popup_window_title">Award</div>
            <form onSubmit="return false;">
                <input type="hidden" id="referral_id" value="" />
                <div class="award_form">
                    <table class="award_form">
                        <tr>
                            <td class="label">Referrer:</td>
                            <td class="field"><span id="lbl_referrer"></span></td>
                        </tr>
                        <tr>
                            <td class="label">Total Reward:</td>
                            <td class="field">
                                <!-- span id="lbl_reward"></span -->
                                <span id="lbl_reward_currency"></span>$ <input type="text" id="amount" value="1.00" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label">Award as:</td>
                            <td class="field">
                                <div class="award_field">
                                    <input type="radio" name="award_as" id="award_as_money" checked />Monetary Incentive<br/>
                                    Payment Mode:
                                    <select id="payment_mode" name="payment_mode">
                                        <option value="IBT" selected>Bank Transfer</option>
                                        <option value="CSH">Cash</option>
                                        <option value="CHQ">Cheque</option>
                                        <option value="CDB">Bank on-behalf</option>
                                    </select><br/>
                                    Bank Account:
                                    <span id="banks_list"></span><br/>
                                    Receipt #:
                                    <input type="text" id="receipt" value="" />
                                </div>
                                <br/>
                                <div class="award_field">
                                    <input type="radio" name="award_as" id="award_as_gift" />Gift: 
                                    <input type="text" id="gift" value="" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </form>
            <div class="popup_window_buttons_bar">
                <input type="button" value="Confirm" onClick="close_award_popup(true);" />
                <input type="button" value="Cancel" onClick="close_award_popup(false);" />
            </div>
        </div>
        
        <?php 
    }
예제 #13
0
파일: md5.php 프로젝트: chendeng/php-lib
function init($string)
{
    $len = strlen($string) * 8;
    $hex = strhex($string);
    // convert ascii string to hex
    $bin = leftpad(hexbin($hex), $len);
    // convert hex string to bin
    $padded = pad($bin);
    $padded = pad($padded, 1, $len);
    $block = str_split($padded, 32);
    foreach ($block as &$b) {
        $b = implode('', array_reverse(str_split($b, 8)));
    }
    return $block;
}
예제 #14
0
파일: upgrade.php 프로젝트: thctlo/1.2.0
    executeQuery($sql);
    
    *
    ** Finished
    */
    // Phew! - finished
    mysql_close($link);
} else {
    echo " FAILED\n";
    $errors[] = "Database connection failed: " . @mysql_error();
}
echo "\n";
// Check MailScanner settings
echo "Checking MailScanner.conf settings: \n";
$check_settings = array('QuarantineWholeMessage' => 'yes', 'QuarantineWholeMessagesAsQueueFiles' => 'no', 'DetailedSpamReport' => 'yes', 'IncludeScoresInSpamAssassinReport' => 'yes', 'SpamActions' => 'store', 'HighScoringSpamActions' => 'store', 'AlwaysLookedUpLast' => '&MailWatchLogging');
foreach ($check_settings as $setting => $value) {
    echo pad(" - {$setting} ");
    if (preg_match('/' . $value . '/', get_conf_var($setting))) {
        echo " OK\n";
    } else {
        echo " WARNING\n";
        $errors[] = "MailScanner.conf: {$setting} != {$value} (=" . get_conf_var($setting) . ")";
    }
}
echo "\n";
if (is_array($errors)) {
    echo "*** ERROR/WARNING SUMMARY ***\n";
    foreach ($errors as $error) {
        echo $error . "\n";
    }
}
예제 #15
0
</tr>


	

</table>
</div>

<div style="margin:5px 0;">
<input type="text" name="titulo" value="' . $r['title'] . '" size="30" maxlength="50" style="font-size:22px;" /> &nbsp; 
<button onclick="$(\'#doc_opciones\').slideToggle(\'slow\');return false;" style="font-size:16px;color:#666;">Opciones</button> &nbsp; 
<input type="submit" value="Publicar" style="font-size:22px;" /> <a href="/doc/' . $r['url'] . '">Última publicación hace <span class="timer" value="' . strtotime($r['time_last']) . '"></span></a>.</div>

</form>

' . pad('print', $r['ID']);
            $txt_nav = array('/doc' => 'Documentos', '/doc/' . $r['url'] => $r['title'], 'Editar');
            $txt_tab['/doc/' . $r['url']] = 'Ver documento';
            $txt_tab['/doc/' . $r['url'] . '/editar'] = 'Editar';
        } elseif ($_GET['b'] == 'presentacion') {
            //doc/documento-de-test/presentacion
            if (nucleo_acceso($r['acceso_leer'], $r['acceso_cfg_leer'])) {
                presentacion($r['title'], $r['text'], 'http://' . strtolower(PAIS) . '.' . DOMAIN . '/doc/' . $r['url']);
            } else {
                $txt .= '<b style="color:red;">No tienes acceso de lectura.</b>';
            }
        } else {
            //doc/documento-de-test
            if (nucleo_acceso($r['acceso_escribir'], $r['acceso_cfg_escribir']) || nucleo_acceso($vp['acceso']['control_gobierno'])) {
                $boton_editar = boton('Editar', '/doc/' . $r['url'] . '/editar');
                $txt_tab['/doc/' . $r['url'] . '/editar'] = 'Editar';
예제 #16
0
 }
 if (isset($_POST['paid_invoices'])) {
     $paid_on_clause = "paid_on IS NOT NULL";
 }
 $criteria = array('columns' => "id, type, DATEDIFF(payable_by, now()) AS expired, \n                      DATE_FORMAT(issued_on, '%e %b, %Y') AS formatted_issued_on, \n                      DATE_FORMAT(payable_by, '%e %b, %Y') AS formatted_payable_by,\n                      DATE_FORMAT(paid_on, '%e %b, %Y') AS formatted_paid_on", 'match' => "employer = '" . $_POST['id'] . "' AND " . $paid_on_clause, 'order' => $order_by);
 $result = Invoice::find($criteria);
 if (is_null($result) || empty($result)) {
     echo '0';
     exit;
 }
 if ($result === false) {
     echo 'ko';
     exit;
 }
 foreach ($result as $i => $row) {
     $result[$i]['padded_id'] = pad($row['id'], 11, '0');
     $type = 'Others';
     switch ($row['type']) {
         case 'R':
             $type = 'Service Fee';
             break;
         case 'J':
             $type = 'Subscription';
             break;
         case 'P':
             $type = 'Job Posting';
             break;
     }
     $result[$i]['type'] = $type;
 }
 $response = array('invoices' => array('invoice' => $result));
예제 #17
0
파일: invoice.php 프로젝트: pamalite/yel
            <td class="field">Payable By</td>
            <?php 
} else {
    ?>
            <td class="field">Paid On</td>
            <?php 
}
?>
            <td class="field">Amount Payable (<?php 
echo $currency;
?>
)</td>
        </tr>
        <tr>
            <td class="value"><?php 
echo pad($_GET['id'], 11, '0');
?>
</td>
            <td class="value"><?php 
echo $invoice[0]['formatted_issued_on'];
?>
</td>
            <?php 
if (is_null($invoice[0]['paid_on']) || empty($invoice[0]['paid_on'])) {
    ?>
            <td class="value"><?php 
    echo $invoice[0]['formatted_payable_by'];
    ?>
</td>
            <?php 
} else {
예제 #18
0
                  <div class="input-group">
                    <span class="input-group-btn">
                      

                      <select class="btn btn-default" type="button" name="year" id="year">
                        @for($c=2015; $c<(now('Y')+2); $c++)
                          <option <?php 
echo now('Y') == $c ? 'selected' : '';
?>
 value="{{$c}}">{{$c}}</option>
                        @endfor
                      </select>
                      <select class="btn btn-default" type="button" name="month" id="month">
                        @for($c=1; $c<13; $c++)
                          <option <?php 
echo pad(now('M'), 2) == pad($c, 2) ? 'selected' : '';
?>
 value="{{ pad($c,2) }}">{{ pad($c,2) }}</option>
                        @endfor
                      </select>
                      <button id="attached" class="btn btn-default" type="button">
                        <span class="glyphicon glyphicon-paperclip"></span>
                      </button>
                    
                    </span>
                    <input type="text" class="form-control" id="filename" name="filename" readonly required>
                  </div><!-- /input-group -->
                </div><!-- /.col-lg-6 -->
              </div>
              <div class="row" style="margin-top: 10px;">
                <div class="col-lg-12">
예제 #19
0
        $order_by = $_POST['order_by'];
    }
    $now = now();
    $query = "SELECT invoices.id AS invoice, referrals.id AS referral, \n              jobs.title, employers.name AS employer, employers.contact_person, \n              employers.email_addr AS employer_email, employers.phone_num, \n              CONCAT(members.lastname, ', ', members.firstname) AS member, \n              CONCAT(referees.lastname, ', ', referees.firstname) AS referee, \n              DATE_FORMAT(referrals.employed_on, '%e %b, %Y') AS formatted_employed_on \n              FROM referrals \n              LEFT JOIN invoice_items ON invoice_items.item = referrals.id \n              LEFT JOIN invoices ON invoices.id = invoice_items.invoice \n              LEFT JOIN jobs ON jobs.id = referrals.job \n              LEFT JOIN members ON members.email_addr = referrals.member \n              LEFT JOIN members AS referees ON referees.email_addr = referrals.referee \n              LEFT JOIN employers ON employers.id = jobs.employer \n              LEFT JOIN employees ON employers.registered_by = employees.id \n              WHERE invoices.type = 'R' AND \n              (invoices.paid_on IS NOT NULL AND invoices.paid_on <> '0000-00-00 00:00:00') AND \n              (referrals.employed_on IS NOT NULL AND referrals.employed_on <> '0000-00-00 00:00:00') AND \n              (referrals.employer_removed_on IS NULL OR referrals.employer_removed_on = '0000-00-00 00:00:00') AND \n              (referrals.referee_rejected_on IS NULL OR referrals.referee_rejected_on = '0000-00-00 00:00:00') AND \n              (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00') AND \n              (referrals.replaced_on IS NULL OR referrals.replaced_on = '0000-00-00 00:00:00') AND \n              referrals.replaced_referral IS NULL AND \n              referrals.work_commence_on <= '" . $now . "' AND \n              (referrals.guarantee_expire_on > '" . $now . "' OR referrals.guarantee_expire_on IS NULL) AND \n              employees.branch = " . $_SESSION['yel']['employee']['branch']['id'] . " \n              GROUP BY referrals.id \n              ORDER BY " . $order_by;
    $mysqli = Database::connect();
    $result = $mysqli->query($query);
    if (count($result) <= 0 || is_null($result)) {
        echo '0';
        exit;
    }
    if (!$result) {
        echo 'ko';
        exit;
    }
    foreach ($result as $i => $row) {
        $result[$i]['padded_invoice'] = pad($row['invoice'], 11, '0');
    }
    $response = array('replacements' => array('replacement' => $result));
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array($response);
    exit;
}
if ($_POST['action'] == 'authorize_replacement') {
    $today = now();
    $data = array();
    $data['id'] = $_POST['id'];
    $data['replacement_authorized_on'] = $today;
    if (!Referral::update($data)) {
        echo 'ko';
        exit;
    }
예제 #20
0
    public function show()
    {
        $this->begin();
        $branch = $this->employee->getBranch();
        $this->top('Payments - ' . $branch[0]['country']);
        $this->menu_employee('payments');
        $employers = $this->get_employers();
        $receipt_employers = $this->get_employers(false);
        $today = now();
        $invoices = $this->get_payments();
        foreach ($invoices as $i => $row) {
            $invoices[$i]['padded_id'] = pad($row['id'], 11, '0');
            $invoices[$i]['amount_payable'] = number_format($row['amount_payable'], 2, '.', ', ');
            $delta = sql_date_diff($today, $row['payable_by']);
            if ($delta > 0) {
                $invoices[$i]['expired'] = 'expired';
            } else {
                if ($delta == 0) {
                    $invoices[$i]['expired'] = 'nearly';
                } else {
                    $invoices[$i]['expired'] = 'no';
                }
            }
        }
        $receipts = $this->get_payments(false);
        foreach ($receipts as $i => $row) {
            $receipts[$i]['padded_id'] = pad($row['id'], 11, '0');
            $receipts[$i]['amount_payable'] = number_format($row['amount_payable'], 2, '.', ', ');
        }
        ?>
        <!-- submenu -->
        <div class="menu">
            <ul class="menu">
                <li id="item_invoices" style="background-color: #CCCCCC;"><a class="menu" onClick="show_invoices();">Invoices</a></li>
                <li id="item_receipts"><a class="menu" onClick="show_receipts();">Receipts</a></li>
            </ul>
        </div>
        <!-- end submenu -->
        
        <div id="div_status" class="status">
            <span id="span_status" class="status"></span>
        </div>
        
        <div id="invoices">
        <?php 
        if (is_null($invoices) || count($invoices) <= 0 || $invoices === false) {
            ?>
            <div class="empty_results">No invoices issued at this moment.</div>
        <?php 
        } else {
            ?>
            <div class="buttons_bar">
                Employer Filter: 
                <select id="invoices_filter" onChange="filter_invoices();">
                    <option value="" selected>All</option>
                    <option value="" disabled>&nbsp;</option>
        <?php 
            foreach ($employers as $employer) {
                ?>
                    <option value="<?php 
                echo $employer['id'];
                ?>
"><?php 
                echo htmlspecialchars_decode(stripslashes($employer['employer']));
                ?>
</option>
                <?php 
            }
            ?>
                </select>
            </div>
            <div id="div_invoices">
            <?php 
            $invoices_table = new HTMLTable('invoices_table', 'invoices');
            $invoices_table->set(0, 0, '&nbsp;', '', 'header expiry_status');
            $invoices_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'invoices.issued_on');\">Issued On</a>", '', 'header');
            $invoices_table->set(0, 2, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'employers.name');\">Employer</a>", '', 'header');
            $invoices_table->set(0, 3, "Placement", '', 'header');
            $invoices_table->set(0, 4, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'invoices.id');\">Invoice</a>", '', 'header');
            $invoices_table->set(0, 5, 'Payable By', '', 'header');
            $invoices_table->set(0, 6, 'Amount Payable', '', 'header');
            $invoices_table->set(0, 7, 'Actions', '', 'header action');
            foreach ($invoices as $i => $invoice) {
                $status = '';
                if ($invoice['expired'] == 'expired') {
                    $status = '<img class="warning" src="../common/images/icons/expired.png" />';
                } elseif ($invoice['expired'] == 'nearly') {
                    $status = '<img class="warning" src="../common/images/icons/just_expired.png" />';
                }
                $invoices_table->set($i + 1, 0, $status, '', 'cell expiry_status');
                $invoices_table->set($i + 1, 1, $invoice['formatted_issued_on'], '', 'cell');
                $employer_contacts = htmlspecialchars_decode(stripslashes($invoice['employer']));
                $employer_contacts .= '<div class="contacts">';
                $employer_contacts .= '<span class="contact_label">Tel.:</span> ' . $invoice['phone_num'] . '<br/>';
                $employer_contacts .= '<span class="contact_label">Fax.:</span> ' . $invoice['fax_num'] . '<br/>';
                $employer_contacts .= '<span class="contact_label">E-mail:</span> <a href="mailto:' . $invoice['email_addr'] . '">' . $invoice['email_addr'] . '</a><br/>';
                $employer_contacts .= '<span class="contact_label">Contact:</span> ' . $invoice['contact_person'] . '<br/></div>';
                $invoices_table->set($i + 1, 2, $employer_contacts, '', 'cell');
                $invoices_table->set($i + 1, 3, $invoice['placement'], '', 'cell');
                $invoices_table->set($i + 1, 4, '<a class="no_link" onClick="show_invoice_page(' . $invoice['id'] . ');">' . $invoice['padded_id'] . '</a>&nbsp;<a href="invoice_pdf.php?id=' . $invoice['id'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell');
                $invoices_table->set($i + 1, 5, $invoice['formatted_payable_by'], '', 'cell');
                $amount = $invoice['currency'] . '$&nbsp;' . $invoice['amount_payable'];
                $invoices_table->set($i + 1, 6, $amount, '', 'cell');
                $actions = '<input type="button" value="Paid" onClick="show_payment_popup(' . $invoice['id'] . ', \'' . $invoice['padded_id'] . '\');" /><input type="button" value="Resend" onClick="show_resend_popup(' . $invoice['id'] . ', \'' . $invoice['padded_id'] . '\');" />';
                $invoices_table->set($i + 1, 7, $actions, '', 'cell action');
            }
            echo $invoices_table->get_html();
            ?>
            </div>
        <?php 
        }
        ?>
        </div>
                
        <div id="receipts">
        <?php 
        if (is_null($receipts) || count($receipts) <= 0 || $receipts === false) {
            ?>
            <div class="empty_results">No receipts issued at this moment.</div>
        <?php 
        } else {
            ?>
            <div class="buttons_bar">
                Employer Filter: 
                <select id="receipts_filter" onChange="filter_receipts();">
                    <option value="" selected>All</option>
                    <option value="" disabled>&nbsp;</option>
        <?php 
            foreach ($receipt_employers as $employer) {
                ?>
                    <option value="<?php 
                echo $employer['id'];
                ?>
"><?php 
                echo htmlspecialchars_decode(stripslashes($employer['employer']));
                ?>
</option>
                <?php 
            }
            ?>
                </select>
            </div>
            <div id="div_receipts">
            <?php 
            $receipts_table = new HTMLTable('receipts_table', 'receipts');
            $receipts_table->set(0, 0, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'receipts.issued_on');\">Issued On</a>", '', 'header');
            $receipts_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'employers.name');\">Employer</a>", '', 'header');
            $receipts_table->set(0, 2, 'Placement', '', 'header');
            $receipts_table->set(0, 3, "<a class=\"sortable\" onClick=\"sort_by('receipts', 'invoices.id');\">Receipt</a>", '', 'header');
            $receipts_table->set(0, 4, 'Paid On', '', 'header');
            $receipts_table->set(0, 5, 'Amount Paid', '', 'header');
            $receipts_table->set(0, 6, 'Payment', '', 'header payment');
            foreach ($receipts as $i => $receipt) {
                $receipts_table->set($i + 1, 0, $receipt['formatted_issued_on'], '', 'cell');
                $receipts_table->set($i + 1, 1, htmlspecialchars_decode(stripslashes($receipt['employer'])), '', 'cell');
                $receipts_table->set($i + 1, 2, $receipt['placement'], '', 'cell');
                $receipts_table->set($i + 1, 3, '<a class="no_link" onClick="show_receipt_page(' . $receipt['id'] . ');">' . $receipt['padded_id'] . '</a>&nbsp;<a href="invoice_pdf.php?id=' . $receipt['id'] . '"><img src="../common/images/icons/pdf.gif" /></a>', '', 'cell');
                $receipts_table->set($i + 1, 4, $receipt['formatted_paid_on'], '', 'cell');
                $amount = $receipt['currency'] . '$&nbsp;' . $receipt['amount_payable'];
                $receipts_table->set($i + 1, 5, $amount, '', 'cell');
                $payment = 'By Cash';
                if ($receipt['paid_through'] != 'CSH') {
                    $payment = 'Bank Receipt #:<br/>' . $receipt['paid_id'];
                }
                $receipts_table->set($i + 1, 6, $payment, '', 'cell payment');
            }
            echo $receipts_table->get_html();
            ?>
            </div>
        <?php 
        }
        ?>
        </div>
        
        <!-- popup windows goes here -->
        <div id="paid_window" class="popup_window">
            <div class="popup_window_title">Confirm Payment</div>
            <form onSubmit="return false;">
                <input type="hidden" id="invoice_id" value="" />
                <div class="paid_form">
                    <table class="paid_form">
                        <tr>
                            <td class="label">Invoice:</td>
                            <td class="field"><span id="lbl_invoice"></span></td>
                        </tr>
                        <tr>
                            <td class="label">Paid On:</td>
                            <td class="field">
                            <?php 
        echo generate_dropdown('day', 'day', 1, 31, '', 2, 'Day');
        echo generate_month_dropdown('month', 'month', 'Month');
        $today = explode('-', today());
        $year = $today[0];
        echo generate_dropdown('year', 'year', $year - 1, $year, '', 4, 'Year');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">Payment Mode:</td>
                            <td class="field">
                                <select class="field" id="payment_mode" name="payment_mode">
                                    <option value="CSH">Cash</option>
                                    <option value="IBT">Bank Transfer</option>
                                    <option value="CHQ">Cheque</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">Bank Receipt #:</td>
                            <td class="field"><input type="text" class="field" id="payment_number" name="payment_number" /></td>
                        </tr>
                    </table>
                </div>
            </form>
            <div class="popup_window_buttons_bar">
                <input type="button" value="Cancel" onClick="close_payment_popup(false);" />
                <input type="button" value="Confirm" onClick="close_payment_popup(true);" />
            </div>
        </div>
        
        <div id="resend_window" class="popup_window">
            <div class="popup_window_title">Resend Invoice <span id="lbl_resend_invoice"></span></div>
            <div class="employer_details">
                <span style="font-weight: bold;">Employer: </span>
                <span id="employer_name"></span>
                <br/>
                <span style="font-weight: bold;">Contact Person: </span>
                <span id="contact_person"></span>
            </div>
            <form onSubmit="return false;">
                <input type="hidden" id="resend_invoice_id" value="" />
                <div class="resend_form">
                    <span style="font-weight: bold;">Recipients: </span>(separated by commas)<br/>
                    <textarea id="recipients" class="recipients"></textarea>
                </div>
            </form>
            <div class="popup_window_buttons_bar">
                <input type="button" value="Cancel" onClick="close_resend_popup(false);" />
                <input type="button" value="Resend" onClick="close_resend_popup(true);" />
            </div>
        </div>
        <?php 
    }
예제 #21
0
        $order_by = $_POST['order_by'];
    }
    $rewards = get_rewards(true, $order_by);
    if (count($rewards) <= 0 || is_null($rewards)) {
        echo '0';
        exit;
    }
    if (!$rewards) {
        echo 'ko';
        exit;
    }
    foreach ($rewards as $i => $row) {
        $rewards[$i]['member'] = htmlspecialchars_decode(stripslashes($row['member']));
        $rewards[$i]['employer'] = htmlspecialchars_decode(stripslashes($row['employer']));
        $rewards[$i]['title'] = htmlspecialchars_decode(stripslashes($row['title']));
        $rewards[$i]['padded_invoice'] = pad($row['invoice'], 11, '0');
        $rewards[$i]['total_reward'] = number_format($row['total_reward'], 2, '.', ', ');
        $rewards[$i]['paid_reward'] = number_format($row['paid_reward'], 2, '.', ', ');
        $rewards[$i]['gift'] = htmlspecialchars_decode(stripslashes($row['gift']));
    }
    $response = array('rewards' => array('reward' => $rewards));
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array($response);
    exit;
}
if ($_POST['action'] == 'get_reward_details') {
    $criteria = array('columns' => "currencies.symbol AS currency, \n                      referrals.total_reward, referrals.member AS member_id, \n                      CONCAT(members.lastname, ', ', members.firstname) AS member", 'joins' => "jobs ON jobs.id = referrals.job, \n                    members ON members.email_addr = referrals.member, \n                    employers ON employers.id = jobs.employer, \n                    currencies ON currencies.country_code = employers.country", 'match' => "referrals.id = " . $_POST['id'], 'limit' => "1");
    $referral = new Referral();
    $result = $referral->find($criteria);
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array(array('reward' => $result));
예제 #22
0
 public function show()
 {
     $this->begin();
     $this->support($this->employer->getId());
     $this->top('Invoices &amp; Receipts');
     $this->menu('employer', 'invoices');
     $invoices = $this->get_invoices();
     $receipts = $this->get_invoices(true);
     ?>
     <div id="div_status" class="status">
         <span id="span_status" class="status"></span>
     </div>
     
     <div id="div_tabs">
         <ul>
             <li id="li_invoices">Invoices</li>
             <li id="li_receipts">Receipts</li>
         </ul>
     </div>
     
     <div id="div_invoices">
     <?php 
     if (empty($invoices)) {
         ?>
         <div class="empty_results">No invoices issued at this moment.</div>
     <?php 
     } else {
         $invoices_table = new HTMLTable('invoices_table', 'payments');
         $invoices_table->set(0, 0, "&nbsp;", '', 'header cell_indicator');
         $invoices_table->set(0, 1, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'issued_on');\">Issued On</a>", '', 'header');
         $invoices_table->set(0, 2, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'payable_by');\">Payable By</a>", '', 'header');
         $invoices_table->set(0, 3, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'type');\">Type</a>", '', 'header');
         $invoices_table->set(0, 4, "<a class=\"sortable\" onClick=\"sort_by('invoices', 'id');\">Invoice</a>", '', 'header');
         $invoices_table->set(0, 5, "&nbsp;", '', 'header pdf_download');
         foreach ($invoices as $i => $invoice) {
             if ($invoice['expired'] <= 0) {
                 $invoices_table->set($i + 1, 0, '<img src="../common/images/icons/expired.png" />', '', 'cell cell_indicator');
             } else {
                 $invoices_table->set($i + 1, 0, '&nbsp;', '', 'cell cell_indicator');
             }
             $invoices_table->set($i + 1, 1, $invoice['formatted_issued_on'], '', 'cell');
             $invoices_table->set($i + 1, 2, $invoice['formatted_payable_by'], '', 'cell');
             $type = 'Others';
             switch ($invoice['type']) {
                 case 'R':
                     $type = 'Service Fee';
                     break;
                 case 'J':
                     $type = 'Subscription';
                     break;
                 case 'P':
                     $type = 'Job Posting';
                     break;
             }
             $invoices_table->set($i + 1, 3, $type, '', 'cell');
             $invoices_table->set($i + 1, 4, '<a class="no_link" onClick="show_invoice_page(' . $invoice['id'] . ');">' . pad($invoice['id'], 11, '0') . '</a>', '', 'cell');
             $invoices_table->set($i + 1, 5, '<a href="invoice_pdf.php?id=' . $invoice['id'] . '"><img src="../common/images/icons/pdf.gif"/></a>', '', 'cell pdf_download');
         }
         echo $invoices_table->get_html();
     }
     ?>
     </div>
     
     <div id="div_receipts">
     </div>
     
     <?php 
 }
예제 #23
0
파일: srp.php 프로젝트: phipear/srp_php
function srp_test()
{
    $test_phase = 0;
    //$I = "alice";
    //$P = "password123";
    $I = "aliceasd";
    $P = "passasd98173";
    if ($test_phase == 0) {
        $_GET = array("protocol" => "SRP-6a", "type" => "request", "phase" => 0, "I" => $I, "P" => $P, "hash" => "SHA256", "N_size" => 1024, "enc_client_state" => "");
        $json0 = json_encode(srp());
        echo "Rep0=", $json0, "\n\n";
        $json0 = json_decode($json0, true);
    } else {
        $_GET = array("protocol" => "SRP-6a", "type" => "request", "phase" => 1, "I" => $I, "hash" => "SHA256", "N_size" => 1024, "enc_server_state" => "", "enc_client_state" => "");
        echo "Req1=", json_encode($_GET), "\n\n";
        $json = json_encode(srp());
        echo "Rep1=", $json, "\n\n";
        $json = json_decode($json, true);
        if (strlen($json["N_base36"]) < 100) {
            crit("client: N to small");
        }
        if (strlen($json["s_hex"]) < 32) {
            crit("client: s_hex to small");
        }
        $Ng_ok = false;
        if ($json["g_base36"] == "2" && $json["N_base36"] == "16xa82om033wnlk70asiomztdukuffhyjzvfan3p2mx73a3d7m9hws9a6bzc2ln42n93rmtrxi2p22g3xgxrvyryv9petn2256pdt281msxh9e812rhddxq4oo1f35sp7leese5d02obbwmiui7r2ddwfyqu31ctl4959pckt6lbolnlblhf4znrola2vk3wfto3e8z") {
            $Ng_ok = true;
        }
        if ($Ng_ok != true) {
            crit("client: Ng not whitelisted");
        }
        $N_gmp = gmp_init($json["N_base36"], 36);
        $N_bin = gmp_bytes($N_gmp);
        $g_gmp = gmp_init($json["g_base36"], 36);
        $g_bin = gmp_bytes($g_gmp);
        // check if N,g are secure: large, N is prime and g is primitive root, and discrate logarithm is hard
        // because chacking is hard to do in real-time, they should be whitelisted
        $k_hex = H($N_bin . pad($g_bin));
        $k_gmp = gmp_init($k_hex, 16);
        $s_hex = $json["s_hex"];
        $s_bin = hex2bin($s_hex);
        // client oblicza x = H(s~H(I~P))
        $x_bin = H($s_bin . H($I . ":" . $P));
        $x_hex = bin2hex($x_bin);
        $x_gmp = gmp_init($x_hex, 16);
        // secret
        $v_gmp = gmp_powm($g_gmp, $x_gmp, $N_gmp);
        // secret
        // timing attack
        // client generuje randomowe a
        $a_bin = get_random_bytes(128);
        // rfc 5054: at least 256 bit
        $a_hex = bin2hex($a_bin);
        $a_gmp = gmp_init($a_hex, 16);
        // secret
        // client oblicza A=g^a, i nam wysyla
        $A_gmp = gmp_powm($g_gmp, $a_gmp, $N_gmp);
        // public
        // timing attack
        $A_hex = gmp_strval($A_gmp, 16);
        // debug
        $A_bin = gmp_bytes($A_gmp);
        // ponieważ dostalismy B, możemy obliczyc juz S
        $B_gmp = gmp_init($json["B_base36"], 36);
        $B_hex = gmp_strval($B_gmp, 16);
        // debug
        $B_bin = gmp_bytes($B_gmp);
        // klient oblicza u = H(A~B)
        $u_bin = H(pad($A_bin) . pad($B_bin));
        $u_hex = bin2hex($u_bin);
        $u_gmp = gmp_init($u_hex, 16);
        // klient oblicza S = (B - k*g^x)^(a+u*x)
        //$S_gmp = gmp_powm(gmp_sub($B_gmp, gmp_mul($k_gmp, gmp_powm($g_gmp, $v_gmp, $N_gmp))), gmp_add($a_gmp, gmp_mul($u_gmp, $x_gmp)), $N_gmp);
        $S_gmp = gmp_powm(gmp_mod(gmp_sub($B_gmp, gmp_mod(gmp_mul($k_gmp, $v_gmp), $N_gmp)), $N_gmp), gmp_add($a_gmp, gmp_mul($u_gmp, $x_gmp)), $N_gmp);
        // timing attack
        $S_bin = gmp_bytes($S_gmp);
        $S_hex = gmp_strval($S_gmp, 16);
        // secret
        // klient oblicza M1 = H(A~B~S) i wysyla do serwera
        $M1_bin = H($A_bin . $B_bin . $S_bin);
        $M1_hex = bin2hex($M1_bin);
        $_GET = array("protocol" => "SRP-6a", "type" => "request", "phase" => 2, "A_base36" => gmp_strval($A_gmp, 36), "M1_hex" => $M1_hex, "enc_server_state" => $json["enc_server_state"], "enc_client_state" => "");
        echo "Req2=", json_encode($_GET), "\n\n";
        $json2 = json_encode(srp());
        echo "Rep2=", $json2, "\n\n";
        $json2 = json_decode($json2, true);
        // klient oblicza M2 = H(A~M1~S)
        // klient potwierdza poprawnosc otrzymanego M2
        // klient oblicza K = H(S)
        // klient oblicza M = H( (H(N) xor H(g))~H(I)~s~A~B~K )
        $M2_bin = H($A_bin . $M1_bin . $S_bin);
        $M2_hex = bin2hex($M2_bin);
        if ($M2_hex != $json2["M2_hex"]) {
            crit("client: M2 are different, don't trust server!");
        }
        $K_bin = H($S_bin);
        $K_hex = bin2hex($K_bin);
        // secret
        $M_bin = HM((H($N_bin) ^ H($g_bin)) . H($I) . $s_bin . $A_bin . $B_bin, $K_bin);
        $M_hex = bin2hex($M_bin);
        $_GET = array("protocol" => "SRP-6a", "type" => "request", "phase" => 3, "M_hex" => $M_hex, "enc_server_state" => $json2["enc_server_state"], "enc_client_state" => "");
        echo "Req3=", json_encode($_GET), "\n\n";
        $json3 = json_encode(srp());
        echo "Rep3=", $json3, "\n\n";
        $json3 = json_decode($json3, true);
        $Z_bin = HM($A_bin . $M_bin, $K_bin);
        $Z_hex = bin2hex($Z_bin);
        if ($Z_hex != $json3["Z_hex"]) {
            crit("Z_hex different");
        }
        echo "Logged\n";
    }
}
예제 #24
0
파일: html.php 프로젝트: nielsbom/tweetnest
function tweetsHTML($q, $mode = "", $tabs = 4)
{
    global $db, $home, $config;
    $maxTweets = 200;
    $s = "";
    $t = str_repeat("\t", $tabs);
    $path = s(rtrim($config['path'], "/"));
    $first = 0;
    $last = 0;
    $i = 0;
    $tweets = array();
    $array = is_array($q);
    $count = $array ? count($q) : $db->numRows($q);
    if ($count > 0) {
        if (!$array) {
            while ($tweet = $db->fetch($q)) {
                $tweets[] = $tweet;
            }
        } else {
            $tweets = $q;
        }
        foreach ($tweets as $tweet) {
            if ($tweet['time'] < $first || $first == 0) {
                $first = $tweet['time'];
            }
            if ($tweet['time'] > $last) {
                $last = $tweet['time'];
            }
            $s .= tweetHTML($tweet, $tabs);
            $i++;
            if ($mode == "month" && $i >= $maxTweets) {
                $s .= $t . "<div class=\"truncated\"><strong>There&#8217;s more tweets in this month!</strong> <span>Go up and <a href=\"#top\">select a date</a> to see more &uarr;</span></div>\n";
                break;
            }
            if ($mode == "search" && $i >= $maxTweets) {
                $s .= $t . "<div class=\"truncated\"><strong>There&#8217;s even more search results!</strong> <span>Go up and <a href=\"#top\">add a couple of words</a> to your query to find the specific tweets you want &uarr;</span></div>\n";
                break;
            }
        }
        if ($mode == "day") {
            $nextprev = "";
            $half = "SELECT `tweetid`, `time`, YEAR(FROM_UNIXTIME(`time`" . DB_OFFSET . ")) as `year`, MONTH(FROM_UNIXTIME(`time`" . DB_OFFSET . ")) as `month`, DAY(FROM_UNIXTIME(`time`" . DB_OFFSET . ")) as `day` FROM `" . DTP . "tweets` WHERE `time`";
            $pTQ = $db->query($half . " < '" . $db->s($first) . "' ORDER BY `time` DESC LIMIT 1");
            $nTQ = $db->query($half . " > '" . $db->s($last) . "' ORDER BY `time` ASC LIMIT 1");
            if ($db->numRows($pTQ) > 0) {
                $prevTweet = $db->fetch($pTQ);
                $nextprev .= "<a class=\"prev\" href=\"" . $path . "/" . s($prevTweet['year']) . "/" . s(pad($prevTweet['month'])) . "/" . s(pad($prevTweet['day'])) . "\">&larr; <span>" . date("F jS", mktime(4, 0, 0, $prevTweet['month'], $prevTweet['day'], $prevTweet['year'])) . "</span></a> ";
            }
            if ($db->numRows($nTQ) > 0) {
                $nextTweet = $db->fetch($nTQ);
                $nextprev .= "<a class=\"next\" href=\"" . $path . "/" . s($nextTweet['year']) . "/" . s(pad($nextTweet['month'])) . "/" . s(pad($nextTweet['day'])) . "\"><span>" . date("F jS", mktime(4, 0, 0, $nextTweet['month'], $nextTweet['day'], $nextTweet['year'])) . "</span> &rarr;</a>";
            }
            if ($nextprev) {
                $s .= $t . "<div class=\"nextprev\">" . trim($nextprev) . "</div>\n";
            }
        }
    } else {
        $s = $t . "<div class=\"notweets\">No tweets here!</div>\n";
        if ($home) {
            $s .= $t . "<p>If you have <strong>just installed</strong> Tweet Nest and this is your archive page, you need to load in your tweets before something will be displayed here. Check out the installation guide on the <a href=\"http://pongsocket.com/tweetnest/\">web site for Tweet Nest</a> for more information.</p>\n";
        }
    }
    return $s;
}
예제 #25
0
    $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
    $mail_lines = file('../private/mail/employer_general_invoice.txt');
    $message = '';
    foreach ($mail_lines as $line) {
        $message .= $line;
    }
    $message = str_replace('%employer%', $employer->getName(), $message);
    $message = str_replace('%invoice%', pad($invoice[0]['id'], 11, '0'), $message);
    $message = str_replace('%currency%', $currency, $message);
    $message = str_replace('%amount%', $amount_payable, $message);
    $message = str_replace('%issued_on%', sql_date_format($invoice[0]['issued_on']), $message);
    $message = str_replace('%payable_by%', sql_date_format($invoice[0]['payable_by']), $message);
    $body .= $message . "\n";
    $body .= '--yel_mail_sep_alt_' . $invoice[0]['id'] . "--\n\n";
    $body .= '--yel_mail_sep_' . $invoice[0]['id'] . "\n";
    $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice[0]['id'], 11, '0') . '.pdf"' . "\n";
    $body .= 'Content-Transfer-Encoding: base64' . "\n";
    $body .= 'Content-Disposition: attachment' . "\n";
    $body .= $attachment . "\n";
    $body .= '--yel_mail_sep_' . $invoice[0]['id'] . "--\n\n";
    mail($recipients, $subject, $body, $headers);
    /*$handle = fopen('/tmp/email_to_'. $recipients. '.txt', 'w');
      fwrite($handle, 'Subject: '. $subject. "\n\n");
      fwrite($handle, $body);
      fclose($handle);*/
    @unlink($GLOBALS['data_path'] . '/general_invoices/' . $invoice[0]['id'] . '.pdf');
    echo 'ok';
    exit;
}
if ($_POST['action'] == 'get_employers') {
    $criteria = array('columns' => "DISTINCT employers.id, employers.name", 'joins' => "employers ON employers.id = invoices.employer");
예제 #26
0
    $result = $mysqli->query($query);
    if (count($result) <= 0 || is_null($result)) {
        echo '0';
        exit;
    }
    if (!$result) {
        echo 'ko';
        exit;
    }
    $i = 0;
    $rewards = array();
    foreach ($result as $row) {
        $paid = ReferralReward::get_sum_paid_of_referral($row['referral']);
        if ($paid[0]['amount'] <= 0 || is_null($paid)) {
            //$row['member'] = htmlspecialchars_decode($row['member']);
            $row['padded_invoice'] = pad($row['invoice'], 11, '0');
            $row['total_token_reward'] = number_format($row['total_token_reward'], 2, '.', ', ');
            $rewards[$i] = $row;
            $i++;
        }
    }
    if (count($rewards) <= 0 || is_null($rewards)) {
        echo '0';
        exit;
    }
    $response = array('rewards' => array('reward' => $rewards));
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array($response);
    exit;
}
if ($_POST['action'] == 'get_fully_paid') {
예제 #27
0
         $body .= '--yel_mail_sep_alt_' . $filename . "\n";
         $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
         $body .= 'Content-Transfer-Encoding: 7bit"' . "\n";
         $mail_lines = file('../private/mail/employer_credit_note.txt');
         $message = '';
         foreach ($mail_lines as $line) {
             $message .= $line;
         }
         $message = str_replace('%company%', $employer->get_name(), $message);
         $message = str_replace('%previous_invoice%', pad($previous_invoice, 11, '0'), $message);
         $message = str_replace('%new_invoice%', pad($invoice, 11, '0'), $message);
         $message = str_replace('%job_title%', $job_title, $message);
         $body .= $message . "\n";
         $body .= '--yel_mail_sep_alt_' . $filename . "--\n\n";
         $body .= '--yel_mail_sep_' . $filename . "\n";
         $body .= 'Content-Type: application/pdf; name="yel_credit_note_' . pad($invoice, 11, '0') . '.pdf"' . "\n";
         $body .= 'Content-Transfer-Encoding: base64' . "\n";
         $body .= 'Content-Disposition: attachment' . "\n";
         $body .= $attachment . "\n";
         $body .= '--yel_mail_sep_' . $filename . "--\n\n";
         mail($employer->get_email_address(), $subject, $body, $headers);
         unlink($GLOBALS['data_path'] . '/credit_notes/' . $filename . '.pdf');
     }
 }
 // 2.4 If it is a replacement, update both referrals to disable future replacements.
 if ($is_replacement) {
     $queries = "UPDATE referrals SET \n                    replaced_on = '" . now() . "', \n                    replaced_referral = " . $_POST['id'] . " \n                    WHERE id = " . $previous_referral . "; \n                    UPDATE referrals SET \n                    guarantee_expire_on = '" . $today . "', \n                    replacement_authorized_on = NULL, \n                    replaced_on = '" . now() . "', \n                    replaced_referral = " . $_POST['id'] . " \n                    WHERE id = " . $_POST['id'];
     if (!$mysqli->transact($queries)) {
         echo 'ko';
         exit;
     }
예제 #28
0
 static function sort($flip = true)
 {
     $visible = get('visible');
     $invisible = get('invisible');
     $errors = array();
     if (empty($visible) && empty($invisible)) {
         return array('status' => 'error', 'msg' => l::get('pages.errors.nosort'));
     }
     if (!empty($visible)) {
         $cnt = count($visible);
         $len = str::length($cnt);
         $num = 0;
         if ($len <= 1) {
             $len = 2;
         }
         if ($flip) {
             $visible = array_reverse($visible);
         }
         foreach ($visible as $uid) {
             $num++;
             $sort = self::changeNum($uid, pad($num, $len));
             if (error($sort)) {
                 $errors[] = $sort;
             }
         }
     }
     if (!empty($invisible)) {
         foreach ($invisible as $uid) {
             $sort = self::removeNum($uid);
             if (error($sort)) {
                 $errors[] = $sort;
             }
         }
     }
     if (!empty($errors)) {
         return array('status' => 'error', 'msg' => l::get('pages.errors.sort'), 'error' => $errors);
     }
     self::killCache();
     return array('status' => 'success', 'msg' => l::get('pages.sorted'));
 }
예제 #29
0
 function get_nomor_renbut($tanggal)
 {
     $sql = "select substr(kode,10,4) as kode from rencana_kebutuhan where kode != '' and tanggal_renbut like '" . $tanggal . "%' order by kode desc limit 1";
     $row = $this->db->query($sql)->row();
     //echo $sql;
     if (!isset($row->kode)) {
         $nomor = 0;
     } else {
         $nomor = $row->kode;
     }
     return 'RBT' . str_replace('-', '', $tanggal) . pad($nomor + 1, 4);
 }
예제 #30
0
파일: form.php 프로젝트: raylouis/kvwebme
/**
  * This function adds the answer fields to the form 
  * and the radio buttons to select the correct answer
  *
  * @param int $num The index of the answer
  *
  * @return string: Input fields and radio buttons for the answers to be entered
*/
function addAnswer($num)
{
    global $questionID;
    global $question;
    $returnString = '<td>';
    $returnString = $returnString . '<input type="text" name="answers[]"';
    if (isset($_POST['answers']) && isset($_POST['questionErrors'])) {
        $answers = $_POST['answers'];
        $i = $num - 1;
        if (!empty($answers[$i])) {
            $returnString = $returnString . ' value="';
            $returnString = $returnString . htmlspecialchars($answers[$i]) . '"';
        }
    }
    if ($questionID) {
        $key = 'answer' . $num;
        $returnString = $returnString . 'value="';
        foreach ($question as $q) {
            $returnString = $returnString . $q[$key];
            $returnString = $returnString . '"';
        }
    }
    $returnString = $returnString . '/>';
    $returnString = $returnString . pad();
    $returnString = $returnString . '</td>';
    $returnString = $returnString . '<td>';
    $returnString = $returnString . '<input type="radio"';
    $returnString = $returnString . 'name="isCorrect"';
    $returnString = $returnString . 'value="' . $num . '"';
    if ($questionID) {
        foreach ($question as $q) {
            $correctAnswer = $q['correctAnswer'];
            if ($num == $correctAnswer) {
                $returnString = $returnString . 'checked';
            }
        }
    }
    $returnString = $returnString . '/>';
    $returnString = $returnString . '</td>';
    return $returnString;
}