11     $a = $aModuleOverwright ? $aModuleOverwright : 
$aModule;
 
   12     if (!$a || $a[
'uri'] != 
'sites') {
 
   14         $a = $oMain->_aModule;
 
   22     $sUri = preg_replace(
'/[^a-zA-Z0-9]/', 
' ', 
$sTitle);
 
   23     $sUri = preg_replace(
'/ +/', 
'_', trim($sUri));
 
   30 require_once(
'ChSitesPrivacy.php');
 
  113         $this->_oConfig->init($this->_oDb);
 
  116         $GLOBALS[
'oChSitesModule'] = &$this;
 
  119         $this->sHomeUrl = $this->_oConfig->getHomeUrl();
 
  120         $this->sHomePath = $this->_oConfig->getHomePath();
 
  121         $this->sModuleUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri();
 
  123         $sThumbSuffix = 
'data/images/thumbs/';
 
  124         $this->sThumbPath = $this->sHomePath.$sThumbSuffix;
 
  125         $this->sThumbUrl = $this->sHomeUrl.$sThumbSuffix;
 
  133         $this->_oTemplate->addCss(array(
'main.css', 
'block_percent.css'));
 
  134         $this->_oTemplate->pageStart();
 
  136         $this->_oTemplate->pageCode(
_t(
'_ch_sites_caption_home'), 
false, 
false);
 
  143         $this->_oTemplate->pageStart();
 
  144         echo $oCalendar->display();
 
  145         $this->_oTemplate->pageCode(
_t(
'_ch_sites_caption_browse_calendar'), 
true, 
false);
 
  150         $iSiteId = (int)$iSiteId;
 
  151         if (!($aSite = $this->_oDb->getSiteById($iSiteId))) {
 
  152             $this->_oTemplate->displayPageNotFoundExt (
_t(
'_ch_sites_action_title_delete'));
 
  156         header(
'Content-Type: text/html; charset=utf-8');
 
  163             $sRedirect = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'browse/my';
 
  175         $iSiteId = (int)$iSiteId;
 
  177         if (!($aSite = $this->_oDb->getSiteById($iSiteId))) {
 
  178             $this->_oTemplate->displayPageNotFoundExt (
_t(
'_ch_site_caption_edit'));
 
  183             $this->_oTemplate->displayAccessDeniedExt (
_t(
'_ch_site_caption_edit'));
 
  189         $oForm->initChecker($aSite);
 
  191         $this->_oTemplate->addCss(array(
'main.css'));
 
  193         if (
$oForm->isSubmittedAndValid ()) {
 
  194             $sStatus = $this->_oDb->getParam(
'ch_sites_autoapproval') == 
'on' || $this->
isAdmin() ? 
'approved' : 
'pending';
 
  195             $sCategories = implode(
';', array_unique(explode(
';', 
$oForm->getCleanValue(
'categories'))));
 
  196             unset(
$oForm->aInputs[
'categories']);
 
  198                 'photo' => 
$oForm->checkUploadPhoto(),
 
  199                 'categories' => $sCategories,
 
  203             if (
$oForm->update($iSiteId, $aValsAdd)) {
 
  207                     header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/' . $aSite[
'entryUri']);
 
  209                     header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri());
 
  211                 $this->_oTemplate->pageStart();
 
  212                 echo 
MsgBox(
_t(
'_ch_sites_err_edit_site'));
 
  215             $this->_oTemplate->pageStart();
 
  219         $this->_oTemplate->pageCode(
_t(
'_ch_site_caption_edit'));
 
  224         $GLOBALS[
'oTopMenu']->setCustomSubHeader(
_t(
'_ch_sites'));
 
  226         $aSite = is_numeric($mixedVar) ? $this->_oDb->getSiteById((
int)$mixedVar) : $this->_oDb->getSiteByEntryUri(
process_db_input($mixedVar));
 
  229             $this->_oTemplate->displayPageNotFoundExt (
_t(
'_ch_sites'));
 
  234             $this->_oTemplate->displayAccessDeniedExt($aSite[
'title']);
 
  238         if ($aSite[
'status'] == 
'pending' && !$this->
isAdmin() && !($aSite[
'ownerid'] == $this->iOwnerId && $aEvent[
'ownerid']))  {
 
  239             $this->_oTemplate->displayAccessDeniedExt($aSite[
'title']);
 
  243         if ($aSite[
'Status'] == 
'pending') {
 
  244             $this->_oTemplate->displayPendingApproval($aSite[
'title']);
 
  250         $this->_oTemplate->addJsTranslation(array(
'_Are_you_sure'));
 
  251         $this->_oTemplate->addCss(array(
'main.css', 
'cmts.css'));
 
  252         $this->_oTemplate->pageStart();
 
  254         $GLOBALS[
'oTopMenu']->setCustomSubHeader($aSite[
'title']);
 
  255         $GLOBALS[
'oTopMenu']->setCustomSubHeaderUrl(CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/' . $aSite[
'entryUri']);
 
  256         $GLOBALS[
'oTopMenu']->setCustomBreadcrumbs(array(
 
  257             _t(
'_ch_sites') => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'home/',
 
  258             $aSite[
'title'] => 
'',
 
  260         $this->_oTemplate->pageCode($aSite[
'title'], 
false, 
false);
 
  270         $iSiteId = (int)$iSiteId;
 
  272         if (!($aSite = $this->_oDb->getSiteById($iSiteId))) {
 
  273             $this->_oTemplate->displayPageNotFoundExt (
_t(
'_ch_sites_featured_top_menu_sitem'));
 
  277         header(
'Content-Type: text/html; charset=utf-8');
 
  283         if ($this->_oDb->markFeatured($iSiteId)) {
 
  285             $sRedirect = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/' . $aSite[
'entryUri'];
 
  287             echo 
MsgBox($aSite[
'featured'] ? 
_t(
'_ch_sites_msg_removed_from_featured') : 
_t(
'_ch_sites_msg_added_to_featured')) . 
$sJQueryJS;
 
  303         $this->_oTemplate->addCss(array(
'main.css', 
'block_percent.css'));
 
  304         $this->_oTemplate->pageStart();
 
  306         $this->_oTemplate->pageCode(
_t(
'_ch_sites_hon'), 
false, 
false);
 
  312             $this->_oTemplate->displayAccessDeniedExt(
_t(
'_ch_sites_caption_browse_search'), 
false);
 
  320         $this->_oTemplate->addCss(array(
'main.css'));
 
  322         if (
$oForm->isSubmittedAndValid ()) {
 
  328                 $this->_oTemplate->displayPageNotFoundExt (
_t(
'_ch_sites_caption_browse_search'));
 
  332             if (
$s = 
$o->processing()) {
 
  333                 $this->_oTemplate->pageStart();
 
  336                 $this->_oTemplate->displayNoDataExt (
_t(
'_ch_sites_caption_browse_search'));
 
  341             $this->_oTemplate->pageCode(
$o->aCurrent[
'title'], 
false, 
false);
 
  344             $this->_oTemplate->pageStart();
 
  346             $this->_oTemplate->pageCode(
_t(
'_ch_sites_caption_browse_search'));
 
  352         $bAjaxMode = isset($_SERVER[
'HTTP_X_REQUESTED_WITH']) 
and $_SERVER[
'HTTP_X_REQUESTED_WITH'] == 
'XMLHttpRequest' ? 
true : 
false;
 
  354         if ((
'user' == 
$sMode || 
'my' == 
$sMode) && $this->iOwnerId > 0) {
 
  356             if (0 == strcasecmp($sValue, 
$aProfile[
'NickName']) || 
'my' == 
$sMode) {
 
  363             $this->_oTemplate->displayAccessDeniedExt(
_t(
'_ch_sites'), 
$bAjaxMode);
 
  376             $this->_oTemplate->displayNoDataExt(
$o->aCurrent[
'title'], 
$bAjaxMode);
 
  389                 $this->_oTemplate->pageStart();
 
  391                 $this->_oTemplate->pageCode(
$o->aCurrent[
'title'], 
false, 
false);
 
  395             $this->_oTemplate->displayNoDataExt(
$o->aCurrent[
'title'], 
$bAjaxMode);
 
  402         if (!
$iProfileId || !defined(
'CH_SITES_ON_PROFILE_DELETE'))
 
  405         $aSites = $this->_oDb->getSitesByAuthor(
$iProfileId);
 
  406         foreach ($aSites 
as $aSiteRow)
 
  412         parent::_actionSharePopup ($iSiteId, 
_t(
'_ch_sites_caption_share_site'), 
true);
 
  428             $this->_oTemplate->displayAccessDeniedExt (
_t(
'_ch_sites'));
 
  434                 'title' => 
_t(
'_ch_sites_pending_approval'),
 
  435                 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'administration/home',
 
  436                 '_func' => array (
'name' => 
'_actionAdministrationManage', 
'params' => array(
false)),
 
  438             'admin_entries' => array(
 
  439                 'title' => 
_t(
'_ch_sites_administration_admin_sites'),
 
  440                 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'administration/admin_entries',
 
  441                 '_func' => array (
'name' => 
'_actionAdministrationManage', 
'params' => array(
true)),
 
  444                 'title' => 
_t(
'_ch_sites_administration_add_site'),
 
  445                 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'administration/add',
 
  446                 '_func' => array (
'name' => 
'_actionAdministrationAdd', 
'params' => array()),
 
  449                 'title' => 
_t(
'_ch_sites_administration_settings'),
 
  450                 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'administration/settings',
 
  451                 '_func' => array (
'name' => 
'_actionAdministrationSettings', 
'params' => array()),
 
  461         $this->_oTemplate->pageStart();
 
  462         echo $this->_oTemplate->adminBlock (
$sContent, 
_t(
'_ch_sites_administration'), 
$aMenu);
 
  463         $this->_oTemplate->addCssAdmin(array(
'forms_adv.css', 
'main.css', 
'twig.css'));
 
  464         $this->_oTemplate->pageCodeAdmin (
_t(
'_ch_sites_administration'));
 
  470             $this->_oTemplate->displayAccessDeniedExt(
_t(
'_ch_sites'));
 
  474         $this->_oTemplate->addCss(array(
'main.css'));
 
  475         $this->_oTemplate->pageStart();
 
  477         $this->_oTemplate->pageCode(
_t(
'_ch_sites_bcaption_site_add'), 
true, 
false);
 
  484             'type' => 
'ch_sites',
 
  485             'orderby' => 
'popular' 
  487             $oTags = 
new ChTemplTagsModule($aParam, 
'', CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'tags');
 
  488             $this->_oTemplate->pageStart();
 
  489             echo $oTags->getCode();
 
  490             $this->_oTemplate->pageCode(
_t(
'_ch_sites_caption_browse_tags'), 
false, 
false);
 
  499             $oCateg = 
new ChTemplCategoriesModule($aParam, 
'', CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'categories');
 
  500             $this->_oTemplate->pageStart();
 
  501             echo $oCateg->getCode();
 
  502             $this->_oTemplate->pageCode(
_t(
'_ch_sites_caption_browse_categories'), 
false, 
false);
 
  520         $aDataEntry = $this->_oDb->getSiteById($iEntryId);
 
  521         if (
empty($aDataEntry) || $aDataEntry[
'status'] != 
'approved') {
 
  522             return array(
'skip' => 
true);
 
  525         $aActionList = array(
 
  526             'commentPost' => 
'_ch_sites_sbs_comment' 
  529         $sActionName = isset($aActionList[
$sAction]) ? 
' (' . 
_t($aActionList[
$sAction]) . 
')' : 
'';
 
  532             'template' => array (
 
  533                 'Subscription' => $aDataEntry[
'title'] . $sActionName,
 
  534                 'ViewLink' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/' . $aDataEntry[
'entryUri'],
 
  544         $aObjectIds = strpos($aEvent[
'object_id'], 
',') !== 
false ? explode(
',', $aEvent[
'object_id']) : array($aEvent[
'object_id']);
 
  549         foreach($aObjectIds 
as $iId) {
 
  550             $aItem = $this->_oDb->getSiteById(
$iId);
 
  553             else if($aItem[
'status'] == 
'approved' && $this->oPrivacy->check(
'view', $aItem[
'id'], $this->iOwnerId))
 
  557         if($iDeleted == count($aObjectIds))
 
  558             return array(
'perform_delete' => 
true);
 
  561         if(!
empty($aEvent[
'owner_id']))
 
  562             $iOwner = (int)$aEvent[
'owner_id'];
 
  565         if(!
empty($aEvent[
'date']))
 
  566             $iDate = (
int)$aEvent[
'date'];
 
  568         $bItems = !
empty($aItems) && is_array($aItems);
 
  569         if($iOwner == 0 && $bItems && !
empty($aItems[0][
'ownerid']))
 
  570             $iOwner = (int)$aItems[0][
'ownerid'];
 
  572         if(
$iDate == 0 && $bItems && !
empty($aItems[0][
'date']))
 
  573             $iDate = (
int)$aItems[0][
'date'];
 
  575         if($iOwner == 0 || !$bItems)
 
  579         $sCssPrefix = str_replace(
'_', 
'-', $this->_sPrefix);
 
  580         $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/';
 
  581         if($aEvent[
'js_mode'])
 
  582             $sCss = $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'), 
true);
 
  584             $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'));
 
  586         $iItems = count($aItems);
 
  595                 $aItems = array_slice($aItems, 0, 4);
 
  597             $aTmplItems = array();
 
  598             foreach($aItems 
as $aItem)
 
  599                 $aTmplItems[] = array(
 
  600                     'unit' => $this->_oTemplate->unit ($aItem, 
'unit_wall', $oVoting),
 
  604                 'owner_id' => $iOwner,
 
  605                 'title' => 
_t(
'_ch_sites_wall_added_new_title_items', $sOwner, $iItems),
 
  607                 'content' => $sCss . $this->_oTemplate->parseHtmlByName(
'modules/cheetah/wall/|timeline_post_twig_grouped.html', array(
 
  608                     'mod_prefix' => $sCssPrefix,
 
  609                     'mod_icon' => 
'link',
 
  610                     'cpt_user_name' => $sOwner,
 
  611                     'cpt_added_new' => 
_t(
'_ch_sites_wall_added_new_items', $iItems),
 
  612                     'ch_repeat:items' => $aTmplItems,
 
  613                     'post_id' => $aEvent[
'id']
 
  620         $sTxtWallObject = 
_t(
'_ch_sites_wall_object');
 
  624             'owner_id' => $iOwner,
 
  625             'title' => 
_t(
'_ch_sites_wall_added_new_title', $sOwner, $sTxtWallObject),
 
  626             'description' => $aItem[
'description'],
 
  627             'content' => $sCss . $this->_oTemplate->parseHtmlByName(
'modules/cheetah/wall/|timeline_post_twig.html', array(
 
  628                 'mod_prefix' => $sCssPrefix,
 
  629                 'mod_icon' => 
'link',
 
  630                 'cpt_user_name' => $sOwner,
 
  631                 'cpt_added_new' => 
_t(
'_ch_sites_wall_added_new'),
 
  632                 'cpt_object' => $sTxtWallObject,
 
  633                 'cpt_item_url' => $sBaseUrl . $aItem[
'entryUri'],
 
  634                 'post_id' => $aEvent[
'id'],
 
  635                 'content' => $this->_oTemplate->unit ($aItem, 
'unit_wall', $oVoting),
 
  644         $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/';
 
  646         $aOwner = 
db_assoc_arr(
"SELECT `ID` AS `id`, `NickName` AS `username` FROM `Profiles` WHERE `ID`='" . (
int)$aEvent[
'owner_id'] . 
"' LIMIT 1");
 
  648         $aObjectIds = strpos($aEvent[
'object_id'], 
',') !== 
false ? explode(
',', $aEvent[
'object_id']) : array($aEvent[
'object_id']);
 
  651         $iItems = count($aObjectIds);
 
  653         if($iItems > $iItemsLimit)
 
  654             $aObjectIds = array_slice($aObjectIds, 0, $iItemsLimit);
 
  657         if(!
empty($aEvent[
'content']))
 
  658             $aContent = unserialize($aEvent[
'content']);
 
  661         $aItems = $aTmplItems = array();
 
  662         foreach($aObjectIds 
as $iId) {
 
  663             $aItem = $this->_oDb->getSiteById(
$iId);
 
  666             else if($aItem[
'status'] == 
'approved' && $this->oPrivacy->check(
'view', $aItem[
'id'], $this->iOwnerId)) {
 
  667                 $aItem[
'thumb_file'] = 
'';
 
  668                 if($aItem[$this->_oDb->_sFieldThumb]) {
 
  669                     $aImage = 
ChWsbService::call(
'photos', 
'get_entry', array($aItem[$this->_oDb->_sFieldThumb], 
'browse'), 
'Search');
 
  670                     $aItem[
'thumb_file'] = $aImage[
'no_image'] || 
empty($aImage) ? 
'' : $aImage[
'file'];
 
  673                 $aItem[$this->_oDb->_sFieldUri] = $sBaseUrl . $aItem[$this->_oDb->_sFieldUri];
 
  674                 $aItem[
'url'] = strncasecmp($aItem[
'url'], 
'http://', 7) !== 0 && strncasecmp($aItem[
'url'], 
'https://', 8) !== 0 ? 
'http://' . $aItem[
'url'] : $aItem[
'url'];
 
  678                 if ($aItem[
'thumb_file'] == 
'' && 
getParam(
'ch_sites_account_type') != 
'No Automated Screenshots') {
 
  684                 $aTmplItems[] = array(
 
  685                     'mod_prefix' => $this->_sPrefix,
 
  686                     'item_title' => $aItem[$this->_oDb->_sFieldTitle],
 
  688                     'ch_if:is_image' => array(
 
  689                         'condition' => $sThumbHTML == 
false,
 
  690                         'content' => array(
'item_page' => $aItem[$this->_oDb->_sFieldUri], 
'image' => $aImage[
'file'] ? $aImage[
'file'] : $this->_oTemplate->getImageUrl(
'no-image-thumb.png'))
 
  692                     'ch_if:is_thumbhtml' => array(
 
  693                         'condition' => $sThumbHTML != 
'',
 
  694                         'content' => array(
'item_page' => $aItem[$this->_oDb->_sFieldUri], 
'thumbhtml' => $sThumbHTML)
 
  701         if($iDeleted == count($aObjectIds))
 
  702             return array(
'perform_delete' => 
true);
 
  708         if($aEvent[
'js_mode'])
 
  709             $sCss = $this->_oTemplate->addCss(array(
'wall_outline.css'), 
true);
 
  711             $this->_oTemplate->addCss(array(
'wall_outline.css'));
 
  714         $iOwner = (int)$aEvent[
'owner_id'];
 
  719         $iItems = count($aItems);
 
  721             $aResult[
'content'] = $sCss . $this->_oTemplate->parseHtmlByName(
'wall_outline_grouped.html', array(
 
  722                 'mod_prefix' => $this->_sPrefix,
 
  723                 'mod_icon' => $sIcon,
 
  724                 'user_name' => $sOwner,
 
  725                 'user_link' => $sOwnerLink,
 
  726                 'ch_repeat:items' => $aTmplItems,
 
  729                 'album_description' => 
'',
 
  730                 'album_comments' => 0 ? 
_t(
'_wall_n_comments', 0) : 
_t(
'_wall_no_comments'),
 
  731                 'album_comments_link' => 
'',
 
  732                 'post_id' => $aEvent[
'id'],
 
  733                 'post_ago' => $aEvent[
'ago']
 
  741         $aTmplItem = $aTmplItems[0];
 
  743         $aResult[
'content'] =  $sCss . $this->_oTemplate->parseHtmlByName(
'wall_outline.html', array_merge($aTmplItem, array(
 
  744             'mod_prefix' => $this->_sPrefix,
 
  745             'mod_icon' => $sIcon,
 
  746             'user_name' => $sOwner,
 
  747             'user_link' => $sOwnerLink,
 
  748             'item_page' => $aItem[$this->_oDb->_sFieldUri],
 
  749             'item_title' => $aItem[$this->_oDb->_sFieldTitle],
 
  750             'item_description' => $this->_formatSnippetText($aItem, 200),
 
  751             'item_site_url' => $aItem[
'url'],
 
  752             'item_site_url_title' => $this->_oTemplate->_getDomain($aItem[
'url']),
 
  753             'item_comments' => (
int)$aItem[
'commentsCount'] > 0 ? 
_t(
'_wall_n_comments', $aItem[
'commentsCount']) : 
_t(
'_wall_no_comments'),
 
  754             'item_comments_link' => $aItem[$this->_oDb->_sFieldUri] . 
'#cmta-' . $this->_sPrefix . 
'-' . $aItem[
'id'],
 
  755             'post_id' => $aEvent[
'id'],
 
  756             'post_ago' => $aEvent[
'ago']
 
  764         $iId = (int)$aEvent[
'object_id'];
 
  765         $iOwner = (int)$aEvent[
'owner_id'];
 
  766         $sOwner = $iOwner != 0 ? 
getNickName($iOwner) : 
_t(
'_Anonymous');
 
  768         $aContent = unserialize($aEvent[
'content']);
 
  769         if(
empty($aContent) || 
empty($aContent[
'object_id']))
 
  772         $iItem = (int)$aContent[
'object_id'];
 
  773         $aItem = $this->_oDb->getSiteById($iItem);
 
  774         if(
empty($aItem) || !is_array($aItem))
 
  775             return array(
'perform_delete' => 
true);
 
  777         if(!$this->oPrivacy->check(
'view', $iItem, $this->iOwnerId))
 
  782         if(!$oCmts->isEnabled())
 
  785         $aComment = $oCmts->getCommentRow(
$iId);
 
  786         if(
empty($aComment) || !is_array($aComment))
 
  787             return array(
'perform_delete' => 
true);
 
  790         if($aItem[
'photo']) {
 
  791             $a = array(
'ID' => $aItem[
'id'], 
'Avatar' => $aItem[
'photo']);
 
  793             $sImage = $aImage[
'no_image'] ? 
'' : $aImage[
'file'];
 
  797         $sCssPrefix = str_replace(
'_', 
'-', $this->_sPrefix);
 
  798         $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/';
 
  799         if($aEvent[
'js_mode'])
 
  800             $sCss = $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'), 
true);
 
  802             $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'));
 
  807         $sTextWallObject = 
_t(
'_ch_sites_wall_object');
 
  809             'title' => 
_t(
'_ch_sites_wall_added_new_title_comment', $sOwner, $sTextWallObject),
 
  810             'description' => $aComment[
'cmt_text'],
 
  811             'content' => $sCss . $this->_oTemplate->parseHtmlByName(
'modules/cheetah/wall/|timeline_comment.html', array(
 
  812                 'mod_prefix' => $sCssPrefix,
 
  813                 'cpt_user_name' => $sOwner,
 
  814                 'cpt_added_new' => 
_t(
'_ch_sites_wall_added_new_comment'),
 
  815                 'cpt_object' => $sTextWallObject,
 
  816                 'cpt_item_url' => $sBaseUrl . $aItem[
'entryUri'],
 
  817                 'cnt_comment_text' => $aComment[
'cmt_text'],
 
  818                 'snippet' => $this->_oTemplate->unit ($aItem, 
'unit_wall', $oVoting),
 
  828         $iId = (int)$aEvent[
'object_id'];
 
  829         $iOwner = (int)$aEvent[
'owner_id'];
 
  832         $aItem = $this->_oDb->getSiteById(
$iId);
 
  833         if(
empty($aItem) || !is_array($aItem))
 
  834             return array(
'perform_delete' => 
true);
 
  836         if(!$this->oPrivacy->check(
'view', 
$iId, $this->iOwnerId))
 
  839         $aContent = unserialize($aEvent[
'content']);
 
  840         if(
empty($aContent) || !isset($aContent[
'comment_id']))
 
  845         if(!$oCmts->isEnabled())
 
  848         $aComment = $oCmts->getCommentRow((
int)$aContent[
'comment_id']);
 
  849         if(
empty($aComment) || !is_array($aComment))
 
  850             return array(
'perform_delete' => 
true);
 
  853         if($aItem[
'photo']) {
 
  854             $a = array(
'ID' => $aItem[
'id'], 
'Avatar' => $aItem[
'photo']);
 
  856             $sImage = $aImage[
'no_image'] ? 
'' : $aImage[
'file'];
 
  860         $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/';
 
  861         if($aEvent[
'js_mode'])
 
  862             $sCss = $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'), 
true);
 
  864             $this->_oTemplate->addCss(array(
'wall_post.css', 
'main.css', 
'twig.css'));
 
  869         $sTextWallObject = 
_t(
'_ch_sites_wall_object');
 
  871             'title' => 
_t(
'_ch_sites_wall_added_new_title_comment', $sOwner, $sTextWallObject),
 
  872             'description' => $aComment[
'cmt_text'],
 
  873             'content' => $sCss . $this->_oTemplate->parseHtmlByName(
'modules/cheetah/wall/|timeline_comment.html', array(
 
  874                 'mod_prefix' => str_replace(
'_', 
'-', $this->_sPrefix),
 
  875                 'cpt_user_name' => $sOwner,
 
  876                 'cpt_added_new' => 
_t(
'_ch_sites_wall_added_new_comment'),
 
  877                 'cpt_object' => $sTextWallObject,
 
  878                 'cpt_item_url' => $sBaseUrl . $aItem[
'entryUri'],
 
  879                 'cnt_comment_text' => $aComment[
'cmt_text'],
 
  880                 'snippet' => $this->_oTemplate->unit ($aItem, 
'unit_wall', $oVoting),
 
  889                 array(
'alert_unit' => 
'ch_sites', 
'alert_action' => 
'add', 
'module_uri' => 
'sites', 
'module_class' => 
'Module', 
'module_method' => 
'get_spy_post'),
 
  890                 array(
'alert_unit' => 
'ch_sites', 
'alert_action' => 
'change', 
'module_uri' => 
'sites', 
'module_class' => 
'Module', 
'module_method' => 
'get_spy_post'),
 
  891                 array(
'alert_unit' => 
'ch_sites', 
'alert_action' => 
'rate', 
'module_uri' => 
'sites', 
'module_class' => 
'Module', 
'module_method' => 
'get_spy_post'),
 
  892                 array(
'alert_unit' => 
'ch_sites', 
'alert_action' => 
'commentPost', 
'module_uri' => 
'sites', 
'module_class' => 
'Module', 
'module_method' => 
'get_spy_post')
 
  895                 array(
'unit' => 
'ch_sites', 
'action' => 
'add'),
 
  896                 array(
'unit' => 
'ch_sites', 
'action' => 
'change'),
 
  897                 array(
'unit' => 
'ch_sites', 
'action' => 
'rate'),
 
  898                 array(
'unit' => 
'ch_sites', 
'action' => 
'delete'),
 
  899                 array(
'unit' => 
'ch_sites', 
'action' => 
'commentPost'),
 
  900                 array(
'unit' => 
'ch_sites', 
'action' => 
'commentRemoved')
 
  914                 $aSite = $this->_oDb->getSiteById($iObjectId);
 
  917                         'lang_key'  => 
'_ch_sites_poll_' . 
$sAction,
 
  919                             'profile_link' => $iSenderId ? 
getProfileLink($iSenderId) : 
'javascript:void(0)',
 
  920                             'profile_nick' => $iSenderId ? 
getNickName($iSenderId) : 
_t(
'_Guest'),
 
  921                             'site_url' => !
empty($aSite) ? $this->_oConfig->getBaseUri() . 
'view/' . $aSite[
'entryUri'] : 
'',
 
  922                             'site_caption' => !
empty($aSite) ? $aSite[
'title'] : 
'' 
  924                         'recipient_id' => $aSite[
'ownerid'],
 
  925                         'spy_type' => 
'content_activity',
 
  936         return parent::_serviceGetMemberMenuItem (
_t(
'_ch_sites'), 
_t(
'_ch_sites'), 
'link');
 
  943         return parent::_serviceGetMemberMenuItem (
_t(
'_ch_sites_site'), 
_t(
'_ch_sites_site'), 
'link', 
false, 
'add');
 
  950             $sTitle = 
_t(
'_ch_sites_caption_browse_' . $sValue);
 
  952             $sTitle = 
_t(
'_ch_sites_caption_browse_my');
 
  954         $this->_oTemplate->addCss(array(
'main.css'));
 
  955         $this->_oTemplate->pageStart();
 
  957         $this->_oTemplate->pageCode(
$sTitle, 
false, 
false, 
true);
 
  962         return isAdmin($this->iOwnerId);
 
  970         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_EDIT_ANY_SITE, $isPerformAction);
 
  981         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_ADD, $isPerformAction);
 
  990         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_MARK_AS_FEATURED, $isPerformAction);
 
  999         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_DELETE_ANY_SITE, $isPerformAction);
 
 1014         if ($this->
isAdmin() || $aSite[
'ownerid'] == $this->iOwnerId)
 
 1019         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_VIEW, $isPerformAction);
 
 1024         return $this->oPrivacy->check(
'view', $aSite[
'id'], $this->iOwnerId);
 
 1029         if ($this->
isAdmin()) 
return true;
 
 1031         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_BROWSE, $isPerformAction);
 
 1040         $aCheck = 
checkAction($this->iOwnerId, CH_SITES_SEARCH, $isPerformAction);
 
 1046         $aSite = $this->_oDb->getSiteById($iSiteId);
 
 1048         if (count($aSite) > 0 && $this->_oDb->deleteSiteById($iSiteId)) {
 
 1049             if ($aSite[
'photo'] != 0)
 
 1070         $aSite = $this->_oDb->getSiteById($iSiteId);
 
 1072         if (count($aSite) > 0) {
 
 1073             $aSTWOptions = array(
 
 1074                 'RefreshOnDemand' => 
true,
 
 1089         if (!($rHandler = opendir($this->sThumbPath)))
 
 1092         while ((
$sFile = readdir($rHandler)) !== 
false)
 
 1093             @unlink($this->sThumbPath . 
$sFile);
 
 1095         closedir($rHandler);
 
 1104         $this->_oDb->setStatusSite($iSiteId, 
$sStatus);
 
 1110         defineMembershipActions(array(
'sites view', 
'sites browse', 
'sites search', 
'sites add', 
'sites edit any site', 
'sites delete any site', 
'sites mark as featured', 
'sites approve'));
 
 1119         $o->reparseObjTags(
'ch_sites', $iSiteId);
 
 1126         $o->reparseObjTags(
'ch_sites', $iSiteId);
 
 1161         $oVotingProfile = 
new ChWsbVoting (
'ch_sites', 0, 0);
 
 1162         $oVotingProfile->deleteVotings ($iSiteId);
 
 1166         $oCmts = 
new ChWsbCmts (
'ch_sites', $iSiteId);
 
 1167         $oCmts->onObjectDelete ();
 
 1171         $oViews = 
new ChWsbViews(
'ch_sites', $iSiteId, 
false);
 
 1172         $oViews->onObjectDelete($iSiteId);
 
 1176         $oSubscription->unsubscribe(array(
'type' => 
'object_id', 
'unit' => 
'ch_sites', 
'object_id' => $iSiteId));
 
 1188         $oAlert = 
new ChWsbAlerts(
'ch_sites', 
'mark_as_featured', $aSite[
'id'], $aSite[
'Featured']);
 
 1196         if ($_POST[
'action_activate'] && is_array($_POST[
'entry'])) {
 
 1197             foreach ($_POST[
'entry'] 
as $iSiteId)
 
 1199         } elseif ($_POST[
'action_delete'] && is_array($_POST[
'entry'])) {
 
 1200             foreach ($_POST[
'entry'] 
as $iSiteId)
 
 1204         if ($_POST[
'action_refresh_thumb'] && is_array($_POST[
'entry']))
 
 1205             foreach ($_POST[
'entry'] 
as $iSiteId)
 
 1209             'action_delete' => 
'_ch_sites_admin_delete',
 
 1212         if (
getParam(
'ch_sites_redo') == 
'on' && 
getParam(
'ch_sites_account_type') == 
'Enabled') {
 
 1213             $aButtons[
'action_refresh_thumb'] = 
'_ch_sites_admin_refresh_thumb';
 
 1216             if (!$isAdminEntries)
 
 1217             $aButtons[
'action_activate'] = 
'_ch_sites_admin_activate';
 
 1219             $sForm = $this->
_manageSites($isAdminEntries ? 
'admin' : 
'adminpending', 
'', $aButtons);
 
 1220             return $this->_oTemplate->parseHtmlByName(
'my_sites_manage.html', array(
'form' => 
$sForm));
 
 1225         return $GLOBALS[
'oSysTemplate']->parseHtmlByName(
'default_padding.html', array(
'content' => $this->
_addSiteForm()));
 
 1230         $iId = $this->_oDb->getSettingsCategory($sSettingsCatName);
 
 1232             return MsgBox(
_t(
'_sys_request_page_not_found_cpt'));
 
 1237         if(isset($_POST[
'save']) && isset($_POST[
'cat'])) {
 
 1239             $mixedResult = 
$oSettings->saveChanges($_POST);
 
 1242         if (!
empty($_POST[
'clear_cache'])) {
 
 1248         if (
getParam(
'ch_sites_key_id') != 
'' && 
getParam(
'ch_sites_secret_key') != 
'') {
 
 1250             if ($aResponse[
'stw_response_status'] == 
'Success') {
 
 1251                 $sCodeSTW = 
MsgBox(
_t(
'_ch_sites_administration_stw_acc_success'), 5);
 
 1253                 $sCodeSTW = 
MsgBox(
_t(
'_ch_sites_administration_stw_acc_failed'), 5);
 
 1256             $sCodeSTW = 
MsgBox(
_t(
'_ch_sites_administration_stw_acc_no_data'), 5);
 
 1262         $aAccInfo = $this->_oDb->getAccountInfo(
getParam(
'ch_sites_key_id'));
 
 1264             'actual_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'administration/settings',
 
 1265             'response_status' => $aResponse[
'stw_response_status'] == 
'Success' ? 1 : 0,
 
 1266             'account_level' => $aAccInfo[
'account_level'] != 0 ? $aAccInfo[
'account_level'] : 0,
 
 1267             'inside_pages' => $aAccInfo[
'inside_pages'] == 1 ? 1 : 0,
 
 1268             'custom_size' => $aAccInfo[
'custom_size'] == 1 ? 1 : 0,
 
 1269             'full_length' => $aAccInfo[
'full_length'] == 1 ? 1 : 0,
 
 1270             'refresh_ondemand' => $aAccInfo[
'refresh_ondemand'] == 1 ? 1 : 0,
 
 1271             'custom_delay' => $aAccInfo[
'custom_delay'] == 1 ? 1 : 0,
 
 1272             'custom_quality' => $aAccInfo[
'custom_quality'] == 1 ? 1 : 0,
 
 1273             'custom_resolution' => $aAccInfo[
'custom_resolution'] == 1 ? 1 : 0,
 
 1274             'custom_messages' => $aAccInfo[
'custom_messages'] == 1 ? 1 : 0,
 
 1276         $sCode = $this->_oTemplate->parseHtmlByName(
'settings_info.html', 
$aVars);
 
 1279         if($mixedResult !== 
true && !
empty($mixedResult))
 
 1287         return $this->_oTemplate->parseHtmlByName(
'default_padding.html', 
$aVars);
 
 1298         if (isset($_POST[
'url'])) {
 
 1299             if (isset($_POST[
'title'])) {
 
 1301                 if (isset($_POST[
'thumbnail_html']))
 
 1305                 if (
$oForm->isSubmittedAndValid()) {
 
 1306                     $sCategories = implode(
';', array_unique(explode(
';', 
$oForm->getCleanValue(
'categories'))));
 
 1308                     unset(
$oForm->aInputs[
'categories']);
 
 1311                         'entryUri' => 
$oForm->generateUri(),
 
 1312                         'status' => $this -> _oConfig -> _bAutoapprove || $this->isAdmin() ? 
'approved' : 
'pending',
 
 1313                         'categories' => $sCategories
 
 1317                     if (isset($_FILES[
'photo'][
'tmp_name']) && $_FILES[
'photo'][
'tmp_name'])
 
 1318                         $aValsAdd[
'photo'] = 
$oForm->uploadPhoto($_FILES[
'photo'][
'tmp_name']);
 
 1321                             'thumbnailUrl' => array(
'tag' => 
'link', 
'content_attr' => 
'href'),
 
 1322                             'OGImage' => array(
'name_attr' => 
'property', 
'name' => 
'og:image'),
 
 1325                         $sSiteThumbnailUrl = 
'';
 
 1326                         if(!
empty($aSiteInfo[
'thumbnailUrl']))
 
 1327                             $sSiteThumbnailUrl = $aSiteInfo[
'thumbnailUrl'];
 
 1328                         else if(!
empty($aSiteInfo[
'OGImage']))
 
 1329                             $sSiteThumbnailUrl = $aSiteInfo[
'OGImage'];
 
 1332                         $aHeaders = get_headers($sSiteThumbnailUrl);
 
 1333                         foreach ($aHeaders 
as $sHeader) {
 
 1334                             $aMatches = array();
 
 1335                             if(preg_match(
"/^Content-Type:\s*([a-z]*)\/([a-z]*)$/i", $sHeader, $aMatches))
 
 1336                                 if($aMatches[1] == 
'image' && in_array($aMatches[2], array(
'png', 
'jpeg', 
'gif'))) {
 
 1343                             $aValsAdd[
'photo'] = 
$oForm->uploadPhoto($sSiteThumbnailUrl, 
true);
 
 1348                     if ($iSiteId = 
$oForm->insert($aValsAdd)) {
 
 1351                         header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'browse/my');
 
 1353                         $sMsgBox = 
MsgBox(
_t(
'_ch_sites_error_occured'));
 
 1357                 if (
$oForm->isSubmittedAndValid()) {
 
 1359                     $sUrlFull = strncasecmp(
$sUrl, 
'http://', 7) !== 0 && strncasecmp(
$sUrl, 
'https://', 8) !== 0 ? 
'http://' . 
$sUrl : 
$sUrl;
 
 1362                     if (
empty($aSite) || !is_array($aSite)) {
 
 1368                                 'title' => 
$aInfo[
'title'],
 
 1369                                 'description' => 
$aInfo[
'description']
 
 1373                             if (
getParam(
'ch_sites_account_type') != 
'No Automated Screenshots') {
 
 1374                                 $aSTWOptions = array(
 
 1386                             $sMsgBox = 
MsgBox(
_t(
'_ch_sites_site_link_error'));
 
 1390                         header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 
'view/' . $aSite[
'entryUri']);
 
 1395         return $sMsgBox . $this->_oTemplate->parseHtmlByName(
'form.html', array(
'form' => 
$oForm->getCode()));
 
 1410         require_once(CH_DIRECTORY_PATH_MODULES . 
'/cheetah/sites/classes/ChSitesSearchResult.php');
 
 1411         $this->_oTemplate->addCss(array(
'main.css'));
 
 1414         return $o->displayResultBlock(
true, 
true);
 
 1419         require_once(CH_DIRECTORY_PATH_MODULES . 
'/cheetah/sites/classes/ChSitesSearchResult.php');
 
 1420         $this->_oTemplate->addCss(array(
'main.css'));
 
 1423         return $o->displayResultBlock(
true, 
true);
 
 1430         $oSearchResult->sUnitTemplate = 
'unit_admin';
 
 1431         $sActionsPanel = 
'';
 
 1433         $sFormName = 
'manageSitesForm';
 
 1435         if (
$sContent = $oSearchResult->displayResultBlock(
true))
 
 1436         $sActionsPanel = $oSearchResult->showAdminActionsPanel($sFormName, $aButtons);
 
 1441             'form_name' => $sFormName,
 
 1443             'actions_panel' => $sActionsPanel
 
 1446         return $this->_oTemplate->parseHtmlByName(
'manage.html', 
$aVars);