Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - byrev

Pages: [1]
1
Discussion & Troubleshooting / Re: High Mysql Load through 4images
« on: March 29, 2007, 09:04:44 PM »
Same problem... is a big one.
I use huge database ... 200.000+ image in databse and server is to slow for tihis script, specialy in home page.
If i chose category is a more better. If i go to home page i get mysq lost conexion error, php to much time for execution: 30secons... huge time for cpu & i lost 90% visitors !!
I think i need another better softer with best code & mysql optimisatin, this is not goot for big database an high trafic.

2
i see many scripts: cms, forum, blogs, gallery... no one have this modification... wtf, i am to smart for this job !!!
i made similar modification to wordpress, runcms, Jupiter CMS and ... other scripts !!! works all time :)

3
in file: categories.php from admin folder  ( ./admin/categories.php )
find first aparence: if (empty($error)) {
for me i find this at line 502.
now form 502 to 537 you have this code:
Quote
  if (empty($error)) {
    if (!$cat_order) {
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }

    $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
    $result = $site_db->query($sql);
    $cat_id = $site_db->get_insert_id();

    if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
    }
    else {
      $msg = $lang['cat_add_error'];
    }
    //$action = "modifycats";
    forward_to_modify($msg);
  }

Replace code from line 502 to 537, with the next code:
Quote
  if (empty($error)) {
   $cat_name_array = explode('|', $cat_name);
   $cat_name_count = count($cat_name_array);
    for ($i=0;$i<$cat_name_count;$i++)
    {     
    $cat_name = $cat_name_array[$i];   
   /** Start ADD **/
    if (!$cat_order) {         
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }
         
     $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
     $result = $site_db->query($sql);
     $cat_id = $site_db->get_insert_id();

     if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
     }
     else {
      $msg = $lang['cat_add_error'];
     }
     /** End ADD **/
     // echo $cat_name.' , ';
    } // end FOR!
    forward_to_modify($msg);   
  }

Done... must be ok now !!!

4
With this modification you can add in "ACP -> Add Categories " several categories with one single click !


if i have 400 category i must lose days with simple procedure ... ;)
modify function for multiple category/subcategory one time, one click !!!

========= This is my modification code for this job ===========
Code: [Select]
  if (empty($error)) {
$cat_name_array = explode('|', $cat_name);
$cat_name_count = count($cat_name_array);
    for ($i=0;$i<$cat_name_count;$i++)
    {     
    $cat_name = $cat_name_array[$i];   
/** Start ADD **/
    if (!$cat_order) {         
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }
         
     $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
     $result = $site_db->query($sql);
     $cat_id = $site_db->get_insert_id();

     if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
     }
     else {
      $msg = $lang['cat_add_error'];
     }
     /** End ADD **/
     // echo $cat_name.' , ';
    } // end FOR!
    forward_to_modify($msg);   
  }

modification in: admin/categories.php
position: in body "savecat" action: if ($action == "savecat") {

so....
now you can enter categories like this example:
Animals|Cars|Bussines|Nature|Musical|Sports|Abstract|Art|People|Objects|Musical|Food|Education
and .. done ... 13 categories with only 1 click !!! ;)

This modification works here : http://www.findavatar.com

Edited by mawenzi :
- how to add the modification : here
- how to add APC description extension : here

Pages: [1]