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


PHP sys::varpath方法代码示例

本文整理汇总了PHP中sys::varpath方法的典型用法代码示例。如果您正苦于以下问题:PHP sys::varpath方法的具体用法?PHP sys::varpath怎么用?PHP sys::varpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


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

示例1: calendar_adminapi_get_calendars

/**
 * generate the common admin menu configuration
 */
function calendar_adminapi_get_calendars()
{
    // Initialise the array that will hold the menu configuration
    $cals = array();
    $curdir = sys::varpath() . '/calendar';
    $ics_array = array();
    if ($dir = @opendir($curdir)) {
        while (($file = @readdir($dir)) !== false) {
            if (preg_match('/\\.(ics)$/', $file)) {
                $ics_array[] = $file;
            }
        }
    }
    $cals['icsfiles'] = $ics_array;
    $cals['thereAreIcs'] = sizeof($ics_array);
    // Return the array containing the menu configuration
    return $cals;
}
开发者ID:godboko,项目名称:modules,代码行数:21,代码来源:get_calendars.php

示例2: calendar_user_publish

/**
 * Publish a calendar
 */
function calendar_user_publish($args)
{
    extract($args);
    xarVarFetch('calid', 'id', $calid, 0, XARVAR_NOT_REQUIRED);
    xarVarFetch('calname', 'str:1:', $calname, '', XARVAR_NOT_REQUIRED);
    // test
    xarModVars::set('calendar', 'SupportShortURLs', 1);
    // TODO: security et al.
    if (!empty($calid) || !empty($calname)) {
        /* TEST: protect remote calendar access with basic authentication
            // cfr. notes at http://www.php.net/features.http-auth for IIS or CGI support
                if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW']) ||
                    // is this a valid user/password ?
                    !xarUserLogIn($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) ||
                    // does this user have access to this calendar ?
                    !xarSecurityCheck('ViewCalendar',0,'All',$calname)) {
        
                    $realm = xarModVars::get('themes','SiteName');
                    header('WWW-Authenticate: Basic realm="'.$realm.'"');
                    //header('HTTP/1.0 401 Unauthorized');
                    header("Status: 401 Access Denied");
                    echo xarML('You must enter a valid username and password to access this calendar');
                    exit;
                 }
        */
        $calendars = xarMod::apiFunc('calendar', 'user', 'get', array('calid' => $calid, 'calname' => $calname));
        if (!isset($calendars)) {
            return;
        }
        // we found a calendar
        if (count($calendars) == 1) {
            if (empty($calendars[0]['cpath'])) {
                // TODO: retrieve entries from database and create ics file
            } else {
                $curdir = sys::varpath() . '/calendar';
                $curfile = $curdir . '/' . $calendars[0]['cpath'];
                if (file_exists($curfile) && filesize($curfile) > 0) {
                    if ($_SERVER['REQUEST_METHOD'] != 'PUT') {
                        // return the .ics file
                        header('Content-Type: text/calendar');
                        @readfile($curfile);
                        // TODO: use webdavserver instead ?
                        // Cfr. phpicalendar/calendars/publish.php (doesn't seem to work for PHP < 4.3)
                        // publishing
                    } else {
                        // get calendar data
                        $data = '';
                        if ($fp = fopen('php://input', 'r')) {
                            while ($chunk = fgets($fp, 4096)) {
                                $data .= $chunk;
                            }
                            /*
                            while(!@feof($fp))
                            {
                                $data .= fgets($fp,4096);
                            }
                            */
                            @fclose($fp);
                        } else {
                            xarLogMessage('failed opening standard input');
                        }
                        if (!empty($data)) {
                            //xarLogMessage($data);
                            // write to file
                            if ($fp = fopen($curfile, 'w+')) {
                                fputs($fp, $data, strlen($data));
                                @fclose($fp);
                            } else {
                                xarLogMessage('couldnt open file ' . $curfile);
                            }
                        } else {
                            xarLogMessage('failed getting any data');
                        }
                    }
                    // we're done here
                    exit;
                }
            }
        }
    }
    $data = array();
    $data['calendars'] = xarMod::apiFunc('calendar', 'user', 'getall');
    return $data;
}
开发者ID:godboko,项目名称:modules,代码行数:87,代码来源:publish.php


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