Beispiel #1
0
/**
	List all files in a directory and store various informations about them in the resulting array.

	@param $sPath Path to the directory to list.
	@param $aMimeIcons List of icons for each known mime types.
	@return array The verbose list of files.
	@todo links pointing to nothing fail
	@todo handle empty $aMimeIcons properly
*/
function fs_list_directory_contents($sPath, $aMimeIcons = array())
{
    try {
        $oDirectory = new DirectoryIterator($sPath);
    } catch (Exception $e) {
        // The folder doesn't exist, so there is no files to list.
        return array();
    }
    $oFileInfo = new finfo(FILEINFO_MIME);
    $aFiles = array();
    foreach ($oDirectory as $oFile) {
        if ($oFile->isDot()) {
            continue;
        }
        $sFilename = $oFile->getFilename();
        $sExt = strrchr($sFilename, '.');
        $iSize = $oFile->getSize();
        $sMimeType = $oFileInfo->file($oFile->getRealPath());
        $iMTime = $oFile->getMTime();
        // Folder is preferred
        if ($sMimeType == 'directory') {
            $sMimeType = 'folder';
        }
        $aFiles[$sFilename] = array('icon' => ui_mime_to_icon($sMimeType, $aMimeIcons), 'filename' => $sFilename, 'ext' => $sExt === false ? null : substr($sExt, 1), 'size' => $iSize, 'husize' => human_size($iSize), 'mimetype' => $sMimeType, 'mtime' => $iMTime, 'humtime' => human_date($iMTime));
    }
    ksort($aFiles);
    return $aFiles;
}
function format_datetime($format, $date_time)
{
    $date_time = mysql_to_unix($date_time);
    if ($format == 'ELAPSED') {
        $return = elapsed_date($date_time) . ' ago';
    } else {
        $return = human_date($format, $date_time);
    }
    return $return;
}
Beispiel #3
0
 function get_sites()
 {
     $query = $this->db->get($this->table_blogs);
     if ($query->num_rows() > 0) {
         $result = $query->result_array();
         foreach (array_keys($result) as $key) {
             $result[$key]['blog_registered'] = human_date($result[$key]['blog_registered']);
             $result[$key]['blog_last_updated'] = human_date($result[$key]['blog_last_updated']);
         }
         return $result;
     }
 }
Beispiel #4
0
<?php 
} else {
    ?>
    <h2 class="title icon-<?php 
    echo $event->getIcon();
    ?>
"><?php 
    echo $event;
    ?>
</h2>
<?php 
}
?>

<h2 class="event-fire-at"><?php 
echo human_date($event->getFireAt(), true);
?>
</h2>

<p class="estimate-time"><?php 
echo distance_of_time_in_words(time(), strtotime($event->getFireAt()));
?>
 до начала</p>

<?php 
if ($description = $event->getDescription()) {
    ?>
    <p class="point-desc"><?php 
    echo nl2br($description);
    ?>
</p>
Beispiel #5
0
                <div class="media">
                  <div class="media-left">
                    <a href="#">
                      <img class="media-object" src="<?php 
                echo base_url('views/frontend/default/assets/img/noavatar.jpg');
                ?>
" alt="...">
                    </a>
                  </div>
                  <div class="media-body">
                    <h4 class="media-heading"><?php 
                echo $comment['comment_author'];
                ?>
</h4>
                    <p>at <?php 
                echo human_date($comment['comment_date']);
                ?>
</p>
                    <p><?php 
                echo $comment['comment_content'];
                ?>
</p>
                  </div>
                </div>
                <?php 
            }
            ?>
                </div>
                <?php 
        }
        ?>
function fetch_library($userid)
{
    $stored = cache_fetch($userid, 'user');
    if ($stored !== false) {
        return $stored;
    }
    global $message;
    $codes = array();
    $db = getdb();
    if (!$db) {
        return $codes;
    }
    $sql = 'select now() as now, m.*, u.editable from ' . DB_TABLE . ' m, ' . DB_TABLE . '_users u where u.codeid = m.codeid and u.userid = \'' . $db->escape_string($userid) . '\' order by m.updated desc limit 100';
    $res = $db->query($sql);
    if ($res) {
        require_once 'mapbbcode.php';
        while ($row = $res->fetch_assoc()) {
            $item = array();
            $item['codeid'] = $row['codeid'];
            $item['editid'] = $row['editable'] ? $row['editid'] : '';
            $item['created'] = human_date($row['created'], $row['now']);
            $item['updated'] = human_date($row['updated'], $row['now']);
            $item['title'] = $row['title'];
            $item['stats'] = mapbbcode_stats($row['bbcode']);
            $codes[] = $item;
        }
        $res->free();
        cache_put($userid, 'user', $codes);
    } else {
        $message = 'Failed to retrieve user library: ' . $db->error;
    }
    return $codes;
}
Beispiel #7
0
            ?>
"><?php 
            echo $cat['category_name'];
            ?>
</a>,
        			<?php 
        }
        ?>
                by <a href="#"><?php 
        echo $post['user_display_name'];
        ?>
</a>, at <a href="<?php 
        echo $post['post_permalink'];
        ?>
"><?php 
        echo human_date($post['post_date']);
        ?>
</a>, Comments: <?php 
        echo $post['comment_count'];
        ?>
				</p>
				<p><?php 
        echo $post['post_excerpt'];
        ?>
</p>
				<p>
					<a href="<?php 
        echo $post['post_permalink'];
        ?>
"><i class="fa fa-external-link"></i> Read more</a>
				</p>
Beispiel #8
0
function get_files_info($files, $dir = null) {
    if (!count($files)) return array();

    if (!isset($dir)) $dir = $_SESSION['DIR'];
    $old_dir = getcwd();
    if (!chdir($dir)) return d_error('Cannot change directory');
    $result = array();
    $sizes = array();
    // a more reliable way of computing size
    if (is_callable('exec') && in_array(php_uname('s'), array('Linux', 'FreeBSD', 'Darwin'))) {
        $filepaths = array();
        foreach ($files as $f) $filepaths[] = escapeshellarg('./' . $f);
        exec("stat -f '%z' " . implode(' ', $filepaths), $out, $retval);
        if ($retval == 0 && count($out) == count($files)) {
            foreach ($out as $i => $sz) {
                $sizes[$files[$i]] = $sz;
            }
        }
    }

    foreach ($files as $f) {
        $result[$f] = array(
            'modified' => human_date(filemtime($f)),
            'size'     => show_size($f, true, isset($sizes[$f]) ? $sizes[$f] : filesize($f)),
            'type'     => is_dir($f) ? 'dir' : 'file',
        );
    }
    chdir($old_dir);
    return $result;
}
Beispiel #9
0
<div class="author">
    <?php 
echo avatar($post);
?>
<br/>
    <strong><a href="<?php 
echo site_url('user/profile/' . $post['login']);
?>
"><?php 
echo $post['login'];
?>
</a></strong><br/>
    <?php 
echo human_date($post['added_at']);
?>
<br/>
    <span class="icon icon-comment"></span> <a href="<?php 
echo post_link($post);
?>
#disqus_thread"></a>
</div>
Beispiel #10
0
function form_select_date($id, $date = '', $lang = 'russian', $today = '')
{
    $common = CI()->config->item('common');
    Asset::add_js($common['js'] . '/datepicker.js');
    add_css($common['css'] . '/datepicker/datepicker.css');
    $date = not_empty($date, date('d.m.Y'));
    $date = human_date($date);
    if (empty($page['laguage']) or $page['language'] == 'russian') {
        $locale = '
            locale: {
            days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
            daysShort: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
            daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
            months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
            monthsShort: ["Янв", "Фев", "Март", "Апр", "Май", "Июнь", "Июль", "Авг", "Сен", "Окт", "Нояб", "Дек"],
            weekMin: "№"
            },
        ';
    }
    $out = <<<DOT
<input name="{$id}" id="{$id}" type="text" class="input size100" value="{$date}" />
<script language="JavaScript" type="text/javascript">
\t\$(function() {
        \$('#{$id}').DatePicker({
            format:'d.m.Y',
            date: \$('#{$id}').val(),
            starts: 1,
            position: 'right',
            {$locale}
            onBeforeShow: function(){
                \$('#{$id}').DatePickerSetDate(\$('#{$id}').val(), true);
            },
            onChange: function(formated, dates){
                \$('#{$id}').val(formated);
            }
        });
\t});
</script>
DOT;
    return $out;
}
Beispiel #11
0
 function human_datetime_split($ts)
 {
     return human_time($ts) . '<BR>' . human_date($ts);
 }
 function comments()
 {
     $this->data['page_title'] = "Comments";
     $this->data['sub_title'] = "Recent";
     $this->data['navigation'] = $this->load->view(config_item('dashboard_theme') . '/partials/navigation_comments.php', $this->data, true);
     $comments = $this->social_tools->get_comments(config_item('site_id'), $this->session->userdata('user_id'), $this->uri->segment(3));
     $comments_view = NULL;
     $this->data['feed_type'] = 'comments';
     $this->data['item_verb'] = item_type($this->lang->line('object_types'), 'comment');
     if (empty($comments)) {
         $comments_view = '<li>No comments to show!</li>';
     } else {
         foreach ($comments as $comment) {
             // Item
             $this->data['item_id'] = $comment->comment_id;
             $this->data['item_type'] = item_type_class($comment->type);
             $this->data['item_viewed'] = item_viewed('item', $comment->viewed);
             // Contributor
             $this->data['item_avatar'] = $this->social_igniter->profile_image($comment->user_id, $comment->image, $comment->gravatar);
             $this->data['item_contributor'] = $comment->name;
             $this->data['item_profile'] = base_url() . 'profile/' . $comment->username;
             // Activity
             if ($comment->title) {
                 $this->data['item_article'] = '';
                 $this->data['item_object'] = $comment->title;
             } else {
                 $this->data['item_article'] = item_type($this->lang->line('object_articles'), $comment->type);
                 $this->data['item_object'] = $comment->type;
             }
             $this->data['item_text'] = item_linkify($comment->comment);
             $this->data['item_date'] = human_date('SIMPLE', mysql_to_unix($comment->created_at));
             $this->data['item_approval'] = $comment->approval;
             // Alerts
             $this->data['item_alerts'] = item_alerts_comment($comment);
             // Actions
             $this->data['item_view'] = base_url() . $comment->module . '/view/' . $comment->content_id . '/' . $comment->comment_id;
             $this->data['item_reply'] = base_url() . $comment->module . '/reply/id/' . $comment->content_id . '/' . $comment->comment_id;
             $this->data['item_approve'] = base_url() . 'api/comments/approve/id/' . $comment->comment_id;
             $this->data['item_delete'] = base_url() . 'api/comments/destroy/id/' . $comment->comment_id;
             // Load Partial For Items
             $comments_view .= $this->load->view(config_item('dashboard_theme') . '/partials/item_comments.php', $this->data, true);
         }
     }
     $this->data['comments_view'] = $comments_view;
     $this->render();
 }
Beispiel #13
0
/**
 * Коммент
 *
 * @param Comment $comment
 */
?>
<li class="comment" id="comment-<?php 
echo $comment->id;
?>
">
    <div class="desc">
        <?php 
echo link_to('<span>' . $comment->getUser()->getUsername() . '</span>', 'user_show', $comment->getUser(), array('class' => 'ajax userlink'));
?>

        <span class="date"><?php 
echo human_date($comment->getCreatedAt(), true);
?>
</span>
        <span class="action">
        <?php 
echo link_to_comment_delete($comment);
?>
        </span>
    </div>
    <div class="text">
        <?php 
echo simple_format_text($comment->getComment());
?>
    </div>
</li>