Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateInfoButton
  • generateJs
  • getAktuellType
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • modTestModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • xmlFileToArray
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: /**
   3:  * This file contains the CONTENIDO statistic functions.
   4:  *
   5:  * @package          Core
   6:  * @subpackage       Backend
   7:  * @version          SVN Revision $Rev:$
   8:  *
   9:  * @author           Olaf Niemann
  10:  * @copyright        four for business AG <www.4fb.de>
  11:  * @license          http://www.contenido.org/license/LIZENZ.txt
  12:  * @link             http://www.4fb.de
  13:  * @link             http://www.contenido.org
  14:  */
  15: 
  16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
  17: 
  18: cInclude("includes", "functions.database.php");
  19: 
  20: /**
  21:  * Displays statistic information layer (a div Tag)
  22:  *
  23:  * @param   int     $id    Either article or directory id
  24:  * @param   string  $type  The type
  25:  * @param   int     $x     Style top position
  26:  * @param   int     $y     Style left position
  27:  * @param   int     $w     Style width
  28:  * @param   int     $h     Style height
  29:  * @return  string  Composed info layer
  30:  */
  31: function statsDisplayInfo($id, $type, $x, $y, $w, $h) {
  32:     if (strcmp($type, "article" == 0)) {
  33:         $text = i18n("Info about article") . " " . $id;
  34:     } else {
  35:         $text = i18n("Info about directory") . " " . $id;
  36:     }
  37: 
  38:     $div = new cHTMLDiv($text, "text_medium", "idElement14");
  39:     $div->appenStyleDefinition("border", "1px solid #e8e8ee");
  40:     $div->appendStyleDefinition("position", "absolute");
  41:     $div->appendStyleDefinition("top", $x."px");
  42:     $div->appendStyleDefinition("left", $y."px");
  43:     $div->appendStyleDefinition("width", $w."px");
  44:     $div->appendStyleDefinition("height", $h."px");
  45: 
  46:     return $div->toHTML();
  47: }
  48: 
  49: /**
  50:  * Archives the current statistics
  51:  *
  52:  * @param $yearmonth String with the desired archive date (YYYYMM)
  53:  * @return void
  54:  */
  55: function statsArchive($yearmonth) {
  56:     global $cfg;
  57: 
  58:     $yearmonth = preg_replace('/\s/', '0', $yearmonth);
  59: 
  60:     $db = cRegistry::getDb();
  61:     $db2 = cRegistry::getDb();
  62: 
  63:     $sql = "SELECT idcatart, idlang, idclient, visited, visitdate FROM " . $cfg["tab"]["stat"];
  64: 
  65:     $db->query($sql);
  66: 
  67:     while ($db->nextRecord()) {
  68:         $insertSQL = "INSERT INTO
  69:                           " . $cfg["tab"]["stat_archive"] . "
  70:                           ( archived, idcatart, idlang, idclient, visited, visitdate)
  71:                       VALUES
  72:                           (
  73:                            " . $yearmonth . ",
  74:                            " . cSecurity::toInteger($db->f(0)) . ",
  75:                            " . cSecurity::toInteger($db->f(1)) . ",
  76:                            " . cSecurity::toInteger($db->f(2)) . ",
  77:                            " . cSecurity::toInteger($db->f(3)) . ",
  78:                            '" . $db2->escape($db->f(4)) . "')";
  79: 
  80:         $db2->query($insertSQL);
  81:     }
  82: 
  83:     $sql = "DELETE FROM " . $cfg["tab"]["stat"];
  84:     $db->query($sql);
  85: 
  86:     // Recreate empty stats
  87:     $sql = "SELECT
  88:                 A.idcatart, B.idclient, C.idlang
  89:             FROM
  90:                 " . $cfg["tab"]["cat_art"] . " AS A INNER JOIN
  91:                 " . $cfg["tab"]["cat"] . " AS B ON A.idcat = B.idcat INNER JOIN
  92:                 " . $cfg["tab"]["cat_lang"] . " AS C ON A.idcat = C.idcat ";
  93: 
  94:     $db->query($sql);
  95: 
  96:     while ($db->nextRecord()) {
  97:         $insertSQL = "INSERT INTO
  98:                           " . $cfg["tab"]["stat"] . "
  99:                           ( idcatart, idlang, idclient, visited )
 100:                       VALUES (
 101:                           " . cSecurity::toInteger($db->f(0)) . ",
 102:                           " . cSecurity::toInteger($db->f(2)) . ",
 103:                           " . cSecurity::toInteger($db->f(1)) . ",
 104:                           '0000-00-00 00:00:00')";
 105: 
 106:         $db2->query($insertSQL);
 107:     }
 108: }
 109: 
 110: /**
 111:  * Generates a statistics page
 112:  *
 113:  * @param $yearmonth  Specifies the year and month from which to retrieve the
 114:  *                    statistics, specify "current" to retrieve the current
 115:  *                    entries
 116:  * @return void
 117:  */
 118: function statsOverviewAll($yearmonth) {
 119:     global $cfg, $db, $tpl, $client, $lang, $cfgClient;
 120: 
 121:     $sDisplay = 'table-row';
 122: 
 123:     $bUseHeapTable = $cfg["statistics_heap_table"];
 124: 
 125:     $sHeapTable = $cfg['tab']['stat_heap_table'];
 126: 
 127:     if ($bUseHeapTable) {
 128:         if (!dbTableExists($db, $sHeapTable)) {
 129:             buildHeapTable($sHeapTable, $db);
 130:         }
 131:     }
 132: 
 133:     if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
 134:         $sDisplay = 'block';
 135:     }
 136: 
 137:     $sql = "SELECT
 138:                     idtree, A.idcat, level, preid, C.name, visible
 139:                 FROM
 140:                     " . $cfg["tab"]["cat_tree"] . " AS A,
 141:                     " . $cfg["tab"]["cat"] . " AS B,
 142:                     " . $cfg["tab"]["cat_lang"] . " AS C
 143:                 WHERE
 144:                     A.idcat=B.idcat AND
 145:                     B.idcat=C.idcat AND
 146:                     C.idlang=" . cSecurity::toInteger($lang) . " AND
 147:                     B.idclient=" . cSecurity::toInteger($client) . "
 148:                 ORDER BY idtree";
 149: 
 150:     $db->query($sql);
 151: 
 152:     $currentRow = 2;
 153: 
 154:     $aRowname = array();
 155:     $iLevel = 0;
 156:     $backendUrl = cRegistry::getBackendUrl();
 157:     $tpl->set('s', 'IMG_EXPAND', $backendUrl . $cfg['path']['images'] . 'open_all.gif');
 158:     $tpl->set('s', 'IMG_COLLAPSE', $backendUrl . $cfg['path']['images'] . 'close_all.gif');
 159: 
 160:     $sumNumberOfArticles = 0;
 161: 
 162:     while ($db->nextRecord()) {
 163:         if ($db->f("level") == 0 && $db->f("preid") != 0) {
 164:             $tpl->set('d', 'PADDING_LEFT', '10');
 165:             $tpl->set('d', 'TEXT', '&nbsp;');
 166:             $tpl->set('d', 'NUMBEROFARTICLES', '');
 167:             $tpl->set('d', 'TOTAL', '');
 168:             $tpl->set('d', 'ICON', '');
 169:             $tpl->set('d', 'STATUS', '');
 170:             $tpl->set('d', 'ONCLICK', '');
 171:             $tpl->set('d', 'ROWNAME', '');
 172:             $tpl->set('d', 'INTHISLANGUAGE', '');
 173:             $tpl->set('d', 'EXPAND', '');
 174:             $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 175:             $tpl->set('d', 'PATH', '');
 176:             $tpl->set('d', 'ULR_TO_PAGE', '');
 177: 
 178:             $tpl->next();
 179:             $currentRow++;
 180:         }
 181: 
 182:         $padding_left = 10 + (15 * $db->f("level"));
 183:         $text = $db->f(4);
 184:         $idcat = $db->f("idcat");
 185:         $bCatVisible = $db->f("visible");
 186: 
 187:         if ($db->f("level") < $iLevel) {
 188:             $iDistance = $iLevel - $db->f("level");
 189: 
 190:             for ($i = 0; $i < $iDistance; $i++) {
 191:                 array_pop($aRowname);
 192:             }
 193:             $iLevel = $db->f("level");
 194:         }
 195: 
 196:         if ($db->f("level") >= $iLevel) {
 197:             if ($db->f("level") == $iLevel) {
 198:                 array_pop($aRowname);
 199:             } else {
 200:                 $iLevel = $db->f("level");
 201:             }
 202:             array_push($aRowname, $idcat);
 203:         }
 204: 
 205:         $db2 = cRegistry::getDb();
 206:         //************** number of arts **************
 207:         $sql = "SELECT COUNT(*) FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat=" . cSecurity::toInteger($idcat);
 208:         $db2->query($sql);
 209:         $db2->nextRecord();
 210: 
 211:         $numberOfArticles = $db2->f(0);
 212:         $sumNumberOfArticles += $numberOfArticles;
 213:         //************** hits of category total**************
 214:         if (strcmp($yearmonth, "current") == 0) {
 215:             $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . " AND B.idclient=" . cSecurity::toInteger($client);
 216:         } else {
 217:             if (!$bUseHeapTable) {
 218:                 $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 219:                         AND B.idclient=" . cSecurity::toInteger($client) . " AND B.archived='" . $db2->escape($yearmonth) . "'";
 220:             } else {
 221:                 $sql = "SELECT SUM(visited) FROM " . $db2->escape($sHeapTable) . " WHERE idcat=" . cSecurity::toInteger($idcat) . "
 222:                         AND idclient=" . cSecurity::toInteger($client) . " AND archived='" . $db2->escape($yearmonth) . "'";
 223:             }
 224:         }
 225:         $db2->query($sql);
 226:         $db2->nextRecord();
 227: 
 228:         $total = $db2->f(0);
 229: 
 230:         //************** hits of category in this language ***************
 231:         if (strcmp($yearmonth, "current") == 0) {
 232:             $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 233:                     AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client);
 234:         } else {
 235:             if (!$bUseHeapTable) {
 236:                 $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 237:                         AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client) . " AND B.archived='" . $db2->escape($yearmonth) . "'";
 238:             } else {
 239:                 $sql = "SELECT SUM(visited) FROM " . $db2->escape($sHeapTable) . " WHERE idcat=" . cSecurity::toInteger($idcat) . " AND idlang=" . cSecurity::toInteger($lang) . "
 240:                         AND idclient=" . cSecurity::toInteger($client) . " AND archived='" . $db2->escape($yearmonth) . "'";
 241:             }
 242:         }
 243: 
 244:         $db2->query($sql);
 245:         $db2->nextRecord();
 246: 
 247:         $inThisLanguage = $db2->f(0);
 248: 
 249:         $icon = '<img src="' . $cfg['path']['images'] . 'folder.gif" class="vAlignMiddle">';
 250: 
 251:         //************ art ********************************
 252:         $sql = "SELECT * FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["art"] . " AS B, " . $cfg["tab"]["art_lang"] . " AS C WHERE A.idcat=" . cSecurity::toInteger($idcat) . "
 253:                 AND A.idart=B.idart AND B.idart=C.idart AND C.idlang=" . cSecurity::toInteger($lang) . " ORDER BY B.idart";
 254:         $db2->query($sql);
 255: 
 256:         $numrows = $db2->numRows();
 257:         $onclick = "";
 258: 
 259:         $online = $db->f("visible");
 260:         if ($bCatVisible == 1) {
 261:             $offonline = '<img src="' . $cfg['path']['images'] . 'online_off.gif" alt="' . i18n("Category is online") . '" title="' . i18n("Category is online") . '">';
 262:         } else {
 263:             $offonline = '<img src="' . $cfg['path']['images'] . 'offline_off.gif" alt="' . i18n("Category is offline") . '" title="' . i18n("Category is offline") . '">';
 264:         }
 265: 
 266:         //************check if there are subcategories ******************
 267:         $iSumSubCategories = 0;
 268:         $sSql = "SELECT COUNT(*) AS cat_count FROM " . $cfg["tab"]["cat"] . " WHERE parentid=" . cSecurity::toInteger($idcat) . ";";
 269:         $db3 = cRegistry::getDb();
 270:         $db3->query($sSql);
 271:         if ($db3->nextRecord()) {
 272:             $iSumSubCategories = $db3->f('cat_count');
 273:         }
 274:         $db3->free();
 275: 
 276:         $tpl->set('d', 'PADDING_LEFT', $padding_left);
 277:         $tpl->set('d', 'TEXT', $text.' (idcat: '.cSecurity::toInteger($db->f('idcat')).')');
 278:         $tpl->set('d', 'ONCLICK', $onclick);
 279:         $tpl->set('d', 'ICON', $icon);
 280:         $tpl->set('d', 'STATUS', $offonline);
 281:         $tpl->set('d', 'NUMBEROFARTICLES', $numberOfArticles);
 282:         $tpl->set('d', 'TOTAL', $total);
 283:         $tpl->set('d', 'ROWNAME', implode('_', $aRowname));
 284:         if ($numrows > 0 || $iSumSubCategories > 0) {
 285:             $tpl->set('d', 'EXPAND', '<a href="javascript:changeVisibility(\'' . implode('_', $aRowname) . '\', ' . $db->f("level") . ', ' . $idcat . ')">
 286:                                           <img src="' . $cfg['path']['images'] . 'open_all.gif"
 287:                                                alt="' . i18n("Open category") . '"
 288:                                                title="' . i18n("Open category") . '"
 289:                                                id="' . implode('_', $aRowname) . '_img"
 290:                                                class="vAlignMiddle">
 291:                                       </a>');
 292:         } else {
 293:             $tpl->set('d', 'EXPAND', '<img src="' . $cfg['path']['images'] . 'spacer.gif" width="7">');
 294:         }
 295:         $tpl->set('d', 'INTHISLANGUAGE', $inThisLanguage);
 296:         if ($db->f("level") != 0) {
 297:             $tpl->set('d', 'DISPLAY_ROW', 'none');
 298:         } else {
 299:             $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 300:         }
 301:         $frontendURL = cRegistry::getFrontendUrl();
 302:         $cat_name = "";
 303:         statCreateLocationString($db->f('idcat'), "&nbsp;/&nbsp;", $cat_name);
 304:         $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 305:         $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idcat=' . $db->f('idcat'));
 306: 
 307:         $tpl->next();
 308:         $currentRow++;
 309: 
 310:         $onclick = "";
 311:         $text = "";
 312:         $numberOfArticles = "";
 313:         $total = "";
 314:         $inThisLanguage = "";
 315: 
 316:         while ($db2->nextRecord()) {
 317:             $idart = $db2->f("idart");
 318: 
 319:             array_push($aRowname, $idart);
 320: 
 321:             $text = "";
 322:             $numberOfArticles = "";
 323:             $total = "";
 324:             $inThisLanguage = "";
 325: 
 326:             $padding_left = 10 + (15 * ($db->f("level") + 1));
 327: 
 328:             $text = $db2->f("title");
 329:             $online = $db2->f("online");
 330: 
 331:             //************** number of arts **************
 332:             $db3 = cRegistry::getDb();
 333: 
 334:             //************** hits of art total **************
 335:             if (strcmp($yearmonth, "current") == 0) {
 336:                 $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 337:                      AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idclient=" . cSecurity::toInteger($client);
 338:             } else {
 339:                 if (!$bUseHeapTable) {
 340:                     $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 341:                             AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idclient=" . cSecurity::toInteger($client) . " AND B.archived='" . $db3->escape($yearmonth) . "'";
 342:                 } else {
 343:                     $sql = "SELECT SUM(visited) FROM " . $db3->escape($sHeapTable) . " WHERE idcat=" . cSecurity::toInteger($idcat) . " AND idart=" . cSecurity::toInteger($idart) . "
 344:                             AND idclient=" . cSecurity::toInteger($client) . " AND archived='" . $db3->escape($yearmonth) . "'";
 345:                 }
 346:             }
 347: 
 348:             $db3->query($sql);
 349:             $db3->nextRecord();
 350: 
 351:             $total = $db3->f(0);
 352: 
 353:             //************** hits of art in this language ***************
 354:             if (strcmp($yearmonth, "current") == 0) {
 355:                 $sql = "SELECT visited, idart FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 356:                         AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client);
 357:             } else {
 358:                 if (!$bUseHeapTable) {
 359:                     $sql = "SELECT visited, idart FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 360:                             AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client) . "
 361:                             AND B.archived='" . $db3->escape($yearmonth) . "'";
 362:                 } else {
 363:                     $sql = "SELECT visited, idart FROM " . $db3->escape($sHeapTable) . " WHERE idcat=" . cSecurity::toInteger($idcat) . " AND idart=" . cSecurity::toInteger($idart) . "
 364:                             AND idlang=" . cSecurity::toInteger($lang) . " AND idclient=" . cSecurity::toInteger($client) . " AND archived='" . $db3->escape($yearmonth) . "'";
 365:                 }
 366:             }
 367: 
 368:             $db3->query($sql);
 369:             $db3->nextRecord();
 370: 
 371:             $inThisLanguage = $db3->f(0);
 372: 
 373:             if ($online == 0) {
 374:                 $offonline = '<img src="' . $cfg['path']['images'] . 'offline_off.gif" alt="' . i18n("Article is offline") . '" title="' . i18n("Article is offline") . '">';
 375:             } else {
 376:                 $offonline = '<img src="' . $cfg['path']['images'] . 'online_off.gif" alt="' . i18n("Article is online") . '" title="' . i18n("Article is online") . '">';
 377:             }
 378: 
 379:             $icon = '<img src="' . $cfg['path']['images'] . 'article.gif"  class="vAlignMiddle">';
 380:             $tpl->set('d', 'PADDING_LEFT', $padding_left);
 381:             $tpl->set('d', 'TEXT', $text.' (idart: '.cSecurity::toInteger($db3->f('idart')).')');
 382:             $tpl->set('d', 'ONCLICK', "");
 383:             $tpl->set('d', 'ICON', $icon);
 384:             $tpl->set('d', 'STATUS', $offonline);
 385:             $tpl->set('d', 'ROWNAME', implode('_', $aRowname));
 386:             //$tpl->set('d', 'ROWNAME', "HIDE".($db->f("level")+1));
 387:             $tpl->set('d', 'NUMBEROFARTICLES', $numberOfArticles);
 388:             $tpl->set('d', 'TOTAL', $total);
 389:             $tpl->set('d', 'INTHISLANGUAGE', $inThisLanguage);
 390:             $tpl->set('d', 'EXPAND', '<img src="' . $cfg['path']['images'] . 'spacer.gif" width="7">');
 391:             $tpl->set('d', 'DISPLAY_ROW', 'none');
 392:             $cat_name = "";
 393:             statCreateLocationString($db3->f('idart'), "&nbsp;/&nbsp;", $cat_name);
 394:             $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 395:             $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idart=' . $db3->f('idart'));
 396:             $tpl->next();
 397:             $currentRow++;
 398: 
 399:             array_pop($aRowname);
 400:         }
 401:     }
 402: 
 403:     //************** hits total**************
 404:     if (strcmp($yearmonth, "current") == 0) {
 405:         $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND B.idclient=" . cSecurity::toInteger($client);
 406:     } else {
 407:         if (!$bUseHeapTable) {
 408:             $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND B.idclient=" . cSecurity::toInteger($client) . "
 409:                     AND B.archived='" . $db->escape($yearmonth) . "'";
 410:         } else {
 411:             $sql = "SELECT SUM(visited) FROM " . $db->escape($sHeapTable) . " WHERE idclient=" . cSecurity::toInteger($client) . " AND archived='" . $db->escape($yearmonth) . "'";
 412:         }
 413:     }
 414: 
 415:     $db->query($sql);
 416:     $db->nextRecord();
 417: 
 418:     $total = $db->f(0);
 419: 
 420:     //************** hits total on this language ***************
 421:     if (strcmp($yearmonth, "current") == 0) {
 422:         $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat"] . " AS B WHERE A.idcatart=B.idcatart AND B.idlang=" . cSecurity::toInteger($lang) . "
 423:                 AND B.idclient=" . cSecurity::toInteger($client);
 424:     } else {
 425:         if (!$bUseHeapTable) {
 426:             $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND B.idlang=" . cSecurity::toInteger($lang) . "
 427:                     AND B.idclient=" . cSecurity::toInteger($client) . " AND B.archived='" . $db->escape($yearmonth) . "'";
 428:         } else {
 429:             $sql = "SELECT SUM(visited) FROM " . $db->escape($sHeapTable) . " WHERE idlang=" . cSecurity::toInteger($lang) . " AND idclient=" . cSecurity::toInteger($client) . "
 430:                     AND archived='" . $db->escape($yearmonth) . "'";
 431:         }
 432:     }
 433: 
 434:     $db->query($sql);
 435:     $db->nextRecord();
 436: 
 437:     $inThisLanguage = $db->f(0);
 438: 
 439:     $tpl->set('d', 'TEXT', '&nbsp;');
 440:     $tpl->set('d', 'ICON', '');
 441:     $tpl->set('d', 'STATUS', '');
 442:     $tpl->set('d', 'PADDING_LEFT', '10');
 443:     $tpl->set('d', 'NUMBEROFARTICLES', '');
 444:     $tpl->set('d', 'TOTAL', '');
 445:     $tpl->set('d', 'INTHISLANGUAGE', '');
 446:     $tpl->set('d', 'EXPAND', '');
 447:     $tpl->set('d', 'ROWNAME', '');
 448:     $tpl->set('d', 'ONCLICK', '');
 449:     $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 450: 
 451:     $tpl->set('s', 'SUMTEXT', i18n("Sum"));
 452:     $tpl->set('s', 'SUMNUMBEROFARTICLES', $sumNumberOfArticles);
 453:     $tpl->set('s', 'SUMTOTAL', $total);
 454:     $tpl->set('s', 'SUMINTHISLANGUAGE', $inThisLanguage);
 455:     $tpl->next();
 456: }
 457: 
 458: /**
 459:  * Generates a statistics page for a given year
 460:  *
 461:  * @param $year       Specifies the year to retrieve the
 462:  *                    statistics for
 463:  * @return void
 464:  */
 465: function statsOverviewYear($year) {
 466:     global $cfg, $db, $tpl, $client, $lang;
 467: 
 468:     $sDisplay = 'table-row';
 469: 
 470:     if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
 471:         $sDisplay = 'block';
 472:     }
 473: 
 474:     $sql = "SELECT
 475:                 idtree, A.idcat, level, preid, C.name, visible
 476:             FROM
 477:                 " . $cfg["tab"]["cat_tree"] . " AS A,
 478:                 " . $cfg["tab"]["cat"] . " AS B,
 479:                 " . $cfg["tab"]["cat_lang"] . " AS C
 480:             WHERE
 481:                 A.idcat=B.idcat AND
 482:                 B.idcat=C.idcat AND
 483:                 C.idlang=" . cSecurity::toInteger($lang) . " AND
 484:                 B.idclient=" . cSecurity::toInteger($client) . "
 485:             ORDER BY idtree";
 486: 
 487:     $db->query($sql);
 488: 
 489:     $currentRow = 2;
 490: 
 491:     $aRowname = array();
 492:     $iLevel = 0;
 493:     $backendUrl = cRegistry::getBackendUrl();
 494:     $tpl->set('s', 'IMG_EXPAND', $backendUrl . $cfg['path']['images'] . 'open_all.gif');
 495:     $tpl->set('s', 'IMG_COLLAPSE', $backendUrl . $cfg['path']['images'] . 'close_all.gif');
 496: 
 497:     while ($db->nextRecord()) {
 498:         if ($db->f("level") == 0 && $db->f("preid") != 0) {
 499:             $tpl->set('d', 'PADDING_LEFT', '10');
 500:             $tpl->set('d', 'TEXT', '&nbsp;');
 501:             $tpl->set('d', 'NUMBEROFARTICLES', '');
 502:             $tpl->set('d', 'TOTAL', '');
 503:             $tpl->set('d', 'STATUS', '');
 504:             $tpl->set('d', 'ONCLICK', '');
 505:             $tpl->set('d', 'ICON', '');
 506:             $tpl->set('d', 'INTHISLANGUAGE', '');
 507:             $tpl->set('d', 'EXPAND', '');
 508:             $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 509:             $tpl->set('d', 'ROWNAME', '');
 510:             $tpl->next();
 511:             $currentRow++;
 512:         }
 513: 
 514:         $padding_left = 10 + (15 * $db->f("level"));
 515:         $text = $db->f(4);
 516:         $idcat = $db->f("idcat");
 517:         $bCatVisible = $db->f("visible");
 518: 
 519:         if ($db->f("level") < $iLevel) {
 520:             $iDistance = $iLevel - $db->f("level");
 521: 
 522:             for ($i = 0; $i < $iDistance; $i++) {
 523:                 array_pop($aRowname);
 524:             }
 525:             $iLevel = $db->f("level");
 526:         }
 527: 
 528:         if ($db->f("level") >= $iLevel) {
 529:             if ($db->f("level") == $iLevel) {
 530:                 array_pop($aRowname);
 531:             } else {
 532:                 $iLevel = $db->f("level");
 533:             }
 534:             array_push($aRowname, $idcat);
 535:         }
 536: 
 537:         $db2 = cRegistry::getDb();
 538:         //************** number of arts **************
 539:         $sql = "SELECT COUNT(*) FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat=" . cSecurity::toInteger($idcat);
 540:         $db2->query($sql);
 541:         $db2->nextRecord();
 542: 
 543:         $numberOfArticles = $db2->f(0);
 544:         $sumNumberOfArticles += $numberOfArticles;
 545:         $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 546:                 AND B.idclient=" . cSecurity::toInteger($client) . " AND SUBSTRING(B.archived,1,4)=" . cSecurity::toInteger($year, $db2) . " GROUP BY SUBSTRING(B.archived,1,4)";
 547:         $db2->query($sql);
 548:         $db2->nextRecord();
 549: 
 550:         $total = $db2->f(0);
 551: 
 552:         //************** hits of category in this language ***************
 553:         $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 554:                 AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client) . " AND SUBSTRING(B.archived,1,4)=" . $db2->escape($year) . "
 555:                 GROUP BY SUBSTRING(B.archived,1,4)";
 556:         $db2->query($sql);
 557:         $db2->nextRecord();
 558: 
 559:         $inThisLanguage = $db2->f(0);
 560: 
 561:         $icon = '<img src="' . $cfg['path']['images'] . 'folder.gif" class="vAlignMiddle">';
 562: 
 563:         //************ art ********************************
 564:         $sql = "SELECT * FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["art"] . " AS B, " . $cfg["tab"]["art_lang"] . " AS C WHERE A.idcat=" . cSecurity::toInteger($idcat) . " AND A.idart=B.idart AND B.idart=C.idart
 565:                 AND C.idlang=" . cSecurity::toInteger($lang) . " ORDER BY B.idart";
 566:         $db2->query($sql);
 567: 
 568:         $numrows = $db2->numRows();
 569:         $onclick = "";
 570: 
 571:         if ($bCatVisible == 0) {
 572:             $offonline = '<img src="' . $cfg['path']['images'] . 'offline_off.gif" alt="' . i18n("Category is offline") . '" title="' . i18n("Category is offline") . '">';
 573:         } else {
 574:             $offonline = '<img src="' . $cfg['path']['images'] . 'online_off.gif" alt="' . i18n("Category is online") . '" title="' . i18n("Category is online") . '">';
 575:         }
 576: 
 577:         //************check if there are subcategories ******************
 578:         $iSumSubCategories = 0;
 579:         $sSql = "SELECT count(*) as cat_count from " . $cfg["tab"]["cat"] . " WHERE parentid=" . cSecurity::toInteger($idcat) . ";";
 580:         $db3 = cRegistry::getDb();
 581:         $db3->query($sSql);
 582:         if ($db3->nextRecord()) {
 583:             $iSumSubCategories = $db3->f('cat_count');
 584:         }
 585:         $db3->free();
 586: 
 587:         $tpl->set('d', 'PADDING_LEFT', $padding_left);
 588:         $tpl->set('d', 'TEXT', $text.' (idcat: '.cSecurity::toInteger($db->f('idcat')).')');
 589:         $tpl->set('d', 'ONCLICK', $onclick);
 590:         $tpl->set('d', 'ICON', $icon);
 591:         $tpl->set('d', 'STATUS', $offonline);
 592:         $tpl->set('d', 'NUMBEROFARTICLES', $numberOfArticles);
 593:         $tpl->set('d', 'TOTAL', $total);
 594:         $tpl->set('d', 'ROWNAME', implode('_', $aRowname));
 595:         $tpl->set('d', 'INTHISLANGUAGE', $inThisLanguage);
 596: 
 597:         if ($numrows > 0 || $iSumSubCategories > 0) {
 598:             $tpl->set('d', 'EXPAND', '<a href="javascript:changeVisibility(\'' . implode('_', $aRowname) . '\', ' . $db->f("level") . ', ' . $idcat . ')">
 599:                                           <img src="' . $cfg['path']['images'] . 'open_all.gif"
 600:                                                alt="' . i18n("Open category") . '"
 601:                                                title="' . i18n("Open category") . '"
 602:                                                id="' . implode('_', $aRowname) . '_img"
 603:                                                class="vAlignMiddle">
 604:                                       </a>');
 605:         } else {
 606:             $tpl->set('d', 'EXPAND', '<img src="' . $cfg['path']['images'] . 'spacer.gif" width="7">');
 607:         }
 608: 
 609:         if ($db->f("level") != 0) {
 610:             $tpl->set('d', 'DISPLAY_ROW', 'none');
 611:         } else {
 612:             $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 613:         }
 614:         $frontendURL = cRegistry::getFrontendUrl();
 615:         $cat_name = "";
 616:         statCreateLocationString($db->f('idcat'), "&nbsp;/&nbsp;", $cat_name);
 617:         $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 618:         $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idcat=' . $db->f('idcat'));
 619: 
 620:         $tpl->next();
 621:         $currentRow++;
 622: 
 623:         $onclick = "";
 624:         $text = "";
 625:         $numberOfArticles = "";
 626:         $total = "";
 627:         $inThisLanguage = "";
 628: 
 629:         while ($db2->nextRecord()) {
 630:             $idart = $db2->f("idart");
 631: 
 632:             array_push($aRowname, $idart);
 633: 
 634:             $text = "";
 635:             $numberOfArticles = "";
 636:             $total = "";
 637:             $inThisLanguage = "";
 638: 
 639:             $padding_left = 10 + (15 * ($db->f("level") + 1));
 640: 
 641:             $text = $db2->f("title");
 642:             $online = $db2->f("online");
 643: 
 644:             //************** number of arts **************
 645:             $db3 = cRegistry::getDb();
 646: 
 647:             //************** hits of art total **************
 648:             $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 649:                     AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idclient=" . cSecurity::toInteger($client) . " AND SUBSTRING(B.archived,1,4)=" . $db3->escape($year) . "
 650:                     GROUP BY SUBSTRING(B.archived,1,4)";
 651:             $db3->query($sql);
 652:             $db3->nextRecord();
 653: 
 654:             $total = $db3->f(0);
 655: 
 656:             //************** hits of art in this language ***************
 657:             $sql = "SELECT visited FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND A.idcat=" . cSecurity::toInteger($idcat) . "
 658:                     AND A.idart=" . cSecurity::toInteger($idart) . " AND B.idlang=" . cSecurity::toInteger($lang) . " AND B.idclient=" . cSecurity::toInteger($client) . "
 659:                     AND SUBSTRING(B.archived,1,4)=" . $db3->escape($year) . " GROUP BY SUBSTRING(B.archived,1,4)";
 660:             $db3->query($sql);
 661:             $db3->nextRecord();
 662: 
 663:             $inThisLanguage = $db3->f(0);
 664: 
 665:             if ($online == 0) {
 666:                 $offonline = '<img src="' . $cfg['path']['images'] . 'offline_off.gif" alt="' . i18n("Article is offline") . '" title="' . i18n("Article is offline") . '">';
 667:             } else {
 668:                 $offonline = '<img src="' . $cfg['path']['images'] . 'online_off.gif" alt="' . i18n("Category is online") . '" title="' . i18n("Category is online") . '">';
 669:             }
 670: 
 671:             $icon = '<img src="' . $cfg['path']['images'] . 'article.gif" class="vAlignMiddle">';
 672:             $tpl->set('d', 'PADDING_LEFT', $padding_left);
 673:             $tpl->set('d', 'TEXT', $text.' (idart: '.cSecurity::toInteger($idart).')');
 674:             $tpl->set('d', 'ONCLICK', "");
 675:             $tpl->set('d', 'ICON', $icon);
 676:             $tpl->set('d', 'STATUS', $offonline);
 677:             $tpl->set('d', 'ROWNAME', implode('_', $aRowname));
 678:             $tpl->set('d', 'NUMBEROFARTICLES', $numberOfArticles);
 679:             $tpl->set('d', 'TOTAL', $total);
 680:             $tpl->set('d', 'ROWNAME', implode('_', $aRowname));
 681:             $tpl->set('d', 'EXPAND', '<img src="' . $cfg['path']['images'] . 'spacer.gif" width="7">');
 682:             $tpl->set('d', 'INTHISLANGUAGE', $inThisLanguage);
 683:             $tpl->set('d', 'DISPLAY_ROW', 'none');
 684:             $cat_name = "";
 685:             statCreateLocationString($idart, "&nbsp;/&nbsp;", $cat_name);
 686:             $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 687:             $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idart=' . $idart);
 688: 
 689:             $tpl->next();
 690:             $currentRow++;
 691: 
 692:             array_pop($aRowname);
 693:         }
 694:     }
 695: 
 696:     //************** hits total**************
 697:     $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND B.idclient=" . cSecurity::toInteger($client) . "
 698:             AND SUBSTRING(B.archived,1,4)='" . $db->escape($year) . "' GROUP BY SUBSTRING(B.archived,1,4)";
 699:     $db->query($sql);
 700:     $db->nextRecord();
 701: 
 702:     $total = $db->f(0);
 703: 
 704:     //************** hits total on this language ***************
 705:     $sql = "SELECT SUM(visited) FROM " . $cfg["tab"]["cat_art"] . " AS A, " . $cfg["tab"]["stat_archive"] . " AS B WHERE A.idcatart=B.idcatart AND B.idlang=" . cSecurity::toInteger($lang) . "
 706:             AND B.idclient=" . cSecurity::toInteger($client) . " AND SUBSTRING(B.archived,1,4)='" . $db->escape($year) . "' GROUP BY SUBSTRING(B.archived,1,4)";
 707:     $db->query($sql);
 708:     $db->nextRecord();
 709: 
 710:     $inThisLanguage = $db->f(0);
 711: 
 712:     $tpl->set('d', 'TEXT', '&nbsp;');
 713:     $tpl->set('d', 'ICON', '');
 714:     $tpl->set('d', 'STATUS', '');
 715:     $tpl->set('d', 'PADDING_LEFT', '10');
 716:     $tpl->set('d', 'NUMBEROFARTICLES', '');
 717:     $tpl->set('d', 'TOTAL', '');
 718:     $tpl->set('d', 'ONCLICK', '');
 719:     $tpl->set('d', 'EXPAND', '');
 720:     $tpl->set('d', 'ROWNAME', '');
 721:     $tpl->set('d', 'INTHISLANGUAGE', '');
 722:     $tpl->set('d', 'DISPLAY_ROW', $sDisplay);
 723:     $tpl->set('s', 'SUMTEXT', "Summe");
 724:     $tpl->set('s', 'SUMNUMBEROFARTICLES', $sumNumberOfArticles);
 725:     $tpl->set('s', 'SUMTOTAL', $total);
 726:     $tpl->set('s', 'SUMINTHISLANGUAGE', $inThisLanguage);
 727:     $tpl->next();
 728: }
 729: 
 730: /**
 731:  * Generates a top<n> statistics page
 732:  *
 733:  * @param $yearmonth  Specifies the year and month from which to retrieve the
 734:  *                    statistics, specify "current" to retrieve the current
 735:  *                    entries
 736:  * @param $top        Specifies the amount of pages to display
 737:  * @return void
 738:  */
 739: function statsOverviewTop($yearmonth, $top) {
 740:     global $cfg, $db, $tpl, $client, $cfgClient, $lang;
 741: 
 742:     if (strcmp($yearmonth, "current") == 0) {
 743:         $sql = "SELECT DISTINCT
 744:                     C.title, A.visited, C.idart
 745:                 FROM
 746:                     " . $cfg["tab"]["stat"] . " AS A,
 747:                     " . $cfg["tab"]["cat_art"] . " AS B,
 748:                     " . $cfg["tab"]["art_lang"] . " AS C
 749:                 WHERE
 750:                     C.idart = B.idart AND
 751:                     C.idlang = A.idlang AND
 752:                     B.idcatart = A.idcatart AND
 753:                     A.idclient = " . cSecurity::toInteger($client) . " AND
 754:                     A.idlang = " . cSecurity::toInteger($lang) . "
 755:                 ORDER BY A.visited DESC
 756:                 LIMIT " . $db->escape($top);
 757:     } else {
 758:         $sql = "SELECT DISTINCT
 759:                     C.title, A.visited, B.idcat, C.idart
 760:                 FROM
 761:                     " . $cfg["tab"]["stat_archive"] . " AS A,
 762:                     " . $cfg["tab"]["cat_art"] . " AS B,
 763:                     " . $cfg["tab"]["art_lang"] . " AS C
 764:                 WHERE
 765:                     C.idart = B.idart AND
 766:                     C.idlang = A.idlang AND
 767:                     B.idcatart = A.idcatart AND
 768:                     A.idclient = " . cSecurity::toInteger($client) . " AND
 769:                     A.archived = '" . $db->escape($yearmonth) . "' AND
 770:                     A.idlang = " . cSecurity::toInteger($lang) . " ORDER BY
 771:                     A.visited DESC
 772:                 LIMIT " . $db->escape($top);
 773:     }
 774: 
 775:     $db->query($sql);
 776: 
 777:     $frontendURL = cRegistry::getFrontendUrl();
 778:     while ($db->nextRecord()) {
 779:         $cat_name = "";
 780:         statCreateLocationString($db->f(2), "&nbsp;/&nbsp;", $cat_name);
 781:         $tpl->set('d', 'PADDING_LEFT', '5');
 782:         $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 783:         $tpl->set('d', 'TEXT', $db->f(0).' (idart: '.cSecurity::toInteger($db->f('idart')).')');
 784:         $tpl->set('d', 'TOTAL', $db->f(1));
 785:         $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idart=' . $db->f('idart'));
 786:         $tpl->next();
 787:     }
 788: }
 789: 
 790: /**
 791:  * Generates the location string for passed category id.
 792:  *
 793:  * Performs a recursive call, if parent category doesn't matches to 0
 794:  *
 795:  * @param   int  $idcat  The category id
 796:  * @param   string  $seperator  Separator for location string
 797:  * @param   string  $cat_str    The location string variable (reference)
 798:  * @return  void
 799:  */
 800: function statCreateLocationString($idcat, $seperator, &$cat_str) {
 801:     $cats = array();
 802: 
 803:     // get category path
 804:     $helper = cCategoryHelper::getInstance();
 805:     foreach ($helper->getCategoryPath($idcat) as $categoryLang) {
 806:         $cats[] = $categoryLang->getField('name');
 807:     }
 808: 
 809:     $cat_str = implode($seperator, $cats);
 810: }
 811: 
 812: /**
 813:  * Generates a top<n> statistics page
 814:  *
 815:  * @param $year       Specifies the year from which to retrieve the
 816:  *                    statistics
 817:  * @param $top        Specifies the amount of pages to display
 818:  * @return void
 819:  */
 820: function statsOverviewTopYear($year, $top) {
 821:     global $cfg, $db, $tpl, $client, $lang, $cfgClient;
 822: 
 823:     $sql = "SELECT
 824:                 C.title, SUM(A.visited) as visited, B.idcat AS idcat, C.idart AS idart
 825:             FROM
 826:                 " . $cfg["tab"]["stat_archive"] . " AS A,
 827:                 " . $cfg["tab"]["cat_art"] . " AS B,
 828:                 " . $cfg["tab"]["art_lang"] . " AS C
 829:             WHERE
 830:                 C.idart = B.idart AND
 831:                 C.idlang = A.idlang AND
 832:                 B.idcatart = A.idcatart AND
 833:                 A.idclient = " . cSecurity::toInteger($client) . " AND
 834:                 A.archived LIKE '" . $db->escape($year) . "%' AND
 835:                 A.idlang = " . cSecurity::toInteger($lang) . "
 836:             GROUP BY A.idcatart
 837:             ORDER BY visited DESC
 838:             LIMIT " . $db->escape($top);
 839: 
 840:     $db->query($sql);
 841:     $frontendURL = cRegistry::getFrontendUrl();
 842:     while ($db->nextRecord()) {
 843:         $cat_name = '';
 844:         statCreateLocationString($db->f('idcat'), "&nbsp;/&nbsp;", $cat_name);
 845: 
 846:         $tpl->set('d', 'PADDING_LEFT', '0');
 847:         $tpl->set('d', 'PATH', i18n("Path") . ":&nbsp;/&nbsp;" . $cat_name);
 848:         $tpl->set('d', 'TEXT', $db->f(0).' (idart: '.cSecurity::toInteger($db->f('idart')).')');
 849:         $tpl->set('d', 'TOTAL', $db->f(1));
 850:         $tpl->set('d', 'ULR_TO_PAGE', $frontendURL . 'front_content.php?idart=' . $db->f('idart'));
 851:         $tpl->next();
 852:     }
 853: }
 854: 
 855: /**
 856:  * Returns a drop down to choose the stats to display
 857:  *
 858:  * @param  string  $default
 859:  * @return string Returns a drop down string
 860:  */
 861: function statDisplayTopChooser($default) {
 862:     if ($default == "top10") {
 863:         $defaultTop10 = "selected";
 864:     }
 865:     if ($default == "top20") {
 866:         $defaultTop20 = "selected";
 867:     }
 868:     if ($default == "top30") {
 869:         $defaultTop30 = "selected";
 870:     }
 871:     if ($default == "all") {
 872:         $defaultAll = "selected";
 873:     }
 874: 
 875:     return ("<form name=\"name\">" .
 876:             "  <select class=\"text_medium\" onchange=\"top10Action(this)\">" .
 877:             "    <option value=\"top10\" $defaultTop10>" . i18n("Top 10") . "</option>" .
 878:             "    <option value=\"top20\" $defaultTop20>" . i18n("Top 20") . "</option>" .
 879:             "    <option value=\"top30\" $defaultTop30>" . i18n("Top 30") . "</option>" .
 880:             "    <option value=\"all\" $defaultAll>" . i18n("All") . "</option>" .
 881:             "  </select>" .
 882:             "</form>");
 883: }
 884: 
 885: /**
 886:  * Returns a drop down to choose the stats to display for yearly summary pages
 887:  *
 888:  * @param string  $default
 889:  * @return string Returns a drop down string
 890:  */
 891: function statDisplayYearlyTopChooser($default) {
 892:     if ($default == "top10") {
 893:         $defaultTop10 = "selected";
 894:     }
 895:     if ($default == "top20") {
 896:         $defaultTop20 = "selected";
 897:     }
 898:     if ($default == "top30") {
 899:         $defaultTop30 = "selected";
 900:     }
 901:     if ($default == "all") {
 902:         $defaultAll = "selected";
 903:     }
 904: 
 905:     return ("<form name=\"name\">" .
 906:             "  <select class=\"text_medium\" onchange=\"top10ActionYearly(this)\">" .
 907:             "    <option value=\"top10\" $defaultTop10>" . i18n("Top 10") . "</option>" .
 908:             "    <option value=\"top20\" $defaultTop20>" . i18n("Top 20") . "</option>" .
 909:             "    <option value=\"top30\" $defaultTop30>" . i18n("Top 30") . "</option>" .
 910:             "    <option value=\"all\" $defaultAll>" . i18n("All") . "</option>" .
 911:             "  </select>" .
 912:             "</form>");
 913: }
 914: 
 915: /**
 916:  * Return an array with all years which are available as stat files
 917:  *
 918:  * @param mixed many
 919:  * @return array  Array of strings with years.
 920:  */
 921: function statGetAvailableYears($client, $lang) {
 922:     global $cfg, $db;
 923: 
 924:     $availableYears = array();
 925: 
 926:     $sql = "SELECT SUBSTRING(`archived`,1,4)
 927:             FROM
 928:                 " . $cfg["tab"]["stat_archive"] . "
 929:             WHERE
 930:                 idlang = " . cSecurity::toInteger($lang) . " AND
 931:                 idclient = " . cSecurity::toInteger($client) . "
 932:             GROUP BY
 933:                 SUBSTRING(`archived`,1,4)
 934:             ORDER BY
 935:                 SUBSTRING(`archived`,1,4) DESC";
 936: 
 937:     $db->query($sql);
 938:     while ($db->nextRecord()) {
 939:         $availableYears[] = $db->f(0);
 940:     }
 941: 
 942:     return($availableYears);
 943: }
 944: 
 945: /**
 946:  * Return an array with all months for a specific year which are available
 947:  * as stat files
 948:  *
 949:  * @param mixed many
 950:  * @return array  Array of strings with months.
 951:  */
 952: function statGetAvailableMonths($year, $client, $lang) {
 953:     global $cfg, $db;
 954: 
 955:     $availableYears = array();
 956: 
 957:     $sql = "SELECT SUBSTRING(`archived`,5,2)
 958:             FROM
 959:                 " . $cfg["tab"]["stat_archive"] . "
 960:             WHERE
 961:                 idlang = " . cSecurity::toInteger($lang) . " AND
 962:                 idclient = " . cSecurity::toInteger($client) . " AND
 963:                 SUBSTRING(`archived`,1,4) = '" . $db->escape($year) . "'
 964:             GROUP BY
 965:                 SUBSTRING(`archived`,5,2)
 966:             ORDER BY SUBSTRING(`archived`,5,2) DESC";
 967: 
 968:     $db->query($sql);
 969:     while ($db->nextRecord()) {
 970:         $availableYears[] = $db->f(0);
 971:     }
 972: 
 973:     return($availableYears);
 974: }
 975: 
 976: /**
 977:  * Resets the statistic for passed client
 978:  *
 979:  * @param   int  $client  Id of client
 980:  * @return  void
 981:  */
 982: function statResetStatistic($client) {
 983:     global $db, $cfg;
 984:     $sql = "UPDATE " . $cfg["tab"]["stat"] . " SET visited=0 WHERE idclient=" . cSecurity::toInteger($client);
 985:     $db->query($sql);
 986: }
 987: 
 988: /**
 989:  * Deletes existing heap table (table in memory) and creates it.
 990:  *
 991:  * @param   string        $sHeapTable  Table name
 992:  * @param   cDb  $db          Database object
 993:  * @return  void
 994:  */
 995: function buildHeapTable($sHeapTable, $db) {
 996:     global $cfg;
 997: 
 998:     $sql = "DROP TABLE IF EXISTS " . $db->escape($sHeapTable) . ";";
 999:     $db->query($sql);
1000: 
1001:     $sql = "CREATE TABLE " . $db->escape($sHeapTable) . " TYPE=HEAP
1002:                 SELECT
1003:                     A.idcatart,
1004:                     A.idcat,
1005:                     A.idart,
1006:                     B.idstatarch,
1007:                     B.archived,
1008:                     B.idlang,
1009:                     B.idclient,
1010:                     B.visited
1011:                 FROM
1012:                     " . $cfg['tab']['cat_art'] . " AS A, " . $cfg['tab']['stat_archive'] . " AS B
1013:                 WHERE
1014:                     A.idcatart = B.idcatart;";
1015:     $db->query($sql);
1016: 
1017:     $sql = "ALTER TABLE `" . $db->escape($sHeapTable) . "` ADD PRIMARY KEY (`idcatart`,`idcat` ,`idart`,`idstatarch` ,`archived`,`idlang`,`idclient` ,`visited`);";
1018:     $db->query($sql);
1019: }
1020: 
1021: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0