<commit_before><?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_connect extends pfcCommand
{
  function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid)
  {
    $c =& $this->c;
    $u =& $this->u;

    // disconnect last connected users from the server if necessary 
    $container =& $c->getContainerInstance();
    $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout);

    // reset the message id indicator (see getnewmsg.class.php)
    // i.e. be ready to re-get all last posted messages
    require_once(dirname(__FILE__)."/join.class.php");
    foreach($u->channels as $chan)
    {
      $channame  = $chan["name"];
      $chanrecip = pfcCommand_join::GetRecipient($channame);
      $chanid    = pfcCommand_join::GetRecipientId($channame);
      // reset the fromid flag
      $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$chanid;
      $from_id     = $container->getLastId($chanrecip)-$c->max_msg;
      $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id;
      // reset the oldmsg flag
      $oldmsg_sid = $c->prefix."oldmsg_".$c->getId()."_".$clientid."_".$chanid;
      $_SESSION[$oldmsg_sid] = true;
    }
    
    // check if the user is alone on the server, and give it the admin status if yes
    $isadmin = $c->isadmin;
    if (!$isadmin)
    {
      $users = $container->getOnlineNick(NULL);
      if (count($users["nickid"]) == 0) $isadmin = true;<commit_msg>Bug fix: when this is the first connection, the u->channels is empty, to setup the oldmsg flag, c->channels must be used<commit_after><?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_connect extends pfcCommand
{
  function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid)
  {
    $c =& $this->c;
    $u =& $this->u;

    // disconnect last connected users from the server if necessary 
    $container =& $c->getContainerInstance();
    $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout);

    // reset the message id indicator (see getnewmsg.class.php)
    // i.e. be ready to re-get all last posted messages
    require_once(dirname(__FILE__)."/join.class.php");
    $channels = array();
    if (count($u->channels) == 0)
      $channels = $c->channels;
    else
      foreach($u->channels as $chan)
        $channels[] = $chan["name"];
    foreach($channels as $channame)
    {
      $chanrecip = pfcCommand_join::GetRecipient($channame);
      $chanid    = pfcCommand_join::GetRecipientId($channame);
      // reset the fromid flag
      $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$chanid;
      $from_id     = $container->getLastId($chanrecip)-$c->max_msg;
      $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id;
      // reset the oldmsg flag
      $oldmsg_sid = $c->prefix."oldmsg_".$c->getId()."_".$clientid."_".$chanid;
      $_SESSION[$oldmsg_sid] = true;
    }
    
    // check if the user is alone on the server, and give it the admin status if yes
    $isadmin = $c->isadmin;
    if (!$isadmin)
    {
      $users = $container->getOnlineNick(NULL);
      if (count($users["nickid"]) == 0) $isadmin = true;
{'fraction_non_alphanumeric': 0.16521197007481297, 'fraction_numerical': 0.0021820448877805485, 'mean_word_length': 3.2901069518716577, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4799016', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1074, 'n_words': 240}