Cheetah
ChVideosModule.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbFilesModule');
9 define('PROFILE_VIDEO_CATEGORY', 'Profile videos');
10 
12 {
13  function __construct (&$aModule)
14  {
15  parent::__construct($aModule);
16 
17  // add more sections for administration
18  $this->aSectionsAdmin['processing'] = array('exclude_btns' => 'all');
19  $this->aSectionsAdmin['failed'] = array(
20  'exclude_btns' => array('activate', 'deactivate', 'featured', 'unfeatured')
21  );
22  }
23 
25  {
26  $aInfo = $this->_oDb->getFileInfo(array('fileId'=>(int)$iFileId), false, array('medID', 'medProfId', 'medUri', 'albumId', 'Approved'));
27  if ($aInfo && $this->isAllowedDownload($aInfo)) {
28 
29  $sPathFull = $this->_oConfig->getFilesPath() . $aInfo['medID'] . '.';
30  $aExts = array('flv', 'm4v');
31  if (getSettingValue('video', "usex264") == TRUE_VAL)
32  rsort($aExts);
33  reset($aExts);
34  $sExt = '';
35  foreach ($aExts as $sPostfix)
36  {
37  if (file_exists($sPathFull . $sPostfix))
38  {
39  $sExt = $sPostfix;
40  $sPathFull .= $sExt;
41  break;
42  }
43  }
44  if (!empty($sExt)) {
45  $this->isAllowedDownload($aInfo, true);
46  header('Connection: close');
47  header('Content-Type: video/x-' . $sExt);
48  header('Content-Length: ' . filesize($sPathFull));
49  header('Last-Modified: ' . gmdate('r', filemtime($sPathFull)));
50  header('Content-Disposition: attachment; filename="' . $aInfo['medUri'] . '.' . $sExt . '";');
51  readfile($sPathFull);
52  exit;
53  } else {
54  $this->_oTemplate->displayPageNotFound();
55  }
56 
57  } elseif (!$aInfo) {
58  $this->_oTemplate->displayPageNotFound();
59  } else {
60  $this->_oTemplate->displayAccessDenied();
61  }
62  }
63 
65  {
67  }
68 
69  function serviceGetMemberMenuItem ($sIcon = 'film')
70  {
71  return parent::serviceGetMemberMenuItem ($sIcon);
72  }
73 
74  function serviceGetMemberMenuItemAddContent ($sIcon = 'film')
75  {
76  return parent::serviceGetMemberMenuItemAddContent ($sIcon);
77  }
78 
79  function getWallPost($aEvent, $sIcon = 'save', $aParams = array())
80  {
81  return parent::getWallPost($aEvent, $sIcon, array(
82  'templates' => array(
83  'single' => 'timeline_post.html',
84  'grouped' => 'timeline_post_grouped.html'
85  )
86  ));
87  }
88 
89  function getWallPostOutline($aEvent, $sIcon = 'save', $aParams = array())
90  {
91  return parent::getWallPostOutline($aEvent, $sIcon, array(
92  'templates' => array(
93  'single' => 'outline_item_image.html',
94  'grouped' => 'outline_item_image_grouped.html'
95  )
96  ));
97  }
98 
99  function getEmbedCode ($iFileId, $aExtra = array())
100  {
101  return $this->_oTemplate->getEmbedCode($iFileId, $aExtra);
102  }
103 
104  function isAllowedShare(&$aDataEntry)
105  {
106  if($aDataEntry['AllowAlbumView'] != CH_WSB_PG_ALL)
107  return false;
108 
109  return true;
110  }
111 
112  function isAllowedDownload (&$aFile, $isPerformAction = false)
113  {
114  if (getSettingValue('video', "save") != TRUE_VAL)
115  return false;
116  return $this->isAllowedView($aFile, $isPerformAction);
117  }
118 
119  function serviceGetWallPost($aEvent)
120  {
121  return $this->getWallPost($aEvent, 'film');
122  }
123 
124  function serviceGetWallPostOutline($aEvent)
125  {
126  return $this->getWallPostOutline($aEvent, 'film');
127  }
128 
129  function actionView ($sUri) {
130  $aInfo = $this->_oDb->getFileInfo(array('fileUri' => $sUri));
131  if(isBlocked($aInfo['medProfId'], getLoggedId())) {
132  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
133  return;
134  }
135 
136  parent::actionView($sUri);
137  }
138 
139  function actionBrowse ($sParamName = '', $sParamValue = '', $sParamValue1 = '', $sParamValue2 = '', $sParamValue3 = '') {
140  if ($sParamName == 'album' && $sParamValue1 == 'owner') {
141  $iOwnerId = getID($sParamValue2);
142  if(isBlocked($iOwnerId, getLoggedId())) {
143  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
144  return;
145  }
146  }
147 
148  parent::actionBrowse($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3);
149  }
150 
151  function actionAlbums ($sParamName = '', $sParamValue = '', $sParamValue1 = '', $sParamValue2 = '', $sParamValue3 = '') {
152  if($sParamName == 'browse' && $sParamValue == 'owner') {
153  $iOwnerId = getID($sParamValue1);
154  if(isBlocked($iOwnerId, getLoggedId())) {
155  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
156  return;
157  }
158  }
159 
160  parent::actionAlbums($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3);
161  }
162 
163 }
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChVideosModule\isAllowedShare
isAllowedShare(&$aDataEntry)
Definition: ChVideosModule.php:104
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbFilesModule\isAllowedView
isAllowedView(&$aFile, $isPerformAction=false)
Definition: ChWsbFilesModule.php:1173
ChVideosModule\actionView
actionView($sUri)
Definition: ChVideosModule.php:129
$aModule
$aModule
Definition: classifieds.php:21
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
$sExt
$sExt
Definition: get_file.php:14
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChVideosModule\actionGetFile
actionGetFile($iFileId)
Definition: ChVideosModule.php:24
ChVideosModule
Definition: ChVideosModule.php:12
ChVideosModule\serviceGetMemberMenuItemAddContent
serviceGetMemberMenuItemAddContent($sIcon='film')
Definition: ChVideosModule.php:74
$aInfo
$aInfo
Definition: constants.inc.php:21
ChVideosModule\actionAlbums
actionAlbums($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='', $sParamValue3='')
Definition: ChVideosModule.php:151
exit
exit
Definition: cart.php:21
ChVideosModule\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChVideosModule.php:119
$sParamName
$sParamName
Definition: actions.inc.php:15
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChVideosModule\serviceGetMemberMenuItem
serviceGetMemberMenuItem($sIcon='film')
Definition: ChVideosModule.php:69
ChWsbFilesModule
Definition: ChWsbFilesModule.php:13
PROFILE_VIDEO_CATEGORY
const PROFILE_VIDEO_CATEGORY
Definition: ChVideosModule.php:9
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChVideosModule\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChVideosModule.php:124
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
ChVideosModule\actionBrowse
actionBrowse($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='', $sParamValue3='')
Definition: ChVideosModule.php:139
ChVideosModule\getEmbedCode
getEmbedCode($iFileId, $aExtra=array())
Definition: ChVideosModule.php:99
ChVideosModule\getWallPostOutline
getWallPostOutline($aEvent, $sIcon='save', $aParams=array())
Definition: ChVideosModule.php:89
isBlocked
isBlocked($iFirstProfile, $iSecondProfile)
Definition: utils.inc.php:128
ChVideosModule\getWallPost
getWallPost($aEvent, $sIcon='save', $aParams=array())
Definition: ChVideosModule.php:79
$iFileId
$iFileId
Definition: embed.php:12
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
ChVideosModule\__construct
__construct(&$aModule)
Definition: ChVideosModule.php:13
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChVideosModule\isAllowedDownload
isAllowedDownload(&$aFile, $isPerformAction=false)
Definition: ChVideosModule.php:112
ChVideosModule\serviceGetProfileCat
serviceGetProfileCat()
Definition: ChVideosModule.php:64