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


PHP make_bool函数代码示例

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


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

示例1: parse

 /**
  * parse
  *
  * Takes an url and parses out all the chewy goodness.
  */
 public static function parse($url)
 {
     if (AmpConfig::get('stream_beautiful_url')) {
         $posargs = strpos($url, '/play/');
         if ($posargs !== false) {
             $argsstr = substr($url, $posargs + 6);
             $url = substr($url, 0, $posargs + 6) . 'index.php?';
             $args = explode('/', $argsstr);
             for ($i = 0; $i < count($args); $i += 2) {
                 if ($i > 0) {
                     $url .= '&';
                 }
                 $url .= $args[$i] . '=' . $args[$i + 1];
             }
         }
     }
     $query = parse_url($url, PHP_URL_QUERY);
     $elements = explode('&', $query);
     $results = array();
     $results['base_url'] = $url;
     foreach ($elements as $element) {
         list($key, $value) = explode('=', $element);
         switch ($key) {
             case 'oid':
                 $key = 'id';
                 break;
             case 'video':
                 if (make_bool($value)) {
                     $results['type'] = 'video';
                 }
             default:
                 // Nothing
                 break;
         }
         $results[$key] = $value;
     }
     return $results;
 }
开发者ID:nioc,项目名称:ampache,代码行数:43,代码来源:stream_url.class.php

示例2: debug_event

        if (isset($_REQUEST['subtitle'])) {
            $subtitle = $media->get_subtitle_file($_REQUEST['subtitle']);
        }
        $media->format();
    }
}
if (!User::stream_control(array(array('object_type' => $type, 'object_id' => $media->id)))) {
    debug_event('UI::access_denied', 'Stream control failed for user ' . $GLOBALS['user']->username . ' on ' . $media->get_stream_name(), 3);
    UI::access_denied();
    exit;
}
if ($media->catalog) {
    // Build up the catalog for our current object
    $catalog = Catalog::create_from_id($media->catalog);
    /* If the media is disabled */
    if (!make_bool($media->enabled)) {
        debug_event('Play', "Error: {$media->file} is currently disabled, song skipped", '5');
        // Check to see if this is a democratic playlist, if so remove it completely
        if ($demo_id && isset($democratic)) {
            $democratic->delete_from_oid($oid, $type);
        }
        header('HTTP/1.1 404 File Disabled');
        exit;
    }
    // If we are running in Legalize mode, don't play medias already playing
    if (AmpConfig::get('lock_songs')) {
        if (!Stream::check_lock_media($media->id, $type)) {
            exit;
        }
    }
    $media = $catalog->prepare_media($media);
开发者ID:ivan801,项目名称:ampache,代码行数:31,代码来源:index.php

示例3: set_include_override

 /**
  * set_include_override
  * This sets the including div override, used only one place. Kind of a
  * hack.
  */
 public static function set_include_override($value)
 {
     self::$include_override = make_bool($value);
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:9,代码来源:ajax.class.php

示例4: set_static_content

 /**
  * set_static_content
  * This sets true/false if the content of this browse
  * should be static, if they are then content filtering/altering
  * methods will be skipped
  * @param boolean $value
  */
 public function set_static_content($value)
 {
     $value = make_bool($value);
     $this->_state['static'] = $value;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:12,代码来源:query.class.php

示例5: get_chunk

 public function get_chunk()
 {
     $chunk = null;
     if (!$this->is_init) {
         $this->init_channel_songs();
     }
     if ($this->is_init) {
         // Move to next song
         while ($this->media == null && ($this->random || $this->song_pos < count($this->songs))) {
             if ($this->random) {
                 $randsongs = $this->playlist->get_random_items(1);
                 $this->media = new Song($randsongs[0]['object_id']);
             } else {
                 $this->media = new Song($this->songs[$this->song_pos]);
             }
             $this->media->format();
             if ($this->media->catalog) {
                 $catalog = Catalog::create_from_id($this->media->catalog);
                 if (make_bool($this->media->enabled)) {
                     if (AmpConfig::get('lock_songs')) {
                         if (!Stream::check_lock_media($this->media->id, 'song')) {
                             debug_event('channel', 'Media ' . $this->media->id . ' locked, skipped.', '3');
                             $this->media = null;
                         }
                     }
                 }
                 if ($this->media != null) {
                     $this->media = $catalog->prepare_media($this->media);
                     if (!$this->media->file || !Core::is_readable(Core::conv_lc_file($this->media->file))) {
                         debug_event('channel', 'Cannot read media ' . $this->media->id . ' file, skipped.', '3');
                         $this->media = null;
                     } else {
                         $valid_types = $this->media->get_stream_types();
                         if (!in_array('transcode', $valid_types)) {
                             debug_event('channel', 'Missing settings to transcode ' . $this->media->file . ', skipped.', '3');
                             $this->media = null;
                         } else {
                             debug_event('channel', 'Now listening to ' . $this->media->file . '.', '5');
                         }
                     }
                 }
             } else {
                 debug_event('channel', 'Media ' . $this->media->id . ' doesn\'t have catalog, skipped.', '3');
                 $this->media = null;
             }
             $this->song_pos++;
             // Restart from beginning for next song if the channel is 'loop' enabled
             // and load fresh data from database
             if ($this->media != null && $this->song_pos == count($this->songs) && $this->loop) {
                 $this->init_channel_songs();
             }
         }
         if ($this->media != null) {
             // Stream not yet initialized for this media, start it
             if (!$this->transcoder) {
                 $this->transcoder = Stream::start_transcode($this->media, $this->stream_type, $this->bitrate);
                 $this->media_bytes_streamed = 0;
             }
             if (is_resource($this->transcoder['handle'])) {
                 $chunk = fread($this->transcoder['handle'], 4096);
                 $this->media_bytes_streamed += strlen($chunk);
                 // End of file, prepare to move on for next call
                 if (feof($this->transcoder['handle'])) {
                     $this->media->set_played();
                     if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
                         fread($this->transcoder['stderr'], 4096);
                         fclose($this->transcoder['stderr']);
                     }
                     fclose($this->transcoder['handle']);
                     proc_close($this->transcoder['process']);
                     $this->media = null;
                     $this->transcoder = null;
                 }
             } else {
                 $this->media = null;
                 $this->transcoder = null;
             }
             if (!strlen($chunk)) {
                 $chunk = $this->get_chunk();
             }
         }
     }
     return $chunk;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:84,代码来源:channel.class.php

示例6: set_enabled

 /**
  * set_enabled
  * Changes the value of enabled
  * @param bool|null $value
  */
 public static function set_enabled($value = null)
 {
     if (is_null($value)) {
         self::$enabled = self::$enabled ? false : true;
     } else {
         self::$enabled = make_bool($value);
     }
     $_SESSION['art_enabled'] = self::$enabled;
     //setcookie('art_enabled', self::$enabled, time() + 31536000, "/");
 }
开发者ID:cheese1,项目名称:ampache,代码行数:15,代码来源:art.class.php

示例7: create

 /**
  * create
  *
  * This takes a keyed array of data and trys to insert it as a
  * new ACL entry
  */
 public static function create($data)
 {
     if (!self::_verify_range($data['start'], $data['end'])) {
         return false;
     }
     // Check existing ACLs to make sure we're not duplicating values here
     if (self::exists($data)) {
         debug_event('ACL Create', 'Error: An ACL equal to the created one already exists. Not adding another one: ' . $data['start'] . ' - ' . $data['end'], 1);
         Error::add('general', T_('Duplicate ACL defined'));
         return false;
     }
     $start = @inet_pton($data['start']);
     $end = @inet_pton($data['end']);
     $name = $data['name'];
     $user = $data['user'] ?: '-1';
     $level = intval($data['level']);
     $type = self::validate_type($data['type']);
     $enabled = make_bool($data['enabled']) ? 1 : 0;
     $sql = 'INSERT INTO `access_list` (`name`, `level`, `start`, `end`, ' . '`user`,`type`,`enabled`) VALUES (?, ?, ?, ?, ?, ?, ?)';
     Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:28,代码来源:access.class.php

示例8: invert_bool

/**
 * invert_bool
 * This returns the opposite of what you've got
 */
function invert_bool($value)
{
    return make_bool($value) ? false : true;
}
开发者ID:nioc,项目名称:ampache,代码行数:8,代码来源:general.lib.php

示例9: _get_extra_info

 /**
  * _get_extra_info
  * This pulls the extra information from our tables, this is a 3 table join, which is why we don't normally
  * do it
  */
 private function _get_extra_info()
 {
     if (parent::is_cached('album_extra', $this->id)) {
         return parent::get_from_cache('album_extra', $this->id);
     }
     $sql = "SELECT " . "COUNT(DISTINCT(`song`.`artist`)) AS `artist_count`, " . "COUNT(`song`.`id`) AS `song_count`, " . "SUM(`song`.`time`) as `total_duration`," . "`song`.`catalog` as `catalog_id`," . "`artist`.`name` AS `artist_name`, " . "`artist`.`prefix` AS `artist_prefix`, " . "`artist`.`id` AS `artist_id` " . "FROM `song` INNER JOIN `artist` " . "ON `artist`.`id`=`song`.`artist` ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
     }
     $suite_array = array();
     if ($this->allow_group_disks) {
         $suite_array = $this->album_suite;
     }
     if (!count($suite_array)) {
         $suite_array[] = $this->id;
     }
     $idlist = '(' . implode(',', $suite_array) . ')';
     $sql .= "WHERE `song`.`album` IN {$idlist} ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "AND `catalog`.`enabled` = '1' ";
     }
     if (!count($this->album_suite)) {
         $sql .= "GROUP BY `song`.`album`";
     } else {
         $sql .= "GROUP BY `song`.`artist`";
     }
     $db_results = Dba::read($sql);
     $results = Dba::fetch_assoc($db_results);
     $art = new Art($this->id, 'album');
     $art->get_db();
     $results['has_art'] = make_bool($art->raw);
     $results['has_thumb'] = make_bool($art->thumb);
     if (AmpConfig::get('show_played_times')) {
         $results['object_cnt'] = Stats::get_object_count('album', $this->id);
     }
     parent::add_to_cache('album_extra', $this->id, $results);
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:43,代码来源:album.class.php

示例10: media_to_urlarray

 /**
  * media_to_urlarray
  * Formats the URL and media information and adds it to the object
  */
 public static function media_to_urlarray($media, $additional_params = '')
 {
     $urls = array();
     foreach ($media as $medium) {
         $url = array();
         if ($medium['custom_play_action']) {
             $additional_params .= "&custom_play_action=" . $medium['custom_play_action'];
         }
         $type = $medium['object_type'];
         //$url['object_id'] = $medium['object_id'];
         $url['type'] = $type;
         $object = new $type($medium['object_id']);
         $object->format();
         // Don't add disabled media objects to the stream playlist
         // Playing a disabled media return a 404 error that could make failed the player (mpd ...)
         if (make_bool($object->enabled)) {
             //FIXME: play_url shouldn't be static
             $url['url'] = $type::play_url($object->id, $additional_params);
             $api_session = AmpConfig::get('require_session') ? Stream::$session : false;
             // Set a default which can be overridden
             $url['author'] = 'Ampache';
             $url['time'] = $object->time;
             switch ($type) {
                 case 'song':
                     $url['title'] = $object->title;
                     $url['author'] = $object->f_artist_full;
                     $url['info_url'] = $object->f_link;
                     $url['image_url'] = Art::url($object->album, 'album', $api_session);
                     $url['album'] = $object->f_album_full;
                     break;
                 case 'video':
                     $url['title'] = 'Video - ' . $object->title;
                     $url['author'] = $object->f_artist_full;
                     break;
                 case 'radio':
                     $url['title'] = 'Radio - ' . $object->name;
                     if (!empty($object->site_url)) {
                         $url['title'] .= ' (' . $object->site_url . ')';
                     }
                     $url['codec'] = $object->codec;
                     break;
                 case 'song_preview':
                     $url['title'] = $object->title;
                     $url['author'] = $object->f_artist_full;
                     break;
                 case 'channel':
                     $url['title'] = $object->name;
                     break;
                 case 'random':
                     $url['title'] = 'Random URL';
                     break;
                 default:
                     $url['title'] = 'URL-Add';
                     $url['time'] = -1;
                     break;
             }
             $urls[] = new Stream_URL($url);
         }
     }
     return $urls;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:65,代码来源:stream_playlist.class.php

示例11: Video

    $media = new Video($oid);
    if (isset($_REQUEST['subtitle'])) {
        $subtitle = $media->get_subtitle_file($_REQUEST['subtitle']);
    }
    $media->format();
}
if (!User::stream_control(array(array('object_type' => $type, 'object_id' => $media->id)))) {
    debug_event('UI::access_denied', 'Stream control failed for user ' . $GLOBALS['user']->username . ' on ' . $media->get_stream_name(), 3);
    UI::access_denied();
    exit;
}
if ($media->catalog) {
    // Build up the catalog for our current object
    $catalog = Catalog::create_from_id($media->catalog);
    /* If the media is disabled */
    if (isset($media->enabled) && !make_bool($media->enabled)) {
        debug_event('Play', "Error: {$media->file} is currently disabled, song skipped", '5');
        // Check to see if this is a democratic playlist, if so remove it completely
        if ($demo_id && isset($democratic)) {
            $democratic->delete_from_oid($oid, $type);
        }
        header('HTTP/1.1 404 File Disabled');
        exit;
    }
    // If we are running in Legalize mode, don't play medias already playing
    if (AmpConfig::get('lock_songs')) {
        if (!Stream::check_lock_media($media->id, $type)) {
            exit;
        }
    }
    $media = $catalog->prepare_media($media);
开发者ID:bl00m,项目名称:ampache,代码行数:31,代码来源:index.php

示例12: update

 /**
  * update
  * This takes a key'd array of data as input and updates a shoutbox entry
  */
 public static function update($data)
 {
     $id = Dba::escape($data['shout_id']);
     $text = Dba::escape(strip_tags($data['comment']));
     $sticky = make_bool($data['sticky']);
     $sql = "UPDATE `user_shout` SET `text`='{$text}', `sticky`='{$sticky}' WHERE `id`='{$id}'";
     Dba::write($sql);
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:13,代码来源:shoutbox.class.php

示例13: media_object_to_url

 /**
  * media_object_to_url
  */
 public static function media_object_to_url($object, $additional_params = '', $urltype = 'web')
 {
     $surl = null;
     $url = array();
     $type = strtolower(get_class($object));
     $url['type'] = $type;
     // Don't add disabled media objects to the stream playlist
     // Playing a disabled media return a 404 error that could make failed the player (mpd ...)
     if (!isset($object->enabled) || make_bool($object->enabled)) {
         if ($urltype == 'file') {
             $url['url'] = $object->file;
             // Relative path
             if (!empty($additional_params) && strpos($url['url'], $additional_params) === 0) {
                 $url['url'] = substr($url['url'], strlen($additional_params));
                 if (strlen($url['url']) < 1) {
                     return null;
                 }
                 if ($url['url'][0] == DIRECTORY_SEPARATOR) {
                     $url['url'] = substr($url['url'], 1);
                 }
             }
         } else {
             //FIXME: play_url shouldn't be static
             $url['url'] = $type::play_url($object->id, $additional_params);
         }
         $api_session = AmpConfig::get('require_session') ? Stream::get_session() : false;
         // Set a default which can be overridden
         $url['author'] = 'Ampache';
         $url['time'] = $object->time;
         switch ($type) {
             case 'song':
                 $url['title'] = $object->title;
                 $url['author'] = $object->f_artist_full;
                 $url['info_url'] = $object->f_link;
                 $url['image_url'] = Art::url($object->album, 'album', $api_session, AmpConfig::get('ajax_load') ? 3 : 4);
                 $url['album'] = $object->f_album_full;
                 $url['track_num'] = $object->f_track;
                 break;
             case 'video':
                 $url['title'] = 'Video - ' . $object->title;
                 $url['author'] = $object->f_artist_full;
                 $url['resolution'] = $object->f_resolution;
                 break;
             case 'live_stream':
                 $url['title'] = 'Radio - ' . $object->name;
                 if (!empty($object->site_url)) {
                     $url['title'] .= ' (' . $object->site_url . ')';
                 }
                 $url['codec'] = $object->codec;
                 break;
             case 'song_preview':
                 $url['title'] = $object->title;
                 $url['author'] = $object->f_artist_full;
                 break;
             case 'channel':
                 $url['title'] = $object->name;
                 break;
             case 'random':
                 $url['title'] = 'Random URL';
                 break;
             default:
                 $url['title'] = 'URL-Add';
                 $url['time'] = -1;
                 break;
         }
         $surl = new Stream_URL($url);
     }
     return $surl;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:72,代码来源:stream_playlist.class.php

示例14: array_val_bool

/**
 * a wrapper for make_bool that safely takes a value out of an array
 *
 * @author Craig Ulliott
 */
function array_val_bool(array $array, $key, $default = false)
{
    return make_bool(array_val($array, $key, $default));
}
开发者ID:Tapac,项目名称:hotscot,代码行数:9,代码来源:array.php

示例15: check_function

 /**
  * check_function
  *
  * This checks if specific functionality is enabled.
  * @param string $type
  * @return boolean
  */
 public static function check_function($type)
 {
     switch ($type) {
         case 'download':
             return make_bool(AmpConfig::get('download'));
         case 'batch_download':
             if (!function_exists('gzcompress')) {
                 debug_event('access', 'ZLIB extension not loaded, batch download disabled', 3);
                 return false;
             }
             if (AmpConfig::get('allow_zip_download') and $GLOBALS['user']->has_access('5')) {
                 return make_bool(AmpConfig::get('download'));
             }
             break;
     }
     return false;
 }
开发者ID:nioc,项目名称:ampache,代码行数:24,代码来源:access.class.php


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