Cheetah
ChSitesDb.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( CH_DIRECTORY_PATH_CLASSES . 'ChWsbModuleDb.php' );
9 
10 define('CH_SITES_TABLE_PREFIX', 'ch_sites');
11 
12 class ChSitesDb extends ChWsbModuleDb
13 {
14  var $_oConfig;
16  var $_sFieldId = 'id';
17  var $_sFieldAuthorId = 'ownerid';
18  var $_sFieldUri = 'entryUri';
19  var $_sFieldTitle = 'title';
20  var $_sFieldDescription = 'description';
21  var $_sFieldThumb = 'photo';
22 
23  /*
24  * Constructor.
25  */
26  function __construct(&$oConfig)
27  {
28  parent::__construct();
29 
30  $this->_oConfig = $oConfig;
31  $this->sTablePrefix = $oConfig->getDbPrefix();
32  }
33 
35  {
36  $sSql = "SELECT `ID` AS `id`, `Name` AS `name` FROM `sys_acl_actions` WHERE `Name`='use sites'";
37  return $this->getAll($sSql);
38  }
39 
40  function getSiteById($iSiteId)
41  {
42  return $this->getRow ("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `id` = ? LIMIT 1", [$iSiteId]);
43  }
44 
45  function getEntryByIdAndOwner ($iSiteId, $iUnusedParam = 0, $bUnusedParam = true)
46  {
47  return $this->getSiteById($iSiteId);
48  }
49 
50  function getSiteByEntryUri($sEntryUri)
51  {
52  return $this->getRow ("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `entryUri` = ? LIMIT 1", [$sEntryUri]);
53  }
54 
55  function getSiteLatest()
56  {
57  return $this->getRow ("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main` ORDER BY `date` DESC LIMIT 1");
58  }
59 
60  function getSiteByUrl($sUrl)
61  {
62  return $this->getRow ("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `url` = ? LIMIT 1", [$sUrl]);
63  }
64 
65  function getSites()
66  {
67  return $this->getAll("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main`");
68  }
69 
71  {
72  return $this->getAll("SELECT * FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `ownerid` = $iProfileId");
73  }
74 
75  function markFeatured($iSiteId)
76  {
77  return $this->query ("UPDATE `" . CH_SITES_TABLE_PREFIX . "_main` SET `featured` = (`featured` - 1)*(`featured` - 1) WHERE `id` = $iSiteId LIMIT 1");
78  }
79 
80  function deleteSiteById($iSiteId)
81  {
82  return $this->query("DELETE FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `id` = $iSiteId");
83  }
84 
86  {
87  return $this->getOne ("SELECT `ID` FROM `Profiles` WHERE `NickName` = '$sNick' LIMIT 1");
88  }
89 
90  function getSitesByMonth($iYear, $iMonth, $iNextYear, $iNextMonth)
91  {
92  return $this->getAll("SELECT *, DAYOFMONTH(FROM_UNIXTIME(`date`)) AS `Day`
93  FROM `" . CH_SITES_TABLE_PREFIX . "_main`
94  WHERE `date` >= UNIX_TIMESTAMP('$iYear-$iMonth-1') AND `date` < UNIX_TIMESTAMP('$iNextYear-$iNextMonth-1') AND `status` = 'approved'");
95  }
96 
98  {
99  return $this->getOne("SELECT `ID` FROM `sys_options_cats` WHERE `name` = '{$sName}' LIMIT 1");
100  }
101 
102  function setStatusSite($iSiteId, $sStatus)
103  {
104  $this->query("UPDATE `" . CH_SITES_TABLE_PREFIX . "_main` SET `status` = '$sStatus' WHERE `id` = $iSiteId");
105  }
106 
107  function getCountByOwnerAndStatus($iOwnerId, $sStatus)
108  {
109  return $this->getOne ("SELECT count(*) FROM `" . CH_SITES_TABLE_PREFIX . "_main` WHERE `status` = '$sStatus' AND `ownerid` = $iOwnerId");
110  }
111 
112  // BEGIN STW INTEGRATION
113 
114  function addRequest($aSTWArgs, $aResponse, $sHash)
115  {
116  $iTimestamp = time();
117  $aSTWArgs = process_db_input($aSTWArgs);
118  $aResponse = process_db_input($aResponse);
119  $sQuery = "UPDATE `{$this->sTablePrefix}stw_requests` SET `timestamp` = '" . process_db_input($iTimestamp) . "', `capturedon` = '" . $aResponse['stw_last_captured'] . "', `invalid` = '" . $aResponse['invalid'] . "',
120  `stwerrcode` = '" . $aResponse['stw_response_code'] . "', `error` = '" . $aResponse['error'] . "', `errcode` = '" . $aResponse['stw_response_status'] . "' WHERE `hash` = '" . process_db_input($sHash) . "'";
121  if ($this->query($sQuery) == 0) { // doesn't exist
122  $this->res("INSERT INTO `{$this->sTablePrefix}stw_requests` SET `domain` = '" . $aSTWArgs['stwurl'] . "', `timestamp` = '" . process_db_input($iTimestamp) . "', `capturedon` = '" . $aResponse['stw_last_captured'] . "',
123  `quality` = '" . $aSTWArgs['stwqual'] . "', `full` = '" . $aSTWArgs['stwfull'] . "', `xmax` = '" . $aSTWArgs['stwxmax'] . "', `ymax` = '" . $aSTWArgs['stwymax'] . "',
124  `nrx` = '" . $aSTWArgs['stwnrx'] . "', `nry` = '" . $aSTWArgs['stwnry'] . "', `invalid` = '" . $aResponse['invalid'] . "', `stwerrcode` = '" . $aResponse['stw_response_code'] . "',
125  `error` = '" . $aResponse['error'] . "', `errcode` = '" . $aResponse['stw_response_status'] . "', `hash` = '" . process_db_input($sHash) . "'");
126  }
127  }
128 
129  function addAccountInfo($sKeyID, $aResponse)
130  {
131  $iTimestamp = time();
132  $aResponse = process_db_input($aResponse);
133  $sQuery = "UPDATE `{$this->sTablePrefix}stwacc_info` SET `account_level` = '" . $aResponse['stw_account_level'] . "', `inside_pages` = '" . $aResponse['stw_inside_pages'] . "', `custom_size` = '" . $aResponse['stw_custom_size'] . "',
134  `full_length` = '" . $aResponse['stw_full_length'] . "', `refresh_ondemand` = '" . $aResponse['stw_refresh_ondemand'] . "', `custom_delay` = '" . $aResponse['stw_custom_delay'] . "', `custom_quality` = '" . $aResponse['stw_custom_quality'] . "',
135  `custom_resolution` = '" . $aResponse['stw_custom_resolution'] . "', `custom_messages` = '" . $aResponse['stw_custom_messages'] . "', `timestamp` = '" . process_db_input($iTimestamp) . "' WHERE `key_id` = '" . process_db_input($sKeyID) . "'";
136  if ($this->query($sQuery) == 0) { // doesn't exist
137  $this->res("INSERT INTO `{$this->sTablePrefix}stwacc_info` SET `key_id` = '" . process_db_input($sKeyID) . "', `account_level` = '" . $aResponse['stw_account_level'] . "', `inside_pages` = '" . $aResponse['stw_inside_pages'] . "', `custom_size` = '" . $aResponse['stw_custom_size'] . "',
138  `full_length` = '" . $aResponse['stw_full_length'] . "', `refresh_ondemand` = '" . $aResponse['stw_refresh_ondemand'] . "', `custom_delay` = '" . $aResponse['stw_custom_delay'] . "', `custom_quality` = '" . $aResponse['stw_custom_quality'] . "',
139  `custom_resolution` = '" . $aResponse['stw_custom_resolution'] . "', `custom_messages` = '" . $aResponse['stw_custom_messages'] . "', `timestamp` = '" . process_db_input($iTimestamp) . "'");
140  }
141  }
142 
143  function getAccountInfo($sKeyID)
144  {
145  return $this->getRow("SELECT * FROM `{$this->sTablePrefix}stwacc_info` WHERE `key_id` = ? LIMIT 1", [$sKeyID]);
146  }
147 
148  // END STW INTEGRATION
149 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChSitesDb\getAccountInfo
getAccountInfo($sKeyID)
Definition: ChSitesDb.php:143
ChSitesDb\getSettingsCategory
getSettingsCategory($sName)
Definition: ChSitesDb.php:97
ChSitesDb\getSiteByEntryUri
getSiteByEntryUri($sEntryUri)
Definition: ChSitesDb.php:50
ChSitesDb\$_sFieldDescription
$_sFieldDescription
Definition: ChSitesDb.php:20
ChSitesDb\deleteSiteById
deleteSiteById($iSiteId)
Definition: ChSitesDb.php:80
ChSitesDb\$_sFieldUri
$_sFieldUri
Definition: ChSitesDb.php:18
$sUrl
$sUrl
Definition: cart.php:15
ChSitesDb\markFeatured
markFeatured($iSiteId)
Definition: ChSitesDb.php:75
php
ChWsbModuleDb
Definition: ChWsbModuleDb.php:12
ChWsbDb\getAll
getAll($sQuery, $aBindings=[], $iFetchType=PDO::FETCH_ASSOC)
Definition: ChWsbDb.php:206
ChSitesDb\getEntryByIdAndOwner
getEntryByIdAndOwner($iSiteId, $iUnusedParam=0, $bUnusedParam=true)
Definition: ChSitesDb.php:45
ChSitesDb\getSiteLatest
getSiteLatest()
Definition: ChSitesDb.php:55
ChSitesDb\getCountByOwnerAndStatus
getCountByOwnerAndStatus($iOwnerId, $sStatus)
Definition: ChSitesDb.php:107
ChSitesDb\$_oConfig
$_oConfig
Definition: ChSitesDb.php:14
ChWsbDb\getRow
getRow($sQuery, $aBindings=[], $iFetchStyle=PDO::FETCH_ASSOC)
Definition: ChWsbDb.php:225
ChSitesDb\getSiteById
getSiteById($iSiteId)
Definition: ChSitesDb.php:40
ChSitesDb\getSites
getSites()
Definition: ChSitesDb.php:65
ChSitesDb\addRequest
addRequest($aSTWArgs, $aResponse, $sHash)
Definition: ChSitesDb.php:114
ChSitesDb\$_sFieldTitle
$_sFieldTitle
Definition: ChSitesDb.php:19
ChSitesDb\$_sFieldThumb
$_sFieldThumb
Definition: ChSitesDb.php:21
ChSitesDb\addAccountInfo
addAccountInfo($sKeyID, $aResponse)
Definition: ChSitesDb.php:129
ChWsbDb\query
query($sQuery, $aBindings=[])
Definition: ChWsbDb.php:386
ChSitesDb\setStatusSite
setStatusSite($iSiteId, $sStatus)
Definition: ChSitesDb.php:102
ChSitesDb\getSiteByUrl
getSiteByUrl($sUrl)
Definition: ChSitesDb.php:60
ChSitesDb\getSitesByAuthor
getSitesByAuthor($iProfileId)
Definition: ChSitesDb.php:70
ChWsbDb\res
res($sQuery, $aBindings=[], $bReplaying=false)
Definition: ChWsbDb.php:150
ChSitesDb\getProfileIdByNickName
getProfileIdByNickName($sNick)
Definition: ChSitesDb.php:85
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ChWsbDb\getOne
getOne($sQuery, $aBindings=[], $iIndex=0)
Definition: ChWsbDb.php:263
ChSitesDb\getSitesByMonth
getSitesByMonth($iYear, $iMonth, $iNextYear, $iNextMonth)
Definition: ChSitesDb.php:90
ChSitesDb\__construct
__construct(&$oConfig)
Definition: ChSitesDb.php:26
CH_SITES_TABLE_PREFIX
const CH_SITES_TABLE_PREFIX
Definition: ChSitesDb.php:10
ChSitesDb\$_sFieldAuthorId
$_sFieldAuthorId
Definition: ChSitesDb.php:17
ChSitesDb\$_sFieldId
$_sFieldId
Definition: ChSitesDb.php:16
ChSitesDb
Definition: ChSitesDb.php:13
$sNick
$sNick
Definition: actions.inc.php:9
ChSitesDb\$sTablePrefix
$sTablePrefix
Definition: ChSitesDb.php:15
$sName
$sName
Definition: ChWsbAdminTools.php:853
$sStatus
$sStatus
Definition: actions.inc.php:11
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
ChSitesDb\getMembershipActions
getMembershipActions()
Definition: ChSitesDb.php:34