Exemplo n.º 1
0
 /**
  * @return self|null
  */
 public function getParent()
 {
     if (!$this->parent && $this->parent_id) {
         $this->parent = Category::getById($this->parent_id);
     }
     return $this->parent;
 }
Exemplo n.º 2
0
 /**
  * @return Category|null
  */
 public function getCategory()
 {
     if (!$this->category && $this->category_id) {
         $this->category = Category::getById($this->category_id);
     }
     return $this->category;
 }
Exemplo n.º 3
0
 public static function isCategoryInUseById($categoryId)
 {
     $categories = Category::getById($categoryId);
     $rows = ZurmoRedBean::getAll('SELECT * FROM customfieldvalue WHERE multiplevaluescustomfield_id IN (SELECT category_multiplevaluescustomfield_id FROM costbook) AND VALUE="' . $categories->name . '"');
     if (count($rows) > 0) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public function actionEdit($id)
 {
     //get boject by id
     $category = Category::getById(intval($id));
     //Security check
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($category);
     //create view and render
     $editAndDetailsView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($category), 'Edit');
     $view = new CategoriesPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editAndDetailsView));
     echo $view->render();
 }
Exemplo n.º 5
0
function viewArticle()
{
    if (!isset($_GET["articleId"]) || !$_GET["articleId"]) {
        homepage();
        return;
    }
    $results = array();
    $results['article'] = Article::getById((int) $_GET["articleId"]);
    $results['category'] = Category::getById($results['article']->categoryId);
    $results['pageTitle'] = $results['article']->title . " | SystemBolaget";
    require TEMPLATE_PATH . "/viewArticle.php";
}
Exemplo n.º 6
0
 function writeNZBforReleaseId($relid, $relguid, $name, $catId, $path, $echooutput = false)
 {
     $db = new DB();
     $binaries = array();
     $cat = new Category();
     $catrow = $cat->getById($catId);
     $site = new Sites();
     $fp = gzopen($path, "w");
     if ($fp) {
         gzwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
         gzwrite($fp, "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.1//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd\">\n");
         gzwrite($fp, "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\">\n\n");
         gzwrite($fp, "<head>\n");
         if ($catrow) {
             gzwrite($fp, " <meta type=\"category\">" . htmlspecialchars($catrow["title"], ENT_QUOTES, 'utf-8') . "</meta>\n");
         }
         if ($name != "") {
             gzwrite($fp, " <meta type=\"name\">" . htmlspecialchars($name, ENT_QUOTES, 'utf-8') . "</meta>\n");
         }
         gzwrite($fp, "</head>\n\n");
         $result = $db->queryDirect(sprintf("SELECT binaries.*, UNIX_TIMESTAMP(date) AS unixdate, groups.name as groupname FROM binaries inner join groups on binaries.groupID = groups.ID WHERE binaries.releaseID = %d ORDER BY binaries.name", $relid));
         while ($binrow = mysql_fetch_assoc($result)) {
             $groups = array();
             $groupsRaw = explode(' ', $binrow['xref']);
             foreach ($groupsRaw as $grp) {
                 if (preg_match('/^([a-z0-9\\.\\-_]+):(\\d+)?$/i', $grp, $match) && strtolower($grp) !== 'xref') {
                     $groups[] = $match[1];
                 }
             }
             if (count($groups) == 0) {
                 $groups[] = $binrow["groupname"];
             }
             gzwrite($fp, "<file poster=\"" . htmlspecialchars($binrow["fromname"], ENT_QUOTES, 'utf-8') . "\" date=\"" . $binrow["unixdate"] . "\" subject=\"" . htmlspecialchars($binrow["name"], ENT_QUOTES, 'utf-8') . " (1/" . $binrow["totalParts"] . ")\">\n");
             gzwrite($fp, " <groups>\n");
             foreach ($groups as $group) {
                 gzwrite($fp, "  <group>" . $group . "</group>\n");
             }
             gzwrite($fp, " </groups>\n");
             gzwrite($fp, " <segments>\n");
             $resparts = $db->queryDirect(sprintf("SELECT DISTINCT(messageID), size, partnumber FROM parts WHERE binaryID = %d ORDER BY partnumber", $binrow["ID"]));
             while ($partsrow = mysql_fetch_assoc($resparts)) {
                 gzwrite($fp, "  <segment bytes=\"" . $partsrow["size"] . "\" number=\"" . $partsrow["partnumber"] . "\">" . htmlspecialchars($partsrow["messageID"], ENT_QUOTES, 'utf-8') . "</segment>\n");
             }
             gzwrite($fp, " </segments>\n</file>\n");
         }
         gzwrite($fp, "<!-- generated by newznab " . $site->version() . " -->\n</nzb>");
         gzclose($fp);
     }
 }
Exemplo n.º 7
0
}
$genre = isset($_REQUEST['genre']) && array_key_exists($_REQUEST['genre'], $tmpgnr) ? $_REQUEST['genre'] : '';
$page->smarty->assign('genres', $genres);
$page->smarty->assign('genre', $genre);
$browseby_link = '&amp;title=' . $title . '&amp;platform=' . $platform;
$page->smarty->assign('pagertotalitems', $browsecount);
$page->smarty->assign('pageroffset', $offset);
$page->smarty->assign('pageritemsperpage', ITEMS_PER_COVER_PAGE);
$page->smarty->assign('pagerquerybase', WWW_TOP . "/console?t=" . $category . $browseby_link . "&amp;ob=" . $orderby . "&amp;offset=");
$page->smarty->assign('pagerquerysuffix', "#results");
$pager = $page->smarty->fetch("pager.tpl");
$page->smarty->assign('pager', $pager);
if ($category == -1) {
    $page->smarty->assign("catname", "All");
} else {
    $cdata = $cat->getById($category);
    if ($cdata) {
        $page->smarty->assign('catname', $cdata["title"]);
    } else {
        $page->show404();
    }
}
foreach ($ordering as $ordertype) {
    $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/console?t=" . $category . $browseby_link . "&amp;ob=" . $ordertype . "&amp;offset=0");
}
$page->smarty->assign('results', $consoles);
$page->meta_title = "Browse Console";
$page->meta_keywords = "browse,nzb,console,games,description,details";
$page->meta_description = "Browse for Games";
$page->content = $page->smarty->fetch('console.tpl');
$page->render();
Exemplo n.º 8
0
<? require_once("classes/Recipe.php"); ?>
<? require_once("classes/Category.php"); ?>
<? require_once("classes/Text.php"); ?>
<?
    $c = NULL;
    $cat = $_REQUEST['cat'];
    if (strlen($cat) == 0) {
        //$all = Recipe::getAll();
        $all = Recipe::getInCategory(NULL);
    } else {
        if ($cat == "null") {
            $all = Recipe::getInCategory(NULL);
        } else {
            $c = Category::getById($cat);
            $all = Recipe::getInCategory($c);
        }
    }

    include("header.php");
    if ($cat == "") {
        // Include only on the very front page
        include("welcome.php");
    }
    include("recipeNav.php");
    $rssUrl = $baseUrl."/rss.php?cat=".(strlen($cat) == 0 ? "null" : $cat);
?>

<? if ($c != NULL) { ?>
<h2><?php 
echo $c->getName();
?>
 /**
  * Return a list of releases with a similar name to that provided.
  */
 public function searchSimilar($currentid, $name, $limit = 6, $excludedcats = array())
 {
     $name = $this->getSimilarName($name);
     $results = $this->search($name, array(-1), 0, $limit, '', -1, $excludedcats);
     if (!$results) {
         return $results;
     }
     //
     // Get the category for the parent of this release
     //
     $currRow = $this->getById($currentid);
     $cat = new Category();
     $catrow = $cat->getById($currRow["categoryID"]);
     $parentCat = $catrow["parentID"];
     $ret = array();
     foreach ($results as $res) {
         if ($res["ID"] != $currentid && $res["categoryParentID"] == $parentCat) {
             $ret[] = $res;
         }
     }
     return $ret;
 }
Exemplo n.º 10
0
 function build($line) {
 
     $r = new Recipe();
     
     $r->id = $line['id'];
     $r->setTitle($line['title']);
     $r->setOrigin($line['origin']);
     $r->setSize($line['size']);
     $r->setIngredients($line['ingredients']);
     $r->setSteps($line['steps']);
     $r->dateAdded = $line['date_added_ts'];
     $r->hasPhoto = $line['has_photo'];
     $r->rating = $line['rating'];
     $r->authorId = $line['author_user_id'];
     
     $catId = $line['category_id'];
     if (strlen($catId) > 0) {
         $cat = Category::getById($catId);
         $r->setCategory($cat);
     }
     
     return $r;
 }
Exemplo n.º 11
0
<?
    $title = Text::getText("CategoryDeletion");
    $thisCat = Category::getById($_REQUEST['id']);
    $newCat = Category::getById($_REQUEST['newCat']);
    $action = $_REQUEST['action'];
    if ($thisCat == NULL) {
        $errMsg = Text::getText("CategoryNotFound");
        include("error.php");
        exit;
    } else {
        if ($action == "delete") {
            if (strlen($newCat) > 0) {
                if ($newCat == NULL || $newCat == "null") {
                    $newCategory = NULL;
                } else {
                    $newCategory = Category::getById($newCat);
                    if ($newCategory == NULL) {
                        $errMsg = Text::getText("CategoryNotFound");
                        include("error.php");
                        exit;
                    }
                }
                $recipesToMove = Recipe::getInCategory($thisCat);
                for ($i = 0; $i < count($recipesToMove); $i++) {
                    $r2m = $recipesToMove[$i];
                    $r2m->setCategory($newCategory);
                    $r2m->save();
                }
            }
            $thisCat->delete();
            header("Location: categoryList.php");
Exemplo n.º 12
0
function deleteCategory()
{
    if (!($category = Category::getById((int) $_GET['categoryId']))) {
        header("Location: admin.php?action=listCategories&error=categoryNotFound");
        return;
    }
    $articles = Article::getList(1000000, $category->id);
    if ($articles['totalRows'] > 0) {
        header("Location: admin.php?action=listCategories&error=categoryContainsArticles");
        return;
    }
    $category->delete();
    header("Location: admin.php?action=listCategories&status=categoryDeleted");
}
Exemplo n.º 13
0
 /**
  * [POST]
  * return categories for corresponding cafe
  */
 public function getItems()
 {
     $id = $this->f3->get('PARAMS.id');
     $result = array('success' => false, 'info' => '', 'total' => 0, 'records' => array());
     try {
         // Only process to database if cafe id is valid
         if ($id > 0) {
             $items = new Item($this->db);
             $items = $items->getAllByCafeId($id);
             // prepare category object to avoid creating too many objects during loop
             $category = new Category($this->db);
             // change result indicatior to true
             $result[success] = true;
             $result[status] = "success";
             // populate records
             foreach ($items as $item) {
                 $result['records'][] = array('recid' => $item->itemId, 'itemName' => $item->itemName, 'description' => $item->description, 'price' => $item->price, 'isActive' => $item->isActive == 1 ? true : false, 'isVegetarian' => $item->isVegetarian == 1 ? true : false, 'isPopular' => $item->isPopular == 1 ? true : false, 'isSpecial' => $item->isSpecial == 1 ? true : false, 'category' => array('id' => $item->categoryId, 'text' => $category->getById($item->categoryId)[0]->categoryName));
             }
         }
         $result[success] = true;
     } catch (Exception $e) {
     }
     // Echo result and return immediately
     header('Content-Type: application/json');
     echo json_encode($result, JSON_NUMERIC_CHECK);
     exit;
 }
Exemplo n.º 14
0
		function getFeedItemsQuery($searchType, $searchKeyword, $searchExtraValue,$viewDelete = false,$owner = 0) {	
			global $db, $database, $config;

			$sQuery = '';

			if (($searchType=='tag' || $searchType=='tag+group_category') && !Validator::is_empty($searchKeyword)) {		
				$tagIds = array();
				$tags = explode(',',$searchKeyword);

				if($tagResult = $db->queryAll('SELECT id FROM '.$database['prefix'].'Tags WHERE name IN ('.Func::implode_string(',',$tags).')')) {
					foreach($tagResult as $tagItem) array_push($tagIds, $tagItem['id']);
				}

				if (empty($tagIds)) {
					return array(null,0);
				} else {
					if($searchType == 'tag') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					} else if($searchType == 'tag+group_category') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed" || r.type = "group_category")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					}
				}

			} else if ($searchType=='blogURL' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {
					$searchFeedId = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword));
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed = '.$searchFeedId;
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
				
			} else if ($searchType=='user' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {

					if(is_numeric($searchKeyword)) {
						$user = User::getById($searchKeyword);
					} else {
						$user = User::getByloginId($searchKeyword);
					}		
					
					$searchFeedId = Feed::getIdListByOwner($user['id']);
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed IN ('.implode(",",$searchFeedId).')';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='author' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				if(!empty($searchKeyword)) {
					$sQuery = ' WHERE i.author = "' . $searchKeyword . '"';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='title+description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			}  else if ($searchType=='title' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.title LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='focus'){		
					$sQuery =  ' WHERE i.focus = "'.$searchKeyword.'"';		
			} else if ($searchType=='group') {
				requireComponent('Bloglounge.Data.Groups');	
				
				if(!empty($searchExtraValue)) {
					$tagId = $db->pick('SELECT id FROM '.$database['prefix'].'Tags WHERE name="'.$db->escape(urldecode($searchExtraValue)).'"');
					if($tagId) {
						$tagId = $tagId[0];
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND r.type = "group_category") ';
					}
				}

				if(!is_numeric($searchKeyword)) {
					$group = Group::getByName($searchKeyword);
					$searchKeyword = $group['id'];
				}
				
				if($searchKeyword) {	
					$feedIds = Group::getFeedIdList($searchKeyword);
					$sQuery .= ' WHERE i.feed IN (' . implode(',',$feedIds) .')';

					if($tagId) {
						$sQuery .= ' AND r.tag="'.$tagId.'"';
					}
				}

			} else if ($searchType=='category') {
				requireComponent('Bloglounge.Data.Category');
				if(is_numeric($searchKeyword)) {
					$category = Category::getById($searchKeyword);
				} else {
					$category = Category::getByName($searchKeyword);
				}

				if($category) {
					$sQuery = ' WHERE c.category = ' . $category['id'];
				}
			} else if ($searchType == 'archive' && !Validator::is_empty($searchKeyword)) {
				if(is_array($searchExtraValue) && array_key_exists('start',$searchExtraValue) && array_key_exists('end',$searchExtraValue)) {
					$tStart = $searchExtraValue['start'];
					$tEnd = $searchExtraValue['end'] + 86400;
				} else {
					$tStart = $searchExtraValue;
					$tEnd = $tStart + 86400;
				}

				$tQuery = ' WHERE i.written > '.$tStart.' AND i.written < '.$tEnd.' ';
				if (strpos($sQuery, 'WHERE') !== false) {
					$sQuery = str_replace('WHERE ', $tQuery.' AND (', $sQuery);
					$sQuery .= ')';
				} else {
					$sQuery .= $tQuery;
				}

			} else {
				if (!Validator::is_empty($searchKeyword)) {
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);
					
					if(empty($searchExtraValue)) { // all : title, description, tags, permlink						
						$sQuery =  ' WHERE i.author LIKE "%'.$keyword.'%" OR i.title LIKE "%'.$keyword.'%" OR i.description LIKE "%'.$keyword.'%" OR i.tags LIKE "%'.$keyword.'%" OR i.permalink LIKE "%'.$keyword.'%"';					
					} else { // custom					
						$sQuery = ' WHERE ' . $searchExtraValue;
					}
				}
			}


			// boomDownReactor, boomDownReactorLimit : 리액터가 숨기기일때 쿼리에서 제외 파트 추가 ( 특정수만큼 붐다운(비추천)한글은 제외하거나 특정기능..
			
			if(isset($config)) {
				
				if (($config->boomDownReactor == 'hide') && ($config->boomDownReactLimit > 0)) {
					$bQuery = ' WHERE (i.boomDown <= '.$config->boomDownReactLimit.') ';
					if (strpos($sQuery, 'WHERE') !== false) {
						$sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery);
						$sQuery .= ')';
					} else {
						$sQuery .= $bQuery;
					}
				}
			
			}
								

			if(empty($owner)) {
				if($viewDelete) {
					// 공개된 블로그만 뽑기 + 삭제된 글 보이기		
					if(!isAdmin()) {
						$bQuery = ' WHERE  (i.visibility = "d") AND (i.feedVisibility = "y") ';
					} else {
						$bQuery = ' WHERE  (i.visibility = "d") ';
					}
				} else {
					// 공개된 블로그만 뽑기
					if(!isAdmin()) {
						$bQuery = ' WHERE  (i.visibility = "y") AND (i.feedVisibility = "y") ';
					} else {
						$bQuery = ' WHERE  (i.visibility != "d") ';
					}
				}
			} else {		
				if($viewDelete) {
					// 공개된 블로그만 뽑기		
				//	if(!isAdmin()) {
				//		$bQuery = ' WHERE  (i.visibility = "d") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')';
				//	} else {
						$bQuery = ' WHERE  (i.visibility = "d") AND (f.owner = ' . $owner . ')';
				//	}
				} else {
					// 공개된 블로그만 뽑기		
				//	if(!isAdmin()) {
				//		$bQuery = ' WHERE  (i.visibility = "y") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')';
				//	} else {
						$bQuery = ' WHERE  (i.visibility != "d") AND (f.owner = ' . $owner . ')';
				//	}
				}
			}

			if($viewDelete) {
				if(strpos($sQuery, 'Feeds f') === false ) {
				$bQuery = ' LEFT JOIN '.$database['prefix'].'Feeds f ON (f.id = i.feed) ' . $bQuery;
				}
			}

			if (strpos($sQuery, 'WHERE') !== false) {
				$sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery);
				$sQuery .= ')';
			} else {
				$sQuery .= $bQuery;
			}
	
			return $sQuery;
		}
Exemplo n.º 15
0
    }
    echo "true";
} else {
    if (isset($_POST['catIds']) && $_POST['catIds'] != "" && isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "true") {
        // add pages to the menu
        $menuId = $database->escapeString($_POST['menuId']);
        $appearName = $database->escapeString($_POST['appearName']);
        $links->setMenuId($menuId);
        $links->setIsCustomLink(0);
        $links->setHttp("");
        $links->setPageId(0);
        $startPos = $links->numByMenu($database) + 1;
        foreach ($_POST['catIds'] as $id) {
            if ($appearName == "") {
                $category->setCategoryId($database->escapeString($id));
                $category->getById($database);
                $links->setAppearName($category->getCategory());
            } else {
                $links->setAppearName($appearName);
            }
            $links->setCategoryId($database->escapeString($id));
            $links->setPosition($startPos);
            $links->create($database);
            $startPos++;
        }
        echo "true";
    } else {
        if (isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "false" && isset($_POST['isCustomLink']) && $_POST['isCustomLink'] == "true") {
            // add pages to the menu
            $menuId = $database->escapeString($_POST['menuId']);
            $appearName = $database->escapeString($_POST['appearName']);
Exemplo n.º 16
0
    /**
     * Writes out the nzb when processing releases. Performed outside of smarty due to memory issues
     * of holding all parts in an array.
     */
    function writeNZBforReleaseId($relid, $name, $catId, $path, $groupID)
    {
        $db = new Settings();
        $cat = new Category();
        $this->groupID = $groupID;
        // Set table names
        if ($this->tablePerGroup === true) {
            if ($this->groupID == '') {
                exit("{$this->groupID} is missing\n");
            }
            $bName = 'binaries_' . $this->groupID;
            $pName = 'parts_' . $this->groupID;
        } else {
            $bName = 'binaries';
            $pName = 'parts';
        }
        $catrow = $cat->getById($catId);
        $site = new Sites();
        $fp = gzopen($path, "w");
        if ($fp) {
            $nzb_guid = '';
            gzwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            gzwrite($fp, "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.1//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd\">\n");
            gzwrite($fp, "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\">\n\n");
            gzwrite($fp, "<head>\n");
            if ($catrow) {
                gzwrite($fp, " <meta type=\"category\">" . htmlspecialchars($catrow["title"], ENT_QUOTES, 'utf-8') . "</meta>\n");
            }
            if ($name != "") {
                gzwrite($fp, " <meta type=\"name\">" . htmlspecialchars($name, ENT_QUOTES, 'utf-8') . "</meta>\n");
            }
            gzwrite($fp, "</head>\n\n");
            $result = $db->queryDirect(sprintf("SELECT %s.*, UNIX_TIMESTAMP(date) AS unixdate, groups.name as groupname FROM %s inner join groups on %s.groupid = groups.id WHERE %s.releaseid = %d ORDER BY %s.name", $bName, $bName, $bName, $bName, $relid, $bName));
            while ($binrow = $this->pdo->getAssocArray($result)) {
                $groups = array();
                $groupsRaw = explode(' ', $binrow['xref']);
                foreach ($groupsRaw as $grp) {
                    if (preg_match('/^([a-z0-9\\.\\-_]+):(\\d+)?$/i', $grp, $match) && strtolower($grp) !== 'xref') {
                        $groups[] = $match[1];
                    }
                }
                if (count($groups) == 0) {
                    $groups[] = $binrow["groupname"];
                }
                gzwrite($fp, "<file poster=\"" . htmlspecialchars($binrow["fromname"], ENT_QUOTES, 'utf-8') . "\" date=\"" . $binrow["unixdate"] . "\" subject=\"" . htmlspecialchars($binrow["name"], ENT_QUOTES, 'utf-8') . " (1/" . $binrow["totalparts"] . ")\">\n");
                gzwrite($fp, " <groups>\n");
                foreach ($groups as $group) {
                    gzwrite($fp, "  <group>" . $group . "</group>\n");
                }
                gzwrite($fp, " </groups>\n");
                gzwrite($fp, " <segments>\n");
                $resparts = $db->queryDirect(sprintf("SELECT DISTINCT(messageid), size, partnumber FROM %s WHERE binaryid = %d ORDER BY partnumber", $pName, $binrow["id"]));
                while ($partsrow = $db->getAssocArray($resparts)) {
                    if ($nzb_guid === '') {
                        $nzb_guid = $partsrow['messageid'];
                    }
                    gzwrite($fp, "  <segment bytes=\"" . $partsrow["size"] . "\" number=\"" . $partsrow["partnumber"] . "\">" . htmlspecialchars($partsrow["messageid"], ENT_QUOTES, 'utf-8') . "</segment>\n");
                }
                gzwrite($fp, " </segments>\n</file>\n");
            }
            gzwrite($fp, "<!-- generated by newznab " . $site->version() . " -->\n</nzb>");
            gzclose($fp);
            if (is_file($path)) {
                $this->pdo->queryExec(sprintf('
						UPDATE releases SET nzbstatus = %d %s WHERE id = %d', NZB::NZB_ADDED, $nzb_guid === '' ? '' : ', nzb_guid = UNHEX( ' . $this->pdo->escapestring(md5($nzb_guid)) . ' )', $relid));
                // Chmod to fix issues some users have with file permissions.
                chmod($path, 0777);
                return true;
            } else {
                echo "ERROR: {$path} does not exist.\n";
            }
        }
    }
Exemplo n.º 17
0
 * Trang chỉnh sửa danh mục sản phẩm
 */
//Khởi động session
session_start();
//Kiểm tra nếu chưa đăng nhập thì quay về trang đăng nhập
if (!isset($_SESSION['user'])) {
    header('location:../user/login.php');
}
require '../../config/Config.php';
require '../../models/Category.php';
date_default_timezone_set('Asia/Ho_Chi_Minh');
//Lấy category_id từ URL
$category_id = $_GET['category_id'];
//Khởi tạo đối tượng danh mục sản phẩm
$categoryModel = new Category();
//Nếu có POST dữ liệu lên thì xử lý cập nhật
if ($_POST) {
    //Nhận dữ liệu từ form và gán vào một mãng
    $data = array('name' => $_POST['name'], 'status' => isset($_POST['status']) ? 1 : 0, 'modified' => date('Y-m-d H:i:s'));
    if ($categoryModel->edit($data, $category_id)) {
        //Tạo session để lưu cờ thông báo thành công
        $_SESSION['success'] = true;
        //Tải lại trang (Mục đích là để tải lại thông tin mới)
        header('location:list.php');
    }
    exit;
}
//Lấy thông tin danh mục sản phẩm để trình bày trên form
$category = $categoryModel->getById($category_id);
//Giao diện
require '../../views/category/v_edit.php';