当前位置: 首页>>代码示例>>PHP>>正文


PHP sync_file函数代码示例

本文整理汇总了PHP中sync_file函数的典型用法代码示例。如果您正苦于以下问题:PHP sync_file函数的具体用法?PHP sync_file怎么用?PHP sync_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sync_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:46,代码来源:splurgh.php

示例2: _handle_permission_check_logging

/**
 * Log permission checks to the permission_checks.log file
 *
 * @param  MEMBER         The user checking against
 * @param  ID_TEXT        The function that was called to check a permission
 * @param  array          Parameters to this permission-checking function
 * @param  boolean        Whether the permission was held
 */
function _handle_permission_check_logging($member, $op, $params, $result)
{
    global $PERMISSION_CHECK_LOGGER;
    if ($op == 'has_specific_permission') {
        require_all_lang();
        $params[0] = $params[0] . ' ("' . do_lang('PT_' . $params[0]) . '")';
    }
    $str = $op;
    if (count($params) != 0) {
        $str .= ': ';
        foreach ($params as $i => $p) {
            if ($i != 0) {
                $str .= ',';
            }
            $str .= is_string($p) ? $p : (is_null($p) ? '' : strval($p));
        }
    }
    if ($PERMISSION_CHECK_LOGGER !== false && !$result) {
        fwrite($PERMISSION_CHECK_LOGGER, "\t" . $str);
        $username = $GLOBALS['FORUM_DRIVER']->get_username($member);
        if (is_null($username)) {
            $username = do_lang('UNKNOWN');
        }
        if ($member != get_member()) {
            fwrite($PERMISSION_CHECK_LOGGER, ' -- ' . $username);
        }
        //	fwrite($PERMISSION_CHECK_LOGGER,' --> '.($result?do_lang('YES'):do_lang('NO')).chr(10));
        fwrite($PERMISSION_CHECK_LOGGER, chr(10));
        sync_file(get_custom_file_base() . '/data_custom/permissioncheckslog.php');
    }
    if (function_exists('fb') && get_param_integer('keep_firephp', 0) == 1 && !headers_sent()) {
        fb('Permission check ' . ($result ? 'PASSED' : 'FAILED') . ': ' . $str);
    }
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:42,代码来源:permissions2.php

示例3: _delete_attachment

/**
 * Delete the specified attachment
 *
 * @param  AUTO_LINK		The attachment ID to delete
 * @param  object			The database connection to use
 * @set    ocp forum
 */
function _delete_attachment($id, $connection)
{
    $connection->query_delete('attachment_refs', array('a_id' => $id));
    // Get attachment details
    $_attachment_info = $connection->query_select('attachments', array('a_url', 'a_thumb_url'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $_attachment_info)) {
        return;
    }
    // Already gone
    $attachment_info = $_attachment_info[0];
    // Delete url and thumb_url if local
    if (url_is_local($attachment_info['a_url']) && substr($attachment_info['a_url'], 0, 19) == 'uploads/attachments') {
        $url = rawurldecode($attachment_info['a_url']);
        @unlink(get_custom_file_base() . '/' . $url);
        sync_file($url);
        if ($attachment_info['a_thumb_url'] != '' && strpos($attachment_info['a_thumb_url'], 'uploads/filedump/') === false) {
            $thumb_url = rawurldecode($attachment_info['a_thumb_url']);
            @unlink(get_custom_file_base() . '/' . $thumb_url);
            sync_file($thumb_url);
        }
    }
    // Delete attachment
    $connection->query_delete('attachments', array('id' => $id), '', 1);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:31,代码来源:attachments3.php

示例4: write_file

 /**
  * Standard modular file writing function for OcCLE FS hooks.
  *
  * @param  array	The current meta-directory path
  * @param  string	The root node of the current meta-directory
  * @param  string	The file name
  * @param  string	The new file contents
  * @param  array	A reference to the OcCLE filesystem object
  * @return boolean	Success?
  */
 function write_file($meta_dir, $meta_root_node, $file_name, $contents, &$occle_fs)
 {
     $file_name = filter_naughty($file_name);
     $path = get_custom_file_base() . '/data/modules/admin_occle';
     foreach ($meta_dir as $meta_dir_section) {
         $path .= '/' . filter_naughty($meta_dir_section);
     }
     if (is_dir($path) && (file_exists($path . '/' . $file_name) && is_writable_wrap($path . '/' . $file_name) || !file_exists($path . '/' . $file_name) && is_writable_wrap($path))) {
         $fh = @fopen($path . '/' . $file_name, 'wt') or intelligent_write_error($path . '/' . $file_name);
         $output = fwrite($fh, $contents);
         fclose($fh);
         if ($output < strlen($contents)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fix_permissions($path . '/' . $file_name);
         sync_file($path . '/' . $file_name);
         return $output;
     } else {
         return false;
     }
     //File doesn't exist
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:32,代码来源:bin.php

示例5: data_to_disk

 /**
  * Convert a WowBB database file to an ocPortal uploaded file (stored on disk).
  *
  * @param  string			The file data
  * @param  string			The optimal filename
  * @param  ID_TEXT		The upload type (e.g. ocf_photos)
  * @return URLPATH		The URL
  */
 function data_to_disk($data, $filename, $sections)
 {
     $filename = find_derivative_filename('uploads/' . $sections, $filename);
     $path = get_custom_file_base() . '/uploads/' . $sections . '/' . $filename . '.dat';
     $myfile = @fopen($path, 'wb') or warn_exit(do_lang_tempcode('WRITE_ERROR', escape_html('uploads/' . $sections . '/' . $filename . '.dat')));
     if (fwrite($myfile, $data) < strlen($data)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions($path);
     sync_file($path);
     $url = 'uploads/' . $sections . '/' . $filename . '.dat';
     return $url;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:22,代码来源:wowbb.php

示例6: db_connect

<?php

//print_r($_SESSION);
if (isset($_SESSION["userid"])) {
    db_connect();
    show_connection_details();
    if ($_POST["submit_filter"]) {
        process_submission();
    }
    if ($_POST["submit_export"]) {
        //print_r($_POST);
        sync_file();
    }
} else {
    echo "<font color='red'>Unauthorized access to this page. Please log in.</font>";
    echo "<br><a href='{$_SERVER['PHP_SELF']}'>Try Again</a>";
}
function db_connect()
{
    $db_conn = mysql_connect('localhost', $_SESSION["dbuser"], $_SESSION["dbpass"]) or die("Cannot query 14: " . mysql_error());
    mysql_select_db($_SESSION["dbname"], $db_conn) or die("Cannot query 15: " . mysql_error());
}
function show_connection_details()
{
    $q_user = mysql_query("SELECT user_lastname, user_firstname, user_id FROM game_user ORDER by user_lastname ASC, user_firstname ASC");
    $q_brgy = mysql_query("SELECT barangay_id, barangay_name FROM m_lib_barangay") or die("Cannot query 21: " . mysql_error());
    echo "<form action='{$_SERVER['PHP_SELF']}' method='POST'>";
    echo "<table border='1' width='50%' style='margin: 0 auto'>";
    echo "<tr><td>Current active database: </td><td>" . $_SESSION["dbname"] . "</td></tr>";
    echo "<tr><td>Select End User Account to Sync</td>";
    echo "<td><select name='sel_user'>";
开发者ID:wahgithub,项目名称:chits_wah_emr,代码行数:31,代码来源:lite1.php

示例7: set_lang_code_2

 /**
  * The actualiser to translate code (called externally, and may operate on many lang files).
  *
  * @return tempcode		The UI
  */
 function set_lang_code_2()
 {
     $lang = post_param('lang');
     $lang_files = get_lang_files(fallback_lang());
     foreach (array_keys($lang_files) as $lang_file) {
         $for_base_lang = get_lang_file_map(fallback_lang(), $lang_file, true);
         $for_base_lang_2 = get_lang_file_map($lang, $lang_file, false);
         $descriptions = get_lang_file_descriptions(fallback_lang(), $lang_file);
         $out = '';
         foreach ($for_base_lang_2 + $for_base_lang as $key => $now_val) {
             $val = post_param('l_' . $key, array_key_exists($key, $for_base_lang_2) ? $for_base_lang_2[$key] : $now_val);
             if (str_replace(chr(10), '\\n', $val) != $now_val || !array_key_exists($key, $for_base_lang) || $for_base_lang[$key] != $val || !file_exists(get_file_base() . '/lang/' . fallback_lang() . '/' . $lang_file . '.ini')) {
                 // if it's changed from default ocPortal, or not in default ocPortal, or was already changed in language file, or whole file is not in default ocPortal
                 $out .= $key . '=' . str_replace(chr(10), '\\n', $val) . "\n";
             }
         }
         if ($out != '') {
             $path = get_custom_file_base() . '/lang_custom/' . filter_naughty($lang) . '/' . filter_naughty($lang_file) . '.ini';
             $path_backup = $path . '.' . strval(time());
             if (file_exists($path)) {
                 @copy($path, $path_backup) or intelligent_write_error($path_backup);
                 sync_file($path_backup);
             }
             $myfile = @fopen($path, 'wt');
             if ($myfile === false) {
                 intelligent_write_error($path);
             }
             fwrite($myfile, "[descriptions]\n");
             foreach ($descriptions as $key => $description) {
                 if (fwrite($myfile, $key . '=' . $description . "\n") == 0) {
                     warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                 }
             }
             fwrite($myfile, "\n[strings]\n");
             fwrite($myfile, $out);
             fclose($myfile);
             fix_permissions($path);
             sync_file($path);
             $path_backup2 = $path . '.latest_in_ocp_edit';
             @copy($path, $path_backup2) or intelligent_write_error($path_backup2);
             sync_file($path_backup2);
         }
     }
     $title = get_page_title('TRANSLATE_CODE');
     log_it('TRANSLATE_CODE');
     require_code('view_modes');
     erase_cached_language();
     erase_cached_templates();
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url == '') {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:60,代码来源:admin_lang.php

示例8: create_video_thumb


//.........这里部分代码省略.........
    if (preg_match('#audio\\/#i', $input_mime_type) != 0) {
        $ret = find_theme_image('audio_thumb', true);
        if ($ret != '') {
            if (!is_null($expected_output_path)) {
                require_code('files');
                $_expected_output_path = fopen($expected_output_path, 'wb');
                http_download_file($ret, NULL, true, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $_expected_output_path);
                fclose($_expected_output_path);
            }
        }
        return $ret;
    }
    // Try one of the hooks for video types
    $ve_hooks = find_all_hooks('systems', 'video_embed');
    foreach (array_keys($ve_hooks) as $ve_hook) {
        require_code('hooks/systems/video_embed/' . $ve_hook);
        $ve_ob = object_factory('Hook_video_embed_' . $ve_hook);
        $thumbnail = $ve_ob->get_video_thumbnail($src_url);
        if (!is_null($thumbnail)) {
            return $thumbnail;
        }
    }
    // Ok, gonna try hard using what FFMPEG techniques we can...
    if (substr($src_url, 0, strlen(get_custom_base_url() . '/')) == get_custom_base_url() . '/') {
        $src_url = substr($src_url, strlen(get_custom_base_url() . '/'));
    }
    if (!url_is_local($src_url)) {
        return '';
    }
    $src_file = get_custom_file_base() . '/' . rawurldecode($src_url);
    $src_file = preg_replace('#(\\\\|/)#', DIRECTORY_SEPARATOR, $src_file);
    if (class_exists('ffmpeg_movie')) {
        $filename = 'thumb_' . md5(uniqid('', true)) . '1.jpg';
        if (is_null($expected_output_path)) {
            $expected_output_path = get_custom_file_base() . '/uploads/galleries/' . $filename;
        }
        if (file_exists($expected_output_path)) {
            return 'uploads/galleries/' . rawurlencode(basename($expected_output_path));
        }
        $movie = @new ffmpeg_movie($src_file, false);
        if ($movie !== false) {
            if ($movie->getFrameCount() == 0) {
                return '';
            }
            $frame = $movie->getFrame(min($movie->getFrameCount(), 25));
            if (method_exists($frame, 'toGDImage')) {
                $gd_img = $frame->toGDImage();
                @imagejpeg($gd_img, $expected_output_path);
            } else {
                $frame->save($expected_output_path);
                // New-style
            }
            if (file_exists($expected_output_path)) {
                require_code('images');
                if (get_option('is_on_gd') == '1' && function_exists('imagecreatefromstring')) {
                    convert_image($expected_output_path, $expected_output_path, -1, -1, intval(get_option('thumb_width')), true, NULL, true);
                }
                return 'uploads/galleries/' . rawurlencode(basename($expected_output_path));
            }
        }
    }
    $ffmpeg_path = get_option('ffmpeg_path');
    if ($ffmpeg_path != '' && strpos(@ini_get('disable_functions'), 'shell_exec') === false) {
        $filename = 'thumb_' . md5(uniqid(strval(post_param_integer('thumbnail_auto_position', 1)), true)) . '%d.jpg';
        $dest_file = get_custom_file_base() . '/uploads/galleries/' . $filename;
        if (is_null($expected_output_path)) {
            $expected_output_path = str_replace('%d', '1', $dest_file);
        }
        if (file_exists($dest_file) && is_null(post_param_integer('thumbnail_auto_position', NULL))) {
            return 'uploads/galleries/' . rawurlencode(basename($expected_output_path));
        }
        @unlink($dest_file);
        // So "if (@filesize($expected_output_path)) break;" will definitely fail if error
        $dest_file = preg_replace('#(\\\\|/)#', DIRECTORY_SEPARATOR, $dest_file);
        $at = display_seconds_period(post_param_integer('thumbnail_auto_position', 1));
        if (strlen($at) == 5) {
            $at = '00:' . $at;
        }
        $shell_command = '"' . $ffmpeg_path . 'ffmpeg" -i ' . @escapeshellarg($src_file) . ' -an -ss ' . $at . ' -r 1 -vframes 1 -y ' . @escapeshellarg($dest_file);
        $shell_commands = array($shell_command, $shell_command . ' -map 0.0:0.0', $shell_command . ' -map 0.1:0.0');
        foreach ($shell_commands as $shell_command) {
            shell_exec($shell_command);
            if (@filesize($expected_output_path)) {
                break;
            }
        }
        if (file_exists(str_replace('%d', '1', $dest_file))) {
            require_code('images');
            if (get_option('is_on_gd') == '1' && function_exists('imagecreatefromstring')) {
                convert_image(str_replace('%d', '1', $dest_file), $expected_output_path, -1, -1, intval(get_option('thumb_width')), true, NULL, true);
            } else {
                copy(str_replace('%d', '1', $dest_file), $expected_output_path);
                fix_permissions($expected_output_path);
                sync_file($expected_output_path);
            }
            return 'uploads/galleries/' . rawurlencode(basename($expected_output_path));
        }
    }
    return '';
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:galleries2.php

示例9: data_to_disk

 /**
  * Convert a AEF database file to an ocPortal uploaded file (stored on disk).
  *
  * @param  string			The file data
  * @param  string			The optimal filename
  * @param  ID_TEXT		The upload type (e.g. ocf_photos)
  * @param  PATH			The base directory we are importing from
  * @return array			Pair: The URL, the thumb url
  */
 function data_to_disk($data, $filename, $sections, $file_base)
 {
     $globals = array();
     require $file_base . '/universal.php';
     $attachments_dir = $globals['server_url'] . '/uploads/attachments/';
     //forum attachments directory
     $file_path = $attachments_dir . $filename;
     $data = $data == '' ? file_get_contents($file_path) : $data;
     $filename = find_derivative_filename('uploads/' . $sections, $filename);
     $path = get_custom_file_base() . '/uploads/' . $sections . '/' . $filename;
     $myfile = @fopen($path, 'wb') or warn_exit(do_lang_tempcode('WRITE_ERROR', escape_html('uploads/' . $sections . '/' . $filename)));
     if (fwrite($myfile, $data) < strlen($data)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions($path);
     sync_file($path);
     $url = 'uploads/' . $sections . '/' . $filename;
     return array($url, $url);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:29,代码来源:aef.php

示例10: _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'));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:21,代码来源:admin_config.php

示例11: _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;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:79,代码来源:tempcode_compiler.php

示例12: import_news_and_categories

 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'news')));
     $categories = $db->query("SELECT id,title,description,image FROM " . $table_prefix . "sections WHERE title='News'");
     foreach ($categories as $category) {
         $title = $category['title'];
         $cat_id = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'), array('nc_title' => $title), '', 1);
         if (count($cat_id) == 0) {
             $cat_title = $category['title'];
             $category_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news_categories AS N ON T.id=N.nc_title AND " . db_string_equal_to('T.text_original', $cat_title));
             if (count($category_id) == 0) {
                 $desc = html_to_comcode($category['description']);
                 $id = add_news_category($category['title'], $category['image'], $desc, NULL, NULL);
             } else {
                 $id = $category_id[0]['id'];
             }
         } else {
             $id = $cat_id[0]['id'];
         }
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'content WHERE sectionid=' . strval($category['id']));
         foreach ($rows as $row) {
             $val = $row['title'];
             $news_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news AS N ON T.id=N.title AND " . db_string_equal_to('T.text_original', $val) . " AND news_category=" . strval($id) . " AND news_category<>''");
             if (count($news_id) == 0) {
                 $title = $row['title'];
                 $news = html_to_comcode($row['introtext']);
                 $author = $db->query_value_null_ok('users', 'name', array('id' => $row['created_by']));
                 if (is_null($author)) {
                     $author = do_lang('UNKNOWN');
                 }
                 $access = $row['access'];
                 if ($access == 0) {
                     $validated = 1;
                 } else {
                     $validated = 0;
                 }
                 $allow_rating = 1;
                 $allow_comments = 1;
                 $allow_trackbacks = 1;
                 $notes = '';
                 $news_article = '';
                 $main_news_category = $id;
                 $news_category = NULL;
                 $datetimearr = explode(' ', $row['created']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $time = mktime($hour, $min, $sec, $month, $date, $year);
                 $submitter = import_id_remap_get('member', strval($row['created_by']));
                 $views = $row['hits'];
                 $datetimearr = explode(' ', $row['modified']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $edit_date = mktime($hour, $min, $sec, $month, $date, $year);
                 $nid = NULL;
                 $image = 'newscats/' . preg_replace('#\\..*$#', '', $row['images']);
                 @mkdir(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 fix_permissions(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 sync_file(get_custom_file_base() . '/themes/default/images_custom/newscats');
                 $newimagepath = get_custom_file_base() . '/themes/default/images_custom/newscats/' . rawurldecode($row['images']);
                 $oldimagepath = $old_base_dir . "/images/stories/" . rawurldecode($row['images']);
                 @copy($oldimagepath, $newimagepath);
                 fix_permissions($newimagepath);
                 sync_file($newimagepath);
                 add_news($title, $news, $author, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, $time, $submitter, $views, $edit_date, $nid, $image);
             }
         }
     }
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:88,代码来源:joomla.php

示例13: 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;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:73,代码来源:admin_import.php

示例14: __delete

 /**
  * The actualiser to delete a page.
  *
  * @return tempcode		The UI
  */
 function __delete()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletepage';
     $zone = post_param('zone', NULL);
     $afm_needed = false;
     $pages = find_all_pages_wrap($zone);
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (get_file_base() != get_custom_file_base() && strpos($type, 'comcode_custom') !== false) {
                 warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
             }
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             $GLOBALS['SITE_DB']->query_delete('menu_items', array('i_url' => $zone . ':' . $page));
             if (substr($type, 0, 7) == 'comcode' || substr($type, 0, 4) == 'html') {
                 $type_shortened = preg_replace('#/.+#', '', $type);
                 if (substr($type, 0, 7) == 'comcode' && get_option('store_revisions') == '1') {
                     $time = time();
                     $fullpath = zone_black_magic_filterer((strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page);
                     $bs_path = zone_black_magic_filterer(str_replace('/comcode/', '/comcode_custom/', $fullpath) . '.' . strval($time));
                     @copy($fullpath, $bs_path) or intelligent_write_error($fullpath);
                     sync_file($bs_path);
                     fix_permissions($bs_path);
                 }
                 $langs = find_all_langs(true);
                 foreach (array_keys($langs) as $lang) {
                     $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type_shortened) . '/' . $lang . '/' . $_page, true);
                     $path = (strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                     if (file_exists($path)) {
                         if ($afm_needed) {
                             afm_delete_file($_path);
                         } else {
                             unlink(get_custom_file_base() . '/' . $_path);
                         }
                     }
                 }
                 if (substr($type, 0, 7) == 'comcode') {
                     require_code('attachments2');
                     require_code('attachments3');
                     delete_comcode_attachments('comcode_page', $zone . ':' . $page);
                     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     persistant_cache_empty();
                     decache('main_comcode_page_children');
                     require_code('seo2');
                     seo_meta_erase_storage('comcode_page', $zone . ':' . $page);
                 }
             } else {
                 $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true);
                 $path = (strpos($type, '_custom') === false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                 if (file_exists($path)) {
                     if ($afm_needed) {
                         afm_delete_file($_path);
                     } else {
                         unlink(get_custom_file_base() . '/' . $_path);
                     }
                 }
             }
             $GLOBALS['SITE_DB']->query_delete('https_pages', array('https_page_name' => $page), '', 1);
             log_it('DELETE_PAGES', $page);
         }
     }
     persistant_cache_empty();
     decache('main_sitemap');
     $title = get_page_title('DELETE_PAGES');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:delete', do_lang_tempcode('DELETE_PAGES'))));
     return $this->do_next_manager($title, NULL, $zone, new ocp_tempcode());
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:96,代码来源:admin_sitetree.php

示例15: make_theme

/**
 * Make a theme. Note that this will trigger the AFM.
 *
 * @param  string		Name of the theme.
 * @param  ID_TEXT	The theme it's being generated from
 * @param  ID_TEXT	The algorithm to use
 * @set equations hsv
 * @param  string		Seed colour to use.
 * @param  boolean	Whether to use the theme immediately.
 * @param  ?boolean  Whether it will be a dark theme (NULL: autodetect).
 * @param  boolean	Whether to inherit the CSS, for easier theme upgrading.
 */
function make_theme($themename, $source_theme, $algorithm, $seed, $use, $dark = false, $inherit_css = false)
{
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    load_themewizard_params_from_theme($source_theme, $algorithm == 'hsv');
    if (file_exists(get_custom_file_base() . '/themes/' . $themename)) {
        require_code('abstract_file_manager');
        force_have_afm_details();
        $extending_existing = true;
    } else {
        if ($source_theme == 'default') {
            actual_add_theme($themename);
        } else {
            require_code('themes3');
            actual_copy_theme($source_theme, $themename);
        }
        $extending_existing = false;
    }
    if ($seed != find_theme_seed($source_theme) || $dark != find_theme_dark($source_theme)) {
        list($colours, $landscape) = calculate_theme($seed, $source_theme, $algorithm, 'colours', $dark);
        // Make images
        global $THEME_WIZARD_IMAGES, $THEME_WIZARD_IMAGES_NO_WILD, $IMG_CODES;
        if (function_exists('imagecolorallocatealpha')) {
            require_code('themes2');
            $full_img_set = array();
            foreach ($THEME_WIZARD_IMAGES as $expression) {
                if (substr($expression, -1) == '*') {
                    $expression = substr($expression, 0, strlen($expression) - 2);
                    // remove "/*"
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images', $expression)));
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images/' . fallback_lang(), $expression)));
                } else {
                    $full_img_set[] = $expression;
                }
            }
            if ($extending_existing) {
                $temp_all_ids = collapse_2d_complexity('id', 'path', $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $themename)));
            } else {
                $temp_all_ids = array();
            }
            $_langs = find_all_langs(true);
            foreach ($full_img_set as $image_code) {
                if (!in_array($image_code, $THEME_WIZARD_IMAGES_NO_WILD)) {
                    if ($extending_existing && array_key_exists($image_code, $temp_all_ids) && strpos($temp_all_ids[$image_code], $themename . '/images_custom/') !== false && (!url_is_local($temp_all_ids[$image_code]) || file_exists(get_custom_file_base() . '/' . $temp_all_ids[$image_code]))) {
                        continue;
                    }
                    foreach (array_keys($_langs) as $lang) {
                        $orig_path = find_theme_image($image_code, true, true, $source_theme, $lang);
                        if ($orig_path == '') {
                            continue;
                        }
                        // Theme has specified non-existent image as themewizard-compatible
                        if (strpos($orig_path, '/' . $lang . '/') === false && $lang != fallback_lang()) {
                            continue;
                        }
                        if (strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/' . $lang . '/';
                        } else {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/';
                        }
                        $saveat = get_custom_file_base() . '/' . $composite . $image_code . '.png';
                        $saveat_url = $composite . $image_code . '.png';
                        // Wipe out ones that might have been copied from source theme
                        if ($source_theme != 'default' && strpos($orig_path, 'images_custom') !== false) {
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.png');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpg');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.gif');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpeg');
                        }
                        if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') {
                            $image = calculate_theme($seed, $source_theme, $algorithm, $image_code, $dark, $colours, $landscape, $lang);
                            if (!is_null($image)) {
                                $pos = strpos($image_code, '/');
                                if ($pos !== false || strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                                    afm_make_directory($composite . substr($image_code, 0, $pos), true, true);
                                }
                                @imagepng($image, $saveat) or intelligent_write_error($saveat);
                                imagedestroy($image);
                                fix_permissions($saveat);
                                sync_file($saveat);
                                actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                                //if ($lang==fallback_lang()) $IMG_CODES['site'][$image_code]=$saveat_url;
                            }
                        } else {
                            actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:themewizard.php


注:本文中的sync_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。