function deleteAlly($id) { $galas = selectsql("select gala from galaxy where aid = {$id}"); if ($galas) { #Galaxien löschen deleteGalaxy(getArrayFromList($galas, "gala")); } return query("delete from alliance where aid = {$id}"); }
function deleteGalaxy($id) { if (is_array($id)) { $sql = "(" . join(",", $id) . ")"; if (!$sql) { return; } $user = selectsql("select uid from user where gala IN " . $sql); } else { $user = selectsql("select uid from user where gala = {$id}"); } if ($user) { #delete user from galaxy deleteUser(getArrayFromList($user, "uid")); } #delete galaxys if (is_array($id)) { $user = query("delete from galaxy where gala IN " . $sql); } else { $user = query("delete from galaxy where gala = {$id}"); } return 1; }
function listUser($filter, $pages, $page = 1, $rows = 10) { Assert::isId($page); Assert::isId($rows); #username if ($filter['username']) { if ($where) { $where .= " and "; } $where .= " u.nick LIKE '" . mysql_real_escape_string($filter['username']) . "%'"; } #gala if ($filter['gala']) { Assert::isId($filter['gala']); if ($where) { $where .= " and "; } $where .= " u.gala = " . (int) $filter['gala'] . " "; } #ally if ($filter['ally']) { Assert::isId($filter['ally']); if ($where) { $where .= " and "; } $where .= " ga.aid = " . (int) $filter['ally'] . " "; if ($filter['checkallygalas']) { $galalist = getGalaListByAlly($filter['ally']); if ($galalist) { $galalist = getArrayFromList($galalist, "gala"); $galalist = "(" . join(",", $galalist) . ")"; $where .= " AND u.gala IN " . $galalist; } else { $page = 0; $pages = 0; return; } } } #phone if ($filter['phone']) { if ($where) { $where .= " and "; } $where .= " u.phone LIKE '" . mysql_real_escape_string($filter['phone']) . "%'"; } #group if ($filter['group']) { Assert::isTrue((int) $filter['group'] >= -1); if ($where) { $where .= " and "; } if ((int) $filter['group'] == -1) { $where .= " u.gid = 0 "; } else { $where .= " u.gid = " . (int) $filter['group']; } } if ($where) { $where = " where " . $where; } #order by if ($filter['order'] == "asc") { $order = " ASC "; } else { $order = " DESC "; } if ($filter['sort'] == "username") { $sort = " u.nick "; } elseif ($filter['sort'] == "group") { $sort = " groupname "; } elseif ($filter['sort'] == "login") { $sort = " u.loggedin "; } elseif ($filter['sort'] == "fleetupdate") { $sort = " u.fleetupdate "; } elseif ($filter['sort'] == "koords") { $sort = " u.gala " . $order . ", u.pos "; } elseif ($filter['sort'] == "phone") { $sort = " u.phone "; } else { $sort = " u.nick "; } $count = selectsqlLine("\n select count(*) as count\n from user u\n left join galaxy ga on (ga.gala = u.gala)\n\t\t\t\t\t\t\t\t" . $where); #Seitenamzahl berechnen $pages = ceil($count['count'] / $rows); #Seite checken if ($pages < $page && $pages != 0) { $page = $pages; } $return = selectsql("select u.*,a.tag,\n\t\t\t\t\tDATE_FORMAT(u.loggedin, '%d.%m.%y') as date,\n\t\t\t\t\tDATE_FORMAT(u.loggedin, '%H:%i') as time,\n\t\t\t\t\tg.name as groupname, g.descr as groupdescr,g.usertitle\n from user u\n left join groups g using(gid)\n left join galaxy ga on(ga.gala = u.gala)\n left join alliance a on(a.aid = ga.aid)\n " . $where . "\n\t\t\t\t\torder by " . $sort . " " . $order . "\n\t\t\t\t\tLIMIT " . $rows * ($page - 1) . ",{$rows}"); return $return; }
# List the latest posts ########################################################## case 'list': #Get basic data $num_page = !empty($_POST['page']) ? $_POST['page'] : 0; $nb_items = !empty($_POST['nb_items']) ? $_POST['nb_items'] : 30; $num_start = $num_page * $nb_items; # Get search value $search_value = !empty($_POST['search']) ? $_POST['search'] : null; if (isset($search_value)) { $search_value = htmlentities($search_value, ENT_QUOTES, 'UTF-8'); $search_value = mysql_real_escape_string($search_value); } # Get filters on tags and users $tags = !empty($_POST['tags']) ? getArrayFromList($_POST['tags']) : array(); $users = !empty($_POST['users']) ? getArrayFromList($_POST['users']) : array(); # Get the period $period = !empty($_POST['period']) ? trim($_POST['period']) : ''; # Order by most popular $popular = !empty($_POST['popular']) ? true : false; $post_status = !empty($_POST['post_status']) ? 2 : 1; # On recupere les informtions sur les membres $sql = generate_SQL($num_start, $nb_items, $users, $tags, $search_value, $period, $popular, null, $post_status); //print $sql; //exit; $rs = $core->con->select($sql); $tpl = new Hyla_Tpl(dirname(__FILE__) . '/../themes/' . $blog_settings->get('planet_theme') . '/'); $tpl->importFile('index', 'index.tpl'); $tpl->render('menu.filter'); # Liste des articles $tpl = showPosts($rs, $tpl, $search_value, true, $popular);
function incoming_details_resetfilter() { $id = param_num("id"); if (!($id = param_num("id")) || !($inc = getuserbyid($id))) { $this->_header(); } $fids = array(); $fids = getArrayFromList(fleetstatus_get_bytarget($inc['gala'], $inc['pos']), "fsid"); if (count($fids)) { reset_fleet_filter($this->userdata, $fids); } $this->_header(); }
function getItemsFromFeeds($rs, $print) { global $blog_settings, $core; $output = ""; $cron_file = dirname(__FILE__) . '/cron_running.txt'; # Duree de mise a jour $debut = explode(" ", microtime()); $debut = $debut[1] + $debut[0]; $cpt = 0; while ($rs->fetch()) { # On verifie si on n'a pas demandé l'arrêt de l'algo if (file_exists(dirname(__FILE__) . '/STOP')) { $log_msg = logMsg(T_("STOP file detected, trying to shut down cron job"), "", 2, $print); if ($print) { $output .= $log_msg; } break; } $log_msg = logMsg(T_("Check feed : ") . $rs->feed_url, "", 0, $print); if ($print) { $output .= $log_msg; } require_once dirname(__FILE__) . '/lib/simplepie_1.3.compiled.php'; # On cree un objet SimplePie et on ajuste les parametres de base $feed = new SimplePie(); $feed->set_feed_url($rs->feed_url); $feed->set_cache_location(dirname(__FILE__) . '/../admin/cache'); #$feed->enable_cache(false); # $feed->set_cache_duration($item_refresh); $feed->init(); # Pour faire fonctionner les lecteurs flash, non recomande par simplepie $feed->strip_htmltags(false); # Si le flux ne contient pas de donnee #$item_nb = $feed->get_item_quantity(); $error = $feed->error(); if (isset($error)) { # Affichage du message d'erreur if (ereg($rs->feed_url, $error)) { $log_msg = logMsg(T_("No feed found : ") . $error, "", 3, $print); } else { $log_msg = logMsg(sprintf(T_("No feed found on %s (owner : %s)"), $rs->feed_url, $rs->user_id) . $error, "", 3, $print); } if ($print) { $output .= $log_msg; } } else { $items = $feed->get_items(); foreach ($items as $item) { #print $item->get_permalink().'<br>'; #continue; # open log file and write activity down $fp = @fopen($cron_file, 'wb'); if ($fp === false) { throw new Exception(sprintf(T_('Cannot write %s file.'), $cron_file)); } fwrite($fp, time()); fclose($fp); # Analyse the item ##################### # Content $item_content = strip_script($item->get_content()); if (empty($item_content)) { $item_content = $item->get_description(); } $item_content = traitementEncodage($item_content); # Title $item_title = traitementEncodage($item->get_title()); if (strlen($item_title) > 254) { $item_title = substr($item_title, 0, 254); } # Permalink $permalink = $item->get_permalink(); $item_image = getFirstPostImageUrl($item->get_content()); # Analyse the possible tags of the item ########################################## # Get tags defined in the database for all posts of that feed $item_tags = array(); # Get the tags on the feed $rs_feed_tag = $core->con->select("SELECT tag_id FROM " . $core->prefix . "feed_tag\r\n\t\t\t\t\tWHERE feed_id = " . $rs->feed_id); while ($rs_feed_tag->fetch()) { $item_tags[] = strtolower($rs_feed_tag->tag_id); } # Get the reserved tags $reserved_tags = array(); $planet_tags = getArrayFromList($blog_settings->get('planet_reserved_tags')); if (is_array($planet_tags)) { foreach ($planet_tags as $tag) { $reserved_tags[] = strtolower($tag); } } # Get tags defined on the item in the feed $categs = $item->get_categories(); if ($categs) { foreach ($categs as $category) { $label = strtolower($category->get_label()); if (!in_array($label, $item_tags) && !in_array($label, $reserved_tags) && !is_int($label) && strlen($label) > 1) { $item_tags[] = $label; } } } # Find hashtags in title $hashtags = array(); preg_match('/#([\\d\\w]+)/', $item->get_title(), $hashtags); foreach ($hashtags as $tag) { $tag = strtolower($tag); if (!in_array($tag, $item_tags) && !in_array($tag, $reserved_tags) && !is_int($tag) && strlen($tag) > 1) { $item_tags[] = $tag; } } # check if some existing tags are in the title foreach (explode(' ', $item_title) as $word) { $word = strtolower($word); $tagRq = $core->con->select('SELECT tag_id FROM ' . $core->prefix . 'post_tag WHERE tag_id = \'' . $word . "'"); if ($tagRq->count() > 1 && !in_array($word, $item_tags) && !in_array($word, $reserved_tags) && !is_int($word) && strlen($word) > 1) { $item_tags[] = $word; } } if (empty($item_content)) { $log_msg = logMsg(sprintf(T_("No content on feed %s"), $rs->feed_url), "", 3, $print); } elseif (empty($permalink)) { $log_msg = logMsg(T_("Error in link cutting : ") . $permalink, "", 3, $print); } else { $log_msg = insertPostToDatabase($rs, $permalink, $item->get_date("U"), $item_title, $item_content, $item_tags, $item_image, $print, $rs->feed_id); $cpt++; } # fin du $item->get_content() if ($print) { $output .= $log_msg; } } # fin du foreach # Le flux a ete mis a jour, on le marque a la derniere date $cur = $core->con->openCursor($core->prefix . 'feed'); $cur->feed_checked = array('NOW()'); $cur->update("WHERE feed_id = '{$rs->feed_id}'"); $log_msg = logMsg(sprintf(T_("The feed %s is updated"), $rs->feed_url), "", 2, $print); if ($print) { $output .= $log_msg; } # On fait un reset du foreach reset($items); } # fin $feed->error() # Destruction de l'objet feed avant de passer a un autre $feed->__destruct(); unset($feed); if ($blog_settings->get('auto_feed_disabling')) { $toolong = time() - 86400 * 7; # seven days ago $check_sql = "SELECT feed_checked FROM " . $core->prefix . "feed WHERE feed_id=" . $rs->feed_id; $rs_check = $core->con->select($check_sql); $last_checked = mysqldatetime_to_timestamp($rs_check->f('feed_checked')); if ($last_checked < $toolong) { $diff = (time() - $last_checked) / 86400; $log_msg = logMsg(sprintf(T_("The feed was not updated since %d days. It'll be disabled : "), $diff) . $rs->feed_url, "", 2, $print); if ($print) { $output .= $log_msg; } # if feed was in error for too long, let's disable it $cur = $core->con->openCursor($core->prefix . 'feed'); $cur->feed_status = 2; $cur->update("WHERE feed_id = '{$rs->feed_id}'"); $from = $blog_settings->get('author_mail'); $to = $from . ',' . $rs->user_email; $reply_to = $from; $subject = sprintf(T_("Due to errors, a feed has been disabled on %s"), $blog_settings->get('planet_title')); $content = sprintf(T_("The feed of %s has been disabled :\n"), $rs->user_fullname); $content .= $rs->feed_url . "\n"; $content .= sprintf(T_("The feed was in error during more than %d days"), $diff); $content .= "\n\n" . T_("Details :"); $content .= "\n" . T_("User id : ") . $rs->user_id; $content .= "\n" . T_("User name : ") . $rs->user_fullname; $content .= "\n" . T_("User email : ") . $rs->user_email; $content .= "\n" . T_("Feed url : ") . $rs->feed_url; $content .= "\n" . T_("Last checked timestamp : ") . $last_checked; $content .= "\n" . T_("Website : ") . $rs->site_url; if (!sendmail($from, $to, $subject, $content, 'normal', $reply_to)) { $log_msg = logMsg(T_("Email alert could not be send")); if ($print) { $output .= $log_msg; } } else { $log_msg = logMsg(T_("Feed disabled and email alert sent !")); if ($print) { $output .= $log_msg; } } } } } # fin du while # Duree de la mise a jour $fin = explode(" ", microtime()); $fin = $fin[1] + $fin[0]; $temps_passe = round($fin - $debut, 2); $log_msg = logMsg("{$cpt} articles mis a jour en {$temps_passe} secondes", "", 2, $print); if ($print) { $output .= $log_msg; } return $output; }
# header('Content-type: text/html; charset=utf-8'); # Valeurs par defaut $params = array('title' => $blog_settings->get('planet_title') . " - " . T_('Users')); $core->tpl->setVar('params', $params); $user_id = ''; if ($core->auth->sessionExists()) { $user_id = $core->auth->userID(); } $sql_tribes = "SELECT\n\t\tuser_id,\n\t\ttribe_name,\n\t\ttribe_tags,\n\t\ttribe_users,\n\t\ttribe_search,\n\t\ttribe_icon,\n\t\ttribe_id\n\tFROM " . $core->prefix . "tribe\n\tWHERE (user_id = 'root' OR user_id = '" . $user_id . "')\n\t\tAND visibility = 1\n\tORDER BY ordering\n\t\t"; $rs = $core->con->select($sql_tribes); while ($rs->fetch()) { $sql_post = generate_tribe_SQL($rs->tribe_id, 0, 0); $rs_post = $core->con->select($sql_post); $tribe_icon = getTribeIcon($rs->tribe_id, $rs->tribe_name, $rs->tribe_icon); $tribe = array("id" => $rs->tribe_id, "user_id" => $rs->user_id, "name" => $rs->tribe_name, "tags" => implode(', ', getArrayFromList($rs->tribe_tags)), "users" => implode(', ', getArrayFromList($rs->tribe_users)), "search" => $rs->tribe_search, "icon" => $tribe_icon, "last" => mysqldatetime_to_date("d/m/Y", $rs_post->last), "nb_post" => $rs_post->count); $core->tpl->setVar('tribe', $tribe); $core->tpl->render("tribe.block"); } $sql_tags = "SELECT\n\t\t" . $core->prefix . "post_tag.tag_id,\n\t\tCOUNT(" . $core->prefix . "post_tag.tag_id) as weigth\n\tFROM " . $core->prefix . "post_tag\n\tGROUP BY " . $core->prefix . "post_tag.tag_id\n\tORDER BY weigth DESC\n\tLIMIT 100"; $rs = $core->con->select($sql_tags); $max = $rs->f('weight'); while ($rs->fetch()) { if ($rs->weigth > $max) { $max = $rs->weigth; } $weigth = intval($rs->weigth * 10 / $max); $tag = array("id" => $rs->tag_id, "weigth" => $weigth); $core->tpl->setVar('tag', $tag); $core->tpl->render("tag.block"); }
function generate_tribe_SQL($tribe_id, $num_start = 0, $nb_items = 10, $popular = false, $search = '') { global $core; $sql_tribes = "SELECT\n\t\t\ttribe_id,\n\t\t\tuser_id,\n\t\t\ttribe_name,\n\t\t\ttribe_search,\n\t\t\ttribe_tags,\n\t\t\ttribe_notags,\n\t\t\ttribe_users,\n\t\t\ttribe_nousers\n\t\tFROM " . $core->prefix . "tribe\n\t\tWHERE tribe_id = '" . $tribe_id . "'\n\t\tAND visibility = 1"; # print $sql_tribes; # exit; $rs = $core->con->select($sql_tribes); if ($rs->f('user_id') != "root") { if (!$core->hasPermission('administration')) { if (!$core->auth->sessionExists() || $core->auth->userID() != $rs->f('user_id')) { return ""; } } } $tribe_name = $rs->f('tribe_name'); $tribe_search = $rs->f('tribe_search'); //getArrayFromList($rs->tribe_search); if ($search != '') { $tribe_search = $search; } $tribe_tags = getArrayFromList($rs->f('tribe_tags')); $tribe_notags = getArrayFromList($rs->f('tribe_notags')); $tribe_users = getArrayFromList($rs->f('tribe_users')); $tribe_nousers = getArrayFromList($rs->f('tribe_nousers')); $align = $align == 'right' ? 'left' : 'right'; $count = true; if ($nb_items > 0) { $count = false; // we just need to count the number of posts } // Generating the SQL request return generate_SQL($num_start, $nb_items, $tribe_users, $tribe_tags, $tribe_search, null, $popular, null, 1, $count, $tribe_notags, $tribe_nousers); }
$output .= "</ul>"; print '<div class="flash_error">' . $output . '</div>'; } else { print '<div class="flash_notice">' . $output . '</div>'; } break; ########################################################## # Add tags to post ########################################################## ########################################################## # Add tags to post ########################################################## case 'add_tags': $post_id = $_POST['post_id']; $user_id = $core->auth->userID(); $tags = getArrayFromList($_POST['tags']); $sql = "SELECT tag_id\n\t\t\tFROM " . $core->prefix . "post_tag\n WHERE post_id = " . $post_id . ";"; $rs = $core->con->select($sql); while ($rs->fetch()) { if (in_array($rs->tag_id, $tags)) { $key = array_keys($tags, $rs->tag_id); unset($tags[$key]); } } $output .= T_("Tags added : "); foreach ($tags as $tag) { $cur = $core->con->openCursor($core->prefix . 'post_tag'); $cur->post_id = $post_id; $cur->tag_id = $tag; $cur->user_id = $user_id; $cur->created = array(' NOW() ');