function get_parent_cat_array() { global $config_vars; $cat_obj = $this; $parent_cat['name'] = $cat_obj->get_name(); $parent_cat['id'] = $cat_obj->get_id(); $parent_cats[] = $parent_cat; while ($cat_obj->get_parent_id() != $config_vars['root_categorie'] and $cat_obj->id != $cat_obj->get_parent_id()) { $old_cat_id = $cat_obj->get_parent_id(); $cat_obj = new categorie(); $cat_obj->generate_from_id($old_cat_id); $parent_cat['name'] = $cat_obj->get_name(); $parent_cat['id'] = $cat_obj->get_id(); $parent_cats[] = $parent_cat; } return array_reverse($parent_cats); }
function get_cats_string($cats) { global $config_vars; if (is_array($cats)) { foreach ($cats as $key => $value) { $cat_obj = new categorie(); $cat_obj->generate_from_id($value['id']); $name = $cat_obj->get_name(); while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) { $old_cat_id = $cat_obj->get_parent_id(); $cat_obj = new categorie(); $cat_obj->generate_from_id($old_cat_id); $name = $cat_obj->get_name() . '/' . $name; } $cats[$key]['name'] = $name; } } return $cats; }
$sql = "SELECT id FROM " . $config_vars['table_prefix'] . "cats"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Coudnt get cats", '', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { $cat = new categorie(); $cat->generate_from_id($row['id']); $catarray[] = $cat; } foreach ($catarray as $cat) { // check how many content is in this cat $should_be = $cat->calc_content_amount(); if ($should_be != $cat->get_content_amount()) { $missmatch['type'] = CONTENT_IN_CAT_AMOUNT; $missmatch['id'] = $cat->id; $missmatch['name'] = $cat->get_name(); $missmatch['value'] = $cat->get_content_amount(); $missmatch['should_be'] = $should_be; $missmatch_array[] = $missmatch; } // check child_content_amount $calc_child_content_amount = $cat->calc_child_content_amount(); if ($calc_child_content_amount != $cat->get_child_content_amount()) { $missmatch['type'] = CHILD_CONTENT_IN_CAT_AMOUNT; $missmatch['id'] = $cat->id; $missmatch['name'] = $cat->get_name(); $missmatch['value'] = $cat->get_child_content_amount(); $missmatch['should_be'] = $calc_child_content_amount; $missmatch_array[] = $missmatch; } // check child comment amount
$root_comments = get_comments_of_cat($HTTP_GET_VARS['cat_id']); if (sizeof($root_comments) > 0) { for ($i = 0; $i < sizeof($root_comments); $i++) { make_comments($root_comments[$i], 0, check_cat_action_allowed($HTTP_GET_VARS['cat_id'], $userdata['user_id'], 'comment_edit')); } $smarty->assign('comments', $comments); } else { $smarty->assign('comments', 'false'); } //link where to go when back to thumbs $HTTP_SESSION_VARS['thumb_link'] = "view_cat.php?cat_id={$HTTP_GET_VARS['cat_id']}"; $smarty->assign('thumb_link', $HTTP_SESSION_VARS['thumb_link']); $smarty->assign('current_page', $HTTP_SESSION_VARS['thumb_link']); //thats for the index.php who needs another template file. index.php just set the $template_file to another value and includes this file if (!isset($template_file)) { $template_file = 'view_cat'; } $smarty->assign('nav_string', build_nav_string($HTTP_GET_VARS['cat_id'])); $smarty->assign('redirect', PHREAKPIC_PATH . "{$template_file}.php"); $smarty->assign('thumb_size', $config_vars['thumb_size']['maxsize']); $smarty->assign('title_page', $lang['view_cat']); $smarty->assign('title_name', htmlspecialchars($category->get_name())); $end_time = getmicrotime(); $execution_time = $end_time - $start_time; $smarty->display($userdata['photo_user_template'] . "/{$template_file}.tpl"); $template_end_time = getmicrotime(); $template_execution_time = $template_end_time - $end_time; echo "execution_time: {$execution_time} seconds<br>"; echo "template_execution_time: {$template_execution_time} seconds<br>"; $execution_time = $end_time - $start_time + $template_execution_time; echo "gesamt execution_time: {$execution_time} seconds<br>";
function generate_filename() { global $config_vars; //check if content is already in a cat if (!isset($this->cat_ids)) { $this->generate_content_in_cat_data(); } if (sizeof($this->cat_ids) > 0) { $cat_obj = new categorie(); $cat_obj->generate_from_id($this->cat_ids[0]); $path = $cat_obj->get_name(); while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) { $old_cat_id = $cat_obj->get_parent_id(); $cat_obj = new categorie(); $cat_obj->generate_from_id($old_cat_id); $path = $cat_obj->get_name() . '/' . $path; } // make $path is it doesnt exists if (!is_dir($config_vars['content_path_prefix'] . '/' . $path)) { makedir($config_vars['content_path_prefix'] . '/' . $path); } $path = $path . '/' . basename($this->name) . '.' . getext($this->file); $filename = $config_vars['content_path_prefix'] . '/' . $path; // if filename has changed check if such a file does not already exists is so add a number behind till its a new file if ($this->file != $filename) { $newfilename = $filename; $i = 0; while (is_file($newfilename)) { $newfilename = getfile($filename) . "-{$i}." . getext($filename); $i++; } $filename = $newfilename; } return $filename; } else { return OP_CONTENT_NOT_IN_CAT; } }