За последние 24 часа нас посетили 22926 программистов и 1244 робота. Сейчас ищут 825 программистов ...

ошибка "syntax error", хотя правок в код не вносил

Тема в разделе "PHP для новичков", создана пользователем estadio, 6 сен 2011.

  1. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    Открыл файл в Notepad2, посмотрел, что хотел. Закрыл, возможно нажал сохранить, не помню. Но точно никаких изменений не вносил. Теперь вылезает ошибка Parse error: syntax error, unexpected $end in .../ec.php on line 1
    Еще до этого код был разбит по строчкам, а сейчас стало все сплошным текстом. Кодировка UTF-8.
    ЧТо это может быть? сам не силен в PHP, а наш программист в отпуске, помогите кто может, пожалуйста. вот код:

    PHP:
    1. <?php class economic_calendar{  var $c,$date,$filter='',$geo;   private $login='****',$password='******';       public function getMini(){      mysql_query("SET time_zone = '".$this->geo["TimeZone"]."'");        $this->dateStart=date('Y-m-d H:i:s',$this->geo["timestamp"]);       $q="SELECT q1.*,q2.title as cur_title,q2.currency as cur FROM `economic_calendar_event` q1 LEFT JOIN `economic_calendar_currency` q2 ON q1.currency_id=q2.currency WHERE q1.`time_actual` > '{$this->dateStart}' && `show` GROUP BY q1.id ORDER BY q1.time_actual ASC LIMIT 10";        $q=mysql_query($q,$this->c);        $result=array();        while($res=mysql_fetch_assoc($q)){          $result[substr($res["time_actual"],0,10)][]=$res;       }       $m=0;       echo '<style>       #economic-calendar-mini{width: 220px;}      #economic-calendar-mini table.table_economic_calendar_mini{width: 100%;border-collapse: collapse;}      #economic-calendar-mini table.table_economic_calendar_mini .none{color: #000;text-align: center;}       #economic-calendar-mini table.table_economic_calendar_mini .mark{background: #f2f2f2;color: #000;text-align: center;}       #economic-calendar-mini table.table_economic_calendar_mini .head{background: #292929;text-align: left;height: 25px;color:#FFF;font-weight: normal;font-size: 105%;margin:0;padding:0;font-size: Tahoma}     #economic-calendar-mini table.table_economic_calendar_mini .head .ec{border-right: 1px solid #666;padding: 5px;width: 170px;text-align: center;}        #economic-calendar-mini table.table_economic_calendar_mini .head .date{width:70px;overflow:hidden;}     #economic-calendar-mini .all{text-align: right;font-size: 90%;}     #economic-calendar-mini .all a:link,#economic-calendar-mini .all a:visited{color:#000;text-decoration: none;margin: 0 2px 0;}       #economic-calendar-mini .all a:hover,#economic-calendar-mini .all       a:active{text-decoration: underline;}       #economic-calendar-mini .currency_NZD{background: url([url=http://kashargin.ru/ec/currency/NZD.png]http://kashargin.ru/ec/currency/NZD.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_GBP{background: url([url=http://kashargin.ru/ec/currency/GBP.png]http://kashargin.ru/ec/currency/GBP.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_USD{background: url([url=http://kashargin.ru/ec/currency/USD.png]http://kashargin.ru/ec/currency/USD.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_CHF{background: url([url=http://kashargin.ru/ec/currency/CHF.png]http://kashargin.ru/ec/currency/CHF.png[/url]) 0% 50% no-repeat;padding: 0 0 0 20px;}        #economic-calendar-mini .currency_CNY{background: url([url=http://kashargin.ru/ec/currency/CNY.png]http://kashargin.ru/ec/currency/CNY.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_CAD{background: url([url=http://kashargin.ru/ec/currency/CAD.png]http://kashargin.ru/ec/currency/CAD.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_JPY{background: url([url=http://kashargin.ru/ec/currency/JPY.png]http://kashargin.ru/ec/currency/JPY.png[/url]) 0 50% no-repeat;padding: 1px 0 0 20px; width: 35px;position: relative; left:-2px}     #economic-calendar-mini .currency_AUD{background: url([url=http://kashargin.ru/ec/currency/AUD.png]http://kashargin.ru/ec/currency/AUD.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      #economic-calendar-mini .currency_EUR{background: url([url=http://kashargin.ru/ec/currency/EUR.png]http://kashargin.ru/ec/currency/EUR.png[/url]) 0% 50% no-repeat;padding: 1px 0 0 20px;}      </style>        ';      echo '<div id="economic-calendar-mini"><table class="table_economic_calendar_mini">';       echo '<tr><td colspan="3" class="head"><table class="" style="width: 100%;"><tr><td class="ec">Economic Calendar</td><td style="text-align: center;"  class="date"><div class="date">'.date('D d,M',$this->geo["timestamp"]).'</div></td></tr></table></td></tr>';      foreach($result as $key=>$val){         foreach($val as $k=>$v){                $l_mark=($m%2==0)?'none':'mark';                echo '<tr class="'.$l_mark.'">';                    echo '<td style="width: 20px;">'.substr($v["time_actual"],11,5).'</td>';                    echo '<td style="width: 45px;"><span class="currency_'.$v["cur"].'">'.$v["cur"].'</span></td>';                 echo '<td style="text-align: left;">';                      if($this->search) echo preg_replace("/$this->searchText/iu","<b>\\0</b>",$v["title"]);                      else echo $v["title"];                  echo '</td>';               echo '</tr>';           $m++;           }       }       echo '</table>';        echo '<div class="all"><a href="/tools/economic-calendar">Full calendar</a></div>';     echo '</div>';  }       public function printPage(){?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"><base href="http://globegain.com"><head><link rel="shortcut icon" href="/sites/default/files/zen_favicon.ico" type="image/x-icon" />  <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/theme/content-module.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/filefield/filefield.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/lightbox2/css/lightbox_alt.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/nice_menus/nice_menus.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/nice_menus/nice_menus_default.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/modules/fieldgroup/fieldgroup.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/html-elements.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/tabs.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/messages.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/block-editing.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/wireframes.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/zen.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/jquery-ui-custom.css?P" /><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/layout-liquid.css?P" /><link type="text/css" rel="stylesheet" media="print" href="/sites/all/themes/zen/print.css?P" /><link type="text/css" rel="stylesheet" media="all" href="http://kashargin.ru/ec/style.css?P" /><script type="text/javascript">function printpage() {   window.print();     }</script><style>.ecomomic_calendar table.table_economic_calendar{width: 100% !important;}</style></head><body onload="printpage()"><div class="ecomomic_calendar"><table width="100%">   <tr>        <td style="width:250px"><img src="/sites/all/themes/zen/images/logo.gif" alt=""/></td>      <td style="font-size: 24px; text-align: center;">Ecomonic calendar<div style="font-size: 14px; color: #999;">www.GlobeGain.com</div></td>   </tr></table><? self::getData();?></div></body></html><?    }       public function delItem(){      $id=(int)$_GET["id"];       if($id){            mysql_query("DELETE FROM `economic_calendar_event` WHERE `id`='$id' LIMIT 1");      }   }       public function editItem(){     $id=(int)$_GET["id"];       $this->up=false;        if($_POST){         $ar=array('title','period','impact','currency_id','previous','forcast','actual','actual_mark','time_actual','show');            foreach($ar as $v){             if($v=='time_actual'){                  $d=explode("/",$_POST["date"]);                 $timestamp=strtotime($d[0].'.'.$d[1].'.'.$d[2].' '.((int)$_POST["time"][1]).':'.(int)$_POST["time"][2].':'.(int)$_POST["time"][3]);                 $timestamp=$timestamp+(3*3600);//                   echo date("d.m.Y H:i:s",$timestamp);//                  $time_actual=$d[2].'-'.$d[1].'-'.$d[0].' '.((int)$_POST["time"][1]).':'.(int)$_POST["time"][2].':'.(int)$_POST["time"][3];                  $time_actual=date("Y-m-d H:i:s",$timestamp);                    $sql .= " `$v`='$time_actual',";                }               else $sql .= " `$v`='".mysql_escape_string($_POST[$v])."',";            }           $sql=substr($sql,0,-1);         if($id)             $q="UPDATE `economic_calendar_event` SET $sql WHERE `id`=$id LIMIT 1";          else                $q="INSERT INTO `economic_calendar_event` SET $sql";            if(mysql_query($q)){                if(!$id)                    header("Location: /sites/all/themes/zen/ec/ec.php?act=edit&id=".mysql_insert_id());             else{                   echo '<script type="text/javascript">window.opener.reloadPage();window.close();</script>';              }               $this->up=true;         }       }       if($id){            $q=mysql_query("SELECT * FROM `economic_calendar_event` WHERE `id`=$id");           if(mysql_num_rows($q)){             $event=mysql_fetch_assoc($q);               $this->event=$event;                preg_match("|([\d]{4}+)\-([\d]{2}+)\-([\d]{2}+)\s([\d]{2}+):([\d]{2}+):([\d]{2}+)|is",$this->event["time_actual"],$d);              $timestamp=strtotime($d[3].'.'.$d[2].'.'.$d[1]." ".$d[4].':'.$d[5].':'.$d[6]);              $timestamp=$timestamp-(3*3600);//               echo date("d.m.Y H:i:s",$timestamp);                $this->event["date"]=date("d/m/Y",$timestamp);              $this->event["time"][1]=date("H",$timestamp);               $this->event["time"][2]=date("i",$timestamp);               $this->event["time"][3]=date("s",$timestamp);           }           else die('<h2>Events not found!</h2>');     }       $cur=mysql_query('SELECT `currency` FROM `economic_calendar_currency` GROUP BY `currency`');        while(list($currency)=mysql_fetch_array($cur))          $this->currency[]=$currency;        echo '<html><head><link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/zen/ec/css/style.css?P" />     <script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?P"></script>     <script type="text/javascript" src="/sites/all/themes/zen/ec/js/economic_calendar.js"></script>     <script type="text/javascript" src="/sites/all/themes/zen/ec/js/jquery.datepick.js"></script>       <script type="text/javascript" src="/sites/all/themes/zen/ec/js/jquery.datepick.ext.js"></script>       <style type="text/css">     @import "/sites/all/themes/zen/ec/css/jquery.datepick.css";     </style>        <script type="text/javascript">     $(\'#dateEvent\').datepick({        defaultDate: new Date(2010, 1 - 1, 1), showTrigger: \'#calImg\'});      '.(($this->up)?'EditReloadFromChild()':'').'        </script>       </head><body>';     echo '<h2>'.(($id)?'Editing events':'Add an event').'</h2>';        echo '<div class="ecomomic_calendar" style="width: 280px;">';       echo '<form action="/sites/all/themes/zen/ec/ec.php?act=edit'.(($id)?'&id='.$id:'').'" method="post">';     echo '<table class="edit-form">';           echo '<tr><td>Time</td><td>';               echo '<input maxlength="2" id="time1" style="width: 20px;" type="text" name="time[1]" value="'.$this->event["time"][1].'" onkeyup="EditChechTimeInput(1);"/>';              echo ':<input maxlength="2" id="time2" style="width: 20px;" type="text" name="time[2]" value="'.$this->event["time"][2].'" onkeyup="EditChechTimeInput(2);"/>';             echo ':<input maxlength="2" id="time3" style="width: 20px;" type="text" name="time[3]" value="'.$this->event["time"][3].'"/> "+00:00"GMT';              echo '<div class="sample">For example: 12:33</div>';            echo '</td></tr>';                      echo '<tr><td>Date</td><td>';               echo '<input id="dateEvent" type="text" name="date" value="'.$this->event["date"].'" onkeyup="EditDateInput(this.id);"/>';              echo '<div class="sample">For example: 12/12/2011</div>';           echo '</td></tr>';                      echo '<tr><td>Currency:</td><td>';              echo '<select name="currency_id"><option value=""></option>';                   foreach($this->currency as $v){                     echo '<option value="'.$v.'"'.(($v==$this->event["currency_id"])?' selected':'').'>'.$v.'</option>';                    }               echo '</select>';           echo '</td></tr>';                      echo '<tr><td>Impact</td><td>';             echo '<select name="impact">';                  for($i=0;$i<4;$i++){                        echo '<option value="'.$i.'"'.(($i==$this->event["impact"])?' selected':'').'>'.$i.'</option>';                 }               echo '</select>';           echo '</td></tr>';                      echo '<tr><td>Title</td><td>';              echo '<textarea name="title">'.$this->event["title"].'</textarea>';         echo '</td></tr>';                      echo '<tr><td>Period</td><td>';             echo '<input type="text" name="period" value="'.$this->event["period"].'"/>';               echo '<div class="sample">For example: February</div>';         echo '</td></tr>';                      echo '<tr><td>Previous</td><td>';               echo '<input type="text" name="previous" value="'.$this->event["previous"].'"/>';               echo '<div class="sample">For example: 8.52B</div>';            echo '</td></tr>';                      echo '<tr><td>Forcast</td><td>';                echo '<input type="text" name="forcast" value="'.$this->event["forcast"].'"/>';             echo '<div class="sample">For example: 0.8%</div>';         echo '</td></tr>';                      echo '<tr><td>Actual</td><td>';             echo '<input type="text" name="actual" value="'.$this->event["actual"].'"/><br/>';              echo 'Mark: <input type="radio" id="red" name="actual_mark" value="red"'.(($this->event["actual_mark"]=='red')?' checked':'').'><label for="red" style="color: #F00;">red</label>';             echo ' <input type="radio" id="green" name="actual_mark" value="green"'.(($this->event["actual_mark"]=='green')?' checked':'').'><label for="green" style="color: #0F0;">green</label>';                echo ' <input type="radio" id="no" name="actual_mark" value="no"'.(($this->event["actual_mark"]=='no')?' checked':'').'><label for="no">no</label>';                echo '<div class="sample">For example: -1.6%</div>';            echo '</td></tr>';                      echo '<tr><td>Show</td><td>';               echo '<select name="show">';                    echo '<option value="yes"'.(($this->event["show"]=='yes')?' checked':'').'>Yes</option>';                   echo '<option value="no"'.(($this->event["show"]=='no')?' checked':'').'>No</option>';              echo '</select>';           echo '</td></tr>';                      echo '<tr><td colspan="2" align="center"><input id="save" type="submit" value="Save"/> <input id="close" onclick="window.close();return false;" type="submit" value="Close"/></td></tr>';       echo '</table>';        echo '</form>';     echo '</div>';      echo '</body></html>';  }       private function auth(){        $login=$_COOKIE["log"];     $password=$_COOKIE["pas"];      if($this->login==$login && $password==md5($this->password))         return true;        else            return false;   }       public function getLogout(){        setcookie("log",'',time()+1,"/");       setcookie("pas",'',time()+1,"/");       header('Location: /tools/economic-calendar');   }       public function getAuth(){      $login=$_POST["login"];     $password=$_POST["password"];       if($this->login==$login && $password==$this->password){         $_SESSION["login"]=$login;          $_SESSION["password"]=$password;            setcookie("log",$login,time()+3600*24,"/");         setcookie("pas",md5($password),time()+3600*24,"/");         header('Location: /tools/economic-calendar');       }       else{           echo '<h3>Please, log in.</h3>';            echo '<form action="?act=auth" method="post">';             echo '<table>';             echo '<tr><td>Login:</td><td><input type="text" name="login" value=""/></td></tr>';             echo '<tr><td>Password:</td><td><input type="password" name="password" value=""/></td></tr>';               echo '<tr><td colspan="2"><input type="submit" value="Log in"></td></tr>';              echo '</table>';        echo '</from>';     }   }       public function userTime(){     $visitorId=$_COOKIE["visitorId"];       $ip_real=self::getRealIpAddr();     $ip=ip2long($ip_real);              if($visitorId){         $q=mysql_query("SELECT * FROM `economic_calendar_views` WHERE `visitorId`='$visitorId'");           if(mysql_num_rows($q)){             $old_record=mysql_query("SELECT q2.City,q2.CityId,q3.Country,q3.Internet as countryCode,q3.CountryId,q2.TimeZone FROM `economic_calendar_views` q1 LEFT JOIN `economic_calendar_cities` q2 ON q1.cityId=q2.CityId LEFT JOIN `economic_calendar_countries` q3 ON q2.CountryID=q3.CountryId WHERE q1.visitorId='$visitorId' && q1.ip='$ip' && q1.type='changed' ORDER BY id DESC LIMIT 1");               if(mysql_num_rows($old_record)){                    list($City,$CityId,$Country,$CountryCode,$CountryId,$TimeZone)=mysql_fetch_array($old_record);                  $this->geo["area"]=($City)?$Country.', '.$City:$Country;                    $this->geo["countryId"]=$CountryId;                 $this->geo["countryCode"]=$CountryCode;                 $this->geo["cityId"]=$CityId;                   $this->geo["cityCode"]=$City;                   $this->geo["typeUser"]='changed';                   $this->geo["TimeZone"]=$TimeZone;                   $this->geo["timestamp"]=self::time($TimeZone);                  $this->geo["time"]=date("Y-m-d H:i:s",$this->geo["timestamp"]);             }               else{                   self::geoIp();                  $this->geo["typeUser"]='direct';                }           }           else{               self::geoIp();              $this->geo["typeUser"]='direct';            }       }       else{           self::geoIp();          $this->geo["typeUser"]='direct';        }       $this->geo["area"]=str_replace('Russian Federation','Russia',$this->geo["area"]);   }       private function chooseDate(){      $this->date[0]=$_GET["dayMin"];     $this->date[1]=$_GET["dayMax"];             if($this->date[0] && $this->date[1]){           if(preg_match('/^([0-9]{4})+\-([0-9]{1,2})+\-([0-9]{1,2})+$/i',$this->date[0]) &&               preg_match('/^([0-9]{4})+\-([0-9]{1,2})+\-([0-9]{1,2})+$/i',$this->date[1])         ){              $this->dateStart=substr($this->date[0],0,10).' 00:00:00';               $this->dateFinish=substr($this->date[1],0,10).' 23:59:59';          }           else{               $w=self::getweek($this->geo["timestamp"]);              $this->dateStart=$w[1].' 00:00:00';             $this->dateFinish=$w[7].' 23:59:59';            }       }       else{           $w=self::getweek($this->geo["timestamp"]);          $this->dateStart=$w[1].' 00:00:00';         $this->dateFinish=$w[7].' 23:59:59';                        if(date("m",$this->geo["timestamp"])>=10) $this->quarter=4;         else if(date("m",$this->geo["timestamp"])>=7) $this->quarter=3;         else if(date("m",$this->geo["timestamp"])>=4) $this->quarter=2;         else $this->quarter=1;                      $this->year=date("Y",$this->geo["timestamp"]);      }   }       public function logView(){      $ip_real=self::getRealIpAddr();     $visitorId=($_COOKIE["visitorId"])?$_COOKIE["visitorId"]:md5($ip_real.'-'.time());      $ip=ip2long($ip_real);      $countryId=$this->geo["countryId"];     $countryCode=$this->geo["countryCode"];     $cityId=$this->geo["cityId"];       $cityCode=$this->geo["cityCode"];       $type=$this->geo["typeUser"];               echo'<script type="text/javascript">setcookie(\'visitorId\',\''.$visitorId.'\',\'365\',\'/\');</script>';               mysql_query("INSERT INTO `economic_calendar_views` SET visitorId='$visitorId', ip='$ip', ip_real='$ip_real',countryId='$countryId',countryCode='$countryCode',cityId='$cityId',cityCode='$cityCode',type='$type'"); }       public function getCityTime(){      $cityId = (int)$_GET["city"];       list($TimeZone,$CountryID,$countryCode,$City)=mysql_fetch_array(mysql_query("SELECT q1.TimeZone,q2.CountryID,q2.Internet as countryCode,q1.City FROM `economic_calendar_cities` q1 LEFT JOIN `economic_calendar_countries` q2 ON q1.CountryID=q2.CountryId WHERE q1.CityId='$cityId'"));        $geo_time=self::time(strtok($TimeZone,":"));        $this->geo["countryId"]=$CountryID;     $this->geo["countryCode"]=$countryCode;     $this->geo["cityId"]=$cityId;       $this->geo["cityCode"]=$City;       $this->geo["typeUser"]='changed';       self::logView($cityId);     $week=self::getweek($geo_time);     echo date("H:i",$geo_time).'&nbsp;&nbsp;'.date("d F,Y",$geo_time).'|'.$week[1].'|'.$week[7];    }       public function logChoose($cityId){     $visitorId=($_COOKIE["visitorId"])?mysql_escape_string($_COOKIE["visitorId"]):md5(self::getRealIpAddr().time());        if(mysql_query("INSERT INTO `economic_calendar_cities_choose` SET ip='".ip2long(self::getRealIpAddr())."', ip_real = '".self::getRealIpAddr()."',cityId='$cityId', visitorId='$visitorId'")){//         setcookie('visitorId',$visitorId,time()+60*60*24*365,'/');      }   }       public function searchLocate(){     $text=mysql_escape_string(trim($_GET["searchlocate"]));     if($text){          $q=mysql_query("SELECT q1.City,q2.Country,q1.CityId FROM `economic_calendar_cities` q1 LEFT JOIN `economic_calendar_countries` q2 ON q1.CountryID=q2.CountryId  WHERE q1.City LIKE '$text%' GROUP BY q2.Country,q1.City");          if(mysql_num_rows($q) < 10) $searchCountry=1;           $m=0;           echo '<ul class="locateList">';         while(list($City,$Country,$CityId)=mysql_fetch_array($q)){              echo '<li onclick="chooseLocation(this.id);" id="'.$m.'" city="'.$Country.', '.$City.'" cityId="'.$CityId.'">'.$Country.', '.preg_replace("/$text/iu","<b>\\0</b>",$City).'</li>';          $m++;           }           if($searchCountry==1){              $q=mysql_query("SELECT q1.City,q2.Country,q1.CityId FROM `economic_calendar_cities` q1 LEFT JOIN `economic_calendar_countries` q2 ON q1.CountryID=q2.CountryId  WHERE q2.Country LIKE '$text%' GROUP BY q2.Country,q1.City LIMIT 50");              while(list($City,$Country,$CityId)=mysql_fetch_array($q)){                  echo '<li onclick="chooseLocation(this.id);" id="'.$m.'" city="'.$Country.', '.$City.'" cityId="'.$CityId.'">'.preg_replace("/$text/iu","<b>\\0</b>",$Country).', '.$City.'</li>';              $m++;               }           }           if($m==0) echo '<li><center><i>No results</i></center></li>';           echo '</ul>';       }           }       public function time($gmt=0){//greenvich time       $time = time();     $shift=60*60;//one hour     $time=$time;//moscow time on server     $gmt_type=substr($gmt,0,1);     $gmt_time=substr($gmt,1,3);     $time=($gmt_type=='-')?($time-$shift*$gmt_time):($time+$shift*$gmt_time);       return $time;   }       public function getTime($country,$city,$region){        //step one - geoip time     $greenvich_time = date("d.m.Y H:i:s",self::time());     if($region)         $sql = " && `region`='$region'";        list($gmt)=mysql_fetch_array(mysql_query("SELECT gmt FROM `economic_calendar_gmt` WHERE `country`='$country'$sql"));        $geo_time=self::time($gmt);     $max_time=$greenvich_time+self::time('+12');        $min_time=$greenvich_time+c;        $jsTime=false;      if($geo_time>$max_time || $geo_time<$min_time){         $jsTime=true;       }       return array(date("d.m.Y H:i:s",$geo_time),$geo_time,$jsTime);  }       public function search(){       $sql='';        $search=mysql_escape_string($_GET["search"]);       $sql=" && q1.title LIKE '%$search%'";       $this->search=$sql;     $this->searchText=$search;  }       public function filter(){       $sql='';        $impact=$_GET["impact"];        $cur=$_GET["cur"];      if(!$cur) $cur = $_SESSION["currency"];     if(is_array($impact)){          if(count($impact)){             foreach($impact as $val){                   if(in_array($val,array('1','2','3'))){                      $sql_imp.=" || q1.impact = '$val'";                 }               }           }       }       if($sql_imp)            $sql = ' && ('.substr($sql_imp,3,999).')';      if(is_array($cur)){         if(count($cur)){                $cr=array();                $q=mysql_query("SELECT currency FROM `economic_calendar_currency`");                while(list($currency)=mysql_fetch_array($q)){                   $cr[]=$currency;                }               foreach($cur as $val){                  if(in_array($val,$cr)){                     $sql_cur.=" || q1.currency_id = '$val'";                    }               }           }       }       if($sql_cur)            $sql .= ' && ('.substr($sql_cur,3,999).')';     $this->filter=$sql; }       public function getHead(){      $week=self::getweek($this->geo["timestamp"]);       echo '<table class="top_section">               <tr>                    <td class="time">Your time: <span id="current_time_calendar"><b>'.date("H:i",$this->geo["timestamp"]).'&nbsp;&nbsp;&nbsp;'.date("d F,Y",$this->geo["timestamp"]).'</b></span><span style="display:none" id="current_time_calendar_hidden">'.date("M",$this->geo["timestamp"]).', '.date("d",$this->geo["timestamp"]).', '.date("Y",$this->geo["timestamp"]).' '.date("H",$this->geo["timestamp"]).':'.date("i",$this->geo["timestamp"]).':'.date("s",$this->geo["timestamp"]).'</span></td>                 <td><div class="Area"><div class="choose"><div id="chooseNew"><span id="chooseId"><input onkeyUp="areaChooseSearch();" id="chooseInput" type="text" name="" value=""/></span><span id="close"><a title="Click to close choice" href="#" onclick="closeChooseArea();return false;"><img src="http://kashargin.ru/ec/close_search.png" alt=""/></a></span><div id="chooseLocatePlace"></div></div></div><div id="location">Location: <span class="buttons"><a href="#" title="Click to select" id="choosen" onclick="getChooseArea();return false;"><b>'.$this->geo["area"].'</b></a></span></div></div></td>                 <td class="show">Show: <span class="buttons"><a href="#'.date("Y-m-d",$this->geo["timestamp"]).'" onclick="getEconomicCalendar(\''.date("Y-m-d",$this->geo["timestamp"]).'\',\''.date("Y-m-d",$this->geo["timestamp"]).'\',\'\');saveDate(\''.date("Y-m-d",$this->geo["timestamp"]).'\',\''.date("Y-m-d",$this->geo["timestamp"]).'\');return false;">Day</a></span> /                      <span class="buttons"><a href="#'.$week[1].'-'.$week[7].'" onclick="getEconomicCalendar(\''.$week[1].'\',\''.$week[7].'\',\'\');saveDate(\''.$week[1].'\',\''.$week[7].'\');return false;">Week</a></span></td>                     <td class="filter"><a href="#" onclick="return false;" id="economic_calendar_filter" title="Click to open">Filter</a>                       <div class="economic_calendar_filter_container"><div class="economic_calendar_filter_place">                            <a href="#" onclick="return false;" id="close_filter" class="head" title="Click to close">Filter</a>                            <form id="filter_form">                             <table>                                 <tr>                                        <td colspan="2"><center><u>Currency</u></center></td>                                   </tr>';                                 $q=mysql_query("SELECT currency FROM `economic_calendar_currency` GROUP BY currency ASC");                                  while(list($cur)=mysql_fetch_array($q)){                                        echo '<tr><td><label for="curency_'.$cur.'"><div class="currency_'.$cur.'"> '.$cur.'</div></label></td><td><input id="curency_'.$cur.'" type="checkbox" name="cur[]" value="'.$cur.'" onclick="getFilter(1);"/></td></tr>';                                 }                           echo '  <tr>                                        <td colspan="2"><center><u>Impact</u></center></td>                                 </tr>';                                 for($j=2;$j<=4;$j++){                                       echo '<tr><td><label for="impact_'.($j-1).'">';                                     for($i=1;$i<$j;$i++)                                            echo '<div class="impact-red"> </div>';                                     for($i;$i<=3;$i++)                                          echo '<div class="impact"> </div></label>';                                     echo '</td><td><input id="impact_'.($j-1).'" type="checkbox" name="impact[]" value="'.($j-1).'" onclick="getFilter(1);"/></td></tr>';                                   }                           echo '  <tr>                                        <td colspan="2"><center><u><a style="border:0;" href="#" onclick="getFilter(\'off\');return false;">Cancel all</a></u></center></td>                                    </tr>                               </table>                            </form>                     </div></div>                    </td>                   <!--<td style="width:20px; height:30px;"><img src="http://kashargin.ru/ec/ajax-loader.gif" alt="loading" id="economic_calendar_loding"/></td>-->                </tr>           </table>';  }       function getRealIpAddr()    {     if (!empty($_SERVER['HTTP_CLIENT_IP']))       $ip=$_SERVER['HTTP_CLIENT_IP'];   elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))     $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];     else      $ip=$_SERVER['REMOTE_ADDR'];      return $ip;       return '194.186.106.0'; }       public function geoIp(){        $gi = geoip_open("/home/globegai/public_html/sites/all/themes/zen/ec/geo/GeoLiteCity.dat",GEOIP_STANDARD);      $record = geoip_record_by_addr($gi,self::getRealIpAddr());      geoip_close($gi);       if(is_null($record)){           $this->geo["area"]='Unknown';       }       else{           $this->geo["countryId"]=0;          $this->geo["countryCode"]=$record->country_code;            $this->geo["cityCode"]=$record->city;           $this->geo["area"]=($record->city)?$record->country_name.', '.$record->city:$record->country_name;          list($time,$timestamp,$jsTime)=self::getTime($record->country_code, $record->city, $record->region);            $this->geo["time"]=$time;           $this->geo["timestamp"]=$timestamp;         $this->geo["TimeZone"]=self::getTzFromCountry($this->geo["countryCode"]);       }   }       public function getTzFromCountry($countryId){       list($Tz)=mysql_fetch_array(mysql_query("SELECT q2.`TimeZone` FROM `economic_calendar_countries` q1 LEFT JOIN `economic_calendar_cities` q2 ON q1.CountryId=q2.CountryID WHERE q1.`Internet`='$countryId' && q1.`Capital`=q2.`City`"));     return $Tz; }       public function getData(){      mysql_query("SET time_zone = '".$this->geo["TimeZone"]."'");        $q="SELECT q1.*,q2.title as cur_title,q2.currency as cur FROM `economic_calendar_event` q1 LEFT JOIN `economic_calendar_currency` q2 ON q1.currency_id=q2.currency WHERE q1.`time_actual` > '{$this->dateStart}' && q1.`time_actual` < '{$this->dateFinish}' && `show` {$this->search} {$this->filter} GROUP BY q1.id ORDER BY q1.time_actual ASC";     $q=mysql_query($q,$this->c);        $result=array();        while($res=mysql_fetch_assoc($q)){          $result[substr($res["time_actual"],0,10)][]=$res;       }       $m=0;       echo '<div id="economic-calendar" minDate="'.substr($this->dateStart,0,10).'" maxDate="'.substr($this->dateFinish,0,10).'"><table class="table_economic_calendar">          <tr class="head">               <td>Time</td>               <td style="width: 60px;">Currency</td>              <td style="width: 40px">Impact</td>             <td>Event</td>              <td>Period</td>             <td>Previous</td>               <td>Forecast</td>               <td style="width: 50px;">Actual</td>';              if(self::auth() && !$_GET["print"]) echo '<td>Edit <a title="Add new event" id="new_add" href="/sites/all/themes/zen/ec/ec.php?act=edit" onclick="EditAddWindow(this.id);return false;">+</a> <a href="/sites/all/themes/zen/ec/ec.php?act=logout" style="color:#F00; text-decoration: none;position: relative; right: -26px;" title="Exit">*</a></td>';            echo '</tr>';       foreach($result as $key=>$val){         echo '<tr>';                echo '<td class="day-title" colspan="8">';                  echo date('l, d F',strtotime($key));                echo '</td>';               if(self::auth() && !$_GET["print"]) echo '<td class="day-title"></td>';         echo '</tr>';           foreach($val as $k=>$v){                $l_mark=($m%2==0)?'mark':'none';                echo '<tr class="'.$l_mark.'">';                    echo '<td>'.substr($v["time_actual"],11,5).'</td>';                 echo '<td><span class="currency_'.$v["cur"].'">'.$v["cur"].'</span></td>';                  echo '<td style="padding: 0 0 0 7px">';                 for($i=0;$i<$v["impact"];$i++)                      echo '<div class="impact-red"> </div>';                 for($i;$i<3;$i++)                       echo '<div class="impact"> </div>';                 echo '</td>';                   echo '<td style="text-align: left;">';                      if($this->search) echo preg_replace("/$this->searchText/iu","<b>\\0</b>",$v["title"]);                      else echo $v["title"];                  echo '</td>';                   echo '<td style="text-align:left;width: 55px;">';                       echo ($v["period"])?$v["period"]:'-';                   echo '</td>';                   echo '<td style="width: 50px;">'.$v["previous"].'</td>';                    echo '<td style="width: 50px;">'.$v["forcast"].'</td>';                 echo '<td style="width: 50px;">';                       if($v["actual_mark"]=='red') echo '<span style="color:#F00;font-weight: bold;">';                       else if($v["actual_mark"]=='green') echo '<span style="color:#00C000;font-weight: bold;">';                 echo $v["actual"];                  echo '</span></td>';                    if(self::auth() && !$_GET["print"]){                        echo '<td style="width: 50px;">';                           echo '<a id="item_edit_'.$v["id"].'" href="/sites/all/themes/zen/ec/ec.php?act=edit&id='.$v["id"].'" onclick="EditAddWindow(this.id);return false;">edit</a>';                          echo ' <a id="item_del_'.$v["id"].'" href="/sites/all/themes/zen/ec/ec.php?act=del&id='.$v["id"].'" onclick="if(confirm(\'Вы уверены что хотите это удалить?\')) EditDelItem(this.id);return false;">del</a>';                          /*                           * <input onClick="if(confirm('Вы уверены что хотите это удалить?')) window.location='dig_del.php?RowId=19035&Str_Code=5'" type="button" value="Удалить" style="width:115" class="red">                           */                     echo '</td>';                   }               echo '</tr>';           $m++;           }       }       echo '</table>';        if(!$_GET["print"]){            echo '<div class="nav-bottom buttons">';            if(substr($this->dateStart,0,10)==substr($this->dateFinish,0,10)){              $d=explode("-",substr($this->dateStart,0,10));              $next_day=date("Y-m-d",strtotime($d[2].'-'.$d[1].'-'.$d[0])+60*60*24);              $prev_day=date("Y-m-d",strtotime($d[2].'-'.$d[1].'-'.$d[0])-60*60*24);              echo '<a href="#'.$prev_day.'" onclick="getEconomicCalendar(\''.$prev_day.'\',\''.$prev_day.'\',\'\');clearFilter();clearSearch();return false;"><<   Previous day</a> <a href="#'.$next_day.'" onclick="getEconomicCalendar(\''.$next_day.'\',\''.$next_day.'\',\'\');clearFilter();clearSearch();return false;">Next day >></a>';         }           else{               $d=explode("-",substr($this->dateStart,0,10));              $timestamp=strtotime($d[2].'-'.$d[1].'-'.$d[0]);                $week= self::getweek($timestamp);               if($week[1]==substr($this->dateStart,0,10) && $week[7]==substr($this->dateFinish,0,10)){                    $prev_week= self::getweek($timestamp-60*60*24*7);                   $next_week= self::getweek($timestamp+60*60*24*7);                   echo '<a href="#'.$prev_week[1].'-'.$prev_week[7].'" onclick="getEconomicCalendar(\''.$prev_week[1].'\',\''.$prev_week[7].'\',\'\');clearFilter();clearSearch();return false;"><<   Previous week</a> <a href="#'.$next_week[1].'-'.$next_week[7].'" onclick="getEconomicCalendar(\''.$next_week[1].'\',\''.$next_week[7].'\',\'\');clearFilter();clearSearch();return false;">Next week >></a>';               }           }           echo '</div>';      }       echo '</div>';  }       private function getweek($timestamp){       $day[1]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp)));        $day[2]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-2'));       $day[3]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-3'));       $day[4]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-4'));       $day[5]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-5'));       $day[6]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-6'));       $day[7]=date('Y-m-d', strtotime(date('Y',$timestamp).'W'.date('W',$timestamp).'-7'));       return $day;    }               private function connect(){     $this->c = @mysql_connect('localhost','globegai_mysql','kXs%d$h~+pMc') or die("Не могу подключиться к серверу БД: " . mysql_error());       mysql_select_db('globegai_base',$this->c) or die("Не могу выбрать базу данных" . mysql_error());     mysql_query("SET NAMES 'utf8'",$this->c);   }       public function r($data){       echo'<pre>';        print_r($data);     echo'</pre>';   }       public function __construct(){      include("geo/geoipcity.inc");               self::connect();        self::userTime();       if(!$_GET["act"]) self::logView();      self::chooseDate();     if($_GET["impact"] || $_GET["cur"])         self::filter();     if($_GET["search"])         self::search(); }}$o=new economic_calendar();if($_GET["print"]){    $o->printPage();}elseif($_GET["act"]=='getMiniCalendar'){   $o->getMini();}elseif($_GET["searchlocate"]){   $o->searchLocate();}elseif($_GET["city"]){  $o->getCityTime();}elseif($_GET["act"]=='auth'){    $o->getAuth();}elseif($_GET["act"]=='logout'){  $o->getLogout();}elseif($_GET["act"]=='edit'){  $o->editItem();}elseif($_GET["act"]=='del'){    $o->delItem();}else{    if(!$_GET["act"])       $o->getHead();  $o->getData();}?>
     
  2. Apple

    Apple Активный пользователь

    С нами с:
    13 янв 2007
    Сообщения:
    4.984
    Симпатии:
    2
    С этим кодом уже сложно что-то сделать.
    Случилось скорее всего слудующее: ты открыл в файл в каком-то говёном редакторе и пересохранил.
    Переносы строк не виндовские, редактор их не понял. И сделал тебе кашу

    В этом коде были комменты однострочные.
    После превращения всего кода в одну строку структура файла нарушилась (у класса нет закрывающейся скобки, нет её и у метода).

    Надейся, что у программиста вашего резервная копия есть.
    Потому что форматировать будет эту хрень сложновато даже автоматически.
     
  3. Mamont

    Mamont Активный пользователь

    С нами с:
    5 дек 2010
    Сообщения:
    183
    Симпатии:
    0
  4. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    В notepad2 открывал, раньше никогда такого не случалось с ним.
     
  5. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    а что это? я не силен в php(
     
  6. tommyangelo

    tommyangelo Старожил

    С нами с:
    6 дек 2009
    Сообщения:
    2.549
    Симпатии:
    0
    Адрес:
    Мариуполь
    estadio
    напиши емейл закину исправленый
     
  7. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    Спасибо! estadio@yandex.ru
    а может я вам лучше сброшу оригинал на почту? а то тут с какими то лишними пробелами вставился код, мне кажется.
     
  8. tommyangelo

    tommyangelo Старожил

    С нами с:
    6 дек 2009
    Сообщения:
    2.549
    Симпатии:
    0
    Адрес:
    Мариуполь
    Пробелы вроде нормально.
    Коменты, которые были, пришлось снести.

    Отправил

    Apple
    Нетбинс без проблем справился. Как ты и говорил, причиной были однострочные коменты.
     
  9. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    Получил, спасибо огромное!
    а в чем проблема была? как в следующий раз этого избежать?
    чем лучше открывать?- мне щас надо будет залезть в него вставить логин и пароль обратно.
     
  10. tommyangelo

    tommyangelo Старожил

    С нами с:
    6 дек 2009
    Сообщения:
    2.549
    Симпатии:
    0
    Адрес:
    Мариуполь
    теперь по идее можно любым) Попробуй виндовым блокнотом. Ну, или Notepad++, если что попродвинутее надо.
     
  11. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    Поставил ++, все сделал, все работает) Ура.
    Еще раз спасибо!
     
  12. tommyangelo

    tommyangelo Старожил

    С нами с:
    6 дек 2009
    Сообщения:
    2.549
    Симпатии:
    0
    Адрес:
    Мариуполь
    estadio
    С тебя пиво ;-)
     
  13. estadio

    estadio Активный пользователь

    С нами с:
    6 сен 2011
    Сообщения:
    7
    Симпатии:
    0
    tommyangelo
    Ну пиво я вряд ли смогу тебе прислать в Мариуполь))
    Но "на пиво" без проблем) говори кошелек)
     
  14. tommyangelo

    tommyangelo Старожил

    С нами с:
    6 дек 2009
    Сообщения:
    2.549
    Симпатии:
    0
    Адрес:
    Мариуполь
    estadio
    Это шутка, спасибо, не стоит))