Changeset 872 for trunk


Ignore:
Timestamp:
Apr 9, 2017, 3:40:35 PM (8 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r867 r872  
    29452945}
    29462946
     2947function UpdateTo872($Manager)
     2948{       
     2949  // Allow to store IPv6 addresses
     2950  $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";');
     2951  $Manager->Execute('ALTER TABLE `UserTrace` CHANGE `LastLogin` `LastLogin` DATETIME NULL;');
     2952  $Manager->Execute('ALTER TABLE `UserTrace` CHANGE `LastLogout` `LastLogout` DATETIME NULL;');
     2953  $Manager->Execute('UPDATE `UserTrace` SET LastLogin=NULL WHERE CAST(LastLogin AS CHAR(20))="0000-00-00 00:00:00"');
     2954  $Manager->Execute('UPDATE `UserTrace` SET LastLogout=NULL WHERE CAST(LastLogout AS CHAR(20))="0000-00-00 00:00:00"');
     2955  $Manager->Execute('ALTER TABLE `UserTrace` CHANGE `LastIP` `LastIP` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;');
     2956}
     2957
    29472958class Updates
    29482959{
     
    29822993  849 => array('Revision' => 857, 'Function' => 'UpdateTo857'),
    29832994  857 => array('Revision' => 867, 'Function' => 'UpdateTo867'),
     2995  867 => array('Revision' => 872, 'Function' => 'UpdateTo872'),
    29842996    ));
    29852997  }
  • trunk/Application/Version.php

    r869 r872  
    77
    88$Version = '1.0';
    9 $Revision = 869; // Subversion revision
    10 $DatabaseRevision = 867; // Database structure revision
    11 $ReleaseDate = strtotime('2016-02-06');
     9$Revision = 872; // Subversion revision
     10$DatabaseRevision = 872; // Database structure revision
     11$ReleaseDate = strtotime('2017-04-09');
  • trunk/includes/Global.php

    r862 r872  
    541541}
    542542
    543 function GetTranslatNames($Text,$mode,$TablesColumn, $FirstBig = True)
     543function GetTranslatNames($Text, $mode, $TablesColumn, $FirstBig = True)
    544544{
    545545  global $System, $Config;
     
    551551  'areatrigger_teleport' => 'Name',
    552552  'areatrigger_tavern' => 'Name',); */
    553     $buff = array();
    554 
    555     //change chars by we want to separate
    556     $Text = str_replace('$B$B',' ',$Text);
    557     $Text = str_replace('$b$b',' ',$Text);
    558     $Text = str_replace('$G',' ',$Text);
    559     $Text = str_replace('$I',' ',$Text);
    560     $Text = str_replace('$N',' ',$Text);
    561     $Text = str_replace('$R',' ',$Text);
    562     $Text = str_replace('$g',' ',$Text);
    563     $Text = str_replace('$i',' ',$Text);
    564     $Text = str_replace('$n',' ',$Text);
    565     $Text = str_replace('$r',' ',$Text);
    566     $Text = str_replace(':',' ',$Text);
    567     $Text = str_replace(';',' ',$Text);
    568     $Text = str_replace('!',' ',$Text);
    569     $Text = str_replace('?',' ',$Text);
    570     $Text = str_replace('.',' ',$Text);
    571     $Text = str_replace(',',' ',$Text);
    572     $Text = str_replace('\'s',' ',$Text);
    573     $Text = str_replace('<',' ',$Text);
    574     $Text = str_replace('>',' ',$Text);
    575     $ArrStr = explode(' ', $Text);
    576     $sqlall = '';
     553  $buff = array();
     554
     555  // change chars by we want to separate
     556  $Text = str_replace('$B$B', ' ', $Text);
     557  $Text = str_replace('$b$b', ' ', $Text);
     558  $Text = str_replace('$G', ' ', $Text);
     559  $Text = str_replace('$I', ' ', $Text);
     560  $Text = str_replace('$N', ' ', $Text);
     561  $Text = str_replace('$R', ' ', $Text);
     562  $Text = str_replace('$g', ' ', $Text);
     563  $Text = str_replace('$i', ' ', $Text);
     564  $Text = str_replace('$n', ' ', $Text);
     565  $Text = str_replace('$r', ' ', $Text);
     566  $Text = str_replace(':', ' ', $Text);
     567  $Text = str_replace(';', ' ', $Text);
     568  $Text = str_replace('!', ' ', $Text);
     569  $Text = str_replace('?', ' ', $Text);
     570  $Text = str_replace('.', ' ', $Text);
     571  $Text = str_replace(',', ' ', $Text);
     572  $Text = str_replace('\'s', ' ', $Text);
     573  $Text = str_replace('<', ' ', $Text);
     574  $Text = str_replace('>', ' ', $Text);
     575  $ArrStr = explode(' ', $Text);
     576  $sqlall = '';
     577
    577578  foreach($TablesColumn as $Table => $Column)
    578579  {
    579580    $orderinby = ' ORDER BY ID DESC ';
    580     $sql = 'SELECT `ID`, (SELECT CONCAT(  \''.GetIDbyName($Table).'\' )) AS  `GoupId`,`'.$Column.'` AS Orig, (SELECT `'.$Column.'` FROM `'.$Table.'` AS `T` WHERE '.
    581       '(`O`.`Entry` = `T`.`Entry`) AND (`Language` <> '.$Config['OriginalLanguage'].') '.$orderinby.' LIMIT 1) AS `Tran` FROM `'.$Table.'` AS `O` WHERE ';
     581    $sql = 'SELECT `ID`, (SELECT CONCAT(\''.GetIDbyName($Table).'\' )) AS `GroupId`,`'.
     582      $Column.'` AS Orig, (SELECT `'.$Column.'` FROM `'.$Table.'` AS `T` WHERE '.
     583      '(`O`.`Entry` = `T`.`Entry`) AND (`Language` <> '.$Config['OriginalLanguage'].') '.
     584      $orderinby.' LIMIT 1) AS `Tran` FROM `'.$Table.'` AS `O` WHERE ';
    582585    $groupby = ' GROUP BY `'.$Column.'` ';
    583586
    584587    $where = '(`Language` = '.$Config['OriginalLanguage'].') ';
    585     if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))';
    586     if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))';
     588    if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.
     589      '` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].
     590      ') AND (`Sub`.`Entry` = `O`.`Entry`))';
     591    if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.
     592      '` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].
     593      ') AND (`Sub`.`Entry` = `O`.`Entry`))';
    587594    $where .= ' AND (';
    588     if (array_search('the' , $ArrStr)) $where .= '(`O`.`'.$Column.'` LIKE "The %") OR ';
     595    if (array_search('the', $ArrStr)) $where .= '(`O`.`'.$Column.'` LIKE "The %") OR ';
    589596
    590597    $SqlOK = false;
    591     if (count($ArrStr) > 0) {
    592       for($i = 0; $i < count($ArrStr); $i++)
     598    if (count($ArrStr) > 0)
     599    {
     600      for ($i = 0; $i < count($ArrStr); $i++)
    593601      {
    594 
    595         //find word only if is 3 characters and more, and if starts by upper char, and search only once
     602        // find word only if is 3 characters and more, and if starts by upper char, and search only once
    596603        if ((strlen($ArrStr[$i]) > 3) or ( ((count($ArrStr) < 6) or ($i == 0)) and (strlen($ArrStr[$i]) > 0) ) )  //length
    597           if ((!$FirstBig) or (ctype_upper(substr($ArrStr[$i],0,1))) or (count($ArrStr) < 6) )  //first big
    598             if (array_search($ArrStr[$i], $ArrStr) == $i) {  //first in array
     604          if ((!$FirstBig) or (ctype_upper(substr($ArrStr[$i], 0, 1))) or (count($ArrStr) < 6) )  //first big
     605            if (array_search($ArrStr[$i], $ArrStr) == $i)
     606            {  // first in array
    599607              $where .= '(`O`.`'.$Column.'` LIKE "'.addslashes($ArrStr[$i]).'%") OR ';
    600608              $SqlOK = true;
     
    604612      $where .= ')';
    605613    }
    606       if ($SqlOK) {
     614    if ($SqlOK)
     615    {
    607616        //$sql.$where.$groupby.$orderby
    608617//          $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']);
    609         if ($sqlall <> '') { $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )';}
     618      if ($sqlall <> '') { $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )';}
    610619        else {$sqlall .= ' ( '.$sql.$where.$groupby.' )'; }
    611       }
    612 
    613   }
    614     if ($SqlOK) {
    615         $orderby = ' ORDER BY LENGTH(Orig) DESC ';
    616       // echo $sqlall. $orderby;
    617         $DbResult = $System->Database->query($sqlall.$orderby);
     620    }
     621  }
     622  if ($SqlOK)
     623  {
     624    $orderby = ' ORDER BY LENGTH(Orig) DESC ';
     625    // echo $sqlall. $orderby;
     626    $DbResult = $System->Database->query($sqlall.$orderby);
    618627    //  echo ($sql.'|'.$where.'|'.$groupby);
    619         while($Line = $DbResult->fetch_assoc())
    620         {
    621           $buff[] = array($Line['ID'], $Line['GoupId'], $Line['Orig'], $Line['Tran']);
    622         }
    623     }
    624     return $buff;
     628    while($Line = $DbResult->fetch_assoc())
     629    {
     630      $buff[] = array($Line['ID'], $Line['GroupId'], $Line['Orig'], $Line['Tran']);
     631    }
     632  }
     633  return $buff;
    625634}
    626635
Note: See TracChangeset for help on using the changeset viewer.