Просмотр файла magmail/editMess.php

Размер файла: 6.05Kb
<?
                    
require("functionChat.ssp");

function loadoptions($id)
{
  openDB();
  $sqlSel="select url,status from www where id='$id'";
  $result=mysql_query($sqlSel) or die(mysql_error()); 
  $CountUsers=mysql_num_rows($result);
  If ($CountUsers != 1) return false;
  // Нет такой записи в БД
  $url = mysql_result($result,0,"url");
  $status = mysql_result($result,0,"status");
  mysql_close();
  return true;
}  


function InsertLinks($s,$login,$pass)
{
global $url, $status, $menu;
  $w = "[:alnum:]";
  $s = preg_replace( "/\s(http:\/\/[^\s]+)/is", " <a href=\"\\1\">\\1 </a>", " ".$s); 
  $s = preg_replace( "/(\s)(wap\.[^\s]+)/is", "\\1<a href=\"http://\\2\">\\2 </a>", $s);
  
  $s = preg_replace("/\s([a-z0-9]+[-_\.a-z0-9]*@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4})/is", " <a href=\"/magmail/writeMess.php?to=\\1&amp;login=$login&amp;pass=$pass\">\\1 </a>", $s); 
  $magistr = "magistr";
  
  $s = preg_replace("/\*\*(\w+)/is"," <img src=\"/logos/magmail/\\1.wbmp\" alt=\"\\1\"/>",$s); // Картинки Mag-mail
  
  if (preg_match("/\slink=([\.\:\/\w]+)/is",$s,$match)==1)
  {
    if (strpos($match[1],".") !== false) 
      $s = preg_replace("/\slink=([\.\:\/\w]+)/is"," <a href=\"/$magistr/index.php?url=\\1\">\\1</a>",$s);
    else if (loadoptions($match[1]) and ($status==2 or $status==3))
    {
      $url = preg_replace("/&(?!amp;)/is","&amp;",$url);
      $s = preg_replace("/\slink=(\d+)/is"," <a href=\"/$magistr/index.php?link=\\1\">\\0</a>",$s);
    } else $s = preg_replace("/\slink=(\d+)/is"," [no link]",$s);
  }
  if (preg_match("/\sfoto=([a-zA-Z0-9_-]+)/is",$s,$match)==1)
  {
    $fotofn = "$match[1].jpg";
    if (!file_exists($GLOBALS["DOCUMENT_ROOT"]."/foto/$fotofn")) 
      $s = preg_replace("/\sfoto=([a-zA-Z0-9_-]+)/is"," [FOTO $match[1] - not found]",$s);  
    else $s = preg_replace("/\sfoto=([a-zA-Z0-9_-]+)/is"," <a href=\"show.php?foto=\\1&amp;login=$login&amp;pass=$pass\">\\0</a>",$s);       
  } 
  return substr($s,1);
} 

function del_utf($s)
{
  $i = 0;
  while ($i < strlen($s))
  {
    $chord1 = ord($s[$i]); 
    if (($chord1 > 127) && (($i+1) < strlen($s))) 
    {
      $i++;
      $chord2 = ord($s[$i]); 
      if (($chord1 < 208) || ($chord1 > 209) || (($chord1 == 208) && ($chord2!=129 && $chord2<144 && $chord2>191)) || (($chord1 == 209) && ($chord2!=145 && $chord2<128 && $chord2>143)))
      {
        $s[$i-1] = "^";
        $s[$i] = "?";
      }
    }
    $i++;
  }
  
  return str_replace("^?","?",$s);
} 


function callback($s)
{ // Обработка картинок
global $ErrorMess,$FileNotFound;
  if (!file_exists($GLOBALS["DOCUMENT_ROOT"]."/logos/magmail/".strtolower($s[1]).".wbmp"))
    LogResult($ErrorMess,$FileNotFound."<br/>".win2utf($s[1]),"prev");    
  return "**".strtolower($s[1]);
}  


$r = GetRandom();
 
if ($long)
{
  $log1 = "sendlong";
  $log2 = "addlong";
}
else
{
  $log1 = "send";
  $log2 = "startlong";
}
     

if (strpos(strtolower($tonick),"@computermag.ru") !== false)
{
  $to = substr($tonick,0,strpos($tonick,"@"));
}  
$email = (strpos($tonick,"@") !== false);
if ($email && !validEmail($tonick)) LogResult($ErrorMess,$InvEmail,"selnick.php?p=$r&amp;login=$login&amp;pass=$pass");

$messtype = $ReadType;


if ($email) 
{
  $subject=del_utf($subject);
  if ($usetrans!=0) $subject=ReplaceChar(trans(iconv("UTF-8","windows-1251",$subject)));
  else $subject=ReplaceChar(iconv("UTF-8","windows-1251",$subject));
  $subject=win2utf($subject);
} else $messtype = $UnReadType;
               
$mymess=del_utf($mymess);
if ($usetrans!=0) $mymess=ReplaceChar(trans(iconv("UTF-8","windows-1251",$mymess)));
else $mymess=ReplaceChar(iconv("UTF-8","windows-1251",$mymess));


preg_replace_callback("/\*\*(\w+)/is",'callback', $mymess);
$mymess = InsertLinks($mymess,$login,$pass);
$mymess=win2utf($mymess);

require("headerwml.ssp");

echo "<card id=\"$MagMail\" title=\"$menu[46]\">\n";

echo "<p align=\"center\">"; 

echo "$menu[22]:<br/>".NoClones($tonick)."<br/>\n";
if ($email) 
{
 echo "$menu[31]:<br/>";
 echo $subject;
 echo "<br/><input name=\"subject\" maxlength=\"40\" emptyok=\"true\" title=\"=\" type=\"text\"/>\n";
 echo "$menu[30]:<br/>";
}
 
echo "$mymess<br/>\n"; 
echo "<input name=\"mymess\" maxlength=\"200\" emptyok=\"true\" title=\"=\" type=\"text\"/>\n"; 


if (!$long) echo "</p><p><anchor>- $menu[21]";
else echo "</p><p><anchor>- $menu[38]";
echo "<go method=\"post\" href=\"addMess.php?p=$r&amp;login=$login&amp;pass=$pass\">\n";
echo "<postfield name=\"log\" value=\"$log1\"/>\n";
echo "<postfield name=\"messtype\" value=\"$messtype\"/>\n";
echo "<postfield name=\"toind\" value=\"$toid\"/>\n";
echo "<postfield name=\"tonick\" value=\"$tonick\"/>\n";
if ($email) {echo "<postfield name=\"subject\" value=\"$(subject)\"/>\n";}
echo "<postfield name=\"mymess\" value=\"$(mymess)\"/>\n";
echo "</go>\n";
echo "</anchor>\n";

if (!$long) echo "<br/><anchor>- $menu[40]";
else echo "<br/><anchor>- $menu[39]";
echo "<go method=\"post\" href=\"addMess.php?p=$r&amp;login=$login&amp;pass=$pass\">\n";
echo "<postfield name=\"log\" value=\"$log2\"/>\n";
echo "<postfield name=\"messtype\" value=\"$ReadType\"/>\n";
echo "<postfield name=\"toind\" value=\"0\"/>\n";
echo "<postfield name=\"tonick\" value=\"$tonick"."+"."\"/>\n";
echo "<postfield name=\"mymess\" value=\"$(mymess)\"/>\n";
echo "</go>\n";
echo "</anchor><br/>\n";

echo "<anchor>- $menu[45]";
echo "<go method=\"post\" href=\"editMess.php?p=$r&amp;login=$login&amp;pass=$pass&amp;tonick=$tonick&amp;usetrans=$usetrans\">\n";
echo "<postfield name=\"long\" value=\"$long\"/>\n";
echo "<postfield name=\"toid\" value=\"$toid\"/>\n";
if ($email) {echo "<postfield name=\"subject\" value=\"$(subject)\"/>\n";}
echo "<postfield name=\"mymess\" value=\"$(mymess)\"/>\n";
echo "</go>\n";
echo "</anchor>\n";
echo "<br/><a href=\"help19.php\">- Help</a>\n";

echo "<do type=\"prev\" label=\"$menu[2]\">\n";
echo "<go href=\"dispMess.php?p=$r&amp;page=old&amp;login=$login&amp;pass=$pass\"/>\n";
echo "</do>\n";

echo "</p>";
include ("bottom.inc");
?>