Jump to content
php.lv forumi

Cibiņš

Reģistrētie lietotāji
  • Posts

    487
  • Joined

  • Last visited

Posts posted by Cibiņš

  1. Nu tad tas superkods varētu būt šāds:

    $from_field = 'Mani sauc Cibins €';
    
    //$remove_tags = str_replace($from_field);
    $remove_tags = $from_field;
    $fixpound= str_replace("£", "£", $remove_tags);
    $fixeur = str_replace("€", "€", $fixpound);
    $remove_symbols = preg_replace("/[^a-zA-Z0-9\s\.\/:!\[\]\*\+\-\|\<\>@#\$%\^&\(\)_=\';,'\?\\\{\}`~\"]/", '', $fixeur);
    $lowercase = strtolower($remove_symbols);
    //$olddata=array(' ',' ');
    //$newdata=array('-','-');
    //$replace_spaces = str_replace($olddata, $newdata, $lowercase);
    $lowercase = trim($lowercase);
    $replace_spaces = str_replace(' ', '-', $lowercase);
    
    
    print "'$replace_spaces'\n";
    

     

    Es gan pats izmantoju šādu kods:

    function urlize($name)
    {
       $name = preg_replace("/[%]/", " ", $name);
       $name = html_entity_decode($name, ENT_QUOTES, "UTF-8");
       $name = mb_strtolower($name);
       $name = strip_tags($name);
       $name = preg_replace("/[\:\/\?\#\[\]\@\"'\(\)\.,&;\+=\\\]/", " ", $name);
       $name = trim($name);
       $name = preg_replace("/\s+/", "-", $name);
       $name = preg_replace("/-+/", "-", $name);
    
       return $name;
    } // urlize
    
    

     

    "Test category 1 pagename €" izvada kā "test-category-1-pagename-"..atkal tas MĪNUSS beigās ir :(

     

    $fixpound= str_replace("£", "£", $categories_pagename);
       $fixeur = str_replace("€", "€", $fixpound);
       $remove_symbols = preg_replace("/[^a-zA-Z0-9\s\.\/:!\[\]\*\+\-\|\<\>@#\$%\^&\(\)_=\';,'\?\\\{\}`~\"]/", '', $fixeur);
       $lowercase = strtolower($remove_symbols);
       $lowercase = trim($lowercase);
       $replace_spaces = str_replace(' ', '-', $lowercase);
       $remove_tags=strip_tags($replace_spaces);
    

  2. Priekš kā ir šīs rindas?

    $remove_tags = str_replace($from_field);
    $fixpound= str_replace("£", "£", $remove_tags);
    $fixeur = str_replace("€", "€", $fixpound);
    

     

    Šo

    $olddata=array(' ',' ');
    $newdata=array('-','-');
    $replace_spaces = str_replace($olddata, $newdata, $lowercase);
    

     

    var aizstāt ar

    $replace_spaces = str_replace(' ', '-', $lowercase);
    

     

    Pamēģināju - nekādi papildus speisi neveidojas. Varbūt jau saņem datus ar atstarpi beigās?

    $from_field = trim($from_field);
    

     

    Sorry nolažojos, kad teksts ir piemēŗam šāds "Mani sauc Cibins €" vai kad ieliek kautkur neatļautus simbolus - copyright, euro, pound utt tad euro vietā veidojas mistisks space. Reāli nezinu kā lai aizvieto teksta beigās vai pa vidu neatļauto simbolu speisus..

  3. Sveiki kolēģi! Tātad ieskrēju ar problēmu - tādu problēmu, ka teksta beigās liek mistisku speisu jeb " ". Mēģināju ar str_replace novākt bet tad iebāž "-", rotams speisos biju paredzējis likt tos mīnusus bet nu nejau teksta beigās!

     

    Respektīvi ja ierakstu formā vārdu "Mani sauc Cibins" tad izvada "mani-sauc-cibins-" bet to "-" beigās nahren nevajag! Kā lai aizvāc? Kā lai padod lai to MĪNUSU neliek teksta beigās? Protams šeit padodot vērtību ir jānovāc visi tagi, visi liekie simboli, ļaujot tekstu sadalīt ar mīnusa zīmēm.

     

    $remove_tags = str_replace($from_field);
    $fixpound= str_replace("£", "£", $remove_tags);
       $fixeur = str_replace("€", "€", $fixpound);
       $remove_symbols = preg_replace("/[^a-zA-Z0-9\s\.\/:!\[\]\*\+\-\|\<\>@#\$%\^&\(\)_=\';,'\?\\\{\}`~\"]/", '', $fixeur);
       $lowercase = strtolower($remove_symbols);
       $olddata=array(' ',' ');
       $newdata=array('-','-');
       $replace_spaces = str_replace($olddata, $newdata, $lowercase);
    

  4. Kā lai izveido:

     

    status.text('Atļauti IR tikai JPG, PNG or GIF faili');
    

     

    lai izvada smuku erroru?

     

    Tas ir -

    status.text('<div class="kludaszinja"><img src="error_checkmark_red.png" width="19" height="19" alt="err_green" style="position: absolute; margin-left: -25px; margin-top: -1px;" />Atļauti IR tikai JPG, PNG or GIF faili</div>');
    

     

    lapā izvadās kā teksts:

     

    <div class="kludaszinja"><img src="error_checkmark_red.png" width="19" height="19" alt="err_green" style="position: absolute; margin-left: -25px; margin-top: -1px;" />Atļauti IR tikai JPG, PNG or GIF faili</div>

     

    nevis kā smuks cssā stilizēts kļūdas bloks :(

  5. $mailheaders .= "Content-type: text/html; charset=UTF-8\r\n";<pre class="prettyprint">

    text/html aizvietojot ar text/plain attēla no

    resources/

    uz

    http://www.lapa.lv/resources/ 

    direktoriju viņš nav samainījis! Moš ir vēl kādi varianti kā aizvietot noteiktus vārdus?

  6. Kapēc nosūtot e-pastu ja cilvēks ir ielicis piem attēlu, pie submit neaizvietojas vārds?

     

    $msgname=$_POST['messagename'];
    $msgtxt=$_POST['messagetext'];
    
    $oldimage = 'src="resources/';
    $newimage='src="http://www.lapa.lv/resources/';
    
    $newtext = str_replace($oldimage, $newimage, $msgtxt);
    
    $message = "<span class='controlGreen'>Ziņa nosūtīta sekmīgi</span>";
    
    $frommail="[email protected]";
    $msgheader="Jauna ziņa no Lapa: ".$msgname;
    
    $mailheaders  = "MIME-Version: 1.0\r\n";
    $mailheaders .= "Content-type: text/html; charset=UTF-8\r\n";
    $mailheaders .= "From: ".$frommail." <".$frommail.">\r\n";
    $mailheaders .= "Reply-To: ".$frommail." <".$frommail.">\r\n";
    $mailmsg .= "
    <html>
    <header>
    </header>
    <body>
    ".$newtext."
    </body>
    </html>
    ";
    

  7. Varbūt tu izvadi vēl kādu simbolu pirms faila vai kā cita. Teiksim, beigās pēc ?> ir jauna rindiņa.

     

    Nē man skripts ir šāds

     

    .........................
    $date = date($dateformat, strtotime($pat_created));
    
    $filenm = 'mape1/mape2/'.$_GET['file'];
    
    if($_GET['file']){
        if(!file)
        {
    die('file not found');
        }
        else{
    		header("Cache-Control: public");
    		header("Content-Description: File Transfer");
        	header("Content-Disposition: attachment; filename=$filenm");
    		header("Content-Type: application/zip");
      	header("Content-Transfer-Encoding: binary");
        	readfile($filenm);
       }
    }
    ?>
    <div id="formBuffer" style="width: 1000px;">
    ............
    

  8. Nesaprotu kas te ir nepareizi ka izvada failu ar nosaukumu failadirektorija_failadirektorija_failavards.failapaplasinajums

     

    Piemeram mape1_mape2_image.jpg

     

    Pietam downloadējot failu itkā viņš downloadē vajadzīgo failu bet ja piemēram attēlu nokačā tad attēlā parādās "Preview not available' vai lejupielādējot doc vai excel failus tos nevar atvērt. Teorētiski viņus VAJADZĒTU atvērt. Esmu pārliecināts ar skriptu ka kautkas ir neritīgi.

     

    Faila nosaukums tiek padots urlī un nosaukumu saņem $_GET['file'] funkcija.

     

    $file = 'mape1/mape2/'.$_GET['file'];
    
    if($_GET['file']){
        if(!file)
        {
    die('file not found');
        }
        else{
    
    		header("Cache-Control: public");
    		header("Content-Description: File Transfer");
        	header("Content-Disposition: attachment; filename=$file");
    		header("Content-Type: application/zip");
      	header("Content-Transfer-Encoding: binary");
    
         readfile($file);
       }
    }
    

  9. Man tur nekas nav sarežģīts rekur ir vēl uzlabotāks variants un viss iet kā smērēts! Nekas nav ne pa maz ne pa daudz!

     

     

    if($width > $height){
      			 if ($width > $max_width){
      				 $scale = $max_width/$width;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
      		 }
      		 elseif($width < $height){
      			 if ($height > $max_height){
      				 $scale = $max_height/$height;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
      		 }
      			 else{
      				 $scale = 1;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
    

  10. Paldies jau pats izstrēbu saskābušo krējumu.

     

    Lūk kas man bija vajadzīgs...

     

                   if ($width > $max_width){
      				 $scale = $max_width/$width;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
      			 elseif ($height > $max_height){
      				 $scale = $max_height/$height;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
      			 else{
      				 $scale = 1;
      				 $uploaded = resizeImage($main_image_location,$width,$height,$scale);
      			 }
    

  11. Nesaprotu KĀ lai panāk ka attēls tiek resizēts norādītajā pozīcijā gan UZ HEIGHT, GAN WIDTH saglabājot proporcijas??? Nevis viens vai otrs...pie uploada paņemot TIKAI VIENU - HEIGHT vai WIDTH atkarībā no tā kurš tiek norādīts pirmais :@

     

    Izmēģināju tik variantus cik seksā pozas - nji*uja! :@

     

    //$max_height ir max definētais pieļaujamais augstums
    //$max_width ir max definētais pieļaujamais platums
    //$height ir reālais attēla augstums
    // $width ir reālais attēla platums
    
    if ($height > $max_height){
                       $scale = $max_height/$height;
                       $uploaded = resizeImage($large_image_location,$width,$height,$scale);
    }
    elseif ($width > $max_width){
                       $scale = $max_width/$width;
                       $uploaded = resizeImage($large_image_location,$width,$height,$scale);
    }
    else{
                   $scale = 1;
                   $uploaded = resizeImage($large_image_location,$width,$height,$scale);
    }
    

  12. Kavacky, ar php no MySQL ir doma izvilkt datus.

     

    LOL daGrevis man nevajag ar jquerijiem bet vienkāršāku. Tikdaudz kā uztaisīt lai ar javascript atvērt popup logu māku, bet nemāku to fīču kad uzklikšķina, lai aizveras logs un ievietojas teksta laukā izvēlētā vērtība pietam es prasīju vai nezin neviens kur tādu skriptu vai vismaz piemēru var izrakt, nevis prasīju kādam uztaisīt.

     

    Kaut kādu tādu kā šeit http://www.quirksmode.org/js/popup.html tas mazais lodzinš.

  13. Tev vajag JavaScipt PHP+MySQLā?

     

    Juu..nu kā piemēram ir internetveikaliem dažiem pieņemsim produkta krāsa. Ir formas lauks, kurā ir piemēram krāsas (tekstuālā informācija jeb text fields). Blakus ir podziņa "Select". Uzspiežot uz "Select" podziņas JavaScript popup logā atveras pieejamās krāsas, uz kurām var uzklikšķināt. Lietotājs uzklikšķina uz kādu no krāsām, piemēram - dzeltens, lodziņš aizveras un formas laukā ieliekās teksts "dzeltens".

×
×
  • Create New...