本文整理汇总了PHP中intelligent_write_error函数的典型用法代码示例。如果您正苦于以下问题:PHP intelligent_write_error函数的具体用法?PHP intelligent_write_error怎么用?PHP intelligent_write_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intelligent_write_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_functions_dat
/**
* Make the functions.dat file
*/
function make_functions_dat()
{
$files = make_functions_dat_do_dir(get_custom_file_base());
$classes = array();
$global = array();
foreach ($files as $filename) {
if (strpos($filename, '_custom') !== false) {
continue;
}
$_filename = substr($filename, strlen(get_custom_file_base()) + 1);
if ($_filename == 'sources/minikernel.php') {
continue;
}
$result = get_php_file_api($_filename, false);
foreach ($result as $i => $r) {
if ($r['name'] == '__global') {
$global = array_merge($global, $r['functions']);
unset($result[$i]);
}
}
$classes = array_merge($classes, $result);
}
$classes['__global'] = array('functions' => $global);
$myfile = @fopen(get_custom_file_base() . '/data_custom/functions.dat', 'wt') or intelligent_write_error(get_custom_file_base() . '/data_custom/functions.dat');
if (fwrite($myfile, serialize($classes)) == 0) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
}
示例2: splurgh_master_build
/**
* Get a splurghified version of the specified item.
*
* @param string The name of what the key we want to reference is in our array of maps (e.g. 'id')
* @param array A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select
* @param URLPATH The stub that links will be passed through
* @param ID_TEXT The page name we will be saving customised HTML under
* @param TIME The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving)
* @param ?AUTO_LINK The ID that is at the root of our tree (NULL: db_get_first_id)
* @return string A string of HTML that represents our splurghing (will desplurgh in the users browser)
*/
function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL)
{
if (is_null($first_id)) {
$first_id = db_get_first_id();
}
if (!array_key_exists($first_id, $map)) {
return '';
}
if (!has_js()) {
warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
}
require_javascript('javascript_splurgh');
if (is_browser_decacheing()) {
$last_change_time = time();
}
$cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm');
if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) {
$myfile = @fopen($cache_file, 'wt');
if ($myfile === false) {
intelligent_write_error($cache_file);
}
$fulltable = array();
$splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0);
$page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh)));
$ev = $page->evaluate();
if (fwrite($myfile, $ev) < strlen($ev)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
fix_permissions($cache_file);
sync_file($cache_file);
return $ev;
}
return file_get_contents($cache_file, FILE_TEXT);
}
示例3: run
function run()
{
$file = basename(rawurldecode($_GET['url']));
//get old media file data
$get_old_file = $GLOBALS['SITE_DB']->query('SELECT url FROM ' . get_table_prefix() . 'videos WHERE url LIKE "uploads/galleries/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
$type = 'galleries';
if (!array_key_exists(0, $get_old_file)) {
$get_old_file = $GLOBALS['SITE_DB']->query('SELECT a_url AS url FROM ' . get_table_prefix() . 'attachments WHERE a_url LIKE "uploads/attachments/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
$type = 'attachments';
if (!array_key_exists(0, $get_old_file)) {
$get_old_file = $GLOBALS['SITE_DB']->query('SELECT cv_value AS url FROM ' . get_table_prefix() . 'catalogue_efv_short WHERE cv_value LIKE "uploads/catalogues/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
$type = 'catalogues';
}
}
require_code('files');
$file_handle = @fopen(get_custom_file_base() . '/uploads/' . $type . '/' . $file, 'wb') or intelligent_write_error(get_custom_file_base() . '/uploads/' . $type . '/' . $file);
http_download_file($_GET['url'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $file_handle, NULL, NULL, 6.0);
fclose($file_handle);
//move the old media file to the archive directory - '/uploads/'.$type.'/archive/'
$new_url = 'uploads/' . $type . '/' . rawurlencode($file);
if (isset($get_old_file[0]['url']) && is_string($get_old_file[0]['url']) && $get_old_file[0]['url'] != $new_url && strlen($get_old_file[0]['url']) > 0) {
$movedir = dirname(str_replace('/uploads/' . $type . '/', '/uploads/' . $type . '_archive_addon/', str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url'])));
@mkdir($movedir, 0777);
require_code('files');
fix_permissions($movedir, 0777);
rename(str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url']), str_replace('/uploads/' . $type . '/', '/uploads/' . $type . '_archive_addon/', str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url'])));
}
switch ($type) {
case 'galleries':
$GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'videos SET video_width=600,video_height=400,url="' . db_escape_string($new_url) . '" WHERE url LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
// Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
break;
case 'attachments':
$GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'attachments SET a_url="' . db_escape_string($new_url) . '" WHERE a_url LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
// Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
break;
case 'catalogues':
$GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'catalogue_efv_short SET cv_value="' . db_escape_string($new_url) . '" WHERE cv_value LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
// Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
break;
}
$transcoding_server = get_option('transcoding_server', true);
if (is_null($transcoding_server)) {
//add option and default value
add_config_option('TRANSCODING_SERVER', 'transcoding_server', 'line', 'return \'http://localhost/convertor\';', 'FEATURE', 'GALLERIES');
$transcoding_server = get_option('transcoding_server', true);
}
file_get_contents($transcoding_server . '/move_to_sent.php?file=' . $_GET['url']);
}
示例4: ocf_switch
/**
* Special import-esque function to aid switching to OCF after importing forum previously served by a forum driver.
*
* @return tempcode Information about progress
*/
function ocf_switch()
{
$out = new ocp_tempcode();
$todos = array('USER' => array('member', db_get_first_id(), NULL), 'GROUP' => array('group', NULL, 'group_id'));
foreach ($todos as $db_abstraction => $definition) {
list($import_code, $default_id, $field_name_also) = $definition;
$count = 0;
$extra = is_null($field_name_also) ? '' : ' OR ' . db_string_equal_to('m_name', $field_name_also);
$fields = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE (NOT (m_table LIKE \'' . db_encode_like('f_%') . '\')) AND (' . db_string_equal_to('m_type', $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '*' . $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '?' . $db_abstraction) . $extra . ')');
foreach ($fields as $field) {
if ($field['m_table'] == 'stats') {
continue;
}
// Lots of data and it's not important
//echo '(working) '.$field['m_table'].'/'.$field['m_name'].'<br />';
$values = $GLOBALS['SITE_DB']->query_select($field['m_table'], array('*'));
foreach ($values as $value) {
$current = $value[$field['m_name']];
$remapped = import_id_remap_get($import_code, $current, true);
if (is_null($remapped)) {
$remapped = $default_id;
}
if (!is_null($remapped)) {
$value2 = $value;
$value2[$field['m_name']] = -$remapped;
$c = $GLOBALS['SITE_DB']->query_update($field['m_table'], $value2, $value, '', NULL, NULL, true, true);
if (is_null($c)) {
$GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
} else {
$count += $c;
}
} else {
$GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
}
}
$GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' SET ' . $field['m_name'] . '=-' . $field['m_name'] . ' WHERE ' . $field['m_name'] . '<0');
}
$out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_' . $db_abstraction, $count == 0 ? '?' : strval($count))));
}
// info.php
global $FILE_BASE;
$info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php';
$info = @fopen($FILE_BASE . '/' . $info_file, 'wt') or intelligent_write_error($FILE_BASE . '/' . $info_file);
fwrite($info, "<" . "?php\n");
global $SITE_INFO;
$SITE_INFO['forum_type'] = 'ocf';
$SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
$SITE_INFO['db_forums'] = $SITE_INFO['db_site'];
$SITE_INFO['db_forums_host'] = array_key_exists('db_site_host', $SITE_INFO) ? $SITE_INFO['db_site_host'] : 'localhost';
$SITE_INFO['db_forums_user'] = $SITE_INFO['db_site_user'];
$SITE_INFO['db_forums_password'] = $SITE_INFO['db_site_password'];
$SITE_INFO['board_prefix'] = get_base_url();
foreach ($SITE_INFO as $key => $val) {
$_val = str_replace('\\', '\\\\', $val);
fwrite($info, '$SITE_INFO[\'' . $key . '\']=\'' . $_val . "';\n");
}
fwrite($info, "?" . ">\n");
fclose($info);
fix_permissions($FILE_BASE . '/' . $info_file);
sync_file($FILE_BASE . '/' . $info_file);
$out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_INFO')));
$LANG = get_site_default_lang();
$trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG);
$GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1));
require_code('menus2');
add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':forumview', 0, 1);
return $out;
}
示例5: import_wordpress_db
/**
* Import wordpress db
*/
function import_wordpress_db()
{
disable_php_memory_limit();
$data = get_wordpress_data();
$is_validated = post_param_integer('wp_auto_validate', 0);
$to_own_account = post_param_integer('wp_add_to_own', 0);
// Create members
require_code('ocf_members_action');
require_code('ocf_groups');
$def_grp_id = get_first_default_group();
$cat_id = array();
$NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
$NEWS_CATS = list_to_map('id', $NEWS_CATS);
foreach ($data as $values) {
if (get_forum_type() == 'ocf') {
$member_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $values['user_login']));
if (is_null($member_id)) {
if (post_param_integer('wp_import_wordpress_users', 0) == 1) {
$member_id = ocf_make_member($values['user_login'], $values['user_pass'], '', NULL, NULL, NULL, NULL, array(), NULL, $def_grp_id, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false, 'wordpress');
} else {
$member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username('admin');
// Set admin as owner
if (is_null($member_id)) {
$member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id() + 1;
}
}
}
} else {
$member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
}
// Guest user
// If post should go to own account
if ($to_own_account == 1) {
$member_id = get_member();
}
if (array_key_exists('POSTS', $values)) {
// Create posts in blog
foreach ($values['POSTS'] as $post_id => $post) {
if (array_key_exists('category', $post)) {
$cat_id = array();
foreach ($post['category'] as $cat_code => $category) {
$cat_code = NULL;
if ($category == 'Uncategorized') {
continue;
}
// Skip blank category creation
foreach ($NEWS_CATS as $id => $existing_cat) {
if (get_translated_text($existing_cat['nc_title']) == $category) {
$cat_code = $id;
}
}
if (is_null($cat_code)) {
$cat_code = add_news_category($category, 'newscats/community', $category);
$NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'));
$NEWS_CATS = list_to_map('id', $NEWS_CATS);
}
$cat_id = array_merge($cat_id, array($cat_code));
}
}
$owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $member_id));
if ($post['post_type'] == 'post') {
$id = add_news($post['post_title'], html_to_comcode($post['post_content']), NULL, $is_validated, 1, $post['comment_status'] == 'closed' ? 0 : 1, 1, '', html_to_comcode($post['post_content']), $owner_category_id, $cat_id, NULL, $member_id, 0, time(), NULL, '');
} elseif ($post['post_type'] == 'page') {
// If dont have permission to write comcode page, skip the post
if (!has_submit_permission('high', get_member(), get_ip_address(), NULL, NULL)) {
continue;
}
require_code('comcode');
// Save articles as new comcode pages
$zone = filter_naughty(post_param('zone', 'site'));
$lang = filter_naughty(post_param('lang', 'EN'));
$file = preg_replace('/[^A-Za-z0-9]/', '_', $post['post_title']);
// Filter non alphanumeric charactors
$parent_page = post_param('parent_page', '');
$fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
// Check existancy of new page
$submiter = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
if (!is_null($submiter)) {
continue;
}
// Skip existing titled articles - may need change
require_code('submit');
give_submit_points('COMCODE_PAGE_ADD');
if (!addon_installed('unvalidated')) {
$is_validated = 1;
}
$GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $is_validated, 'p_edit_date' => NULL, 'p_add_date' => strtotime($post['post_date']), 'p_submitter' => $member_id, 'p_show_as_edit' => 0));
if (!file_exists($fullpath)) {
$_content = html_to_comcode($post['post_content']);
$myfile = @fopen($fullpath, 'wt');
if ($myfile === false) {
intelligent_write_error($fullpath);
}
if (fwrite($myfile, $_content) < strlen($_content)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
//.........这里部分代码省略.........
示例6: test_writable
/**
* Test whether a file exists and is writable.
*
* @param PATH The file path
*/
function test_writable($file)
{
if (!is_writable_wrap($file) && file_exists($file)) {
intelligent_write_error($file);
}
}
示例7: __make_logo
/**
* UI for a logo wizard step (set).
*
* @return tempcode The UI
*/
function __make_logo()
{
$title = get_page_title('_LOGOWIZARD', true, array(integer_format(3), integer_format(3)));
$GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/logowizard';
$theme = post_param('theme');
// Do it
require_code('themes2');
$rand = uniqid('', true);
foreach (array($theme, 'default') as $logo_save_theme) {
$path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png';
$img = generate_logo(post_param('name'), post_param('title'), false, $logo_save_theme, 'logo-template');
@imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
imagedestroy($img);
actual_edit_theme_image('logo/-logo', $logo_save_theme, user_lang(), 'logo/-logo', $path);
if (addon_installed('collaboration_zone')) {
actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, user_lang(), 'logo/collaboration-logo', $path);
}
$rand = uniqid('', true);
$path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png';
$img = generate_logo(post_param('name'), post_param('title'), false, NULL, 'trimmed-logo-template');
@imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
imagedestroy($img);
actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, user_lang(), 'logo/trimmed-logo', $path);
}
persistant_cache_delete('THEME_IMAGES');
breadcrumb_set_parents(array(array('_SELF:_SELF:make_logo', do_lang_tempcode('START'))));
$message = do_lang_tempcode('LOGOWIZARD_3_DESCRIBE', escape_html($theme));
return inform_screen($title, $message);
}
示例8: _xml_breadcrumbs
/**
* The UI actualiser edit the breadcrumbs XML file.
*
* @return tempcode The UI
*/
function _xml_breadcrumbs()
{
$title = get_page_title('BREADCRUMB_OVERRIDES');
$myfile = @fopen(get_custom_file_base() . '/data_custom/breadcrumbs.xml', 'wt');
if ($myfile === false) {
intelligent_write_error(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
}
$xml = post_param('xml');
if (fwrite($myfile, $xml) < strlen($xml)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
fix_permissions(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
sync_file(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
return inform_screen($title, do_lang_tempcode('SUCCESS'));
}
示例9: module_do_delete_file
/**
* The actualiser for deleting a file.
*
* @return tempcode The UI.
*/
function module_do_delete_file()
{
$title = get_page_title('FILEDUMP_DELETE_FILE');
$file = filter_naughty(get_param('file'));
$place = filter_naughty(get_param('place'));
breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('FILE_DUMP'))));
if (post_param_integer('confirmed', 0) != 1) {
$url = get_self_url();
$text = do_lang_tempcode('CONFIRM_DELETE', $file);
breadcrumb_set_self(do_lang_tempcode('CONFIRM'));
$hidden = build_keep_post_fields();
$hidden->attach(form_input_hidden('confirmed', '1'));
return do_template('CONFIRM_SCREEN', array('_GUID' => '19503cf5dc795b9c85d26702b79e3202', 'TITLE' => $title, 'FIELDS' => $hidden, 'PREVIEW' => $text, 'URL' => $url));
}
$owner = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'the_member', array('name' => $file, 'path' => $place));
if (!is_null($owner) && $owner == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump')) {
$test = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => $file, 'path' => $place));
if (!is_null($test)) {
delete_lang($test);
}
$path = get_custom_file_base() . '/uploads/filedump' . $place . $file;
@unlink($path) or intelligent_write_error($path);
sync_file('uploads/filedump/' . $file);
} else {
access_denied('I_ERROR');
}
$return_url = build_url(array('page' => '_SELF', 'type' => 'misc', 'place' => $place), '_SELF');
log_it('FILEDUMP_DELETE_FILE', $file, $place);
return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS'));
}
示例10: _import
/**
* The actualiser to import in bulk from an archive file.
*
* @return tempcode The UI
*/
function _import()
{
post_param('test');
// To pick up on max file size exceeded errors
require_code('uploads');
require_code('images');
is_swf_upload(true);
breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('EMOTICONS')), array('_SELF:_SELF:import', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_EMOTICONS'))));
foreach ($_FILES as $attach_name => $__file) {
$tmp_name = $__file['tmp_name'];
$file = $__file['name'];
switch (get_file_extension($file)) {
case 'zip':
if (!function_exists('zip_open') && get_option('unzip_cmd') == '') {
warn_exit(do_lang_tempcode('ZIP_NOT_ENABLED'));
}
if (!function_exists('zip_open')) {
require_code('m_zip');
$mzip = true;
} else {
$mzip = false;
}
$myfile = zip_open($tmp_name);
if (!is_integer($myfile)) {
while (false !== ($entry = zip_read($myfile))) {
// Load in file
zip_entry_open($myfile, $entry);
$_file = zip_entry_name($entry);
if (is_image($_file)) {
if (file_exists(get_file_base() . '/themes/default/images/emoticons/index.html')) {
$path = get_custom_file_base() . '/themes/default/images_custom/emoticons__' . basename($_file);
} else {
$path = get_custom_file_base() . '/themes/default/images_custom/ocf_emoticons__' . basename($_file);
}
$outfile = @fopen($path, 'wb') or intelligent_write_error($path);
$more = mixed();
do {
$more = zip_entry_read($entry);
if (fwrite($outfile, $more) < strlen($more)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
} while ($more !== false && $more != '');
fclose($outfile);
fix_permissions($path);
sync_file($path);
$this->_import_emoticon($path);
}
zip_entry_close($entry);
}
zip_close($myfile);
} else {
require_code('failure');
warn_exit(zip_error($myfile, $mzip));
}
break;
case 'tar':
require_code('tar');
$myfile = tar_open($tmp_name, 'rb');
if ($myfile !== false) {
$directory = tar_get_directory($myfile);
foreach ($directory as $entry) {
// Load in file
$_file = $entry['path'];
if (is_image($_file)) {
if (file_exists(get_file_base() . '/themes/default/images/emoticons/index.html')) {
$path = get_custom_file_base() . '/themes/default/images_custom/emoticons__' . basename($_file);
} else {
$path = get_custom_file_base() . '/themes/default/images_custom/ocf_emoticons__' . basename($_file);
}
$_in = tar_get_file($myfile, $entry['path'], false, $path);
$this->_import_emoticon($path);
}
}
tar_close($myfile);
}
break;
default:
if (is_image($file)) {
$urls = get_url('', $attach_name, 'themes/default/images_custom');
$path = $urls[0];
$this->_import_emoticon($path);
} else {
attach_message(do_lang_tempcode('BAD_ARCHIVE_FORMAT'), 'warn');
}
}
}
$title = get_page_title('IMPORT_EMOTICONS');
log_it('IMPORT_EMOTICONS');
return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), NULL);
}
示例11: __editor
/**
* The actualiser to edit a zone (via zone editor).
*
* @return tempcode The UI
*/
function __editor()
{
$title = get_page_title('ZONE_EDITOR');
$lang = choose_language($title, true);
if (is_object($lang)) {
return $lang;
}
$id = get_param('id', '');
// Edit settings
$_title = post_param('title');
$default_page = post_param('default_page');
$header_text = post_param('header_text');
$theme = post_param('theme');
$wide = post_param_integer('wide');
if ($wide == -1) {
$wide = NULL;
}
$require_session = post_param_integer('require_session', 0);
$displayed_in_menu = post_param_integer('displayed_in_menu', 0);
actual_edit_zone($id, $_title, $default_page, $header_text, $theme, $wide, $require_session, $displayed_in_menu, $id);
if ($id != '') {
$this->set_permissions($id);
}
// Edit pages
foreach (array('panel_left', 'start', 'panel_right') as $for) {
$redirect = post_param('redirect_' . $for, NULL);
if (!is_null($redirect)) {
if (addon_installed('redirects_editor')) {
$GLOBALS['SITE_DB']->query_delete('redirects', array('r_from_page' => $for, 'r_from_zone' => $id), '', 1);
if ($redirect != $id) {
$GLOBALS['SITE_DB']->query_insert('redirects', array('r_from_page' => $for, 'r_from_zone' => $id, 'r_to_page' => $for, 'r_to_zone' => $redirect, 'r_is_transparent' => 1), false, true);
// Avoid problem when same key entered twice
} else {
$redirect = NULL;
}
} else {
$redirect = NULL;
}
}
$comcode = post_param($for, NULL);
if (!is_null($comcode)) {
// Where to save to
$fullpath = zone_black_magic_filterer(get_custom_file_base() . ((is_null($redirect) ? $id : $redirect) == '' ? '' : '/') . (is_null($redirect) ? $id : $redirect) . '/pages/comcode_custom/' . $lang . '/' . $for . '.txt');
// Make dir if needed
if (!file_exists(dirname($fullpath))) {
if (@mkdir(dirname($fullpath), 0777) === false) {
warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR', escape_html(basename(dirname($fullpath))), escape_html(dirname(dirname($fullpath)))));
}
fix_permissions(dirname($fullpath), 0777);
sync_file(dirname($fullpath));
}
// Store revision
if (file_exists($fullpath) && get_option('store_revisions') == '1') {
$time = time();
@copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time));
fix_permissions($fullpath . '.' . strval($time));
sync_file($fullpath . '.' . strval($time));
}
// Save
$myfile = @fopen($fullpath, 'wt') or intelligent_write_error($fullpath);
if (fwrite($myfile, $comcode) < strlen($comcode)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
fix_permissions($fullpath);
sync_file($fullpath);
// De-cache
$caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => is_null($redirect) ? $id : $redirect, 'the_page' => $for));
foreach ($caches as $cache) {
delete_lang($cache['string_index']);
}
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => is_null($redirect) ? $id : $redirect, 'the_page' => $for));
}
}
persistant_cache_empty();
// Redirect
$url = get_param('redirect');
return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
}
示例12: javascript_tempcode
/**
* Get tempcode to tie in (to the HTML, in <head>) all the Javascript files that have been required.
*
* @param ?string Position to get Javascript for (NULL: all positions)
* @set NULL header footer
* @return tempcode The tempcode to tie in the Javascript files
*/
function javascript_tempcode($position = NULL)
{
global $JAVASCRIPTS, $JAVASCRIPT;
$js = new ocp_tempcode();
$minify = get_param_integer('keep_no_minify', 0) == 0;
$https = get_option('enable_https', true) == '1' && function_exists('is_page_https') && function_exists('get_zone_name') && (tacit_https() || is_page_https(get_zone_name(), get_page_name()));
$mobile = is_mobile();
// Special merge operation for staff. In truth it's to get a better score on Google Page Speed ;)
$to_merge = array('javascript_staff', 'javascript_button_occle', 'javascript_fractional_edit');
$good_to_merge = true;
foreach ($to_merge as $j) {
if (!array_key_exists($j, $JAVASCRIPTS)) {
$good_to_merge = false;
}
}
if ($good_to_merge) {
$j = 'javascript_staff___merged';
if (!$minify) {
$j .= '_non_minified';
}
if ($https) {
$j .= '_ssl';
}
if ($mobile) {
$j .= '_mobile';
}
$theme = filter_naughty($GLOBALS['FORUM_DRIVER']->get_theme());
$dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . filter_naughty(user_lang());
$write_path = $dir . '/' . filter_naughty_harsh($j);
$write_path .= '.js';
/*$rebuild=false; Performance hit
foreach ($to_merge as $j2)
{
$merge_from=javascript_enforce($j2);
if (filemtime($merge_from)==time()) $rebuild=true; // Hmm, just recalculated
}*/
if (!is_file($write_path)) {
$data = '';
foreach ($to_merge as $j2) {
$merge_from = javascript_enforce($j2);
if (is_file($merge_from)) {
$data .= unixify_line_format(file_get_contents($merge_from, FILE_TEXT));
} else {
$good_to_merge = false;
break;
}
}
if ($good_to_merge) {
$myfile = @fopen($write_path, 'wb') or intelligent_write_error($write_path);
// Intentionally wb to stop line ending conversions on Windows
fwrite($myfile, $data);
fclose($myfile);
fix_permissions($write_path, 0777);
sync_file($write_path);
}
}
if ($good_to_merge) {
if ($position != 'header') {
$js->attach(do_template('JAVASCRIPT_NEED', array('CODE' => $j)));
}
}
}
// Our main loop
$bottom_ones = array('javascript_staff' => 1, 'javascript_button_occle' => 1, 'javascript_fractional_edit' => 1, 'javascript_thumbnails' => 1, 'javascript_button_realtime_rain' => 1);
foreach (array_keys($JAVASCRIPTS) as $j) {
if ($good_to_merge && in_array($j, $to_merge)) {
continue;
}
if ($position !== NULL) {
$bottom = isset($bottom_ones[$j]);
// TODO: progmattic way of saying this at point of calls
if ($position == 'header' && $bottom) {
continue;
}
if ($position == 'footer' && !$bottom) {
continue;
}
}
$temp = javascript_enforce($j);
if ($temp != '') {
if (!$minify) {
$j .= '_non_minified';
}
if ($https) {
$j .= '_ssl';
}
if ($mobile) {
$j .= '_mobile';
}
$js->attach(do_template('JAVASCRIPT_NEED', array('_GUID' => 'b5886d9dfc4d528b7e1b0cd6f0eb1670', 'CODE' => $j)));
}
}
if (!is_null($JAVASCRIPT)) {
//.........这里部分代码省略.........
示例13: _do_template
/**
* A template has not been structurally cached, so compile it and store in the cache.
*
* @param ID_TEXT The theme the template is in the context of
* @param PATH The path to the template file
* @param ID_TEXT The codename of the template (e.g. foo)
* @param ID_TEXT The actual codename to use for the template (e.g. foo_mobile)
* @param LANGUAGE_NAME The language the template is in the context of
* @param string File type suffix of template file (e.g. .tpl)
* @param ?ID_TEXT The theme to cache in (NULL: main theme)
* @return tempcode The compiled tempcode
*/
function _do_template($theme, $path, $codename, $_codename, $lang, $suffix, $theme_orig = NULL)
{
if (is_null($theme_orig)) {
$theme_orig = $theme;
}
if (is_null($GLOBALS['CURRENT_SHARE_USER'])) {
$base_dir = ($theme == 'default' && ($suffix != '.css' || strpos($path, '/css_custom') === false) ? get_file_base() : get_custom_file_base()) . '/themes/';
} else {
$base_dir = get_custom_file_base() . '/themes/';
if (!is_file($base_dir . $theme . $path . $codename . $suffix)) {
$base_dir = get_file_base() . '/themes/';
}
}
global $CACHE_TEMPLATES, $FILE_ARRAY, $TEMPLATE_PREVIEW_OP, $MEM_CACHE;
if (isset($FILE_ARRAY)) {
$html = unixify_line_format(file_array_get('themes/' . $theme . $path . $codename . $suffix));
} else {
$html = unixify_line_format(file_get_contents($base_dir . filter_naughty($theme . $path . $codename) . $suffix, FILE_TEXT));
}
if ($GLOBALS['SEMI_DEBUG_MODE'] && strpos($html, '.innerHTML') !== false && !running_script('install') && strpos($html, 'Parser hint: .innerHTML okay') === false) {
attach_message('Do not use the .innerHTML property in your Javascript because it will not work in true XHTML (when the browsers real XML parser is in action). Use ocPortal\'s global setInnerHTML/getInnerHTML functions.', 'warn');
}
// Strip off trailing final lines from single lines templates. Editors often put these in, and it causes annoying "visible space" issues
if (substr($html, -1, 1) == chr(10) && substr_count($html, chr(10)) == 1) {
$html = substr($html, 0, strlen($html) - 1);
}
if ($TEMPLATE_PREVIEW_OP) {
$test = post_param($codename, NULL);
if (!is_null($test)) {
$html = post_param($test . '_new');
}
}
$result = template_to_tempcode($html, 0, false, $suffix != '.tpl' ? '' : $codename, $theme_orig, $lang);
if ($CACHE_TEMPLATES && !$TEMPLATE_PREVIEW_OP && ($suffix == '.tpl' || $codename == 'no_cache')) {
$path2 = get_custom_file_base() . '/themes/' . $theme_orig . '/templates_cached/' . filter_naughty($lang) . '/';
$myfile = @fopen($path2 . filter_naughty($_codename) . $suffix . '.tcp', 'wb');
if ($myfile === false) {
@mkdir(dirname($path2), 0777);
fix_permissions(dirname($path2), 0777);
sync_file(dirname($path2));
if (@mkdir($path2, 0777)) {
fix_permissions($path2, 0777);
sync_file($path2);
} else {
if ($codename == 'SCREEN_TITLE') {
critical_error('PASSON', do_lang('WRITE_ERROR', escape_html($path2 . filter_naughty($_codename) . $suffix . '.tcp')));
}
// Bail out hard if would cause a loop
intelligent_write_error($path2 . filter_naughty($_codename) . $suffix . '.tcp');
}
} else {
$data_to_write = '<' . '?php' . chr(10) . $result->to_assembly($lang) . chr(10) . '?' . '>';
if (fwrite($myfile, $data_to_write) >= strlen($data_to_write)) {
// Success
fclose($myfile);
require_code('files');
fix_permissions($path2 . filter_naughty($_codename) . $suffix . '.tcp');
} else {
// Failure
fclose($myfile);
@unlink($path2 . filter_naughty($_codename) . $suffix . '.tcp');
// Can't leave this around, would cause problems
}
}
}
return $result;
}
示例14: import_blocks
//.........这里部分代码省略.........
$myfile = @fopen($center_panel, 'wt+');
if ($myfile !== false) {
//prepare the content to be written
$out = '';
//just to ensure
$out .= '[block="10000" blogs="0" filter="' . $pinned_news_cat_id . '" title="' . do_lang('PINNED_NEWS') . '"]main_news[/block]' . (chr(10) . ($middle ? chr(10) : '')) . $contents;
//fseek($myfile, 0); //set the pointer at the start of the file
fwrite($myfile, $out);
//write the content of the from it's start
fclose($myfile);
//close file
}
}
fix_permissions($left_panel);
fix_permissions($right_panel);
fix_permissions($center_panel);
sync_file($left_panel);
sync_file($right_panel);
sync_file($center_panel);
}
//start importing PHP blocks
$rows = $db->query('SELECT * FROM ' . $table_prefix . 'blocks WHERE ' . db_string_equal_to('file', '') . ' AND ' . db_string_equal_to('active', 'checked') . ' ORDER BY progressive ASC');
//go through all of the non-PHP blocks
foreach ($rows as $row) {
if (preg_match('/class="mkicon"/im', $row['content']) != 0) {
//it is a links block
$matches = array();
preg_match_all('/href=\\"(.*)\\".*>(.*)<\\/a>/Uim', $row['content'], $matches);
$matches_url = isset($matches[1]) && is_array($matches[1]) ? $matches[1] : array();
$matches_titles = isset($matches[2]) && is_array($matches[2]) ? $matches[2] : array();
$block_title = @html_entity_decode($row['title'], ENT_QUOTES, get_charset());
$out = chr(10) . '[block="mkp_block_' . strval($row['id']) . '" type="tree" caption="' . comcode_escape($block_title) . '"]side_stored_menu[/block]';
$left_panel_contents = file_get_contents($left_panel);
if (strpos($left_panel_contents, $out) === false) {
$myfile = @fopen($left_panel, 'at');
if ($myfile !== false) {
fwrite($myfile, $out);
//write the content of the from it's start
fclose($myfile);
//close file
}
fix_permissions($left_panel);
sync_file($left_panel);
}
//if there are urls to be changed
if (count($matches_url) > 0) {
foreach ($matches_url as $key => $url) {
$link_title = isset($matches_titles[$key]) && strlen($matches_titles[$key]) > 0 ? $matches_titles[$key] : '';
$_url_match = array();
preg_match('/pid=.*/i', $url, $_url_match);
$url_match = isset($_url_match[0]) && strlen($_url_match[0]) > 0 ? $_url_match[0] : '';
$url_match = preg_replace('/pid=/', '', $url_match);
add_menu_item_simple('mkp_block_' . strval($row['id']), NULL, html_entity_decode($link_title, ENT_QUOTES, get_charset()), ':pn' . $url_match);
}
}
} else {
//it is not a links block, so we write it into a new page
$page_title = $row['title'];
$page = '';
$c_dir = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/';
$comcode_pages_title = do_lang('COMCODE_PAGES');
//get other custom comcode pages names
$older_comcode_files = array();
$d = opendir($c_dir);
while (false !== ($entry = readdir($d))) {
if (preg_match('/pn.*\\.txt/', $entry) != 0) {
$arr_index = intval(preg_replace('/pn|\\.txt/', '', $entry));
$older_comcode_files[$arr_index] = $arr_index;
}
}
closedir($d);
ksort($older_comcode_files);
//get the highest comcode page id
$max_index = end($older_comcode_files);
$max_index = is_null($max_index) ? 1 : $max_index;
$page .= ' - [page caption="' . $page_title . '"]pn' . strval($max_index + 1) . '[/page]' . chr(10);
$page2 = do_template('IMPORT_MKPORTAL_FCOMCODEPAGE', array('TITLE' => $page_title, 'SUBTITLE' => '', 'PAGE_HEADER' => '', 'TEXT' => $page, 'PAGE_FOOTER' => '', 'SIGNATURE' => ''));
//save the comcode file
$path = $c_dir . 'pn' . strval($max_index + 1) . '.txt';
$myfile = @fopen($path, 'at');
if ($myfile === false) {
intelligent_write_error($path);
}
fwrite($myfile, $page2->evaluate());
fclose($myfile);
fix_permissions($path);
sync_file($path);
//add info about comcode file
$path = $c_dir . 'pnindex.txt';
$myfile = @fopen($path, 'at');
if ($myfile === false) {
intelligent_write_error($path);
}
fwrite($myfile, $page);
fclose($myfile);
fix_permissions($path);
sync_file($path);
}
}
}
示例15: __edit_templates
/**
* The actualiser to edit a template. Always saves to the most overridden version.
*
* @return tempcode The UI
*/
function __edit_templates()
{
// Erase cache
$theme = filter_naughty(post_param('theme'));
//if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
erase_cached_templates();
require_code('view_modes');
erase_tempcode_cache();
$title = get_page_title('EDIT_TEMPLATES');
foreach (array_keys($_REQUEST) as $_i) {
$matches = array();
if (preg_match('#f(\\d+)file#', $_i, $matches) != 0) {
$i = $matches[1];
} else {
continue;
}
$_file = substr(str_replace('/default/', '/' . $theme . '/', '/' . filter_naughty(post_param('f' . $i . 'file', ''))), 1);
if ($_file == '') {
continue;
}
if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($_file, 'BANNER_TYPED') !== false) {
warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
}
$file = str_replace('templates/', 'templates_custom/', $_file);
$file = str_replace('css/', 'css_custom/', $file);
$fullpath = get_custom_file_base() . '/themes/' . $file;
// Make backup
if (file_exists($fullpath) && get_option('templates_store_revisions') == '1') {
@copy($fullpath, $fullpath . '.' . strval(time())) or intelligent_write_error($fullpath . '.' . strval(time()));
fix_permissions($fullpath . '.' . strval(time()));
sync_file($fullpath . '.' . strval(time()));
}
// Save
$new = post_param('f' . $i . '_new', false, true);
$fullpath_orig = preg_replace('#/themes/[^/]*/(.*)(\\_custom)?/#U', '/themes/default/${1}/', $fullpath);
if (file_exists($fullpath_orig) && $new == file_get_contents($fullpath_orig)) {
if (file_exists($fullpath)) {
unlink($fullpath);
sync_file($fullpath);
}
if (file_exists($fullpath . '.editfrom')) {
unlink($fullpath . '.editfrom');
sync_file($fullpath . '.editfrom');
}
$_file = preg_replace('#[^/]*/(.*)(\\_custom)?/#U', 'default/${1}/', $_file);
$file = $_file;
} else {
$myfile = @fopen($fullpath, 'wt');
if ($myfile === false) {
intelligent_write_error($fullpath);
}
if (fwrite($myfile, $new) < strlen($new)) {
fclose($myfile);
unlink($fullpath);
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
fix_permissions($fullpath);
sync_file($fullpath);
if (file_exists(get_file_base() . '/themes/' . post_param('f' . $i . 'file'))) {
// Make base-hash-thingy
$myfile = @fopen($fullpath . '.editfrom', 'wt');
if ($myfile === false) {
intelligent_write_error($fullpath);
}
$hash = file_get_contents(get_file_base() . '/themes/' . post_param('f' . $i . 'file'), FILE_TEXT);
if (fwrite($myfile, $hash) < strlen($hash)) {
warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
}
fclose($myfile);
fix_permissions($fullpath . '.editfrom');
sync_file($fullpath . '.editfrom');
}
}
log_it('EDIT_TEMPLATES', $file, $theme);
}
breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:edit_templates:theme=' . $theme, do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:_edit_templates:theme=' . $theme . ':file=' . $file, do_lang_tempcode('EDIT_TEMPLATES'))));
breadcrumb_set_self(do_lang_tempcode('DONE'));
if (get_param_integer('save_and_stay', 0) == 1) {
return inform_screen($title, protect_from_escaping('
<script type="text/javascript">// <![CDATA[
window.fauxmodal_alert(\'' . addslashes(do_lang('SUCCESS')) . '\');
//]]></script>
'));
}
return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), $theme, '', 'templates', $file);
}