Пример #1
0
function add_dir_parsed($dir, $group_id, $parent_id = -1)
{
    // Add all pictures under the Directory $dir to categories and series depending on the relativ path to $dir
    global $db, $config_vars, $filetypes;
    if ($parent_id == -1) {
        $parent_id = $config_vars['root_categorie'];
    }
    $dir_handle = opendir($dir);
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            $dir_and_file = $dir . '/' . $file;
            if (isset($filetypes[getext($file)])) {
                // $file is content
                // generate a new album_content obj
                add_content($file, $dir_and_file, getfile($file), $parent_id, 0, $group_id);
            } elseif (is_dir($dir_and_file)) {
                //file is a sub dir
                $cat = new categorie();
                $cat->set_name($file);
                $cat->set_parent_id($parent_id);
                $cat->fill_up();
                $cat->set_catgroup_id($group_id);
                if (!isset($cat->id)) {
                    $cat->commit();
                }
                add_dir_parsed($dir . '/' . $file, $group_id, $cat->get_id());
            }
        }
    }
    closedir($dir_handle);
}
Пример #2
0
 function commit()
 {
     //if the object is already in the db it is updated by the changes made to this object, otherwise a new db entry is made
     global $db, $config_vars;
     if (!isset($this->id)) {
         if ($this->is_serie === false) {
             $is_serie = 0;
         } else {
             $is_serie = 1;
         }
         // this is object is not yet in the datebase, make a new entry
         $sql = 'INSERT INTO ' . $config_vars['table_prefix'] . "cats (name, current_rating, parent_id, catgroup_id,is_serie,content_amount,description,child_content_amount,child_comments_amount)\n\t\t\t\tVALUES ('" . database_encode($this->name) . "', '{$this->current_rating}', '{$this->parent_id}', '{$this->catgroup_id}', '{$is_serie}', '{$this->content_amount}', '" . database_encode($this->description) . "', '{$this->child_content_amount}', '{$this->child_comments_amount}')";
         if (!($result = $db->sql_query($sql))) {
             $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'commit', $this->id, 0, 0, $sql);
             $error->commit();
             // 				error_report(SQL_ERROR, 'commit' , __LINE__, __FILE__,$sql);
         }
         $this->id = $db->sql_nextid();
         return OP_SUCCESSFUL;
     } else {
         // object is already in the database just du an update
         $sql = 'UPDATE ' . $config_vars['table_prefix'] . "cats \n\t\t\t\tSET \tname = '" . database_encode($this->name) . "',\n\t\t\t\t\tcurrent_rating = '{$this->current_rating}', \n\t\t\t\t\tparent_id = '{$this->parent_id}', \n\t\t\t\t\tcatgroup_id = '{$this->catgroup_id}',\n\t\t\t\t\tis_serie = '{$this->is_serie}',\n\t\t\t\t\tcontent_amount = '{$this->content_amount}',\n\t\t\t\t\tdescription = '" . database_encode($this->description) . "',\n\t\t\t\t\tchild_content_amount = '{$this->child_content_amount}',\n\t\t\t\t\tchild_comments_amount = '{$this->child_comments_amount}'\n\t\t\t\tWHERE id like {$this->id}";
         if (!($result = $db->sql_query($sql))) {
             $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'commit', $this->id, 0, 0, $sql);
             $error->commit();
             // 				error_report(SQL_ERROR, 'commmit' , __LINE__, __FILE__,$sql);
         }
         // recalc child content_amount
         if ($this->get_id() != $config_vars['root_categorie']) {
             $cat = new categorie();
             $cat->generate_from_id($this->get_parent_id());
             $cat->set_child_content_amount($cat->calc_child_content_amount());
             $cat->commit();
         }
         if (isset($this->commit_parent_cat)) {
             $this->commit_parent_cat->commit();
         }
         return OP_SUCCESSFUL;
     }
 }
Пример #3
0
        foreach ($HTTP_POST_VARS['correct'] as $key => $value) {
            if ($HTTP_POST_VARS['type'][$key] == CONTENT_IN_CAT_AMOUNT) {
                $cat = new categorie();
                $cat->generate_from_id($HTTP_POST_VARS['id'][$key]);
                $cat->set_content_amount($cat->calc_content_amount());
                $cat->commit();
            } elseif ($HTTP_POST_VARS['type'][$key] == CHILD_CONTENT_IN_CAT_AMOUNT) {
                $cat = new categorie();
                $cat->generate_from_id($HTTP_POST_VARS['id'][$key]);
                $cat->set_child_content_amount($cat->calc_child_content_amount());
                $cat->commit();
            } elseif ($HTTP_POST_VARS['type'][$key] == CHILD_COMMENTS_IN_CAT_AMOUNT) {
                $cat = new categorie();
                $cat->generate_from_id($HTTP_POST_VARS['id'][$key]);
                $cat->set_child_comments_amount($cat->calc_child_comments_amount());
                $cat->commit();
            } elseif ($HTTP_POST_VARS['type'][$key] == CONTENT_COMMENTS_AMOUNT) {
                $content = get_content_object_from_id($HTTP_POST_VARS['id'][$key]);
                $content->set_comments_amount($content->calc_comments_amount());
                $content->commit();
            }
        }
    }
}
// check content amount for each cat
// get all categories
$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)) {
Пример #4
0
unset($HTTP_SESSION_VARS['contents']);
if (!isset($HTTP_GET_VARS['cat_id'])) {
    $HTTP_GET_VARS['cat_id'] = $config_vars['root_categorie'];
    $template_file = 'index';
}
// create new categorie
if (isset($HTTP_POST_VARS['newcat'])) {
    $new_cat = new categorie();
    $new_cat->set_parent_id($HTTP_GET_VARS['cat_id']);
    $new_cat->set_name($HTTP_POST_VARS['cat_name']);
    $new_cat->set_description($HTTP_POST_VARS['cat_describtion']);
    if ($HTTP_POST_VARS['cat_is_serie'] == 'on') {
        $new_cat->set_is_serie(1);
    }
    $new_cat->set_catgroup_id($HTTP_POST_VARS['add_to_catgroup']);
    $new_cat->commit();
}
//get the cats in the actual cat and information about them
$child_cats = get_cats_of_cat($HTTP_GET_VARS['cat_id']);
// get the amount of child_cats without perm checking
$sql = "SELECT * FROM " . $config_vars['table_prefix'] . "cats WHERE (parent_id = {$HTTP_GET_VARS['cat_id']})";
if (!($result = $db->sql_query($sql))) {
    error_report(SQL_ERROR, 'get_cats_of_cat', __LINE__, __FILE__, $sql);
}
$child_cats_total_amount = $db->sql_affectedrows($result);
$child_cats_viewable_amount = sizeof($child_cats);
$smarty->assign('viewable_total_cats', sprintf($lang['viewable_total_cats'], $child_cats_viewable_amount, $child_cats_total_amount));
if (isset($HTTP_POST_VARS['edit_cat'])) {
    for ($i = 0; $i < sizeof($child_cats); $i++) {
        $child_cats[$i]->set_name($HTTP_POST_VARS['cat_name'][$i]);
        $child_cats[$i]->set_description($HTTP_POST_VARS['cat_description'][$i]);
Пример #5
0
 $root_cat->catgroup_id = $admin_group->get_id();
 $root_cat->name = "root_cat";
 $root_cat->description = "This is your Root Category. You can change the name and description, but never delete it!";
 $root_cat->commit();
 // fill config var root cat to prefent infinite update loop on commit
 $config_vars['root_categorie'] = $root_cat->id;
 // set parent id to given id
 $root_cat->parent_id = $root_cat->id;
 echo "Root Cat: " . $root_cat->commit() . "<br>";
 //deleted content cat
 $deleted_content_cat = new categorie();
 $deleted_content_cat->parent_id = $root_cat->id;
 $deleted_content_cat->catgroup_id = $admin_group->get_id();
 $deleted_content_cat->name = "Deleted Content";
 $deleted_content_cat->description = "This is your Deleted Content Category. Here will be your deleted content stored. You can change the name and description, but never delete it!";
 echo "Delete Content Cat: " . $deleted_content_cat->commit() . "<br>";
 echo '<font color=#00ff00>OK</font><br>';
 // alter phpBB tables
 echo "Add basket_enable to phpbb users: ";
 $sql = "ALTER TABLE `{$table_prefix}users` ADD `{$phreakpic_table_prefix}basket_enable` ENUM('0','1') NOT NULL";
 $check = mysql_db_query($dbname, $sql, $connect);
 if ($check == false) {
     echo "<font color=#ff00ff>" . mysql_errno() . ": " . mysql_error() . "</font> ";
 }
 echo '<font color=#0000ff>done</font><br>';
 echo '</p>';
 //end of DB stuff
 //write the config file
 echo '<p> Writing the Config ';
 //fill config_vars;
 $config_vars['table_prefix'] = $phreakpic_table_prefix;
 function delete()
 {
     global $db, $config_vars, $userdata;
     // remove from content table
     // check is user is allowed
     $cat = new categorie();
     $cat->generate_from_id($this->owner_id);
     if ($userdata['user_id'] == $this->user_id or check_cat_action_allowed($cat->get_catgroup_id(), $userdata['user_id'], 'content_edit')) {
         $sql = "DELETE FROM " . $config_vars['table_prefix'] . "cat_comments WHERE id = " . $this->id;
         if (!($result = $db->sql_query($sql))) {
             error_report(SQL_ERROR, 'delete', __LINE__, __FILE__, $sql);
         }
         $cat->dec_child_comments_amount();
         $cat->commit();
         unset($this->id);
     }
 }