src/Controller/BaseController.php line 88

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Ceviri;
  4. use App\Entity\Dil;
  5. use Gumlet\ImageResize;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use App\Controller;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. class BaseController extends AbstractController
  11. {
  12.     function botArama($bas$son$yazi)
  13.     {
  14.         @preg_match_all('/' preg_quote($bas'/') .
  15.             '(.*?)'preg_quote($son'/').'/i'$yazi$m);
  16.         return @$m[1];
  17.     }
  18.     function GetIP()
  19.     {
  20.         if (getenv("HTTP_CLIENT_IP")) {
  21.             $ip getenv("HTTP_CLIENT_IP");
  22.         } elseif (getenv("HTTP_X_FORWARDED_FOR")) {
  23.             $ip getenv("HTTP_X_FORWARDED_FOR");
  24.             if (strstr($ip',')) {
  25.                 $tmp explode(','$ip);
  26.                 $ip trim($tmp[0]);
  27.             }
  28.         } else {
  29.             $ip getenv("REMOTE_ADDR");
  30.         }
  31.         return $ip;
  32.     }
  33.     public function IdBul($entity,$id){
  34.         $em=$this->getDoctrine()->getManager();
  35.         $qb $em->createQueryBuilder();
  36.         $veriler=$qb->select('x.id')
  37.             ->from('App:'.$entity'x')
  38.             ->join('x.dil','d')
  39.             ->where('x.dilgrup='.$id)
  40.             ->groupBy('x.dil')
  41.             ->getQuery()
  42.             ->getScalarResult();
  43.         return $veriler[0]['id'];
  44.     }
  45.     function varsayilanDil(){
  46.         $em=$this->getDoctrine()->getManager();
  47.         $qb $em->createQueryBuilder();
  48.         $diller=$qb->select('d.id,d.kisa,d.uzun')
  49.             ->from('App:Dil''d')
  50.             ->where("d.aktif=1 and d.varsayilan=1")
  51.             ->orderBy('d.id')
  52.             ->getQuery()
  53.             ->getScalarResult();
  54.         return $diller[0];
  55.     }
  56.     function gecerliAktifDil(){
  57.         $em=$this->getDoctrine()->getManager();
  58.         $qb $em->createQueryBuilder();
  59.         $diller=$qb->select('d.id')
  60.             ->from('App:Dil''d')
  61.             ->where("d.aktif=1")
  62.             ->orderBy('d.id')
  63.             ->getQuery()
  64.             ->getScalarResult();
  65.         return $diller[0]['id'];
  66.     }
  67.     public function ayarlar($alan,$dil='')
  68.     {
  69.         $em=$this->getDoctrine()->getManager();
  70.         if($dil=='') {
  71.             $qb $em->createQueryBuilder();
  72.             $dd $qb->select("e.id")
  73.                 ->from('App:Dil''e')
  74.                 ->where('e.aktif=1 and e.varsayilan=1')
  75.                 ->getQuery()
  76.                 ->getScalarResult();
  77.             $dil=$dd[0]['id'];
  78.         }
  79.         $qb $em->createQueryBuilder();
  80.         $ayarlar=$qb->select("e.$alan")
  81.             ->from('App:Ayarlar''e')
  82.             ->where('e.dil='.$dil)
  83.             ->getQuery()
  84.             ->getScalarResult();
  85.         return $ayarlar[0][$alan];
  86.     }
  87.     function uzantiBul($type){
  88.         if($type=='image/jpeg'){ return '.jpg'; }
  89.         elseif($type=='image/png'){ return '.png'; }
  90.         elseif($type=='image/gif'){ return '.gif'; }
  91.         elseif($type=='video/mp4'){ return '.mp4'; }
  92.         elseif($type=='application/rtf'){ return '.rtf'; }
  93.         elseif($type=='text/plain'){ return '.txt'; }
  94.         elseif($type=='application/vnd.ms-powerpoint'){ return '.ppt'; }
  95.         elseif($type=='application/vnd.openxmlformats-officedocument.presentationml.presentation'){ return '.pptx'; }
  96.         elseif($type=='application/xml'){ return '.xml'; }
  97.         elseif($type=='text/xml'){ return '.xml'; }
  98.         elseif($type=='application/vnd.ms-excel'){ return '.xls'; }
  99.         elseif($type=='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){ return '.xlsx'; }
  100.         elseif($type=='application/msword'){ return '.doc'; }
  101.         elseif($type=='application/zip'){ return '.zip'; }
  102.         elseif($type=='application/vnd.openxmlformats-officedocument.wordprocessingml.document'){ return '.docx'; }
  103.         else{ return '.belirsiz'; }
  104.     }
  105.     function rasgele($uzunluk)
  106.     {
  107.         $key='';
  108.         $karakterler "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  109.         for($i=0;$i<$uzunluk;$i++)
  110.         {
  111.             $key .= $karakterler{rand(0,35)};
  112.         }
  113.         return $key;
  114.     }
  115.     function rasgeleSayi($uzunluk)
  116.     {
  117.         $key='';
  118.         $karakterler "1234567890";
  119.         for($i=0;$i<$uzunluk;$i++)
  120.         {
  121.             $key .= $karakterler{rand(0,35)};
  122.         }
  123.         return $key;
  124.     }
  125.     function son_dilgrup($entity){
  126.         $em=$this->getDoctrine()->getManager();
  127.         $qb $em->createQueryBuilder();
  128.         $data=$qb->select('h.dilgrup')
  129.             ->from('App:'.$entity'h')
  130.             ->orderBy('h.dilgrup','desc')
  131.             ->getQuery()
  132.             ->getScalarResult();
  133.         if(count($data)>0){
  134.             $dilgrup intval($data[0]['dilgrup'])+1;
  135.         }else{
  136.             $dilgrup 1;
  137.         }
  138.         return $dilgrup;
  139.     }
  140.     function sonGrup($entity){
  141.         $em=$this->getDoctrine()->getManager();
  142.         $qb $em->createQueryBuilder();
  143.         $data=$qb->select('h.grup')
  144.             ->from('App:'.$entity'h')
  145.             ->orderBy('h.grup','desc')
  146.             ->getQuery()
  147.             ->getScalarResult();
  148.         if(count($data)>0){
  149.             $dilgrup intval($data[0]['grup'])+1;
  150.         }else{
  151.             $dilgrup 1;
  152.         }
  153.         return $dilgrup;
  154.     }
  155.     function seo($url,$dil=1){
  156.         if($dil==1) {
  157.             $tr = array('ş''Ş''ı''I''İ''ğ''Ğ''ü''Ü''ö''Ö''Ç''ç''('')''/'':'',');
  158.             $eng = array('s''s''i''i''i''g''g''u''u''o''o''c''c''''''-''-''');
  159.             $s str_replace($tr$eng$url);
  160.             $find = array('/[^A-Za-z0-9\-<>]/''/[\-]+/''/<[^>]*>/');
  161.             $repl = array('-''-''-');
  162.             $s preg_replace($find$repl$s);
  163.             $s strtolower($s);
  164.             $s preg_replace('/&amp;amp;amp;amp;amp;amp;amp;amp;amp;.+?;/'''$s);
  165.             $s preg_replace('/\s+/''-'$s);
  166.             $s preg_replace('|-+|''-'$s);
  167.             $s preg_replace('/#/'''$s);
  168.             $s str_replace('.'''$s);
  169.             $s trim($s'-');
  170.             $s strtolower($s);
  171.             return $s;
  172.         }else{
  173.             $tr = array('('')''/'':'',');
  174.             $eng = array('''''-''-''');
  175.             $s str_replace($tr$eng$url);
  176.             $find = array('/[^A-Za-z0-9\-<>]/''/[\-]+/''/<[^>]*>/');
  177.             $repl = array('-''-''-');
  178.             $s preg_replace($find$repl$s);
  179.             $s strtolower($s);
  180.             $s preg_replace('/&amp;amp;amp;amp;amp;amp;amp;amp;amp;.+?;/'''$s);
  181.             $s preg_replace('/\s+/''-'$s);
  182.             $s preg_replace('|-+|''-'$s);
  183.             $s preg_replace('/#/'''$s);
  184.             $s str_replace('.'''$s);
  185.             $s trim($s'-');
  186.             $s strtolower($s);
  187.             return $s;
  188.         }
  189.     }
  190.     function yandexToken(){
  191.         if ($this->get('session')->get('iamToken')){
  192.             return $this->get('session')->get('iamToken');
  193.         }else {
  194.             $curl curl_init();
  195.             curl_setopt_array($curl, array(
  196.                 CURLOPT_URL => 'https://iam.api.cloud.yandex.net/iam/v1/tokens',
  197.                 CURLOPT_RETURNTRANSFER => true,
  198.                 CURLOPT_ENCODING => '',
  199.                 CURLOPT_MAXREDIRS => 10,
  200.                 CURLOPT_TIMEOUT => 0,
  201.                 CURLOPT_FOLLOWLOCATION => true,
  202.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  203.                 CURLOPT_CUSTOMREQUEST => 'POST',
  204.                 CURLOPT_POSTFIELDS => '{
  205.     "yandexPassportOauthToken":"y0_AgAAAAAZYEETAATuwQAAAADuaUPsZ3x4KXscRqel7NbnsyEYPaf2HWE"
  206. }',
  207.                 CURLOPT_HTTPHEADER => array(
  208.                     'Content-Type: application/json'
  209.                 ),
  210.             ));
  211.             $response curl_exec($curl);
  212.             $response json_decode($responsetrue);
  213.             $this->get('session')->set('iamToken'$response['iamToken']);
  214.             return $response['iamToken'];
  215.         }
  216.     }
  217.     function cevir($deger,$x,$dil){
  218.         if ($deger==''){
  219.             return "";
  220.         }
  221.         $token $this->yandexToken();
  222.         $curl curl_init();
  223.         curl_setopt_array($curl, array(
  224.             CURLOPT_URL => 'https://translate.api.cloud.yandex.net/translate/v2/translate',
  225.             CURLOPT_RETURNTRANSFER => true,
  226.             CURLOPT_ENCODING => '',
  227.             CURLOPT_MAXREDIRS => 10,
  228.             CURLOPT_TIMEOUT => 0,
  229.             CURLOPT_FOLLOWLOCATION => true,
  230.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  231.             CURLOPT_CUSTOMREQUEST => 'POST',
  232.             CURLOPT_POSTFIELDS =>'{
  233.     "folderId": "b1g1l9b33ueptm8liaou",
  234.     "texts": "'.$deger.'",
  235.     "targetLanguageCode": "'.$dil.'"
  236. }',
  237.             CURLOPT_HTTPHEADER => array(
  238.                 'Authorization: Bearer '.$token,
  239.                 'Content-Type: application/json'
  240.             ),
  241.         ));
  242.         $response curl_exec($curl);
  243.         $response json_decode($responsetrue);
  244.         return $response['translations'][0]['text'];
  245.     }
  246.     public function ceviri($deger,$suanDil='')
  247.     {
  248.         $em $this->getDoctrine()->getManager();
  249.         if ($suanDil==''){
  250.             $suanDil $this->get('session')->get('dil');
  251.         } else {
  252.             $qb $em->createQueryBuilder();
  253.             $dill=$qb->select('d.id,d.kisa,d.uzun')
  254.                 ->from('App:Dil''d')
  255.                 ->where('d.id='.$suanDil)
  256.                 ->getQuery()
  257.                 ->getScalarResult();
  258.             $suanDil $dill[0];
  259.         }
  260.         $qb $em->createQueryBuilder();
  261.         $ceviriTara=$qb->select('c.deger,c.id')
  262.             ->from('App:Ceviri''c')
  263.             ->join('c.dil','d')
  264.             ->where("c.deger='$deger'")
  265.             ->getQuery()
  266.             ->getScalarResult();
  267.         if (count($ceviriTara) > 0) {
  268.             if ($suanDil['id'] != 1) {
  269.                 $qb $em->createQueryBuilder();
  270.                 $ceviriTara2=$qb->select('c.deger')
  271.                     ->from('App:Ceviri''c')
  272.                     ->join('c.dil','d')
  273.                     ->where("d.id=".$suanDil['id']." and c.trId=".$ceviriTara[0]['id'])
  274.                     ->getQuery()
  275.                     ->getScalarResult();
  276.                 if (count($ceviriTara2) > 0) {
  277.                     $deger $ceviriTara2[0]['deger'];
  278.                 } else {
  279.                     if($deger=='İletişim') {
  280.                     }
  281.                     if ($suanDil['id'] != '1') {
  282.                         $deger $this->cevir($deger,'',$suanDil['kisa']);
  283.                         $dill $em->getReference(Dil::class,$suanDil['id']);
  284.                         $ceviri = new Ceviri();
  285.                         $ceviri->setDil($dill);
  286.                         $ceviri->setDeger($deger);
  287.                         $ceviri->setTrId($ceviriTara[0]['id']);
  288.                         $em->persist($ceviri);
  289.                         $em->flush();
  290.                     }
  291.                 }
  292.             }
  293.         }
  294.         else {
  295.             if ($suanDil['id'] == 1) {
  296.                 $dill $em->getReference(Dil::class,$suanDil['id']);
  297.                 $ceviri = new Ceviri();
  298.                 $ceviri->setDil($dill);
  299.                 $ceviri->setDeger($deger);
  300.                 $ceviri->setTrId(0);
  301.                 $em->persist($ceviri);
  302.                 $em->flush();
  303.             }
  304.             else {
  305.                 $dilTr $em->getReference(Dil::class,1);
  306.                 $ceviri = new Ceviri();
  307.                 $ceviri->setDil($dilTr);
  308.                 $ceviri->setDeger($deger);
  309.                 $ceviri->setTrId(0);
  310.                 $em->persist($ceviri);
  311.                 $em->flush();
  312.                 $deger $this->cevir($deger,'',$suanDil['kisa']);
  313.                 $dill $em->getReference(Dil::class,$suanDil['id']);
  314.                 $ceviriDil = new Ceviri();
  315.                 $ceviriDil->setDil($dill);
  316.                 $ceviriDil->setDeger($deger);
  317.                 $ceviriDil->setTrId($ceviri->getId());
  318.                 $em->persist($ceviriDil);
  319.                 $em->flush();
  320.             }
  321.         }
  322.         return $deger;
  323.     }
  324.     public function yetkiler($yetkiler){
  325.         if ($yetkiler==''){
  326.             return 1;
  327.         }
  328.         $yetkiler explode('~',str_replace(array('{','}'),array('',''),substr($yetkiler,0,strlen($yetkiler)-1)));
  329.         $return = [];
  330.         foreach ($yetkiler as $y){
  331.             $x explode(':',$y);
  332.             $z explode(',',$x[1]);
  333.             $return[$x[0]]['gorme']=$z[0];
  334.             $return[$x[0]]['ekleme']=$z[1];
  335.             $return[$x[0]]['duzenleme']=$z[2];
  336.             $return[$x[0]]['silme']=$z[3];
  337.         }
  338.         if($this->getUser()->getRoles()[0]=='ROLE_SUPERADMIN' or $this->getUser()->getRoles()[0]=='ROLE_ADMIN'){
  339.             return 1;
  340.         }else{
  341.             return $return;
  342.         }
  343.     }
  344.     public function domainSorgula(){
  345.         $em $this->getDoctrine()->getManager();
  346.         $suan = new \DateTime('now');
  347.         $tarih = new \DateTime($this->ayarlar('domainTarih'));
  348.         if (empty($this->ayarlar('domainTarih')) or $tarih->format('U') < $suan->format('U')) {
  349.             $domain str_replace(array('/''https:''http:'), array(''''''), $this->ayarlar('siteYolu'));
  350.             $ch curl_init();
  351.             curl_setopt($chCURLOPT_URL"https://www.whois.com/whois/" $domain);
  352.             curl_setopt($chCURLOPT_RETURNTRANSFER1);
  353.             curl_setopt($chCURLOPT_REFERER'https://www.google.com/');
  354.             $output curl_exec($ch);
  355.             curl_close($ch);
  356.             $dBol explode('.'$domain);
  357.             if (count($dBol) == 2) {
  358.                 preg_match_all('@<pre class="df-raw" id="registrarData">(.*?)</pre>@si'$output$icerik);
  359.                 $tarihB explode('Registrar Registration Expiration Date:'$icerik[0][0]);
  360.                 $tarihB explode('Registrar'$tarihB[1]);
  361.                 $tarih str_replace('T'' '$tarihB[0]);
  362.             } else {
  363.                 preg_match_all('@<pre class="df-raw" id="registryData">(.*?)</pre>@si'$output$icerik);
  364.                 $tarihB explode('Expires on..............:'$icerik[0][0]);
  365.                 $tarihB explode('.'$tarihB[1]);
  366.                 $tarih $tarihB[0];
  367.             }
  368.             //echo $tarih;
  369.             $tarih = new \DateTime($tarih);
  370.             if ($this->ayarlar('debug') != 1) {
  371.                 $qb $em->createQueryBuilder();
  372.                 $q $qb->update('App:Ayarlar''a')
  373.                     ->set('a.domainTarih'':domainTarih')
  374.                     ->setParameter('domainTarih'$tarih)
  375.                     ->getQuery()
  376.                     ->execute();
  377.             }
  378.         }
  379.         return $tarih;
  380.     }
  381.     public function hostingSorgulama(){
  382.         $em $this->getDoctrine()->getManager();
  383.         $suan = new \DateTime('now');
  384.         if (empty($this->ayarlar('hostingTarih'))) {
  385.             $domain str_replace(array('/''https:''http:'), array(''''''), $this->ayarlar('siteYolu'));
  386.             $ch curl_init();
  387.             curl_setopt($chCURLOPT_URL"https://174gj41p1.ni.net.tr:2087/json-api/listaccts?api.version=1&search=$domain&searchtype=domain");
  388.             curl_setopt($chCURLOPT_USERPWD'root' ":" 'aKuosv}_x3{K');
  389.             curl_setopt($chCURLOPT_RETURNTRANSFER1);
  390.             $output curl_exec($ch);
  391.             curl_close($ch);
  392.             $output json_decode($output);
  393.             $baslangicTarihi = new \DateTime();
  394.             $baslangicTarihi->setTimestamp($output->data->acct[0]->unix_startdate);
  395.             $baslangicTarihi->modify('+1 year');
  396.             if ($this->ayarlar('debug')!=1) {
  397.                 $qb $em->createQueryBuilder();
  398.                 $q $qb->update('App:Ayarlar''a')
  399.                     ->set('a.hostingTarih'':hostingTarih')
  400.                     ->setParameter('hostingTarih'$baslangicTarihi)
  401.                     ->getQuery()
  402.                     ->execute();
  403.             }
  404.         }else{
  405.             $baslangicTarihi = new \DateTime($this->ayarlar('hostingTarih'));
  406.             if ($baslangicTarihi->format('U') < $suan->format('U')) {
  407.                 if($baslangicTarihi->format('d.m.Y')!=$suan->format('d.m.Y')){
  408.                     $baslangicTarihi->modify('+1 year');
  409.                     if ($this->ayarlar('debug')!=1) {
  410.                         $qb $em->createQueryBuilder();
  411.                         $q $qb->update('App:Ayarlar''a')
  412.                             ->set('a.hostingTarih'':hostingTarih')
  413.                             ->setParameter('hostingTarih'$baslangicTarihi)
  414.                             ->getQuery()
  415.                             ->execute();
  416.                     }
  417.                 }
  418.             }
  419.         }
  420.         return $baslangicTarihi;
  421.     }
  422.     public function dilSay(){
  423.         $em $this->getDoctrine()->getManager();
  424.         $qb $em->createQueryBuilder();
  425.         $ayarlar=$qb->select("e.id")
  426.             ->from('App:Dil''e')
  427.             ->where('e.aktif=1')
  428.             ->getQuery()
  429.             ->getScalarResult();
  430.         return count($ayarlar);
  431.     }
  432.     function altKategoriListeSiteMap($dilgrup,$sSeo,$dil){
  433.         $em $this->getDoctrine()->getManager();
  434.         $qb $em->createQueryBuilder();
  435.         $kategoriler=$qb->select('k.dilgrup,k.seourl,d.kisa as dKisa,k.ustid')
  436.             ->from('App:Kategori''k')
  437.             ->join('k.dil','d')
  438.             ->where('k.ustid='.$dilgrup.' and d.id='.$dil)
  439.             ->orderBy('k.sira','ASC')
  440.             ->getQuery()
  441.             ->getScalarResult();
  442.         $siteyolu $this->ayarlar('siteYolu');
  443.         $suan = new \DateTime('now');
  444.         $veriler='';
  445.         foreach ($kategoriler as $k) {
  446.             if ($this->dilSay() > 1) {
  447.                 $veriler .= '<url>
  448.                                   <loc>' $siteyolu .$k['dKisa'].'/'.$sSeo.'/'.$this->altKategoriGeriYaz($k['ustid'],$dil) .$k['seourl'].'</loc>
  449.                                   <lastmod>' $suan->format('Y-m-d') . 'T' $suan->format('H:i:s') . '+00:00</lastmod>
  450.                                   <priority>0.80</priority>
  451.                                 </url>';
  452.             } else {
  453.                 $veriler .= '<url>
  454.                                   <loc>' $siteyolu .$sSeo.'/'.$this->altKategoriGeriYaz($k['ustid'],$dil) .$k['seourl'].'</loc>
  455.                                   <lastmod>' $suan->format('Y-m-d') . 'T' $suan->format('H:i:s') . '+00:00</lastmod>
  456.                                   <priority>0.80</priority>
  457.                                 </url>';
  458.             }
  459.             $veriler .= $this->altKategoriListeSiteMap($k['dilgrup'], $sSeo,$dil);;
  460.         }
  461.         return $veriler;
  462.     }
  463.     function altKategoriGeriYaz($ustid,$dil=1){
  464.         $em $this->getDoctrine()->getManager();
  465.         $qb $em->createQueryBuilder();
  466.         $kategoriler=$qb->select('k.id,k.dilgrup,k.adi,k.seourl,k.ustid')
  467.             ->from('App:Kategori''k')
  468.             ->join('k.dil','d')
  469.             ->where('k.dilgrup='.$ustid.' and d.id='.$dil)
  470.             ->groupBy('k.dilgrup')
  471.             ->orderBy('k.sira','ASC')
  472.             ->getQuery()
  473.             ->getScalarResult();
  474.         $veriler='';
  475.         foreach ($kategoriler as $k){
  476.             $veriler.=$this->altKategoriGeriYaz($k['ustid'],$dil).$k['seourl'].'/';
  477.         }
  478.         return $veriler;
  479.     }
  480.     public function iletisimBilgileri($alan){
  481.         $em $this->getDoctrine()->getManager();
  482.         $dil $this->get('session')->get('dil');
  483.         $qb $em->createQueryBuilder();
  484.         $iletisim=$qb->select('s.'.$alan)
  485.             ->from('App:Iletisim''s')
  486.             ->join('s.dil''d')
  487.             ->where('d.id='.$dil['id'])
  488.             ->getQuery()
  489.             ->getScalarResult();
  490.         return $iletisim[0][$alan];
  491.     }
  492.     public function imageResizer($resim,$resim2,$boyut=800){
  493.         $resimBol explode('.',$resim);
  494.         $uzanti $resimBol[count($resimBol)-1];
  495.         $yol 'gecici_yukleme/'.$resim;
  496.         $yol2 'gecici_yukleme/'.$resim2.'.webp';
  497.         list($width$height) = getimagesize($yol);
  498.         $oran $width $boyut;
  499.         $yeni_genislik $width $oran;
  500.         $yeni_yukseklik $height $oran;
  501.         if ($uzanti=='jpeg' or $uzanti=='jpg' or $uzanti=='JPEG' or $uzanti=='JPG'){
  502.             $mevcut_resim imagecreatefromjpeg($yol);
  503.         }else{
  504.             $mevcut_resim imagecreatefrompng($yol);
  505.         }
  506.         $yeni_resim imagecreatetruecolor($yeni_genislik$yeni_yukseklik);
  507.         imageAlphaBlending($yeni_resimfalse);
  508.         imageSaveAlpha($yeni_resimtrue);
  509. // By default, the canvas is black, so make it transparent
  510.         $trans imagecolorallocatealpha($yeni_resim000127);
  511.         imagefilledrectangle($yeni_resim00$yeni_genislik 1$yeni_yukseklik 1$trans);
  512.         imagecopyresampled($yeni_resim$mevcut_resim0000$yeni_genislik$yeni_yukseklik$width$height);
  513.         @unlink($yol);
  514.         imagewebp($yeni_resim$yol2 );
  515.         return $resim2.'.webp';
  516.     }
  517.     public function removeEntity($veriler){
  518.         $em $this->getDoctrine()->getManager();
  519.         foreach ($veriler as $veri){
  520.             $em->remove($veri);
  521.         }
  522.     }
  523.     public function uploadFile($file,$klasor="",$filePath=""){
  524.         if ($klasor==""){
  525.             $klasor $this->ayarlar('uploadFolder');
  526.         }
  527.         if ($filePath==""){
  528.             $filePath 'gecici_yukleme/';
  529.         }
  530.         $filePath .= $file;
  531.         $username 'rvcloudstorage';
  532.         $password 'rvrv/*-2020';
  533.         $url 'https://j15502zk.ni.net.tr:2083';
  534.         $yukleme_yeri 'webSitesApp/'.$klasor;
  535.         $curl curl_init();
  536.         $upload_file realpath($filePath);
  537.         $destination_dir "public_html/".$yukleme_yeri;
  538.         if (function_exists('curl_file_create')) {
  539.             $cf curl_file_create($upload_file);
  540.         } else {
  541.             $cf "@/" $upload_file;
  542.         }
  543.         $payload = array(
  544.             'dir' => $destination_dir,
  545.             'file-1' => $cf
  546.         );
  547.         $actionUrl $url "/execute/Fileman/upload_files";
  548.         curl_setopt($curlCURLOPT_SSL_VERIFYPEER0);       // Allow self-signed certs
  549.         curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);       // Allow certs that do not match the hostname
  550.         curl_setopt($curlCURLOPT_HEADER0);               // Do not include header in output
  551.         curl_setopt($curlCURLOPT_RETURNTRANSFER1);       // Return contents of transfer on curl_exec
  552.         $header[0] = "Authorization: Basic " base64_encode($username ":" $password) . "\n\r";
  553.         curl_setopt($curlCURLOPT_HTTPHEADER$header);    // set the username and password
  554.         curl_setopt($curlCURLOPT_URL$actionUrl);        // execute the query
  555.         // Set up a POST request with the payload.
  556.         curl_setopt($curlCURLOPT_POSTtrue);
  557.         curl_setopt($curlCURLOPT_POSTFIELDS$payload);
  558.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  559.         $result curl_exec($curl);
  560.         if ($result == false) {
  561.             error_log("curl_exec threw error \"" curl_error($curl) . "\" for $actionUrl");
  562.             // log error if curl exec fails
  563.         }
  564.         curl_close($curl);
  565.         @unlink($filePath);
  566.         return json_decode($resulttrue);
  567.     }
  568.     function deleteFile($file)
  569.     {
  570.         if ($file!='') {
  571.             $curl curl_init();
  572.             $destination_dir 'public_html/webSitesApp/'.$this->ayarlar('uploadFolder').'/' $file;
  573.             $username 'root';
  574.             $password 'suleyman1995ilgin***';
  575.             $url 'https://j15502zk.ni.net.tr:2083';
  576.             $user 'rvcloudstorage';
  577.             $actionUrl 'https://j15502zk.ni.net.tr:2087/json-api/cpanel?cpanel_jsonapi_user=' $user '&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=fileop&op=unlink&sourcefiles=' $destination_dir '&doubledecode=1';
  578.             curl_setopt($curlCURLOPT_SSL_VERIFYPEER0);       // Allow self-signed certs
  579.             curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);       // Allow certs that do not match the hostname
  580.             curl_setopt($curlCURLOPT_HEADER0);               // Do not include header in output
  581.             curl_setopt($curlCURLOPT_RETURNTRANSFER1);       // Return contents of transfer on curl_exec
  582.             $header[0] = "Authorization: Basic " base64_encode($username ":" $password) . "\n\r";
  583.             curl_setopt($curlCURLOPT_HTTPHEADER$header);    // set the username and password
  584.             curl_setopt($curlCURLOPT_URL$actionUrl);        // execute the query
  585.             curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  586.             $result curl_exec($curl);
  587.             if ($result == false) {
  588.                 error_log("curl_exec threw error \"" curl_error($curl) . "\" for $actionUrl");
  589.                 // log error if curl exec fails
  590.             }
  591.             curl_close($curl);
  592.             return json_decode($resulttrue);
  593.         }
  594.     }
  595.     public function dilgrupBul($entity,$id){
  596.         $em $this->getDoctrine()->getManager();
  597.         $qb $em->createQueryBuilder();
  598.         $veriler=$qb->select('x.dilgrup')
  599.             ->from('App:'.$entity'x')
  600.             ->join('x.dil','d')
  601.             ->where('x.id='.$id)
  602.             ->groupBy('x.dil')
  603.             ->getQuery()
  604.             ->getScalarResult();
  605.         return $veriler[0]['dilgrup'];
  606.     }
  607.     function chatGPT($promp)
  608.     {
  609.         ini_set('max_execution_time'0);
  610.         $data = [];
  611.         $data['model'] = 'gpt-3.5-turbo';
  612.         $data['messages'][0]['role'] = 'user';
  613.         $data['messages'][0]['content'] = $promp;
  614.         $curl curl_init();
  615.         curl_setopt_array($curl, array(
  616.             CURLOPT_URL => 'https://api.openai.com/v1/chat/completions',
  617.             CURLOPT_RETURNTRANSFER => true,
  618.             CURLOPT_ENCODING => '',
  619.             CURLOPT_MAXREDIRS => 10,
  620.             CURLOPT_TIMEOUT => 0,
  621.             CURLOPT_FOLLOWLOCATION => true,
  622.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  623.             CURLOPT_CUSTOMREQUEST => 'POST',
  624.             CURLOPT_POSTFIELDS =>json_encode($data),
  625.             CURLOPT_HTTPHEADER => array(
  626.                 'Authorization: Bearer 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',
  627.                 'Content-Type: application/json'
  628.             ),
  629.         ));
  630.         $response curl_exec($curl);
  631.         $response json_decode($response,true);
  632.         curl_close($curl);
  633.         return $response['choices'][0]['message']['content'];
  634.     }
  635.     public function digerTasarimlar($grupNo){
  636.         $em $this->getDoctrine()->getManager();
  637.         $qb $em->createQueryBuilder();
  638.         $veriler=$qb->select('t.translate')
  639.             ->from('App:Tasarim''t')
  640.             ->where('t.grup='.$grupNo)
  641.             ->getQuery()
  642.             ->getScalarResult();
  643.         $translate="";
  644.         foreach ($veriler as $veri){
  645.             $translate .=$veri['translate'];
  646.         }
  647.         return $translate;
  648.     }
  649.     function emptyDir($dir) {
  650.         if (is_dir($dir)) {
  651.             $scn scandir($dir);
  652.             foreach ($scn as $files) {
  653.                 if ($files !== '.') {
  654.                     if ($files !== '..') {
  655.                         if (!is_dir($dir '/' $files)) {
  656.                             unlink($dir '/' $files);
  657.                         } else {
  658.                             $this->emptyDir($dir '/' $files);
  659.                             rmdir($dir '/' $files);
  660.                         }
  661.                     }
  662.                 }
  663.             }
  664.         }
  665.     }
  666. }