本文整理汇总了PHP中Library函数的典型用法代码示例。如果您正苦于以下问题:PHP Library函数的具体用法?PHP Library怎么用?PHP Library使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Library函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
//$sitemap = new google_sitemap; //Create a new Sitemap Object
$posts = Model('blog')->getRecentPosts('50');
$item = Library('sitemap')->google_sitemap_item(site_url(), date("Y-m-d", time()), 'daily', '1.0');
//Create a new Item
Library('sitemap')->add_item($item);
foreach ($posts->result_array() as $entry) {
$link = get_page_url($entry);
//Create a new Item
$item = Library('sitemap')->google_sitemap_item(site_url($link), date("Y-m-d", strtotime($entry['page_date'])), 'daily', '0.5');
//Append the item to the sitemap object
Library('sitemap')->add_item($item);
}
Library('sitemap')->build("sitemap.xml");
//Build it...
//Let's compress it to gz
$data = implode("", file("sitemap.xml"));
$gzdata = gzencode($data, 9);
$fp = fopen("sitemap.xml.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
//Let's Ping google
$this->_pingGoogleSitemaps(base_url() . "/sitemap.xml.gz");
echo site_url();
}
示例2: index
function index()
{
$data = '';
if (isset($_POST['delete'])) {
$data = $this->_delete();
} elseif (isset($_POST['approve'])) {
$data = $this->_approve();
}
/*
* START: Pagination config and initialization
*/
$this->load->library('pagination');
$config['per_page'] = '20';
$config['uri_segment'] = 3;
$config['num_links'] = 2;
if ($this->uri->segment(3, 'pending-comment') == 'pending-comment') {
$status = 0;
} else {
$status = 1;
}
$config['base_url'] = trim(site_url(), '/') . "/comment/" . $this->uri->segment(3, 'approved-comment') . "/";
$config['total_rows'] = Model('comment')->get_comment_count($status);
$this->pagination->initialize($config);
//END: Pagination
//Get page content for the selected menu item.
$data['pagination'] = $this->pagination->create_links();
//load comment menu
$data['comment'] = Model('comment')->get_comment($config['per_page'], $this->uri->segment(3, 0), $status);
//---
$html_string = $this->load->view('admin/comment/comment_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例3: _check_access
private function _check_access()
{
$is_admin = $this->CI->user('is_admin');
if (!$is_admin) {
return FALSE;
}
$group_id = $this->CI->user('group_id');
//@todo::check if the user can access
//Check access rights
Library('login')->check_login($group_id);
$page = trim($this->CI->cfAdminController . '/' . $this->CI->cfAdminMethod, '/');
$defaultToAll = array('sortdata/menu', 'sortdata/folder', 'sortdata/group', 'form/ajax', 'file/file-search-form');
if (in_array($page, $defaultToAll)) {
return TRUE;
}
$can_access = Model('module')->can_access($group_id, $page);
if ($can_access) {
return TRUE;
}
$default_landing = Model('module')->default_landing($group_id);
if (!$default_landing) {
return FALSE;
}
$msg = array('error' => '<p>You need access to perform action on page <strong>' . $page . '</strong>. </p>');
setMessages($msg, 'error');
redirect('admin/' . $default_landing);
return TRUE;
}
示例4: index
function index()
{
$data = '';
//---
$html_string = $this->load->view('admin/catalog/catalog_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例5: index
/**
* User Group
* Create group
*/
function index()
{
$data = '';
$data['group_id'] = $group_id = $this->input->post('group_id', 1);
$data['modules'] = Model('module')->get();
$data['module_ids'] = Model('module')->get_ids();
$data['groups'] = Model('groups/permission')->get_group();
if (isset($_POST['group_id']) && isset($_POST['permission'])) {
Model('groups/permission')->update_permissions($_POST['group_id'], $_POST['permission']);
}
$data['permissions'] = Model('groups/permission')->get_group_permission($group_id);
//---
$html_string = $this->load->view('admin/group/permission_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例6: index
/**
* Control Panel Admin(Index) Page Function
* Get Top Page Of The Website.
*/
function index()
{
$data = '';
$sort = 1;
$menu_item = Library('module')->_getAdminNav();
$query = $this->db->order_by('parent')->get('module');
$modules_db = $query->result_array();
foreach ($modules_db as $k => $v) {
$modules_db[$v['url']] = $v;
unset($modules_db[$k]);
}
foreach ($menu_item as $v) {
$sql = array();
$key = 0;
$sql[$key] = array('parent' => 'top', 'status' => 1, 'sort' => $sort++, 'url' => $v['url'], 'title' => $v['title'], 'is_menu' => $v['is_menu'], 'void' => $v['void'], 'menu' => serialize($v), 'child' => '');
if (isset($v['child']) && count($v['child']) > 0) {
$sql[$key++]['child'] = serialize(array_keys($v['child']));
foreach ($v['child'] as $k2 => $v2) {
$sql[$key] = array('parent' => $v['url'], 'status' => 1, 'sort' => $sort++, 'url' => $v2['url'], 'title' => $v2['title'], 'is_menu' => $v2['is_menu'], 'void' => $v2['void'], 'child' => '');
if (isset($v2['child']) && count($v2['child']) > 0) {
$sql[$key++]['child'] = serialize(array_keys($v2['child']));
foreach ($v2['child'] as $k3 => $v3) {
$sql[$key++] = array('parent' => $v2['url'], 'status' => 1, 'sort' => $sort++, 'url' => $v3['url'], 'title' => $v3['title'], 'is_menu' => $v3['is_menu'], 'void' => $v3['void'], 'child' => '');
}
}
$key++;
}
$key++;
}
foreach ($sql as $k => $v) {
if (isset($modules_db[$v['url']])) {
$this->db->update('module', $v, array('url' => $v['url']));
unset($sql[$k]);
}
}
if (count($sql) > 0) {
$this->db->insert_batch('module', $sql);
}
}
//---
$html_string = $this->load->view('admin/moduleinstaller/moduleinstaller_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例7: update
/**
* Control Panel Admin/Update Page Function
* Get Release Notes From Official Site Of Codefight CMS.
*/
function update()
{
error_reporting(0);
$data = '';
$codefight = array();
if ($xml =& simplexml_load_file('http://codefight.org/feed/releases')) {
$channel = $xml->channel;
foreach ($channel as $v) {
foreach ($v->item as $w) {
$codefight[] = $w;
}
}
}
$data['codefight'] = $codefight;
//---
$html_string = $this->load->view('admin/cp/update_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例8: Library
</a></h2>
</div>
<div id="pagenav"><?php
//Load page menu horizontal block
Library('block')->load('menu/page_horizontal', 'portfolio');
?>
</div>
</div>
<div id="main">
<div class="container"><?php
//Load message block
Library('block')->load('page_html/message');
//Load Content Block
Library('block')->load($content_block, 'portfolio');
?>
</div>
</div>
<div id="footer">
<div class="footernav">
<ul>
<li class="page_item page-item-3 current_page_item">
<a href="<?php
echo base_url();
?>
" title="Home">Home</a>
</li>
</ul>
示例9: sitemap
function sitemap()
{
$data = array();
$data['websites'] = Model('websites')->get_websites();
//---
$html_string = $this->load->view('admin/setting/sitemap_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例10: index
function index()
{
$url_to_trim = $this->input->post('longurl', TRUE);
//Remove the last slash
while (substr($url_to_trim, -1) == '/') {
$url_to_trim = substr($url_to_trim, 0, -1);
}
//$url_to_trim = prep_url($url_to_trim);
$error = FALSE;
$data = array();
if (!empty($url_to_trim) && preg_match('|^https?://|', $url_to_trim)) {
$this->config->load('trim.php');
$this->base = $this->config->item('allowed_chars');
//check if the client's IP is allowed to trim
if ($_SERVER['REMOTE_ADDR'] != $this->config->item('limit_to_ip')) {
$msg = array('error' => '<p>You are not allowed to trim URLs with this service.</p>');
setMessages($msg, 'error');
$error = TRUE;
}
// check if the URL is valid
$pos = strpos($url_to_trim, base_url());
if ($this->config->item('verify_url') && !$error || $pos === FALSE) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_to_trim);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '404') {
$msg = array('error' => '<p>That is not a valid URL.</p>');
setMessages($msg, 'error');
$error = TRUE;
}
curl_close($ch);
}
if (!$error) {
// check if the URL has already been trimed
$this->db->where('long_url', $url_to_trim);
$query = $this->db->get('trim');
$already_trimed = $query->result_array();
if (!empty($already_trimed)) {
// URL has already been trimed
$integer = $already_trimed[0]['trim_id'];
$trimed_url = $this->_getShortUrl($integer);
} else {
// URL not in database, insert
$sql = array('long_url' => $url_to_trim, 'created' => time(), 'creator' => $_SERVER['REMOTE_ADDR']);
$this->db->insert('trim', $sql);
$trimed_url = $this->_getShortUrl($this->db->insert_id());
}
$data['trim'] = site_url('trim/' . $trimed_url);
$data['url'] = $url_to_trim;
$msg = array('success' => '<p>URL successfully Trimed.</p>');
setMessages($msg, 'success');
}
} elseif (isset($_POST['longurl'])) {
$msg = array('error' => '<p>Not a valid URL.</p>');
setMessages($msg, 'error');
}
$html_string = $this->load->view('admin/trim/trim_view', $data, true);
//Get view data in place of sending to browser.
Library('process')->view($html_string);
}
示例11: echo
<script type="text/javascript">jQuery(document).ready(function($) {
if($('#slider').length)
{
$('#slider').s3Slider({
timeOut: 5000
});
}
});</script>
<script type='text/javascript' src='<?php
echo $this->config->item('skin_url');
?>
skin/frontend/portfolio/js/l10n.js?ver=20101110'></script> <script type='text/javascript' src='<?php
echo $this->config->item('skin_url');
?>
skin/frontend/portfolio/js/comment-reply.js?ver=20090102'></script>
<?php
//Get Assets (js|css)
//Library('asset')->get();
//If head text variable is set, echo it.
if (isset($head_text)) {
echo (string) $head_text;
}
//Load General_js.php file
Library('block')->load('includes/general_js');
//Load Google Analytics
Library('block')->load('seo/google_analytics');
?>
</head>
示例12: parseContent
function parseContent($content = array(), $show_blurb = TRUE)
{
$_content = array();
if (isset($content) && is_array($content) && count($content) > 0) {
foreach ($content as $k => $v) {
//check access
$access = Model('data')->is_granted($v['group_id']);
//Get Author + Date Block
$author_date = Model('data')->author_date($v['page_author'], $v['page_date'], $v['show_author'], $v['show_date']);
//Get Tags Block
$page_tag = Model('data')->page_tag($v['page_tag']);
//Get Tags Block
$content_content = Library('parser/bbcode')->parse(Model('data')->page_content($v, $show_blurb));
//$page_content = $this->phpcolor->color_code($content_content);
$page_content = $content_content;
//Get the Year | Month | Day the post was posted
$_content[$k]['year'] = Model('data')->post_year($v['show_date'], $v['page_date']);
$_content[$k]['month'] = Model('data')->post_month($v['show_date'], $v['page_date']);
$_content[$k]['day'] = Model('data')->post_day($v['show_date'], $v['page_date']);
//check to see if there is a form
if (preg_match_all('#{{form (.+)}}#isU', $page_content, $identifier)) {
$form = Library('form')->create($identifier, current_url());
if (isset($_POST['identifier'])) {
$page_content .= '<script type="text/javascript">
jQuery(document).ready(function(){check_form();});
function check_form() {
jQuery.post(
\'form/ajax\',
{
';
foreach ($_POST as $pk => $pv) {
if (!is_array($_POST[$pk])) {
$page_content .= "{$pk}:document.getElementById(\"{$pk}\").value, \n";
} else {
//print_r($_POST);
foreach ($_POST[$pk] as $chk_k => $chk_v) {
$page_content .= "'" . $pk . '[' . $chk_k . ']' . "'" . ':document.getElementById("' . $pk . '[' . $chk_k . ']").value, ' . "\n";
}
}
}
$page_content .= ' },
function(data){
jQuery(\'#message_' . $_POST['identifier'] . '\').html(data);
}
);
}
</script>';
}
//replace identifiers with form.
foreach ($form as $f) {
$page_content = preg_replace('#' . $f['block'] . '#isU', $f['form'], $page_content);
}
}
//check to see if there is a form
if (preg_match_all('#{{banner (.+)}}#isU', $page_content, $identifier)) {
$page_content = Model('banner')->parse($page_content, $identifier);
}
$_content[$k]['categories'] = Model('data')->post_category($v['menu_id'], true);
//$v['menu_id'] = explode(',',$v['menu_id']);
//$v['menu_id'] = array_filter($v['menu_id']);
//$v['menu_id'] = array_shift($v['menu_id']);
$link = get_page_url($v);
//Model('data')->link_create(array(0 => 'page', 1 => $v['menu_id'], 3 => $v['page_id'], 4 => Model('data')->link_clean($v['page_title'])));
//If the user has right to view this content...
if ($access) {
//Show heading of the content, ...
$_content[$k]['title'] = $v['page_title'];
$_content[$k]['author_date'] = $author_date;
$_content[$k]['content'] = $page_content;
$_content[$k]['tag'] = $page_tag;
//add share button
$_content[$k]['addthis'] = '<br /><!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style "><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=dbashyal"></script><!-- AddThis Button END -->';
if (isset($v['allow_comment']) && $v['allow_comment']) {
$data['page_id'] = $v['page_id'];
$data['link'] = $link;
//include($template_path . '/blocks/comment.php');
$this->lang->load('comment');
$_content[$k]['comment'] = Library('block')->load('comment', false, '.php', true);
}
} else {
//Show heading of the content, ...
$_content[$k]['title'] = $v['page_title'];
$_content[$k]['author_date'] .= $author_date;
//... but Display message to login
$_content[$k]['content'] .= '<p class="error">You do not have access right to view this part of content, Please login.</p>';
$_content[$k]['tag'] .= $page_tag;
}
//Count total comment
$_content[$k]['comment_count'] = Model('data')->post_comment_count($v['page_id']);
}
}
//END: Foreach
return $_content;
}
示例13: _edit
function _edit()
{
$data = '';
Library('asset')->addJs('tiny_mce/tiny_mce');
$data['authors'] = $this->get_authors();
$id_array = array();
if (!isset($_POST['page'])) {
if (isset($_POST['select'])) {
$id_array = $_POST['select'];
} else {
$msg = array('error' => "<p>You must select atleast one page to edit</p>");
setMessages($msg, 'error');
unset($_POST);
$this->index();
exit;
}
}
!is_array($id_array) ? $id_array = array() : '';
//START: for the first page load, get data from database
foreach ($id_array as $id) {
$id = preg_replace('/[^0-9]+/', '', $id);
$this->db->where('page_id', $id);
$query = $this->db->get('page');
foreach ($query->result() as $row) {
$_POST['page'][$row->page_id]['id'] = $row->page_id;
$_POST['page'][$row->page_id]['page_active'] = $row->page_active;
$_POST['page'][$row->page_id]['page_title'] = $row->page_title;
//$_POST['page'][$row->page_id]['page_blurb'] = $row->page_blurb;
//$_POST['page'][$row->page_id]['page_blurb_length'] = $row->page_blurb_length;
$_POST['page'][$row->page_id]['page_body'] = $row->page_body;
$_POST['page'][$row->page_id]['menu_id'] = $row->menu_id;
$_POST['page'][$row->page_id]['websites_id'] = $row->websites_id;
$_POST['page'][$row->page_id]['user_id'] = $row->user_id;
$_POST['page'][$row->page_id]['page_author'] = $row->page_author;
$_POST['page'][$row->page_id]['page_tag'] = $row->page_tag;
$_POST['page'][$row->page_id]['page_date'] = $row->page_date;
$_POST['page'][$row->page_id]['show_date'] = $row->show_date;
$_POST['page'][$row->page_id]['show_author'] = $row->show_author;
$_POST['page'][$row->page_id]['allow_comment'] = $row->allow_comment;
$_POST['page'][$row->page_id]['page_meta_title'] = $row->page_meta_title;
$_POST['page'][$row->page_id]['page_meta_keywords'] = $row->page_meta_keywords;
$_POST['page'][$row->page_id]['page_meta_description'] = $row->page_meta_description;
$_POST['page'][$row->page_id]['page_sort'] = $row->page_sort;
$_POST['page'][$row->page_id]['group_id'] = array('1', '2', '3');
}
$this->db->where('page_id', $id);
$query = $this->db->get('page_access');
//$test = $query->result_array();
foreach ($query->result() as $row) {
$_POST['page'][$row->page_id]['group_id'] = explode('_', $row->group_id);
}
//To make it multiple selected, we need more than two elements in array.
if (count($_POST['page'][$row->page_id]['group_id']) == 1) {
$_POST['page'][$row->page_id]['group_id'][] = '0';
}
}
//END: for the first page load, get data from database
//START: clean data and update in database
if ($this->input->post('edit') == 'Update' && isset($_POST['page']) && is_array($_POST['page'])) {
foreach ($_POST['page'] as $v) {
if (empty($v['menu_id'])) {
$v['menu_id'][0] = 0;
}
if (empty($v['websites_id'])) {
$v['websites_id'][0] = 0;
}
//print_r($v);
//cleaning
$id = xss_clean($v['id']);
$page_active = xss_clean($v['page_active']);
$page_title = $v['page_title'];
$page_blurb = '';
//$page_blurb_length = xss_clean($v['page_blurb_length']);
$page_body = $v['page_body'];
$user_id = $v['user_id'];
$page_author = $v['page_author'];
$page_tag = $v['page_tag'];
$page_date = date('Y-m-d H:i:s', strtotime($v['page_date']));
$show_date = isset($v['show_date']) ? $v['show_date'] : '0';
$show_author = isset($v['show_author']) ? $v['show_author'] : '0';
$allow_comment = isset($v['allow_comment']) ? $v['allow_comment'] : '0';
$page_body = $v['page_body'];
//$menu_id = $v['menu_id'];
$page_meta_title = xss_clean($v['page_meta_title']);
$page_meta_keywords = xss_clean($v['page_meta_keywords']);
$page_meta_description = xss_clean($v['page_meta_description']);
$page_sort = xss_clean($v['page_sort']);
$page_break = explode('<!-- pagebreak -->', $page_body);
if (isset($page_break[0])) {
$page_blurb = trim($page_break[0]);
if (substr($page_blurb, -1, 3) == '<p>') {
$page_blurb = substr($page_blurb, 0, -3);
}
}
//clean up menu ids
$menu_id = array();
foreach ($v['menu_id'] as $w) {
$w = xss_clean($w);
$menu_id[$w] = $w;
}
//.........这里部分代码省略.........
示例14: exit
<?php
if (!defined('BASEPATH')) {
exit(__('No direct script access allowed'));
}
/*
* Check app/modules folder for adding/removing menu items.
* Menu is controlled from config files,
* so its easy to add and remove.
* Those configs are read every page visit in admin,
* @todo::which will be cached in later versions to improve more performance.
*/
error_reporting(E_ALL);
//$menu_item = $this->cf_module_lib->_getAdminNav();
$menu_item = Library('module')->get_nav_from_db();
//$cache = Library('cache')->cache(60);
//print_r(get_class_vars(get_class($cache)));
//$test = $cache->_display(json_encode($menu_item), 'blahblah_id');
//print_r($test);
?>
<style type="text/css">
#top-menu-wrapper{background: #222;}
ul#main-nav {
list-style: none;
padding: 0 20px;
margin: 0;
float: left;
min-width: 908px;
background: #222;
font-size: 12px;
z-index: 10;
示例15: exit
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
$menu = array('menu_type' => 'page', 'ul_param' => 'class="sf-menu sf-js-enabled sf-shadow"');
$menu = Library('menu')->get($menu);
if (!empty($menu)) {
//echo '<div class="round15 sidebar-header">Blog Categories</div>';
echo $menu;
}