YaWK  24.1
Yet another WebKit
chaturbate.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Embed any chaturbate channel or stream on your page.</b>
6  *
7  * <p>Chaturbate.com is an adult webcam streaming service. With this widget, you can embed any public
8  * channel or stream from chaturbate onto your website. All you need is any chaturbate username you
9  * wish to embed. But there are a few things to setup. If you like to, you are able to set width,
10  * height sound settings and more. By using this widget, embedding a stream from chaturbate is very easy.</p>
11  *
12  *
13  * @author Daniel Retzl <[email protected]>
14  * @copyright 2018 Daniel Retzl
15  * @version 1.0.0
16  * @brief Embed chaturbate room (or stream) on your website.
17  */
18  class chaturbate
19  {
20  /** @param object global widget object data */
21  public $widget = '';
22  /** @param string Chaturbate room name (username) */
23  public $chaturbateRoom = '';
24  /** @param string URL of your chaturbate stream */
25  public $chaturbateVideoUrl = '';
26  /** @param string Width in percent */
27  public $chaturbateWidth = '100%';
28  /** @param string Height in px */
29  public $chaturbateHeight = '370';
30  /** @param string Disable Sound */
31  public $chaturbateDisableSound = '';
32  /** @param string Disable Sound */
33  public $chaturbateVideoOnly = '0';
34  /** @param string Heading */
35  public $chaturbateHeading = '';
36  /** @param string Subtext */
37  public $chaturbateSubtext = '';
38  /** @param string Headline HTML Markup */
39  public $chaturbateHeadline = '';
40 
41  /**
42  * @brief Load all widget settings from database and fill object
43  * @param object $db Database Object
44  * @brief Load all widget settings on object init.
45  */
46  public function __construct($db)
47  {
48  // load this widget settings from db
49  $this->widget = new \YAWK\widget();
51  foreach ($settings as $property => $value) {
52  $this->$property = $value;
53  }
54  }
55 
56  /**
57  * @brief Print all object data
58  * @brief (for development and testing purpose)
59  */
60  public function printObject()
61  {
62  echo "<pre>";
63  print_r($this);
64  echo "</pre>";
65  }
66 
67  public function init()
68  {
69  $this->setProperties();
70  $this->embed();
71  }
72 
73  /**
74  * @brief Set widget properties from database and fill object params
75  * @brief Load all widget settings.
76  */
77  public function setProperties()
78  {
79  // if a heading is set and not empty
80  if (isset($this->chaturbateHeading) && (!empty($this->chaturbateHeading)))
81  { // add h1 tag to heading string
82  $this->chaturbateHeading = "$this->chaturbateHeading";
83 
84  // if subtext is set, add <small> subtext to string
85  if (isset($this->chaturbateSubtext) && (!empty($this->chaturbateSubtext)))
86  { // build a headline with heading and subtext
87  $this->chaturbateSubtext = "<small>$this->chaturbateSubtext</small>";
88  $this->chaturbateHeadline = "<h1>$this->chaturbateHeading&nbsp;"."$this->chaturbateSubtext</h1>";
89  }
90  else
91  { // build just a headline - without subtext
92  $this->chaturbateHeadline = "<h1>$this->chaturbateHeading</h1>"; // draw just the heading
93  }
94  }
95  else
96  { // leave empty if it's not set
97  $this->chaturbateHeadline = '';
98  }
99 
100  if (substr($this->chaturbateWidth, -1) !== "%")
101  {
102  $this->chaturbateWidth = $this->chaturbateWidth."%";
103  }
104 
105  // build video url
106  $this->chaturbateVideoUrl = "https://chaturbate.com/embed/$this->chaturbateRoom?bgcolor=transparent&disable_sound=$this->chaturbateDisableSound&fullscreen=true&embed_video_only=$this->chaturbateVideoOnly&target=_blank";
107  }
108 
109  /**
110  * @brief Embed any chaturbate room on your website
111  * @brief This method embeds the chaturbate stream
112  */
113  public function embed()
114  {
115 
116 echo"<style>
117 .videoWrapper {
118  position: relative;
119  padding-bottom: 56.25%; /* 16:9 */
120  padding-top: 25px;
121  height: 0;
122 }
123 .videoWrapper iframe {
124  position: absolute;
125  top: 0;
126  left: 0;
127  width: 100%;
128  height: 100%;
129  border: none;
130  }
131 </style>";
132  // HTML output
133  echo "
134 <!-- chaturbate room stream iframe -->
135 $this->chaturbateHeadline
136 <div class=\"videoWrapper\">
137 <iframe src=\"$this->chaturbateVideoUrl\"
138  width=\"$this->chaturbateWidth\"
139  height=\"$this->chaturbateHeight\"
140  frameborder=\"0\"
141  scrolling=\"no\">
142 </iframe></div>";
143  }
144  }
145 }
Embed chaturbate room (or stream) on your website.
Definition: chaturbate.php:18
__construct($db)
Load all widget settings from database and fill object.
Definition: chaturbate.php:45
embed()
Embed any chaturbate room on your website.
Definition: chaturbate.php:112
printObject()
Print all object data.
Definition: chaturbate.php:59
setProperties()
Set widget properties from database and fill object params.
Definition: chaturbate.php:76
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
getWidgetSettingsArray($db)
Get widget settings and return it as array.
Definition: widget.php:69
if(isset($_POST['save'])) $settings
$value