function hasObjectRights(&$hasRight, $method, $giveError = FALSE) { global $lll; hasAdminRights($isAdm); $hasRight->objectRight = ($method == "modify" || $method == "load") && $isAdm; if (!$hasRight->objectRight && $giveError) { handleError($lll["permission_denied"]); } }
function hasObjectRights(&$hasRight, $method, $giveError = FALSE) { global $lll; hasAdminRights($isAdm); $hasRight->generalRight = TRUE; $hasRight->objectRight = $isAdm; if (!$hasRight->objectRight && $giveError) { handleError($lll["permission_denied"]); } }
function showHtmlList() { global $lll; $_S =& new AppSettings(); hasAdminRights($isAdm); if (!$isAdm) { LocationHistory::rollBack(new AppController("/")); } JavaScript::addCss(CSS_DIR . "/category.css"); $catArr = array(); $adminsettCtrl =& new AppController("settings/modify_form"); $contentManagementCtrl =& new AppController("content/modify_form"); $usersCtrl =& new AppController("user/list"); $NotificationsCtrl =& new AppController("notification/list"); $checkconfCtrl =& new AppController("checkconf/show"); $checkUpdatesCtrl =& new AppController("checkconf/updates"); $customListsCtrl =& new AppController("customlist/list"); $rssCtrl =& new AppController("rss/modify_form/1"); $purchaseItemCtrl =& new AppController("purchaseitem/sortfield_form"); $pendingPurchaseItemsCtrl =& new AppController("purchaseitem/list"); $ecommSettingsCtrl =& new AppController("ecommsettings/modify_form"); $creditRulesCtrl =& new AppController("creditrule/list"); $paymentRulesCtrl =& new AppController("paymentrule/list"); $subscription_ttitleCtrl =& new AppController("subscription/list"); $itemfield_ttitle_globalCtrl =& new AppController("field/sortfield_form/0"); $items = array("adminsett", "contentManagement", "users", "Notifications", "customLists", "itemfield_ttitle_global", "checkUpdates"); if (class_exists("rss")) { $items[] = "rss"; } if ($_S->subscriptionType) { $items[] = "subscription_ttitle"; } if ($_S->ecommerceEnabled()) { $_ES =& new ECommSettings(); $items[] = "ecommSettings"; if ($_ES->model == ecomm_advanced) { $items[] = "creditRules"; $items[] = "purchaseItem"; } else { $items[] = "paymentRules"; $items[] = "pendingPurchaseItems"; } } $i = 0; foreach ($items as $item) { $catArr[$i]->title = $lll[$item]; $catArr[$i]->description = $lll["{$item}Description"]; $catArr[$i]->link = ${$item . "Ctrl"}->makeUrl(); $catArr[$i]->picture = ""; $catArr[$i]->title = $lll[$item]; $i++; } View::assign("categories", $catArr); }
function hasObjectRights(&$hasRight, $method, $giveError = FALSE) { global $lll; hasAdminRights($isAdm); $hasRight->objectRight = $isAdm && $method == "modify" || $method == "load"; $hasRight->generalRight = TRUE; if (!$hasRight->objectRight && $giveError) { handleError($lll["permission_denied"]); } return ok; }
function preview() { hasAdminRights($isAdm); if (!$isAdm) { handleErrorPerm(__FILE__, __LINE__); } $_S =& new AppSettings(); foreach ($_POST as $attr => $val) { $_S->{$attr} = $val; } }
function hasObjectRights(&$hasRight, $method, $giveError = FALSE) { global $lll; hasAdminRights($isAdm); $hasRight->generalRight = TRUE; if ($method == "delete") { $hasRight->generalRight = FALSE; $hasRight->objectRight = $isAdm && (isset($this->id) && $this->id != 1 && $this->id != 2); } else { $hasRight->objectRight = $method == "load" || $isAdm; } if (!$hasRight->objectRight && $giveError) { handleError($lll["permission_denied"]); } }
function create() { global $lll, $noahVersion, $gorumroll; $exportExtensions = array(customlist_xml => "xml", customlist_csv => "csv"); hasAdminRights($isAdm); if (!$isAdm) { return; } include GORUM_DIR . "/gorum_view.php"; $list = new CustomList(); $list->activateVariableFields(); if (loadSQL($list, array("SELECT * FROM @search WHERE id=#id#", $gorumroll->rollid)) || !$list->exportFormat) { return; } $ext = $exportExtensions[$list->exportFormat]; $date = date("Y-m-d-H-i-s"); $fileName = LOG_DIR . "/export_{$date}.{$ext}"; G::load($unsortedColumns, "SELECT * FROM @itemfield WHERE FIND_IN_SET(id, '{$list->exportFields}')!=0"); // Hogy a $columns arary sorrendje ugyanaz legyen, mint $list->exportFields-ben: $columns = array(); $length = count($unsortedColumns); foreach (explode(",", $list->exportFields) as $id) { for ($i = 0; $i < $length; $i++) { if ($unsortedColumns[$i]->id == $id) { $columns[] = $unsortedColumns[$i]; break; } } } $ad = new Item(); $ad->loadHtmlList($ads); array_walk($columns, create_function('$v', ' if( $v->userField ) { list( $v->userColumnIndex, $v->type, $v->name, $v->allowHtml) = G::getAttr($v->userField, "userfield", "columnIndex", "type", "name", "allowHtml"); } else $v->userColumnIndex = ""; $v->name = preg_replace(array("/$[\\d.-]/", "/[^\\w:]/"), "_", $v->name);')); $owner = new User(); $owner->activateVariableFields(); $fgName = "create_{$ext}"; $this->{$fgName}($fileName, $list, $ads, $columns); $this->nextAction =& new AppController("customlist/list"); Roll::setInfoText("exportSavedAs", $fileName); }
function CacheManager(&$base) { global $gorumroll, $language, $theme, $gorumrecognised, $gorumjavascript_cache, $gorumcategory; list($this->timeFrame, $categorySpecific) = $base->getCacheTimeFrameAndCategorySpecificity(); if ($this->timeFrame) { $this->key = "{$gorumroll->list}-{$gorumroll->method}-{$gorumroll->rollid}-"; $details = "language: {$language}, theme: {$theme}, authentication: "; hasAdminRights($isAdm); if ($isAdm) { $details .= "admin, "; } elseif ($gorumrecognised) { $details .= "loggedin, "; } else { $details .= "loggedout, "; } $s = new Sorting($base); $details .= " sorting: " . $s->getSortSql(); $classVars = $gorumroll->getClassVars(); if (!empty($classVars["off"])) { $details .= " offset: {$classVars['off']}"; } if ($categorySpecific) { $details .= " category: {$gorumcategory}"; } //FP::log($details, "Details"); $this->key .= substr(md5($details), 0, 16); $this->fileName = CACHE_DIR . "/" . $this->key . '.html'; $this->incFileName = CACHE_DIR . "/" . $this->key . '.inc'; if ($this->checkCache()) { $inc = file_get_contents($this->incFileName); $gorumjavascript_cache = unserialize($inc); //FP::log($this, "Loading include cache"); JavaScript::mergeCache($gorumjavascript_cache); } else { // Inicializaljuk az inklud kesst: $gorumjavascript_cache = new JavaScript(); //FP::log($gorumjavascript_cache, "IncCache ujainit"); } } }
function create() { global $siteDemo; ini_set("max_execution_time", 0); hasAdminRights($isAdm); if ($siteDemo) { Roll::setInfoText("Cloning is disabled in the site demo!"); } if (!$isAdm || $siteDemo) { return; } G::load($category, $this->cid, "appcategory"); if (empty($this->amount)) { $this->amount = 0; } $sortId = $category->sortId; for ($i = 1; $i <= $this->amount; $i++) { $category->name = sprintf($this->name, $i); $this->cloneCategory($category, $sortId + $i); } Roll::setInfoText("categoriesCloned"); //LocationHistory::rollBack(new AppController("cat/organize_form")); }
function hasAdminRights(&$hasRight, $method = "") { return hasAdminRights($hasRight, $this, $method); }
function doUpdate() { global $gorumroll, $gorumuser, $noahsUpdateScript, $noahsHost; ini_set("max_execution_time", 0); hasAdminRights($isAdm); if (!$isAdm) { LocationHistory::rollBack(new AppController("/")); } $_GS = new GlobalStat(); if (!$_GS->reg) { $_GS->reg = md5(uniqid(rand(), true)); } $data = "id=" . $_GS->reg; $data .= "&version=" . urlencode($_GS->instver); if (isset($_POST["automatic"])) { if (($result = $this->getVersionInfo($noahsHost, "POST", $noahsUpdateScript, $data)) === FALSE) { Roll::setInfoText("unableToConnectNoah"); } else { $result = explode("Data-Start:", $result); eval($result[1]); if ($latestVersion != $_GS->instver) { $f = fopen("u.php", "w"); if (!$f) { Roll::setInfoText("updateFailed"); } else { fwrite($f, $updateFile); fclose($f); include_once NOAH_BASE . "/u.php"; } } } $this->nextAction =& new AppController("checkconf/updates"); } else { ob_start(); if (($fp = @fsockopen($noahsHost, 80, $errno, $errstr, 20)) === FALSE || $errno) { Roll::setInfoText("unableToConnectNoah"); $this->nextAction =& new AppController("checkconf/updates"); while (@ob_end_clean()) { } // clears all output buffers return; // unable to connect } $branch = $this->getBranch(); $source = "update-from-{$_GS->instver}-{$branch}." . (isset($_POST["manualZip"]) ? "zip" : "tgz"); $path = "/versioninfo/get_file.php"; $data .= "&file=" . urlencode($source); fputs($fp, "POST {$path} HTTP/1.1\r\n"); fputs($fp, "Host: {$noahsHost}\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); if (feof($fp) || ($size = $this->getChunkSize($fp)) <= 3) { Roll::setInfoText("downloadFileNotExists", $source); $this->nextAction =& new AppController("checkconf/updates"); while (@ob_end_clean()) { } // clears all output buffers return FALSE; // not exists } while (@ob_end_clean()) { } // clears all output buffers //filenames in IE containing dots will screw up the //filename unless we add this if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { $source = preg_replace('/\\./', '%2e', $source, substr_count($source, '.') - 1); } // required for IE, otherwise Content-disposition is ignored if (ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Description: File Download"); header("Content-type: application/download"); header("Content-Disposition: attachment; filename=\"{$source}\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: {$size}"); while ($size > 0 && !feof($fp)) { $length = min(1024, $size); if ($buf = fgets($fp, $length)) { echo $buf; } else { break; } flush(); $size -= strlen($buf); } fclose($fp); die; } }
function deletePictureOrMedia($isPicture = TRUE) { global $gorumrecognised, $gorumuser, $gorumroll; hasAdminRights($isAdm); $parts = explode("_", $gorumroll->rollid); $this->id = $parts[0]; $className = $this->get_class(); $attr = quoteSQL("{$parts['1']}_{$parts['2']}"); CustomField::addCustomColumns($className); load($this); if ($isAdm || $className == "item" && $gorumrecognised && $gorumuser->id == $this->ownerId) { executeQuery("UPDATE @{$className} SET `attr`='' WHERE id=#id#", $attr, $this->id); } else { die; } return $isPicture ? "{$this->id}_{$parts['2']}." . $this->{$attr} : "{$this->id}_" . $this->{$attr}; }
function deleteExpiredAds() { hasAdminRights($isAdm); if ($isAdm) { $count = deleteExpiredAds(); } Roll::setInfoText("{$count} expired ads have been deleted."); $this->nextAction =& new AppController("/"); }
function recalculateAllItemNums($overridePermission = FALSE) { if (!$overridePermission) { hasAdminRights($isAdm); if (!$isAdm) { handleErrorPerm(__FILE__, __LINE__); } } $cats = new AppCategory(); $query = "SELECT * FROM @category WHERE up=0"; loadObjectsSql($cats, $query, $cats); foreach ($cats as $cat) { $cat->recalculateAllItemNumsCore(); } Roll::setInfoText("itemNumbersRecalculated"); $this->nextAction =& new AppController("/"); }
function ecommerceEnabled() { global $gorumuser, $gorumrecognised, $gorumroll; if (!EComm::isEnabledGlobally()) { return FALSE; } hasAdminRights($isAdm); return isset($this->ecommerceEnabled) && ($this->ecommerceEnabled == Settings_ecommEnabled || $this->ecommerceEnabled == Settings_ecommTestMode && ($isAdm || $gorumrecognised && $gorumuser->name == "ecommtest" || isset($gorumroll) && $gorumroll->list == "purchase" && ($gorumroll->method == "silent_post" || $gorumroll->method == "relay_response"))); }
function makeAdminMenu() { global $gorumroll, $lll, $adminHelp, $merchantsLink; $menu1 = $menu2 = array(); if ($this->display(Init_myProfile)) { $ctrl =& new AppController("user/modify_form"); $menu1["myProfile"]["link"] = $ctrl->makeUrl(); $menu1["myProfile"]["label"] = $lll["my_profile"]; } if ($this->display(Init_settings)) { $ctrl =& new AppController("settings/modify_form"); $menu1["settings"]["link"] = $ctrl->makeUrl(); $menu1["settings"]["label"] = $lll["adminsett"]; } if ($this->display(Init_content)) { $ctrl =& new AppController("content/modify_form"); $menu1["content"]["link"] = $ctrl->makeUrl(); $menu1["content"]["label"] = $lll["contentManagement"]; } // User list: if ($this->display(Init_userList)) { $ctrl =& new AppController("user/list"); $menu1["userList"]["link"] = $ctrl->makeUrl(); $menu1["userList"]["label"] = $lll["users"]; } // Approved items: if ($this->display(Init_activeItems)) { $ctrl =& new AppController("item_active/list"); $menu1["activeAds"]["link"] = $ctrl->makeUrl(); $menu1["activeAds"]["label"] = $lll["item_Active"]; } // Pending items: if ($this->display(Init_inactiveItems)) { $ctrl =& new AppController("item_inactive/list"); $menu1["inactiveAds"]["link"] = $ctrl->makeUrl(); $menu1["inactiveAds"]["label"] = $lll["item_Inctive"]; } // Cronjobs: if ($this->display(Init_cronjobs)) { $ctrl =& new AppController("cronjob/list"); $menu1["cronjobs"]["link"] = $ctrl->makeUrl(); $menu1["cronjobs"]["label"] = $lll["Cronjobs"]; } // Notifications: if ($this->display(Init_notifications)) { $ctrl =& new AppController("notification/list"); $menu1["notifications"]["link"] = $ctrl->makeUrl(); $menu1["notifications"]["label"] = $lll["Notifications"]; } // Create category: if ($this->display(Init_addCategory)) { // TODO: $ctrl =& new AppController("cat/create_form/{$gorumroll->rollid}"); $menu2["addCategory"]["link"] = $ctrl->makeUrl(); $menu2["addCategory"]["label"] = $lll["category_newitem"]; } // Category organizer: if ($this->display(Init_organizeCategory)) { // TODO: $ctrl =& new AppController("cat/organize_form"); $menu2["organizeCategory"]["link"] = $ctrl->makeUrl(); $menu2["organizeCategory"]["label"] = $lll["category_organize"]; } // Clone category: if ($this->display(Init_cloneCategory)) { // TODO: $ctrl =& new AppController("clonecat/create_form/{$gorumroll->rollid}"); $menu2["cloneCategory"]["link"] = $ctrl->makeUrl(); $menu2["cloneCategory"]["label"] = $lll["category_clone"]; } // Modify category: if ($this->display(Init_modCategory)) { $ctrl =& new AppController("cat/modify_form/{$gorumroll->rollid}"); $menu2["modifyCategory"]["link"] = $ctrl->makeUrl(); $menu2["modifyCategory"]["label"] = $lll["category_mod"]; } // Delete category: if ($this->display(Init_delCategory)) { $ctrl =& new AppController("cat/delete_form/{$gorumroll->rollid}"); $menu2["deleteCategory"]["link"] = $ctrl->makeUrl(); $menu2["deleteCategory"]["label"] = $lll["category_del"]; } if ($this->display(Init_adminhelp)) { $menu1["adminHelp"]["link"] = $adminHelp; $menu1["adminHelp"]["label"] = $lll["help"]; } if ($this->display(Init_checkUpdates)) { $ctrl =& new AppController("checkconf/updates"); $menu1["checkUpdates"]["link"] = $ctrl->makeUrl(); $menu1["checkUpdates"]["label"] = $lll["checkUpdates"]; } if ($this->display(Init_registerNoah)) { $ctrl =& new AppController("checkconf/register"); $menu1["registerNoah"]["link"] = $ctrl->makeUrl(); $menu1["registerNoah"]["label"] = $lll["registerNoah"]; } if ($this->display(Init_merchants)) { $menu1["merchants"]["link"] = $merchantsLink; $menu1["merchants"]["label"] = $lll["merchants"]; } if ($this->display(Init_controlPanel)) { $ctrl =& new AppController("controlpanel/showhtmllist"); $menu1["controlPanel"]["link"] = $ctrl->makeUrl(); $menu1["controlPanel"]["label"] = $lll["controlPanel"]; } if ($this->display(Init_confcheck)) { $ctrl =& new AppController("checkconf/show"); $menu1["checkConfiguration"]["link"] = $ctrl->makeUrl(); $menu1["checkConfiguration"]["label"] = $lll["checkconf"]; } if ($this->display(Init_catSubscriptions)) { $ctrl =& new AppController("subscription_cat/list/{$gorumroll->rollid}"); $menu2["categorySubscriptions"]["link"] = $ctrl->makeUrl(); $menu2["categorySubscriptions"]["label"] = $lll["catSubscriptions"]; } if ($this->display(Init_rss)) { $ctrl =& new AppController("rss/modify_form/1"); $menu1["rss"]["link"] = $ctrl->makeUrl(); $menu1["rss"]["label"] = $lll["rss"]; } hasAdminRights($isAdm); $this->addEcommMenuPoints($menu1); if ($isAdm) { View::assign("userMenu", $menu1); } View::assign("categoryMenu", $menu2); if ($isAdm) { View::assign("adminMenu", array_merge($menu1, $menu2)); } else { View::assign("adminMenu", array()); } $this->makeCustomMenu(customlist_categoryMenu, "customCategoryMenuPoints"); $this->makeCustomMenu(customlist_adminMenu, "customAdminMenuPoints"); }
function display($what) { global $itemClassName, $gorumroll; global $gorumrecognised, $fixCss; hasAdminRights($isAdm); switch ($what) { case Init_register: return !$gorumrecognised; case Init_login: return !$gorumrecognised; case Init_loginDifferent: return FALSE; case Init_cangePwd: return $gorumrecognised; case Init_logout: return $gorumrecognised; case Init_myProfile: return $gorumrecognised; case Init_search: return $gorumrecognised && class_exists("search"); case Init_home: return TRUE; case Init_modStyle: return $isAdm && !isset($fixCss); default: return FALSE; } }
function propagateSorting($intoSubcatsOnly = FALSE) { global $gorumroll, $lll; hasAdminRights($isAdm); if (!$isAdm) { die; } if (!class_exists('rss')) { echo $lll["freeNotSupported"]; } G::load($fields, array("SELECT id, sortId FROM @itemfield WHERE cid=#cid#", $gorumroll->rollid)); foreach ($fields as $field) { $field->propagateField("sortId", $field->sortId, $intoSubcatsOnly); } echo $lll["sortingSuccessfullyPropagated"]; die; }
function organize() { global $siteDemo; hasAdminRights($isAdm); if (!$isAdm) { handleErrorPerm(__FILE__, __LINE__); } if (!class_exists('rss') || $siteDemo) { return; } ini_set("max_execution_time", 0); $hierarchyChanged = FALSE; $sortId = 100; $firstIndex = 0; // ebben osszegyujtjuk az osszes olyan kategoria id-jet, ami egy valtoztatott blokkban van: $cidsInBlocksSoFar = array(); if (AppCategory::is_assoc($_REQUEST['nested-sortable-widget'])) { $modifiedBlocks = array($_REQUEST['nested-sortable-widget']); } else { $modifiedBlocks =& $_REQUEST['nested-sortable-widget']; } //FP::log($modifiedBlocks); // ha nincs pagination: if (count($modifiedBlocks) == 1 && $modifiedBlocks[0]["count"] == $this->getCategoryCount()) { //$fp->log("No pagination"); $this->updateOrderIter($modifiedBlocks[0], $sortId, $firstIndex, $hierarchyChanged, $cidsInBlocksSoFar); } else { //$fp->log("Pagination"); // lekerjuk a valtoztatas elotti kategoria fat, mert ossze kell fesulni a valtoztatott blokkokkal: G::load($cats, "SELECT * FROM @category WHERE up=0 ORDER BY sortId ASC"); $tree =& $this->getCategoryTree($cats); //$fp->log($tree, "Tree"); $firstNode =& $tree[0]; // $tIndex egy tomb ami a tree egy agan levo node-okra mutato referenciakat tartalmaz: $tIndex = array($firstNode); foreach ($modifiedBlocks as $block) { //$fp->group("Block begins - first index: $firstIndex"); //$fp->log($sortId, "Starting sortId"); //$fp->log($block["firstIndex"], "First index of the block"); // a regi fa nodjainak sortId-jit frissitgetjuk addig, amig el nem jutunk az aktualis blokkig: while ($firstIndex < $block["firstIndex"]) { $this->updateOriginalTreeNode($tree, $tIndex, $sortId); $firstIndex++; } //$fp->log($firstIndex, "First index after updating old nodes"); //$fp->log($sortId, "SortId after updating old nodes"); // a blokk elemeinek update-je: $this->updateOrderIter($block, $sortId, $firstIndex, $hierarchyChanged, $cidsInBlocksSoFar); //$fp->log($firstIndex, "First index after updating block"); //$fp->log($sortId, "SortId after updating block"); // amig az a blokkokban mar szereplo nodokat tartalmaz, "skippeljuk" a regi fat: while ($tIndex && in_array($tIndex[count($tIndex) - 1]["cat"]->id, $cidsInBlocksSoFar)) { $this->advanceTreeIndex($tree, $tIndex); } //$fp->groupend(); } //$fp->group("Updating the rest of the old nodes"); // az osszes valtoztatott blokk utani regi faban levo elemet is update-ezni kell: while ($tIndex) { $this->updateOriginalTreeNode($tree, $tIndex, $sortId); } //$fp->groupend(); } if ($hierarchyChanged) { $this->recalculateAllItemNums(TRUE); } die; }
function showCsvExportTool($base) { global $lll, $gorumroll; $s = ""; hasAdminRights($isAdm); if ($isAdm) { $ctrl =& new AppController(); $ctrl->method = "showcsv"; $label = $lll["showcsv"]; $s .= $ctrl->generAnchor($label); $ctrl->method = "showfullcsv"; $label = $lll["showfullcsv"]; $s .= " | " . $ctrl->generAnchor($label); } return $s; }
function getNavBarPieces($absolute = FALSE) { global $gorumroll, $lll; hasAdminRights($isAdm); if (!$isAdm) { return array(); } $navBarPieces = ControlPanel::getNavBarPieces(TRUE); if ($gorumroll->method == "showhtmllist") { $navBarPieces[$lll["users"]] = ""; } else { $ctrl =& new AppController("user/list"); $ctrl->setAbsolute($absolute); $navBarPieces[$lll["users"]] = $ctrl; } if ($gorumroll->method == "showdetails") { $navBarPieces[htmlspecialchars($this->name)] = ""; } elseif ($gorumroll->list == "user" && ($gorumroll->method == "modify_form" || $gorumroll->method == "delete_form")) { $ctrl =& new AppController("user/showdetails/{$this->id}"); $ctrl->setAbsolute($absolute); $navBarPieces[htmlspecialchars($this->name)] = $ctrl; } return $navBarPieces; }
function tranformEnumValuesWrapper() { hasAdminRights($isAdm); if (!$isAdm) { return; } ini_set("max_execution_time", 0); CustomField::tranformEnumValues(); }
function getNavBarPieces() { global $lll, $gorumroll; hasAdminRights($isAdm); if (!$isAdm) { return array(); } $navBarPieces = ControlPanel::getNavBarPieces(TRUE); $navBarPieces[$lll["subscription_ttitle"]] = $gorumroll->method == "showhtmllist" ? "" : new AppController("subscription/list"); return $navBarPieces; }