Пример #1
0
 /**
  * Implements \JsonSerializable interface
  *
  * @return array|mixed
  */
 public function jsonSerialize()
 {
     $array = $this->comment->export();
     if (!$this->radix->getContext()->getService('auth')->hasAccess('comment.see_ip')) {
         unset($array['poster_ip']);
     }
     if ($this->media !== null) {
         $array['media'] = $this->media->export();
     } else {
         $array['media'] = null;
     }
     $array['board'] = ['name' => $this->radix->name, 'shortname' => $this->radix->shortname];
     return $array;
 }
Пример #2
0
 static function mqRead($name, $want = 0, $wait = true)
 {
     $mq = msg_get_queue(self::_ftok($name));
     $type = null;
     // Recieved Message Type
     $size = 8192;
     // Max Message Size
     $mess = null;
     // Recieved Message Data
     $unser = true;
     $flags = 0;
     $error = null;
     if ($wait == false) {
         $flags |= MSG_IPC_NOWAIT;
     }
     if (msg_receive($mq, $want, $type, $size, $mess, $unser, $flags, $error)) {
         return $mess;
     }
     Radix::dump($mq);
     Radix::dump($want);
     Radix::dump($type);
     Radix::dump($size);
     Radix::dump($mess);
     Radix::dump($unser);
     Radix::dump($flags);
     Radix::dump($error);
     exit;
 }
Пример #3
0
        $arg[] = $q_term;
        // OR date = ? ';
}
$sql .= ' ORDER BY date DESC, kind DESC, account_journal_id, amount ';
$res = SQL::fetch_all($sql, $arg);
Session::flash('fail', SQL::lastError());
if (empty($res) || 0 == count($res)) {
    Session::flash('info', 'No Matching Transactions');
    return 0;
}
echo '<table>';
foreach ($res as $rec) {
    echo '<tr class="rero">';
    if ($rec['account_journal_id'] != $account_journal_id_x) {
        // Date
        echo '<td class="c"><a href="' . Radix::link('/account/transaction?id=' . $rec['account_journal_id']) . '">' . date('m/d/y', strtotime($rec['date'])) . '</a></td>';
        // Name & Note
        echo '<td>' . html($rec['note']) . '</td>';
        echo '</tr>';
        echo '<tr><td>&nbsp;</td>';
    } else {
        echo '<td>&nbsp;</td>';
    }
    echo '<td>' . $rec['account_full_name'] . '</td>';
    // echo $le['account_full_name'];
    // if (strlen($le->note)) {
    // echo ' <span class="s">(' .  $le->note  . ')</span>';
    // }
    // echo '</td>';
    // Journal Entry ID
    // echo '<td>' . $le->kind . $le->account_journal_id . '</td>';
Пример #4
0
 /**
 	AppModel Save
 	@todo use the _data interface, check for dirty
 */
 function save()
 {
     // Set Sane Defaults
     // if (empty($this->_data['auth_user_id'])) {
     //	 $this->_data['auth_user_id'] = $_SESSION['uid']; // $cu->id;
     // }
     // if (empty($this->_data['hash'])) $this->_data['hash'] = $this->hash();
     // Set some Fields to Null
     // if (empty($this->_data['link_to'])) $this->_data['link_to'] = null;
     // if (empty($this->_data['link_id'])) $this->_data['link_id'] = null;
     if (isset($this->_data['link_to'])) {
         if (empty($this->_data['link_to'])) {
             $this->_data['link_to'] = null;
         }
     }
     if (isset($this->_data['link_id'])) {
         if (empty($this->_data['link_id'])) {
             $this->_data['link_id'] = null;
         }
     }
     // Convert to Array
     // $rec = array();
     // foreach ($this->_properties as $k) {
     //	 if (empty($this->$k)) {
     //		 $rec[$k] = new Zend_Db_Expr('null');
     //	 } else {
     //		 $rec[$k] = $this->$k;
     //	 }
     // }
     // unset($rec['id']);
     $rec = array();
     foreach ($this->_data as $k => $v) {
         $rec[$k] = $v;
     }
     // @todo implement ts_vector
     // update vendors set fulltext = to_tsvector('english',name || ' ' || coalesce(description,''))
     if (isset($this->_properties['fulltext'])) {
         // Build Full Text
         // foreach ($this->_properties as $k=>$v) {
         //
         // }
     }
     if ($this->_data['id']) {
         // if ($this->_diff) Base_Diff::diff($this);
         SQL::update($this->_table, $rec, "id={$this->_data['id']}");
     } else {
         $this->_data['id'] = SQL::insert($this->_table, $rec);
         if (intval($this->_data['id']) == 0) {
             Radix::dump($this);
             Radix::dump(SQL::lastError());
             Radix::trace('Unexpected error saving: ' . get_class($this));
         }
         // if ($this->_diff) Base_Diff::diff($this);
     }
 }
Пример #5
0
echo Radix::block('account-period-input');
echo '</form>';
$cr_total = $dr_total = 0;
// Revenues
echo '<table class="w">';
echo '<tr class="ro"><th class="l" colspan="3" >Revenues</td></tr>';
foreach ($this->RevenueAccountList as $a) {
    $uri = Radix::link('/account/ledger?' . http_build_query(array('id' => $a['account_id'], 'd0' => $this->date_alpha, 'd1' => $this->date_omega)));
    echo '<tr class="rero">';
    //echo "<td style='padding-left: 2em;'>{$item->full_code}  {$item->account_name}</td>";
    echo '<td style="padding-left: 2em;"><a href="' . $uri . '">' . $a['full_code'] . ' ' . $a['full_name'] . '</a></td>';
    echo '<td>&nbsp;</td><td class="r">' . number_format($a['balance'], 2) . '</td>';
    echo '</tr>';
    $cr_total += $a['balance'];
}
echo "<tr class='ro'><td class='b'>Total Revenue:</td><td>&nbsp;</td><td class='b r u'>" . number_format($cr_total, 2) . "</td></tr>\n";
echo "<tr><td colspan='3'>&nbsp;</td></tr>\n";
// Expenses
echo '<tr class="ro"><th class="l" colspan="3" >Expenses</td></tr>';
foreach ($this->ExpenseAccountList as $a) {
    $uri = Radix::link('/account/ledger?' . http_build_query(array('id' => $a['account_id'], 'd0' => $this->date_alpha, 'd1' => $this->date_omega)));
    echo '<tr class="rero">';
    echo '<td style="padding-left: 2em;"><a href="' . $uri . '">' . $a['full_code'] . ' ' . $a['full_name'] . '</a></td>';
    echo "<td class='r'>" . number_format($a['balance'] * -1, 2) . '</td><td>&nbsp;</td>';
    echo '</tr>';
    $dr_total += $a['balance'];
}
echo '<tr class="ro"><td class="b" colspan="2">Total Expenses:</td><td class="b r u">' . number_format($dr_total * -1, 2) . "</td></tr>";
echo '<tr><td colspan="3">&nbsp;</td></tr>';
echo '<tr class="ro"><td class="b" colspan="2" style="border-top:1px solid #333;">Net Income:</td><td class="b r" style="border-top:1px solid #333;">' . number_format($cr_total + $dr_total, 2) . '</td></tr>';
echo '</table>';
Пример #6
0
 /**
     Create a new Route, routes are only process once (that is, no cascade/recurse)
 
     @param $src = the source path, regular expression (with capture)
     @param $dst = the destination path
     @param $arg = the by-ref argument of where to put the matched stuff
 */
 public static function route($src = null, $dst = null, &$arg = null)
 {
     // Accept the $src as RE, but escape only the '/'
     $src = str_replace('/', '\\/', $src);
     self::$_route_list[] = array('src' => $src, 'dst' => $dst, 'arg' => $arg);
     // @deprecated - over-rides existing pages/scripts cause it's in front
     //               we want routes to trigger if no Controller/View Found
     if (preg_match("/{$src}/i", $_SERVER['REQUEST_URI'], $m)) {
         Radix::$path = $dst;
         if ($arg !== null) {
             $arg = array_merge($arg, $m);
         } else {
             $_GET = array_merge($_GET, $m);
         }
     }
     // die( $src );
     // if (preg_match(
 }
Пример #7
0
// 	$this->view->title = array('File','Create',' #' . $f->link);
// }
$f = new Base_File($_POST['id']);
switch (strtolower($_POST['a'])) {
    case 'delete':
        $f->delete();
        Session::flash('info', 'File Deleted');
        Radix::redirect('/file');
        break;
    case 'upload':
        $f->copyPost($_FILES['file']);
        //if ($f) {
        //	$f['id'] = intval($_POST['id']);
        //	$f['link'] = $_POST['link'];
        //	$f->import($_FILES['file']);
        $f->save();
        Session::flash('info', 'File #' . $f['id'] . ' Saved');
        // } else {
        // 	Session::flash('fail', 'Invalid Input');
        // }
        break;
}
// Redirect Out
if (!empty($f['link'])) {
    if (preg_match('/(contact|invoice|workorder):(\\d+)/', $f['link'], $m)) {
        $page = '/' . $m[1] . '/view?' . substr($m[1], 0, 1) . '=' . $m[2];
        Radix::redirect($page);
    }
}
Radix::redirect('/file');
Пример #8
0
function mail_part_list($stat, $depth = null)
{
    if ($depth === null) {
        $depth = null;
    }
    $count = 1;
    // echo "Depth: $depth\n";
    if (empty($stat['parts'])) {
        return false;
    }
    // print_r($stat['parts']);
    // exit;
    $list = array();
    foreach ($stat['parts'] as $i => $chk) {
        // echo "Type: {$chk->type}\n";
        switch ($chk->type) {
            case TYPETEXT:
                // Text (0)
                switch (strtolower($chk->subtype)) {
                    case 'html':
                        $list["{$depth}{$count}"] = array('mime-type' => 'text/html');
                        break;
                    case 'plain':
                        $list["{$depth}{$count}"] = array('mime-type' => 'text/plain');
                        // Radix::dump($chk,true);
                        break;
                    default:
                        die('Unknonw SubType');
                }
                // Encoding?
                switch ($chk->encoding) {
                    case ENC7BIT:
                        $list["{$depth}{$count}"]['mime-encoding'] = '7bit';
                        break;
                    case ENC8BIT:
                        die("8bit\n");
                    case ENCBINARY:
                        die("Binary\n");
                    case ENCBASE64:
                        die("Base64");
                    case ENCQUOTEDPRINTABLE:
                    case 4:
                        // quoted-printable
                        $list["{$depth}{$count}"]['mime-encoding'] = 'quoted-printable';
                        break;
                    case ENCOTHER:
                        die('Other');
                    default:
                        print_r($stat['head']);
                        print_r($chk);
                        die('Unknown Encoding: ' . $chk->encoding);
                }
                break;
            case TYPEMULTIPART:
                // Multipart?
                switch (strtolower($chk->subtype)) {
                    case 'alternative':
                        // Radix::dump($chk,true);
                        $list["1"] = array('mime-type' => 'multipart/alternative');
                        $list += mail_part_list((array) $chk, "{$count}.");
                        break;
                    default:
                        Radix::dump($chk);
                        die("Unknown Multipart?\n");
                }
                break;
            case TYPEIMAGE:
                // Image, blindly accept
                $list["{$depth}{$count}"] = array('mime-type' => 'image/' . strtolower($chk->subtype));
                break;
            default:
                Radix::dump($chk);
                die("Unknown Type: {$chk->type}\n");
        }
        $count++;
    }
    return $list;
}
Пример #9
0
<?php

/**
    @file
    @brief File Controller
*/
$f = new Base_File(intval($_GET['id']));
if (!is_file($f['path'])) {
    Session::flash('fail', 'File not Found');
    Radix::redirect($_SERVER['HTTP_REFERER']);
}
// $this->force_download = true;
header('Cache-Control: private,must-revalidate,max-age=5', true);
//if (empty($this->force_download)) {
header('Content-Disposition: attachment; filename="' . $f['name'] . '"', true);
//} else {
//  header('Content-Disposition: inline; filename="' . $this->name . '"',true);
//}
header('Content-Length: ' . filesize($f['path']), true);
header('Content-Type: ' . $f['kind'], true);
$fh = fopen($f['path'], 'r');
fpassthru($fh);
exit(0);
Пример #10
0
        Radix::bail(500);
        $s = $this->_d->select();
        $s->from('contact', array('email as result', 'name as label'));
        $s->where('contact ~* ?', $q);
        $s->orWhere('company ~* ?', $q);
        $s->orWhere('name ~* ?', $q);
        $s->distinct();
        break;
    case 'kind':
        Radix::bail(500);
        $s = $this->_d->select();
        $s->from('contact', array('kind as result', 'kind as label'));
        $s->distinct();
        break;
    case 'status':
        Radix::bail(500);
        $s = $this->_d->select();
        $s->distinct();
        $s->from('contact', array('status as result', 'status as label'));
        break;
    default:
        $sql .= 'WHERE contact ~* ? OR company ~* ? OR name ~* ? OR email ~* ?';
        $arg[] = $q;
        $arg[] = $q;
        $arg[] = $q;
        $arg[] = $q;
        break;
}
$res = SQL::fetch_all($sql, $arg);
header('Content-Type: application/json');
die(json_encode($res));