Changeset 4 for www/sunrisechat


Ignore:
Timestamp:
Jan 14, 2008, 9:48:39 PM (17 years ago)
Author:
george
Message:

Upraveno: Změna přístupu k databázi na třídu rozšířenou mysqli.
Upraveno: Sjednocení
Upraveno: Změna kódování všech stránek na UTF-8.
Odstraňeno: Staré nepotřebné soubory.

Location:
www
Files:
4 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • www

    • Property svn:ignore set to
      config.php
      php_script_error.log
  • www/sunrisechat/code.php

    r1 r4  
    1 <?
     1<?php
    22/*
    33  ISO8859-2 <-> UTF-8 conversion functions designed for use in PHP-GTK apps
  • www/sunrisechat/history.php

    r1 r4  
    1 <?
    2   include_once('../is/db.php');
    3   include_once('../style.php');
    4   include_once('../global.php');
     1<?php
     2
     3include_once('../global.php');
     4include_once('../style.php'); 
     5ShowHeader('Výpis z historie SunriseChatu','Historie Sunrisechatu');
     6
     7if(array_key_exists('date',$_GET)) $Date = $_GET['date']; else $Date = date('Y-m-d');
     8$DateParts = explode('-',$Date);
    59 
    6   DB_Init('localhost','root','','is');
    7   DB_Query('SET CHARACTER SET latin2');
    8   ShowHeader('Výpis z historie SunriseChatu','Historie Sunrisechatu');
    9 
    10   if(array_key_exists('date',$_GET)) $Date = $_GET['date']; else $Date = date('Y-m-d');
    11   $DateParts = explode('-',$Date);
     10$DbResult = $Database->select('sunrisechat_history','MAX(time),MIN(time)');
     11$RowTotal = $DbResult->fetch_array();
    1212 
    13   DB_Select('sunrisechat_history','MAX(time),MIN(time)');
    14   $RowTotal = DB_Row();
     13$StartDateTimeParts = explode(' ',$RowTotal['MIN(time)']);
     14$StartDateParts = explode('-',$StartDateTimeParts[0]);
     15$EndDateTimeParts = explode(' ',$RowTotal['MAX(time)']);
     16$EndDateParts = explode('-',$EndDateTimeParts[0]);
    1517 
    16   $StartDateTimeParts = explode(' ',$RowTotal['MIN(time)']);
    17   $StartDateParts = explode('-',$StartDateTimeParts[0]);
    18   $EndDateTimeParts = explode(' ',$RowTotal['MAX(time)']);
    19   $EndDateParts = explode('-',$EndDateTimeParts[0]);
     18function dechexr($Num)
     19{
     20  $Num = dechex($Num);
     21  return(substr($Num,4,2).substr($Num,2,2).substr($Num,0,2));
     22}
    2023 
    21   function dechexr($Num)
     24echo('<div style="font-size: small;">');
     25for($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
     26{
     27  echo('<div style="border-style: solid; border-bottom-color: gray; border-width: 0 0 1 0; margin-bottom: 3px; padding-bottom: 2px;">'.$Year.'</div>
     28  <div style="margin-left: 15px; margin-right: 15px;">');
     29  if($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1]+0); else $StartMonth = 1;
     30  if($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1]+0); else $EndMonth = 12;
     31  for($Month = $EndMonth; $Month >= $StartMonth; $Month--)
    2232  {
    23     $Num = dechex($Num);
    24     return(substr($Num,4,2).substr($Num,2,2).substr($Num,0,2));
    25   }
    26  
    27   echo('<div style="font-size: small;">');
    28   for($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
    29   {
    30     echo('<div style="border-style: solid; border-bottom-color: gray; border-width: 0 0 1 0; margin-bottom: 3px; padding-bottom: 2px;">'.$Year.'</div>
    31     <div style="margin-left: 15px; margin-right: 15px;">');
    32     if($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1]+0); else $StartMonth = 1;
    33     if($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1]+0); else $EndMonth = 12;
    34     for($Month = $EndMonth; $Month >= $StartMonth; $Month--)
    35     {
    3633//      echo('<div><span>');
    37       echo('<div style="border-style: solid; border-bottom-color: gray; border-width: 0 0 1 0; margin-bottom: 3px; padding-bottom: 2px;">'.$MonthNames[$Month].'
    38       <span style="position: absolute; left: 100px;">');
    39       if(($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
    40       if(($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
    41       for($Day = $StartDay; $Day <= $EndDay; $Day++)
    42       {
     34    echo('<div style="border-style: solid; border-bottom-color: gray; border-width: 0 0 1 0; margin-bottom: 3px; padding-bottom: 2px;">'.$MonthNames[$Month].'
     35    <span style="position: absolute; left: 100px;">');
     36    if(($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
     37    if(($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
     38    for($Day = $StartDay; $Day <= $EndDay; $Day++)
     39    {
    4340//        $Date = $Year.'-'.$Month.'-'.$Day;
    4441        //DB_Select('sunrisechat_history','COUNT(*)',"roomtype=0 AND time>'".$Date." 00:00:00' AND time<'".$Date." //23:59:59'");
    4542  //      $CR = DB_Row();
    4643//        $Text = '<a href="history.php?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'('.$CR['COUNT(*)'].')</a> ';
    47         $Text = '<a href="history.php?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> ';
    48         flush();
    49         if(($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong style="border-style: solid; border-width: 1; border-color: black; padding-left: 3px;">'.$Text.'</strong>';
    50         echo($Text);
    51       }
    52       echo('</span></div>');
     44      $Text = '<a href="history.php?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> ';
     45      flush();
     46      if(($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong style="border-style: solid; border-width: 1; border-color: black; padding-left: 3px;">'.$Text.'</strong>';
     47      echo($Text);
    5348    }
    54     echo('</div>');
     49    echo('</span></div>');
    5550  }
    5651  echo('</div>');
     52}
     53echo('</div>');
     54
     55$DbResult = $Database->select('sunrisechat_history','nick,color,text,UNIX_TIMESTAMP(time)',"roomtype=0 AND time>'".$Date." 00:00:00' AND time<'".$Date." 23:59:59' ORDER BY time DESC");
     56//echo('Výpis posledních 100 zpráv:<br>');
     57echo('<div style="font-size: small;">');
     58while($Row = $DbResult->fetch_array())
     59{
     60  $Text = $Row['text'];;
     61  // StrTr($Row['text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     62  echo('['.date('d.m.Y H:i:s',$Row['UNIX_TIMESTAMP(time)']).'] <span style="color: #'.dechexr($Row['color']).'"><strong>&lt;'.$Row['nick'].'&gt;</strong> '.(htmlspecialchars($Text)).'</span><br>');
     63  flush();
     64}
     65echo('</div>');
    5766 
    58     DB_Select('sunrisechat_history','nick,color,text,UNIX_TIMESTAMP(time)',"roomtype=0 AND time>'".$Date." 00:00:00' AND time<'".$Date." 23:59:59' ORDER BY time DESC");
    59     //echo('Výpis posledních 100 zpráv:<br>');
    60     echo('<div style="font-size: small;">');
    61     while($Row = DB_Row())
    62     {
    63       $Text = $Row['text'];;
    64       // StrTr($Row['text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
    65       echo('['.date('d.m.Y H:i:s',$Row['UNIX_TIMESTAMP(time)']).'] <span style="color: #'.dechexr($Row['color']).'"><strong>&lt;'.$Row['nick'].'&gt;</strong> '.(htmlspecialchars($Text)).'</span><br>');
    66       flush();
    67     }
    68     echo('</div>');
    69  
    70   ShowFooter();
     67ShowFooter();
    7168?>
  • www/sunrisechat/network.php

    r1 r4  
    1 <?
    2   include_once('../is/db.php');
    3   include_once('../global.php');
    4   include_once('code.php');
    5   DB_Init('localhost','root','','is');
    6   DB_Query('SET CHARACTER SET latin2');
     1<?php
    72
    8   //include_once('../style.php');
    9   //ShowHeader('Obsah souboru Network.cfg Sunrisechatu','Soubor testu sítì Sunrisechatu');
     3include_once('../global.php');
     4include_once('code.php');
    105
    11   $User = array(0 => array('fullname' => ''));
    12   DB_Select('users','*');
    13   while($Row = DB_Row())
    14   {
    15     $User[$Row['id']] = $Row;
    16   }
     6$User = array(0 => array('fullname' => ''));
     7$DbResult = $Database->select('users', '*');
     8while($Row = $DbResult->fetch_array())
     9{
     10  $User[$Row['id']] = $Row;
     11}
    1712
    18   DB_Select('hosts','*','1 ORDER BY id');
    19   while($Row = DB_Row())
    20   {
    21     $Row = $Row['id'].':'.$Row['parent'].':'.$Row['name'].':'.$Row['IP'].':'.$User[$Row['user']]['fullname'].':'.$Row['block']."\n";
    22     $Row = StrTr($Row, "\xA9\xAB\xAE\xB9\xBB\xBE", "\x8A\x8D\x8E\x9A\x9D\x9E");
    23     echo($Row);
    24   }
     13$DbResult = $Database->select('hosts','*','1 ORDER BY id');
     14while($Row = $DbResult->fetch_array())
     15{
     16  $Row = $Row['id'].':'.$Row['parent'].':'.$Row['name'].':'.$Row['IP'].':'.$User[$Row['user']]['fullname'].':'.$Row['block']."\n";
     17  $Row = StrTr($Row, "\xA9\xAB\xAE\xB9\xBB\xBE", "\x8A\x8D\x8E\x9A\x9D\x9E");
     18  echo($Row);
     19}
    2520 
    26   //ShowFooter();
    2721?>
  • www/sunrisechat/sunrisechat.php

    r1 r4  
    1 <?
    2   include_once('/a/html/is/db.php');
    3   DB_Init('localhost','root','','is');
    4   DB_Query('SET CHARACTER SET latin2');
     1<?php
     2
     3include_once('../global.php');
     4include_once('webchatsend.php');
    55 
    6   $Text2 = getenv('sunrisechat');
     6$Debug = 0;
     7 
     8function Packet($Text2)
     9{
     10  global $Debug, $Database;
     11  //echo("{".$Text2."}".ord($Text2[1]).".".strlen($Text2)."\n");
     12  //echo($Text2.strlen($Text2)."\n");
    713  $Text = StrTr($Text2, "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     14  if(strlen($Text) > 1)
     15  {
    816  $Parts = explode('|',$Text);
     17  $TargetIP = $Parts[1];
     18  $TargetID = $Parts[2];
    919  $SenderIP = $Parts[3];
    1020  $SenderID = $Parts[4];
     
    1626    $RoomName = $Parts[9];
    1727    $RoomType = $Parts[10];
    18     echo('Message: '.$Text);
    19     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    20     if(DB_NumRows()>0)
     28    if($Debug == 1) echo('Message: '.$Text."\n");
     29    $DbResult = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     30    if($DbResult->num_rows > 0)
    2131    {
    22       $Row = DB_Row();
     32      $Row = $DbResult->fetch_array();
    2333      $Nick = $Row['nick'];
    2434    } else $Nick = '';
    25     DB_Insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => addslashes($Nick), 'text' => addslashes(htmlspecialchars($Text)), 'color' => $Color,
     35    echo('<'.$Nick.'>'.$Text." ".addslashes($Text)."\n");
     36    $Database->insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => $Nick, 'text' => $Text, 'color' => $Color,
    2637    'roomname' => $RoomName, 'roomtype' => $RoomType));
     38  }
     39  if($Command == 'Alive')
     40  {
     41    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     42    if($DbResult->num_rows() > 0)
     43    {
     44      $Row = $DbResult->fetch_array();
     45      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()'));
     46    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID)); 
     47  }
     48  if($Command == 'GoOnline')
     49  {
     50    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     51    if($DbResult->num_rows() > 0)
     52    {
     53      $Row = $DbResult->fetch_array();
     54      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Online'));
     55    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Online')); 
     56  }
     57  if($Command == 'GoAway')
     58  {
     59    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     60    if($DbResult->num_rows() > 0)
     61    {
     62      $Row = $DbResult->fetch_array();
     63      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Away'));
     64    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Away')); 
    2765  }
    2866  if($Command == 'UserInfo')
    2967  {
    3068    $Nick = $Parts[7];
    31     echo('UserInfo: '.$Nick);
    32     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    33     if(DB_NumRows()>0)
     69    echo('UserInfo: '.$Nick."\n");
     70    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     71    if($DbResult->num_rows() > 0)
    3472    {
    35       $Row = DB_Row();
    36       DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick));
    37     } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID));
     73      $Row = $DbResult->fetch_array();
     74      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
     75    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
    3876  }
     77  if($Command == 'WhoIs')   // for WebSunriseChat support
     78  {
     79    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$TargetID.' AND sender_ip="'.$TargetIP.'" AND operating_system="Fedora Core 2"');
     80    if($DbResult->num_rows() > 0)
     81    {
     82      $Row = $DbResult->fetch_array();
     83      $_SESSION['DetailInfo'] = $Row['info'];
     84      $Nick = $Row['nick'];
     85      $_SESSION['nick'] = $Nick;
     86      $_SESSION['IP'] = $Row['sender_ip'];
     87      $_SESSION['ID'] = $Row['sender_id'];
     88      $_SESSION['sequence'] = $Row['sequence'];
     89      Send('UserInfo','');
     90      if($Debug == 1) echo('UserInfo: '.$Nick."\n");
     91    }
     92  }
     93  }
     94  //DB_Select('sunrisechat_onlinelist','UNIX_TIMESTAMP(lasttime)');
     95  //$Row = DB_Row();
     96  //echo($Row[0]-(time()-200)."\n");
     97  DB_Delete('sunrisechat_onlinelist','UNIX_TIMESTAMP(lasttime)<'.(time()-30));
     98}
     99
     100$Filename = '/tmp/sunrisechatout';
     101$Filename2 = '/tmp/sunrisechatin';
     102$File2 = fopen($Filename2,'w');
     103while(1)
     104{
     105  if(file_exists($Filename))
     106  {
     107    $File = fopen($Filename,'r');
     108    $Data = fread($File,65000);
     109    fclose($File);
     110    unlink($Filename);
     111    //echo($Data);
     112    $Rows = explode("\n",$Data);
     113    array_pop($Rows);
     114    foreach($Rows as $Item)
     115    { 
     116      Packet($Item); 
     117      //echo($Item."\n");
     118    }
     119  }
     120  sleep(5);
     121}
    39122
    40123?>
  • www/sunrisechat/sunrisechat2.php

    r1 r4  
    1 <?
     1<?php
    22
    3 include_once('/a/html/is/db.php');
    4 include_once('/a/html/sunrisechat/webchatsend.php');
    5 DB_Init('localhost','root','','is');
    6 DB_Query('SET NAMES latin2');
     3include_once('../global.php');
     4include_once('webchatsend.php');
    75 
    86$Debug = 0;
     
    108function Packet($Text2)
    119{
    12   global $Debug;
     10  global $Debug, $Database;
    1311  //echo("{".$Text2."}".ord($Text2[1]).".".strlen($Text2)."\n");
    1412  //echo($Text2.strlen($Text2)."\n");
     
    2927    $RoomType = $Parts[10];
    3028    if($Debug == 1) echo('Message: '.$Text."\n");
    31     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    32     if(DB_NumRows()>0)
     29    $DbResult = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     30    if($DbResult->num_rows > 0)
    3331    {
    34       $Row = DB_Row();
     32      $Row = $DbResult->fetch_array();
    3533      $Nick = $Row['nick'];
    3634    } else $Nick = '';
    3735    echo('<'.$Nick.'>'.$Text." ".addslashes($Text)."\n");
    38     DB_Insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => $Nick, 'text' => $Text, 'color' => $Color,
     36    $Database->insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => $Nick, 'text' => $Text, 'color' => $Color,
    3937    'roomname' => $RoomName, 'roomtype' => $RoomType));
    4038  }
    4139  if($Command == 'Alive')
    4240  {
    43     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    44     if(DB_NumRows()>0)
     41    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     42    if($DbResult->num_rows() > 0)
    4543    {
    46       $Row = DB_Row();
    47       DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()'));
    48     } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID)); 
     44      $Row = $DbResult->fetch_array();
     45      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()'));
     46    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID)); 
    4947  }
    5048  if($Command == 'GoOnline')
    5149  {
    52     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    53     if(DB_NumRows()>0)
     50    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     51    if($DbResult->num_rows() > 0)
    5452    {
    55       $Row = DB_Row();
    56       DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Online'));
    57     } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Online')); 
     53      $Row = $DbResult->fetch_array();
     54      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Online'));
     55    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Online')); 
    5856  }
    5957  if($Command == 'GoAway')
    6058  {
    61     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    62     if(DB_NumRows()>0)
     59    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     60    if($DbResult->num_rows() > 0)
    6361    {
    64       $Row = DB_Row();
    65       DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Away'));
    66     } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Away')); 
     62      $Row = $DbResult->fetch_array();
     63      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Away'));
     64    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Away')); 
    6765  }
    6866  if($Command == 'UserInfo')
     
    7068    $Nick = $Parts[7];
    7169    echo('UserInfo: '.$Nick."\n");
    72     DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
    73     if(DB_NumRows()>0)
     70    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');
     71    if($DbResult->num_rows() > 0)
    7472    {
    75       $Row = DB_Row();
    76       DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
    77     } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
     73      $Row = $DbResult->fetch_array();
     74      $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
     75    } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'operating_system' => $Parts[12], 'status' => $Parts[10]));
    7876  }
    7977  if($Command == 'WhoIs')   // for WebSunriseChat support
    8078  {
    81     DB_Select('sunrisechat_onlinelist','*','sender_id='.$TargetID.' AND sender_ip="'.$TargetIP.'" AND operating_system="Fedora Core 2"');
    82     if(DB_NumRows()>0)
     79    $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$TargetID.' AND sender_ip="'.$TargetIP.'" AND operating_system="Fedora Core 2"');
     80    if($DbResult->num_rows() > 0)
    8381    {
    84       $Row = DB_Row();
     82      $Row = $DbResult->fetch_array();
    8583      $_SESSION['DetailInfo'] = $Row['info'];
    8684      $Nick = $Row['nick'];
  • www/sunrisechat/webchat.php

    r1 r4  
    1 <?
    2 session_start();
     1<?php
     2include_once('../global.php');
    33include_once('../style.php');
    44ShowHeader('Okno Sunrisechatu','Sunrisechatu');
    5 
    6 include_once('/a/html/is/db.php');
    7 DB_Init('localhost','root','','is');
    8 DB_Query('SET CHARACTER SET latin2');
    95
    106include_once('webchatsend.php');
     
    1713  Send('Disconnect','');
    1814  session_unregister('nick');
    19   echo('Byl jste odhlá¹en.<br>');
     15  echo('Byl jste odhlášen.<br>');
    2016}
    2117
    2218if(array_key_exists('nick',$_POST))
    2319{
    24   DB_Select('sunrisechat_onlinelist','*'," nick='".$_POST['nick']."'");
    25   if(DB_NumRows()==0)
     20  $DbResult = $Database->select('sunrisechat_onlinelist','*'," nick='".$_POST['nick']."'");
     21  if($DbResult->num_rows == 0)
    2622  {
    2723    $_SESSION['nick'] = $_POST['nick'];
     
    2925    Send('UserInfo','');
    3026    Send('Connect','');
    31   } else echo('Pøezdívka ji¾ pou¾ita! Zvolte jinou pøezdívku.');
     27  } else echo('Přezdívka již použita! Zvolte jinou přezdívku.');
    3228}
    3329
     
    4541  <tr><td>Výpis diskuse:<br>
    4642  <IFRAME MARGINWIDTH="0" MARGINHEIGHT="0" src="webchatframe.php?nick='.$_SESSION['nick'].'" width="100%" height="405" frameborder="0"></IFRAME>
    47   </td><td width="150">U¾ivatelé:<br>
     43  </td><td width="150">Uživatelé:<br>
    4844  <IFRAME MARGINWIDTH="0" MARGINHEIGHT="0" src="webchatframe2.php?nick='.$_SESSION['nick'].'" width="100%" height="405" frameborder="0"></IFRAME>
    4945  </td></tr><tr><td>
     
    5854  <table style="border-color: black; border-size: 1px; border-style: solid;" align="center">
    5955  <tr><th colspan="2">WebSunriseChat</th></tr>
    60   <tr><td align="center">Pøezdívka:</td><td><input type="text" name="nick" size="20"></td></tr>
     56  <tr><td align="center">Přezdívka:</td><td><input type="text" name="nick" size="20"></td></tr>
    6157  <tr><td align="center">Celé jméno:</td><td><input type="text" name="name" size="20"></td></tr>
    6258  <tr><td align="center" colspan="2"><input type="submit" value="Vstoupit"></td></tr>
  • www/sunrisechat/webchatframe.php

    r1 r4  
    1 <?
    2   header('Refresh: 5');
    3   session_start();
     1<?php
     2include('../global.php');
     3header('Refresh: 5');
    44 
    5   echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     5echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    66<html><head><title>Chat frame</title>
    7   <meta http-equiv="Content-Language" content="cs">
    8   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
    9   </head><body>');
     7<meta http-equiv="Content-Language" content="cs">
     8<meta http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
     9</head><body>');
    1010 
    11   if(array_key_exists('nick',$_GET))
    12   {
    13     $_SESSION['nick'] = $_GET['nick']; 
    14     include_once('webchatsend.php');
    15     Send('Alive',''); 
    16   }
    17  
    18   include_once('/a/html/is/db.php');
    19   DB_Init('localhost','root','','is');
    20   DB_Query('SET CHARACTER SET latin2');
     11if(array_key_exists('nick',$_GET))
     12{
     13  $_SESSION['nick'] = $_GET['nick']; 
     14  include_once('webchatsend.php');
     15  Send('Alive',''); 
     16}
    2117 
    22   $List = array();
    23   echo('<table style="height: 100; font-family: Arial;" width="100%" cellspacing="0" cellpadding="2" border="1" bgcolor="#d0d0d0"><tr><td bgcolor="#ffffff" width="90%" valign="top" style="font-size: 14px;">');
     18$List = array();
     19echo('<table style="height: 100; font-family: Arial;" width="100%" cellspacing="0" cellpadding="2" border="1" bgcolor="#d0d0d0"><tr><td bgcolor="#ffffff" width="90%" valign="top" style="font-size: 14px;">');
    2420
    25   DB_Select('sunrisechat_history','*,UNIX_TIMESTAMP(time)',' roomtype=0 ORDER BY time DESC LIMIT 0,24');
    26   while($List[] = DB_Row());
    27   array_pop($List);
    28   $List = array_reverse($List);
    29   foreach($List as $Row)
    30   {
    31     $Text = htmlspecialchars($Row['text']);
    32     if(substr($Text,0,strlen($_SESSION['nick'])) == $_SESSION['nick']) $Text = '<strong>&lt;'.$Row['nick'].'&gt; '.$Text.'</strong>';
    33     else $Text = '&lt;'.$Row['nick'].'&gt; '.$Text;
    34     echo('['.date('H:i:s',$Row['UNIX_TIMESTAMP(time)']).'] <span style="color: #'.dechex($Row['color']).'">'.$Text.'</span><br>');
    35   }
    36   echo('</td></tr></table>
    37   </body></html>');
     21$DbResult = $Database->select('sunrisechat_history','*,UNIX_TIMESTAMP(time)',' roomtype=0 ORDER BY time DESC LIMIT 0,24');
     22while($List[] = $DbResult->fetch_array());
     23array_pop($List);
     24$List = array_reverse($List);
     25foreach($List as $Row)
     26{
     27  $Text = htmlspecialchars($Row['text']);
     28  if(substr($Text,0,strlen($_SESSION['nick'])) == $_SESSION['nick']) $Text = '<strong>&lt;'.$Row['nick'].'&gt; '.$Text.'</strong>';
     29  else $Text = '&lt;'.$Row['nick'].'&gt; '.$Text;
     30  echo('['.date('H:i:s',$Row['UNIX_TIMESTAMP(time)']).'] <span style="color: #'.dechex($Row['color']).'">'.$Text.'</span><br>');
     31}
     32echo('</td></tr></table>
     33</body></html>');
    3834?>
  • www/sunrisechat/webchatframe2.php

    r1 r4  
    1 <?
    2   header('Refresh: 5');
    3   session_start();
     1<?php
     2include('../global.php');
     3header('Refresh: 5');
    44 
    5   echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     5echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    66<html><head><title>User list</title>
    7   <meta http-equiv="Content-Language" content="cs">
    8   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
    9   </head><body>');
     7<meta http-equiv="Content-Language" content="cs">
     8<meta http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
     9</head><body>');
    1010 
    11   if(array_key_exists('nick',$_GET))
    12   {
    13     $_SESSION['nick'] = $_GET['nick']; 
    14     include_once('webchatsend.php');
    15     Send('Alive',''); 
    16   }
    17  
    18   include_once('/a/html/is/db.php');
    19   DB_Init('localhost','root','','is');
    20   DB_Query('SET CHARACTER SET latin2');
     11if(array_key_exists('nick',$_GET))
     12{
     13  $_SESSION['nick'] = $_GET['nick']; 
     14  include_once('webchatsend.php');
     15  Send('Alive',''); 
     16}
    2117 
    22   $List = array();
    23   echo('<table style="height: 100%; font-family: Arial;" width="100%" cellspacing="0" cellpadding="2" border="1" bgcolor="#d0d0d0"><tr>
    24   <td bgcolor="#ffffff" valign="top" width="10%" style="font-size: 14px;">');
    25   DB_Select('sunrisechat_onlinelist','*');
    26   while($Row = DB_Row())
    27   {
    28     if($Row['status'] == 'Away') echo('<img src="images/UserNotAvailable.png" alt="away icon">');
    29     else if($Row['status'] == 'Writting') echo('<img src="images/UserWritting.png" alt="writting icon">');
    30     else echo('<img src="images/UserOnline.png" alt="online icon">');
    31     echo($Row['nick'].'<br>');
    32   }
    33   echo('</td></tr></table>
    34   </body></html>');
     18$List = array();
     19echo('<table style="height: 100%; font-family: Arial;" width="100%" cellspacing="0" cellpadding="2" border="1" bgcolor="#d0d0d0"><tr>
     20<td bgcolor="#ffffff" valign="top" width="10%" style="font-size: 14px;">');
     21$DbResult = $Database->select('sunrisechat_onlinelist','*');
     22while($Row = $DbResult->fetch_array())
     23{
     24  if($Row['status'] == 'Away') echo('<img src="images/UserNotAvailable.png" alt="away icon">');
     25  else if($Row['status'] == 'Writting') echo('<img src="images/UserWritting.png" alt="writting icon">');
     26  else echo('<img src="images/UserOnline.png" alt="online icon">');
     27  echo($Row['nick'].'<br>');
     28}
     29echo('</td></tr></table>
     30</body></html>');
     31
    3532?>
  • www/sunrisechat/webchatsend.php

    r1 r4  
    1 <?
     1<?php
    22
    33function AddPart($Text)
     
    3737    AddPart($Color);        // User text color
    3838    AddPart($Text);                   // Command data
    39     $RoomName = 'V¹ichni';
     39    $RoomName = 'Všichni';
    4040    AddPart($RoomName);               // Room name
    4141    AddPart(0); // Public or private room
Note: See TracChangeset for help on using the changeset viewer.