Exemple #1
0
 public static function user_agents($start, $end)
 {
     $db = new Database();
     $sql = "select DISTINCT user_agent from zest_statistics where when_log > '{$start}' AND when_log < '{$end}'";
     $query = $db->query($sql)->result_array();
     //	print_r($query);
     //	exit;
     $array = array();
     foreach ($query as $q) {
         $count = $db->where(array('user_agent' => $q->user_agent, 'when_log >' => $start, 'when_log <' => $end))->count_records('statistics');
         if (zest::parse_user_agent($q->user_agent, 'is_browser')) {
             $browser = zest::parse_user_agent($q->user_agent, 'browser');
             $version = zest::parse_user_agent($q->user_agent, 'version');
             $version = explode('.', $version);
             $version = $version[0];
             $str = $browser . ' ' . $version;
             //		echo $str.' '.$count.'<br/>';
             if (isset($array[$str])) {
                 $count = $array[$str] + $count;
                 $array[$str] = $count;
             } else {
                 $array[$str] = $count;
             }
         }
     }
     arsort($array);
     //exit;
     return $array;
 }
 public function __technorati()
 {
     $html = "";
     $html .= '<p><a href="http://technorati.com/" target="_BLANK">What is technorati?</a></p>';
     if (isset($_POST['technorati'])) {
         $technorati_ping = ORM::factory('setting', 'technorati_ping');
         $technorati_ping->variable = 'technorati_ping';
         $technorati_ping->value = $_POST['technorati_ping'];
         $technorati_ping->save();
     }
     if (isset($_POST['technorati_ping_now'])) {
         zest::ping();
     }
     $html .= form::open(NULL);
     $html .= form::hidden('technorati', 'true');
     $html .= form::label('technorati_ping', 'Ping Technorati on feed update?');
     $options = array('yes' => 'yes', 'no' => 'no');
     $html .= form::dropdown('technorati_ping', $options, ORM::factory('setting', 'technorati_ping')->value, 'class="fullWidth"');
     $html .= form::submit('submit', 'Save', 'class="submit"') . '';
     $html .= form::close();
     $html .= form::open(NULL);
     $html .= form::hidden('technorati_ping_now', 'true');
     $html .= form::submit('submit', 'Ping Now', 'class="button"');
     $html .= form::close();
     return $html;
 }
Exemple #3
0
 /**
  * Returns the formatted html
  *
  * html example
  * e.g <h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer">&nbsp;</div>
  *
  * @param   array	$options	Options for the rendering array('count', 'date_format','image' = array($width,$height), 'word_count', 'html')
  * @return	string	$html		Formatted HTML
  */
 public function render_summary($options = null, $feedpost_options = null)
 {
     $array = array('per_page' => 5, 'pagination' => 'classic', 'template' => 'feed', 'html' => '{FEEDPOSTS}{PAGINATION}');
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['feed.summary'];
     }
     $array = arr::overwrite($array, $options);
     $uri = uri::instance();
     $page = $uri->segment('page', 1);
     $feedposts = "";
     $posts = $this->get_posts($array['per_page'], ($page - 1) * $array['per_page']);
     foreach ($posts as $post) {
         $feedposts .= $post->render_summary($feedpost_options);
     }
     $pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => count($this->get_posts()), 'items_per_page' => $array['per_page'], 'style' => $array['pagination']));
     if ($array['template'] != '') {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace("{RSS_LINK}", $this->get_rss(), $html);
     $html = str_replace("{FEEDPOSTS}", $feedposts, $html);
     $html = str_replace("{PAGINATION}", $pagination, $html);
     $html = str_replace("{FEED_LINK}", $this->get_url(), $html);
     return $html;
 }
Exemple #4
0
 public function get_template()
 {
     if (file_exists(DOCROOT . THEME_PATH . $this->template . '.html')) {
         $template = THEME_PATH . $this->template . '.html';
     } else {
         $template = DEFAULT_THEME_PATH . $this->template . '.html';
     }
     return zest::template_to_html($template);
 }
Exemple #5
0
 public function __list()
 {
     $html = "<ul style='list-style:none'>";
     $directory = APPPATH . '/views/snippets/';
     $files = zest::dir_to_array($directory);
     foreach ($files as $file) {
         $filename = str_replace('.zest', '', $file);
         $display_name = ucwords(str_replace('_', ' ', $filename));
         $html .= "<li style='padding-left:45px !important;' class='snippet'><div class='right'>&nbsp;" . html::anchor('admin/snippets/edit/' . $filename, html::image('zest/images/icon_pencil.png')) . "</div><span>" . $display_name . "</span></li>";
         // tidy up: close the handler
     }
     $html .= "</ul>";
     return $html;
 }
Exemple #6
0
 public function index()
 {
     $this->template->title = "Please login";
     $this->template->content = new View('zest/login_content');
     $version = zest::get_version(TRUE);
     $this->template->version = $version;
     $return = login::attempt_login();
     if (isset($return->id)) {
         if ($return->roles[0]->id == 4) {
             $this->template->message = "You do not have access to this area of the site";
         } else {
             url::redirect('admin');
         }
     } else {
         $this->template->message = $return;
     }
 }
 public function update()
 {
     // grab xml
     $items = zest::get_xml_entries($this->url);
     $this->last_updated = date('Y-m-d H:i:s');
     $this->save();
     $count = 0;
     if (!is_array($items)) {
     }
     foreach ($items as $item) {
         $values = array("title" => $item->title, "text" => $item->text, "pubDate" => date('Y-m-d H:i:s', strtotime($item->pubDate)), "permalink" => $item->link, "status_id" => $this->default_status, "external_feed_id" => $this->id);
         $item = ORM::factory('external_feedpost')->like(array("permalink" => $values['permalink'], 'external_feed_id' => $this->id))->find();
         if ($item->id > 0) {
         } else {
             $count++;
             foreach ($values as $key => $val) {
                 $item->{$key} = (string) $val;
             }
             $item->save();
         }
     }
     return "Updated " . $count . " " . $this->title . " posts<br/>";
 }
Exemple #8
0
 public function add_this()
 {
     return zest::add_this($this->get_url(), $this->title);
 }
Exemple #9
0
?>

<h2>All Events</h2>
<?php 
foreach ($all_events as $evt) {
    echo '<li><a href="' . $evt->get_url() . '">' . zest::render_image($evt->media, array('width' => 100, 'height' => 100)) . $evt->get_date('d m y') . ' - ' . $evt->title . '</a></li>';
}
echo $all_pagination;
?>

<h2>Future Events</h2>
<?php 
foreach ($future_events as $evt) {
    echo '<li><a href="' . $evt->get_url() . '">' . zest::render_image($evt->media, array('width' => 100, 'height' => 100)) . $evt->get_date('d m y') . ' - ' . $evt->title . '</a></li>';
}
echo $future_pagination;
?>

<h2>Past Events</h2>
<?php 
foreach ($past_events as $evt) {
    echo '<li><a href="' . $evt->get_url() . '">' . zest::render_image($evt->media, array('width' => 100, 'height' => 100)) . $evt->get_date('d m y') . ' - ' . $evt->title . '</a></li>';
}
echo $past_pagination;
?>


<?php 
if (isset($footer)) {
    echo $footer;
}
Exemple #10
0
 private function __user_rows()
 {
     $html = "<ul style='list-style:none'>";
     $users = ORM::factory('user')->find_all();
     foreach ($users as $user) {
         $roles = $user->roles;
         $superuser = FALSE;
         $type = "";
         $i = 0;
         foreach ($roles as $role) {
             $type .= $role->name;
             if ($i > 0) {
                 $type .= ", ";
             }
             $i++;
             if ($role->id == 1) {
                 $superuser = TRUE;
             }
         }
         if ($this->user->id == $user->id) {
         } else {
             if ($superuser && !$this->superuser) {
             } else {
                 $x = "";
                 if ($user->roles[0]->id < 3) {
                     $x = "&nbsp;&nbsp;&nbsp;&nbsp;" . html::anchor('admin/users/sudo/' . $user->id, 'sudo');
                 }
                 $html .= "<li style='padding-left:15px !important;' class='user'><div class='right'><span style='width:250px;display:block;float:left;'>" . $user->logins . " logins&nbsp;&nbsp;&nbsp;&nbsp;<b>last login:</b> " . zest::relative_time(date('Y-m-d H:i:s', $user->last_login)) . "</span>" . $type . "{$x}&nbsp;&nbsp;&nbsp;&nbsp;" . html::anchor('admin/users/edit/' . $user->id, html::image('zest/images/icon_pencil.png')) . "&nbsp;&nbsp;&nbsp;&nbsp;" . html::anchor('admin/delete/user/' . $user->id, html::image('zest/images/delete.png'), array('class' => 'ajax-button', 'rel' => 'delete')) . "</div>" . $user->avatar(32) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>" . $user->title . "</span></li>";
             }
         }
     }
     $html .= "</ul>";
     return $html;
 }
Exemple #11
0
//<[CDATA[
(function() {
		var links = document.getElementsByTagName('a');
		var query = '?';
		for(var i = 0; i < links.length; i++) {
			if(links[i].href.indexOf('#disqus_thread') >= 0) {
				query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
			}
		}
		document.write('<script type="text/javascript" src="http://disqus.com/forums/sydlawrence/get_num_replies.js' + query + '"></' + 'script>');
	})();
//]]>
</script>
<div style="float:right">{execution_time}</div>
<span id="copyright">Copyright &copy; 2009 Me. Running on <?php 
echo zest::get_version(true);
?>
. </span>
</div>

</div></div>

</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7654450-1");
 public function can_modify()
 {
     $user = zest::check_login();
     if ($user && ($this->user->id == $user->id || $user->roles[0]->id < 3)) {
         return true;
     }
     return false;
 }
Exemple #13
0
 private function __right_side()
 {
     $html = new View('zest/new_image_form');
     $html .= "<hr/>";
     $html .= zest::button('#', 'Preview Image', array('onclick' => 'preview_image();return false;'));
     $html .= "<hr/>";
     $html .= zest::button('#', 'Edit Image', array('id' => 'edit_image', 'onclick' => 'edit_image();return false;'));
     $html .= form::open(null, array('id' => 'edit_image_form', 'class' => 'hide'));
     $html .= form::hidden('media_type_id', 1);
     $html .= form::input(array('name' => 'edit_image_id', 'id' => 'edit_image_id', 'style' => 'display:none'));
     $html .= form::input(array('edit_image_title', 'Title'), '');
     $html .= form::input(array('edit_image_category', 'Category'), '', 'class="media_category_complete fullWidth"');
     $html .= "<input type='submit' value='Save' class='submit' />";
     $html .= form::close();
     $html .= "<hr/>";
     $html .= zest::button('#', 'Delete Image', array('onclick' => 'delete_image();return false;'));
     return $html;
 }
Exemple #14
0
 public function __external_feed_render($feed)
 {
     $html = "<p>Last updated: " . zest::relative_time($feed->last_updated) . "</p>";
     $html .= "<ul style='list-style:none'>";
     foreach ($feed->where('status_id', 2)->orderby('pubDate', 'DESC')->external_feedposts as $post) {
         $html .= "<li  class='feedpost' style='padding-left:45px !important;background-image:url(" . $feed->favicon . ") !important;'><span class='right'>&nbsp;" . html::anchor('admin/delete/external_feedpost/' . $post->id, html::image('zest/images/delete.png'), array('class' => 'ajax-button', 'rel' => 'delete')) . "</span><span><a href='" . $post->permalink . "' target='_BLANK'>" . text::limit_chars($post->title, 100, "...", true) . "</a></span></li>";
     }
     $html .= "</ul>";
     return $html;
 }
    public function comment_form()
    {
        $array = array("title" => "", "display_name" => "", "email" => "");
        $user = zest::check_login();
        if ($user) {
            $array = array("title" => "", "display_name" => $user->username, "email" => $user->email);
        }
        $comments_form = "";
        if (isset($_POST['post_comment'])) {
            $comment = ORM::factory('comment');
            unset($_POST['post_comment']);
            $post = $comment->validate($_POST);
            if (count($post['errors']) == 0) {
                foreach ($_POST as $key => $value) {
                    $comment->{$key} = $value;
                }
                $comment->feedpost_id = $this->id;
                if (!$user) {
                    $comment->status_id = 1;
                    $comment->save();
                    $to = $comment->email;
                    $from = 'no-reply@' . str_replace('www.', '', $_SERVER['HTTP_HOST']);
                    $subject = "Please confirm your email address";
                    $message = "Please click on the link below to confirm your email address and make your comment active\n\n" . $comment->activate_url();
                    email::send($to, $from, $subject, $message, FALSE);
                    return "<p>You have been sent an email. You must confirm your email before your comment will become active.</p>";
                } else {
                    $comment->user_id = $user->id;
                    $comment->status_id = 2;
                    $comment->email = $user->email;
                    $comment->save();
                    url::redirect($this->get_url() . '#comments');
                    return "<p>Thank you for your comment.</p>";
                }
            } else {
                $comments_form .= "<p style='color:red'>";
                foreach ($post['errors'] as $key => $value) {
                    $comments_form .= $value . "<br/>";
                }
                $comments_form .= "</p>";
                $array = arr::overwrite($array, $post);
            }
        }
        $comments_form .= form::open();
        $comments_form .= form::hidden('post_comment', 'true');
        $comments_form .= '<div class="user_auth">';
        $comments_form .= form::label('display_name', 'Display Name');
        $comments_form .= form::input('display_name', $array['display_name']) . '<br/>';
        $comments_form .= form::label('email', 'Email');
        $comments_form .= form::input('email', $array['email']) . '<br/>';
        $comments_form .= '<fb:login-button onlogin="******"></fb:login-button>';
        $comments_form .= '</div>';
        $comments_form .= '
		<script type="text\\javascript">
		function update_user_box() {
			var user_box =  document.getElementById("user_auth");
			user_box.innerHTML 
		}
		</script>
		';
        $comments_form .= form::textarea('title', $array['title'], 'style="width:100%;"');
        $comments_form .= form::label('', '&nbsp;');
        $comments_form .= form::submit('', 'Submit', 'class="submit"');
        $comments_form .= form::close();
        return $comments_form;
    }



<p>Venue: <?php 
echo $event->venue;
?>
</p>


<h2>Attendees (<?php 
echo count($attendees);
?>
)</h2>
<?php 
foreach ($attendees as $person) {
    echo '<li>' . $person->get_full_name() . '</li>';
}
?>

<?php 
foreach ($event->medias as $m) {
    echo zest::render_image($m, array('width' => 50, 'height' => 50, 'thickbox' => true));
}
?>


<?php 
if (isset($footer)) {
    echo $footer;
}
Exemple #17
0
 private function __check_login()
 {
     // IF LOGGED IN
     if ($this->user = zest::check_login()) {
         $roles = $this->user->roles;
         foreach ($roles as $role) {
             if ($role->id == 1) {
                 $this->superuser = TRUE;
             }
             if ($role->id == 1 || $role->id == 2) {
                 $this->admin = TRUE;
             }
         }
     } else {
         // Redirect back to the login page
         url::redirect('admin/login');
     }
 }
Exemple #18
0
 public function __render_feedpost($options = null)
 {
     $this->template->bind("feed", $this->feed)->bind("feedpost", $this->feedpost);
     $this->header->bind("feed", $this->feed)->bind("feedpost", $this->feedpost);
     $this->footer->bind("feed", $this->feed)->bind("feedpost", $this->feedpost);
     zest::add_stat('feedpost', $this->feedpost->id);
     if (isset($_GET['activate'])) {
         $comment = ORM::factory('comment', $_GET['id'])->attempt_activate($_GET['hash']);
         url::redirect($this->feedpost->get_url() . '#comments');
     }
     if (isset($_GET['delete'])) {
         $comment = ORM::factory('comment', $_GET['id']);
         if ($comment->can_modify()) {
             $comment->delete();
             url::redirect($this->feedpost->get_url() . '#comments');
         }
     }
     $this->seoTitle = $this->feedpost->title . " : " . $this->feed->title;
     $this->extraHead = $this->feed->render_rss();
     $this->title = $this->feedpost->title;
     $this->content = $this->feedpost->render($options);
 }