Пример #1
0
 static function __init($id = false)
 {
     global $globals, $db;
     self::$info = false;
     if ($id > 0) {
         self::$id = $id;
     } elseif (!isset($globals['site_id'])) {
         if (empty($globals['site_shortname'])) {
             echo "Error, site_shortname not found, check your global['site_shortname']: " . $globals['site_shortname'];
         }
         self::$info = $db->get_row("select * from subs where name = '" . $globals['site_shortname'] . "'");
         if (self::$info) {
             self::$id = self::$info->id;
         } else {
             self::$id = 0;
             return;
         }
     } else {
         self::$id = $globals['site_id'];
     }
     if (self::$info == false) {
         self::$info = $db->get_row("select * from subs where id = " . self::$id);
     }
     self::$parent = self::$info->created_from;
     if (self::$id > 0) {
         $db->query('set @site_id = ' . self::$id);
     }
 }
Пример #2
0
 static function __init($id = false)
 {
     global $globals, $db;
     if ($id > 0) {
         self::$id = $id;
     } elseif (!isset($globals['site_id'])) {
         $res = $db->get_row("select id, parent from subs where name = '" . $globals['site_shortname'] . "'");
         self::$id = $res->id;
         self::$parent = $res->parent;
         if (!self::$id) {
             echo "Error, site_shortname not found, check your global['site_shortname']: " . $globals['site_shortname'];
         }
     } else {
         self::$id = $globals['site_id'];
     }
     if (self::$parent === false && self::$id > 0) {
         self::$parent = (int) $db->get_var("select parent from subs where id = " . self::$id);
     }
 }