示例#1
0
    function __construct($path)
    {
        $chanbar = '				<ul>
						<li id="settings" class="option"><a href="#" class="button">settings</a></li>
						<li id="files" class="option"><a href="#" class="button">files</a></li>
						<li id="people" class="option"><a href="#" class="button">people</a></li>
						</ul>
						';
        $user = Auth::user();
        $curchan = DB::get()->val('SELECT name from channels where user_id = :user_id AND active = 1', array('user_id' => $user->id));
        if ($curchan == '') {
            $curchan = 'bar';
        }
        $widgets = Widgets::get_widgets();
        $components = array('title' => 'Barchat Home', 'path' => $path, 'chanbar' => $chanbar, 'user_id' => Auth::user_id(), 'username' => $user->username, 'nickname' => $user->nickname, 'session_key' => $user->session_key, 'cur_chan' => addslashes($curchan), 'widgets' => $widgets);
        $v = new View($components);
        Plugin::call('reload', $user);
        //check for user agent
        $useragent = $_SERVER['HTTP_USER_AGENT'];
        //
        if (preg_match('/ip(hone|od|ad)/i', $useragent)) {
            $v->render('template-ios');
        } else {
            $v->render('template');
        }
    }
示例#2
0
    function header($header)
    {
        $toolpanelwidth = DB::get()->val("SELECT value FROM options WHERE user_id = :user_id AND grouping = 'Interface' AND name = 'toolpanel';", array('user_id' => Auth::user_id()));
        $header .= <<<HEADER
<script type="text/javascript">
\$(function(){
\tgetToolpanel({$toolpanelwidth});
\t\$('#drawer').width(\$(window).width() - {$toolpanelwidth} - 30);
});
</script>
HEADER;
        echo $header;
    }
示例#3
0
 function __construct()
 {
     //Instancia de Codeigniter
     self::$ci =& get_instance();
     //Instancia de Libreria ACL de Zend Framework
     self::$acl = new Acl();
     //Informacion del Usuario
     self::$user_id = self::$ci->session->userdata('id_usuario');
     //Recurso Actual
     self::$resource_name = self::$ci->uri->uri_string;
     //Verificar si la session existe
     self::check_session();
     //Inicializar permisos del usuario
     self::init_acl();
 }
示例#4
0
    function upload($path)
    {
        $access = DB::get()->assoc("SELECT name, value FROM options WHERE grouping = 'Amazon Web Services'");
        $s3 = new S3($access['AWS Access Key ID'], $access['AWS Secret Access Key']);
        $bucketname = $access['S3 Bucket Name'];
        $filename = $_FILES['uploaded']['name'];
        $s3filename = $this->_safestring(Auth::user()->username) . '/' . date('YmdHis') . '/' . $filename;
        preg_match('%\\.(\\w+)$%', $filename, $matches);
        $filetype = $matches[1];
        $s3->putObject(S3::inputFile($_FILES['uploaded']['tmp_name']), $bucketname, $s3filename, S3::ACL_PUBLIC_READ, array(), array("Content-Type" => "application/octet-stream", "Content-Disposition" => "attachment; filename=" . urlencode($filename) . ';'));
        //echo "Put {$filename} to {$bucketname} at {$s3filename}\n";
        $url = "http://{$bucketname}.s3.amazonaws.com/{$s3filename}";
        DB::get()->query("INSERT INTO files (user_id, filename, filesize, filetype, url) VALUES (:user_id, :filename, :filesize, :filetype, :url);", array('user_id' => Auth::user_id(), 'filename' => $filename, 'filesize' => $_FILES['uploaded']['size'], 'filetype' => $filetype, 'url' => $url));
        $filenumber = DB::get()->lastInsertId();
        echo <<<RELOAD_FILES
atbottom = isVisible(\$('#notices tr:last-child'));
\$('#filelisting').load('/files/filelist', function(){
\t\$('body').css('margin-bottom', \$('#command').height() + 15);
\tdo_scroll();
});
send('/file {$filenumber}');
RELOAD_FILES;
    }
示例#5
0
    function save($path)
    {
        $options = DB::get()->results('SELECT * FROM options WHERE user_id = 0 OR user_id = :user_id', array('user_id' => Auth::user_id()));
        foreach ($options as $option) {
            if ($option->istoggle) {
                if (isset($_POST['option'][$option->id])) {
                    DB::get()->query('UPDATE options SET value = 1 WHERE id = :id', array('id' => $option->id));
                } else {
                    DB::get()->query('UPDATE options SET value = 0 WHERE id = :id', array('id' => $option->id));
                }
            } elseif ($option->ispassword) {
                if (isset($_POST['option'][$option->id]) && !preg_match('%^\\*+$%', $_POST['option'][$option->id])) {
                    DB::get()->query('UPDATE options SET value = :value WHERE id = :id', array('id' => $option->id, 'value' => $_POST['option'][$option->id]));
                }
            } else {
                if (isset($_POST['option'][$option->id])) {
                    DB::get()->query('UPDATE options SET value = :value WHERE id = :id', array('id' => $option->id, 'value' => $_POST['option'][$option->id]));
                }
            }
        }
        echo <<<JSOUT
<script type="text/javascript">window.parent.\$('#options').slideToggle('fast');</script>
JSOUT;
    }
示例#6
0
 /**
  *
  *	Create the cart array if it doesn't already exist
  *
  **/
 private static function create_cart()
 {
     if (!isset($_SESSION[Config::$sitename]['cart'][Auth::user_id()])) {
         $_SESSION[Config::$sitename]['cart'][Auth::user_id()] = array();
     }
 }
示例#7
0
<?php

#1. LOGIC
Auth::kickout('/pokecart/');
$comment = new Comment();
$comment->load(Route::param('id'));
if ($comment->user_id == Auth::user_id()) {
    if (Input::posted()) {
        $comment->content = Input::get('message');
        $comment->save();
        URL::restore();
    }
}
Sticky::set('message', $comment->content);
#2. LOAD VIEWS
include VIEWS . 'header.php';
include VIEWS . 'edit_comment.php';
include VIEWS . 'footer.php';
示例#8
0
    function _get_search_sql(&$sql, &$params, $crit, $fortitle = false)
    {
        $where = <<<DEFAULT_WHERE
((user_to = 0)
OR
(user_to = :user_id)
OR
(presence.user_id = :user_id))
DEFAULT_WHERE;
        $criteria = array();
        $limited = false;
        $limit = '';
        $title = '';
        if (preg_match('%date\\s*=\\s*(?P<date>("[^"]+"|\\S+))%i', $crit, $datematches)) {
            $crit = preg_replace('%date\\s*=\\s*(?P<date>("[^"]+"|\\S+))%i', '', $crit);
            $date = trim($datematches['date'], '"');
            $df = date('Y-m-d', strtotime($date));
            $dt = date('Y-m-d', strtotime($date) + 86400);
            $where .= ' AND (presence.msgtime >= :fromtime) AND (presence.msgtime < :totime)';
            $params['fromtime'] = $df;
            $params['totime'] = $dt;
            $criteria[] = 'On ' . date('D, M j, Y', strtotime($df));
            $limited = true;
            $title = $df;
        }
        if (preg_match('%(channel|room)\\s*=\\s*(?P<channel>("[^"]+"|\\S+))%i', $crit, $channelmatches)) {
            $channel = $channelmatches['channel'];
            $crit = preg_replace('%(channel|room)\\s*=\\s*(?P<channel>("[^"]+"|\\S+))%i', '', $crit);
            $where .= ' AND (presence.channel = :channel)';
            $params['channel'] = $channel;
            $criteria[] = 'In channel "' . htmlspecialchars($channel) . '"';
            $title = htmlspecialchars($channel);
        }
        if ($allowedchannels = DB::get()->col("SELECT room FROM options WHERE grouping = 'Permissions' AND name = 'allowedchannel' AND user_id = :user_id", array('user_id' => Auth::user_id()))) {
            $inclause = DB::inclause($allowedchannels, 'allowed');
            $where .= ' AND (presence.channel IN (' . implode(',', array_keys($inclause)) . '))';
            $params = array_merge($params, $inclause);
        }
        if ($deniedchannels = DB::get()->col("SELECT room FROM options WHERE grouping = 'Permissions' AND name = 'deniedchannel' AND user_id = :user_id", array('user_id' => Auth::user_id()))) {
            $inclause = DB::inclause($deniedchannels, 'denied');
            $where .= ' AND (presence.channel NOT IN (' . implode(',', array_keys($inclause)) . '))';
            $params = array_merge($params, $inclause);
        }
        if (preg_match('%(type)\\s*=\\s*(?P<type>("[^"]+"|\\S+))%i', $crit, $typematches)) {
            $type = $typematches['type'];
            $crit = preg_replace('%(type)\\s*=\\s*(?P<type>("[^"]+"|\\S+))%i', '', $crit);
            $where .= ' AND (presence.type = :type)';
            $params['type'] = $type;
            $criteria[] = 'Message type "' . htmlspecialchars($type) . '"';
            $title = htmlspecialchars($type);
        }
        if (trim($crit) != '') {
            $where .= " AND data LIKE CONCAT('%', :crit, '%')";
            $params['crit'] = trim($crit);
            $criteria[] = '"' . htmlspecialchars(trim($crit)) . '"';
            $title = htmlspecialchars(trim($crit));
        } else {
            if (!$limited) {
                $limit = 'LIMIT 100';
                $criteria[] = 'Last 100 messages';
            }
        }
        $sql = <<<SEARCH_SQL
SELECT
\tpresence.status,
\tpresence.type,
\tpresence.data,
\tpresence.msgtime,
\tpresence.user_id,
\tpresence.cssclass,
\tpresence.js,
\tpresence.user_to,
\tpresence.received,
\tpresence.channel as inchannel,
\t:searchchannel as channel,
\tusers.username,
\toptions.value as nickname,
\t:crit as crit
FROM
\tpresence
LEFT JOIN
\tusers
\tON presence.user_id = users.id
LEFT JOIN
\toptions
\tON options.user_id = users.id AND options.name = 'Nickname' AND options.grouping = 'Identity'
WHERE
\t{$where}
ORDER BY
\tinchannel DESC,
\tstatus DESC
{$limit}
SEARCH_SQL;
        if ($fortitle) {
            return $title;
        } else {
            return implode(' &middot ', $criteria);
        }
    }
示例#9
0
<?php

# new_task.php
# 1. logic
$project = new Project();
$project->load(['slug' => Route::param('slug')]);
if (Input::posted()) {
    $task = new Task();
    $task->fill(Input::all());
    $task->user_id = Auth::user_id();
    $task->project_id = $project->id;
    if (Input::get('name') != "" || Input::get('description') != "") {
        $task->save();
    }
}
URL::redirect('/' . $project->slug);
示例#10
0
 public static function get($grouping, $name)
 {
     $sql = "SELECT * FROM options WHERE grouping = :grouping AND name = :name AND (user_id = 0 OR user_id = :user_id) ORDER BY user_id DESC;";
     return DB::get()->row($sql, array('grouping' => $grouping, 'name' => $name, 'user_id' => Auth::user_id()), __CLASS__);
 }
示例#11
0
<?php

# controllers/user.php
# Logic
if (!Auth::is_logged_in()) {
    Auth::kickout('/login');
}
$user = new User();
$user->load(Auth::user_id());
## ------------------------------------------------------------------------
$unpaidaccounts = new Accounts_Collection();
$unpaidaccounts->where('paid', '0');
$unpaidaccounts->where('confirmed', '0');
$unpaidaccounts->where('deleted', '0');
$unpaidaccounts->where('user_id', Auth::user()->id);
$unpaidaccounts->get();
$bills = new Bills_Collection();
$bills->where('deleted', '0');
$bills->where('paid', '0');
foreach ($unpaidaccounts->items as $key => $ua) {
    $bills->where('id', $ua->bill_id, true, $key != 0);
}
$bills->order_by('date', 'asc');
if (count($unpaidaccounts->items)) {
    $bills->get();
}
$total = 0;
foreach ($bills->items as $bill) {
    $total += $bill->splitcost;
}
## ------------------------------------------------------------------------
示例#12
0
<?php

Auth::kickout('/pokecart/product/' . Route::param('id') . '/view');
$comment = new Comment();
$comment->content = Input::get('message');
$comment->product_id = Route::param('id');
$comment->user_id = Auth::user_id();
$comment->date_time = date('Y-m-d H:i:s');
$comment->save();
URL::redirect('/pokecart/product/' . Route::param('id') . '/view');
示例#13
0
 function _state_task($list, $taskid, $state = 0)
 {
     $tasks = $this->_get_tasks($list);
     $tasks[$taskid]['state'] = $state;
     switch ($state) {
         case 1:
             $tasks[$taskid]['completed'] = time();
             break;
     }
     DB::get()->query("DELETE FROM options WHERE grouping = 'tasklists' AND name = :name AND user_id = :user_id", array('name' => $list, 'user_id' => Auth::user_id()));
     DB::get()->query("INSERT INTO options (grouping, name, user_id, value) VALUES ('tasklists', :name, :user_id, :value);", array('name' => $list, 'user_id' => Auth::user_id(), 'value' => serialize($tasks)));
 }
示例#14
0
# new_project.php
# 1. logic
AUTH::kickout('login');
$projects = new Projects_Collection();
$projects->where(['deleted' => '0']);
$projects->where(['user_id' => AUTH::user_id()]);
$projects->get();
if (Input::posted()) {
    $slug = Input::get('project_name');
    $slug = strtolower($slug);
    $slug = explode(" ", $slug);
    $slug = implode("-", $slug);
    $deadline = Input::get('deadline');
    $deadline = intval($deadline);
    $project = new project();
    $project->fill(Input::all());
    $project->date = date('Y-m-d H:i:s');
    $project->slug = $slug;
    $project->user_id = Auth::user_id();
    if (Input::get('project_name') != "" || Input::get('project_description') != "") {
        $project->save();
        URL::redirect('/' . $project->slug);
    }
    URL::redirect('/new_project');
}
$title = 'New Project';
# 2. views
include VIEWS . 'header.php';
include VIEWS . 'new_project.php';
include VIEWS . 'footer.php';
示例#15
0
				
				<div class="thumbnail comment">
					<h3><?php 
echo ucfirst($comment->author->username);
?>
</h3>
					<p>at <?php 
echo date('g:ia y/m/d', strtotime($comment->date_time));
?>
</p>
					<p><?php 
echo $comment->content;
?>
</p>	
				
				<? if(Auth::user_id() == $comment->user_id) : ?>
				
					
						<a href="/pokecart/delete_comment/<?php 
echo $comment->id;
?>
" class="white btn btn-danger">Delete</a>
					
					
						<a href="/pokecart/edit_comment/<?php 
echo $comment->id;
?>
" class="white btn btn-success">Edit</a>
					
			
				<? endif; ?>
示例#16
0
 function autocomplete($auto, $cmd)
 {
     // Get the list of projects by most logged hours
     // select p.uri from project_projects p left join (select t.pid, sum(t.hours) as hours from project_issue_time t where t.uid = 13 and created > unix_timestamp(date_sub(now(), interval 21 month)) group by t.pid) t2 on t2.pid = p.nid order by t2.hours desc, p.uri asc;
     if (preg_match('/^@(?P<time>\\s*(\\d*:\\d{2})|\\s*(\\d*(?:\\.\\d{1,2})?))/i', $cmd, $timematch)) {
         $projects = $this->_get_projects();
         $aliases = DB::get()->col("SELECT name FROM options where user_id = :user_id and grouping = 'time alias'", array('user_id' => Auth::user_id()));
         $projects = array_merge($projects, $aliases);
         if (strpos($timematch['time'], ':') === 0) {
             $task = 'task for ' . substr($timematch['time'], 1) . ' minutes';
         } elseif (strpos($timematch['time'], ':') > 0) {
             $task = 'task started at ' . $timematch['time'];
         } else {
             $task = 'task for';
             if (floor($timematch['time']) > 0) {
                 $task .= ' ' . floor($timematch['time']) . ' hours';
             }
             if (round(60 * ($timematch['time'] - floor($timematch['time']))) > 0) {
                 $task .= ' ' . round(60 * ($timematch['time'] - floor($timematch['time']))) . ' minutes';
             }
         }
         foreach ($projects as $project) {
             $auto[] = '@' . $timematch['time'] . ' ' . $project . " \t{$task}";
         }
     }
     if (preg_match('/^@@(?P<time>\\s*(\\d*:\\d{1,2})|\\s*(\\d+(?:\\.\\d{1,2})?))/i', $cmd, $timematch)) {
         $projects = $this->_get_projects();
         $aliases = DB::get()->col("SELECT name FROM options where user_id = :user_id and grouping = 'time alias'", array('user_id' => Auth::user_id()));
         $projects = array_merge($projects, $aliases);
         if (strpos($timematch['time'], ':') === 0) {
             $task = 'instant task for ' . substr($timematch['time'], 1) . ' minutes';
         } elseif (strpos($timematch['time'], ':') > 0) {
             list($hours, $minutes) = split(':', $timematch['time']);
             $task = "instant task for {$hours} hours {$minutes} minutes";
         } else {
             $task = 'instant task for';
             if (floor($timematch['time']) > 0) {
                 $task .= ' ' . floor($timematch['time']) . ' hours';
             }
             if (round(60 * ($timematch['time'] - floor($timematch['time']))) > 0) {
                 $task .= ' ' . round(60 * ($timematch['time'] - floor($timematch['time']))) . ' minutes';
             }
         }
         foreach ($projects as $project) {
             $auto[] = '@@' . $timematch['time'] . ' ' . $project . " \t{$task}";
         }
     } else {
         if ($cmd[0] == '@') {
             $projects = $this->_get_projects();
             $aliases = DB::get()->col("SELECT name FROM options where user_id = :user_id and grouping = 'time alias'", array('user_id' => Auth::user_id()));
             $projects = array_merge($projects, $aliases);
             foreach ($projects as $project) {
                 $auto[] = '@' . $project . " \ttask begins now";
             }
         }
     }
     return $auto;
 }