Jump to content
php.lv forumi

DZIEDI

Reģistrētie lietotāji
  • Posts

    31
  • Joined

  • Last visited

Posts posted by DZIEDI

  1. Flash nederēs, tur ir sarežģīāka attēla veidošana, jāsaliek kopā visa mašīna ar fonu.

     

    Cik noprotu, tad Imagick nenāk līdz php un ir papildus jāpievieno php.ini failam. Lai gan neesmu pārbaudījis tā darbības ātrumu, tomēr laikam izmantot jebkurā gadījumā nesanāks, jo plānots izmantot web hostinga pakalpojumus un nevarēšu pievienot imagick

     

    Prieks par lielo atsaucību :) Nu sliktākajā gadījumā var izmantot mašīnu bez izpludinātām robežām, bet gribējās pa glauno...

  2. Sveiki! Vēlos pārkrāsot šādu gradient. (otra krāsa nav blata, bet caurspīdīga)

    q3dfkxxr24rgba6hb11.png

     

    Patreizējais kods

    ini_set("memory_limit","1024M");
    $s=time();
    $png = imagecreatefrompng("grad.png");
    imagealphablending($png, false);
    imagesavealpha($png, true);
    imagetruecolortopalette($png, false, 255);
    $old = imagecolorclosest($png, 0, 0, 255);
    imagecolorset($png, $old, 0, 255, 0);
    imagealphablending($png, false);
    imagesavealpha($png, true);
    Imagepng($png, "grad2.png", 7);
    imagedestroy($png);
    echo "Aprēķināts: ".(time()-$s);

     

    Izmantojot

    imagetruecolortopalette($png, false, 255);

    pārkrāsojas, bet gradients nepaliek - galarezultāts ir vienkārši zaļš attēls. Neizmantojot to funkciju - vispār nekas nemainās.

     

    Šāds kods strādā, bet uz vairākiem attēliem tas ir par lēnu

    	for($j=0;$j<5000;$j++){
         for($i=0;$i<5000;$i++){
            $rgb = imagecolorat($png, $i, $j);
    	$colors = imagecolorsforindex($png, $rgb);
            $new_r = 255;
            $new_g = 0;
            $new_b = 0;
            $alpha = round($colors['alpha']);
            $new_color = imagecolorallocatealpha($png, $new_r, $new_g, $new_b,$alpha); 
            imagesetpixel($png, $i, $j, $new_color);    
         }
      }

     

    Ir kādas idejas kā izlabot pirmo?

  3. Sveiki!

    Es visādi izmēģinājos lai piedabūtu to bibliotēku darboties, bet bez panākumiem. Mēģināju pēc parauga veidot savu kodu, mēģināju lapu saglabāt, mēģināju nokopēt lapas pirmkodu un norādīt viņa servera ārējos failus - viss bez panākumiem.

     

    Mani interesē tieši linear burn blend opcija, bet man neizdevās piedabūt nevienu darboties

    http://www.pixastic.com/lib/docs/actions/blend/

     

    Ja tas ko līdz, tad šeit ir pēdējais ko mēģināju, html failā ir pievienoti visi vajadzīgie javascript faili.

    http://www.failiem.lv/list.php?i=cvaswm

     

    Lūdzu izpalīdziet!

  4. Ja nevar veikt vairāk kā divus savienojumus, tad šī doma atkrīt, ja vien nav iespējams šo skaitu kaut kā manuāli nomainīt. Pietiktu, ja tas strādātu kaut vai uz vienu pārlūku.

     

    Tieši tāpēc, ka izpildās asinhroni es vēlējos vairākus while ciklus paralēli. Mērķis ir panākt lai requestus veic pēc iespējas ātrāk izmantojot visu interneta ātrumu.

    Vai šādā pierakstā tas izpildītos?

    function cikls1(){
    var i=0;
    while(i<2000){
     $('#a').html(i);
     i=i+1;
    }
    }
    function cikls2(){
    var j=2000;
    while(j<4000){
     $('#b').html(j);
     j=j+1;
    }
    }
    setTimeout('cikls1();',0);
    setTimeout('cikls2();',0);
    

    Vēl pāris jautājumi:

    1)Vai šāda situācija darbotos ar 10 funkcijām? Kurš browseris to pieļautu?

    2)Ja negaida callback, vai informācija tik un tā tiks vienmēr nosūtīta vai nav garantēts?

  5. šķiet, ka mans piemērs radīja vairāk problēmas nekā atrisināja.

     

    Runājot precīzāk, es vēlos veikt vairākus ajax request vienlaicīgi. Ar vienu request nav iespējams izmantot 100% interneta ātrumu, tāpēc ar vienu ciklu veicot 100000 requestus vajadzēs vairāk laika nekā ja būs vairāki requesti vienlaicīgi kuri izmantos visu interneta ātrumu. Tāpēc ir nepieciešams izpildīt vairākus request vienlaicīgi.

     

    Āķis vēl ir tajā, ka ir jāpārliecinās vai serveris ir informāciju saņēmis, tāpēc katrs no cikliem veic nākošo requestu atšķirīgā laika, proti if(xmlhttp.readyState==3)

  6. Sveiki!

     

    Vai ir iespējams veikt divus ciklus paralēli?

     

    Piemēram:

    var i=0;
    var j=0;
    while(i<2000){
    $.('#a').html(i);
    i=i+1;
    }
    
    while(j<2000){
    $.('#b').html(j);
    j=j+1;
    }
    

     

    Protams, ka viss ko šeit redzēs ir gala skaitļi, jo dators pagūs aizskaitīt pirms acis nomirkšķinās, bet ja būtu jāveic garākas darbības, vai var veikt divas paralēli?

  7. Sveiki!

    Tātad, problēma sekojoša, ir nodefinēti šādi php headeri:

    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    header("Content-type: text/html; charset=utf-8");
    header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
    header("Pragma: no-cache");

    bet browseri turpina cachot.

    Lūk ko parāda Google Chrome Developer Tool:

     

    Cache-Control:public, max-age=10800

    Connection:Keep-Alive

    Content-Length:1566

    Content-Type:text/html; charset=utf-8

    Date:Wed, 25 Nov 2009 19:08:06 GMT

    Expires:Wed, 25 Nov 2009 22:08:06 GMT

    Keep-Alive:timeout=5, max=100

    Last-Modified:Tue, 03 Nov 2009 16:07:19 GMT

    Pragma:no-cache

    Server:Apache/2.2.8 (Win32) PHP/5.2.6

    X-Powered-By:PHP/5.2.6

     

    Kāpēc atšķiras cache-control un expires? Lūdzu palīdziet.

  8. Beigās izdevās atrisināt problēmu.

    Risinājums:

    				OdbcCommand cad = new OdbcCommand();
    			cad.Connection = conn;
    			cad.CommandText = "SELECT "+horoskops+" FROM horoskopi WHERE datums='"+DateTime.Now.ToString("MM-dd-yyyy")+"'<CR><LF>";
    			string respmsg = cad.ExecuteScalar().ToString();

    un

    			string ConnectionString = 
    			"Driver={MySQL ODBC 5.1 Driver};"+ //jāieraksta bija draiveris
    			"SERVER=localhost;" +
    			"DATABASE=adresati;" +
    "UID=lietotajs;" +
    "PASSWORD=*****;";

  9. Tādā gadījumā cad nebūs definēt. Pašā pirmajā no tām rindiņām tiek definēts, kad cad būs ObcdCommand, tālāk tiek noteikt kurš savienojums tiks izmantots, tad pati komanda, proti sql query. It kā neko lieku nesaskatu. mani vēl jo projām tirda tā adrese, kuru norādīju pirmajā postā, meklēju google iespēju atrast to pašu bez reģistrēšanās - nesanāca.

  10. SELECT vienmēr atgriezīs vienu vērtību (es parūpēšos, lai vienmēr būtu dati, ko atgriezt). Kur tiek veidots un iznīcināts savienojums n-tās reizes?

     

    Izmantojot šo:

    			while (Reader.Read())
    		{
    			string horoskops = Reader.GetString(1);;
    			OdbcCommand cad = new OdbcCommand();
    			cad.Connection = conn;
    			cad.CommandText = "SELECT * FROM horoskopi";
    			OdbcDataReader Horo = cad.ExecuteReader();
    			while (Horo.Read())
    			{
    				string respmsg = Horo.GetString(4);
    				string destnum = Reader.GetString(0);;
    				string resptype = "SMS:TEXT";
    				string resp = "{"+resptype+"}{}{}{"+destnum+"}{"+respmsg+"}";
    				Response.Write(resp);
    			}
    			Horo.Close();
    			cad.Dispose();
    		}

    Vispār tiek atgriezts kaut kas mistisks:

    ERROR [iM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

     

    Exception Details: System.Data.Odbc.OdbcException: ERROR [iM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

     

    Source Error:

     

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

     

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

     

    <%@ Page Language="C#" Debug="true" %>

     

    or:

     

    2) Add the following section to the configuration file of your application:

     

    <configuration>

    <system.web>

    <compilation debug="true"/>

    </system.web>

    </configuration>

     

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

     

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

     

    Stack Trace:

     

    [OdbcException (0x80131937): ERROR [iM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified]

    System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) +35

    System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) +121

    System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +100

    System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27

    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +49

    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89

    System.Data.Odbc.OdbcConnection.Open() +20

    ASP.sample_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) +313

    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98

    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +21

    System.Web.UI.Page.Render(HtmlTextWriter writer) +27

    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +53

    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +280

    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24

    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7425

  11. Horo.Read() nekad nebūs false. Es domāju, ka ārpus while visi mainīgie tiek anulēti un tas ko vajag paturēt ir kaut kā savādāk jānodefinē/jānokonvertē un nezinu ka. Es nedrīkstu definēt respmsg kā "", jo man vajag to atgriezto vērtību.

     

    Ierakstot šādi:

    while (Horo.Read())
    			{
    				string respmsg = "atgriezta zina";
    			}

    Vienalga saņemu šo:

    Compiler Error Message: CS0103: The name 'respmsg' does not exist in the current context

  12. Sveiki! Zinu, ka nav gluži php, bet nu varbūt kāds var palīdzēt.

    Lūdzu palīdziet atrast kļūdu sekojošā kodā (zem koda ir atgrieztais error`s):

     

    <%@ Page Language="C#"%>
    <%@ import namespace="System.Data.Odbc" %>
    <%
    OdbcConnection conn = new OdbcConnection();
    conn.ConnectionString = "SERVER=localhost;" +
    "DATABASE=adresati;" +
    "UID=lietotajs;" +
    "PASSWORD=*****;";
    conn.Open();
    OdbcCommand cmd = new OdbcCommand();
              cmd.Connection = conn;
              string SQLInsert = "SELECT numurs, zime FROM horoskopu_sanemeji";
              cmd.CommandText = SQLInsert;
    OdbcDataReader Reader = cmd.ExecuteReader();
    while (Reader.Read())
    {
    string horoskops = Reader.GetString(1);
    OdbcCommand cad = new OdbcCommand();
    cad.Connection = conn;
    cad.CommandText = "SELECT "+horoskops+" FROM horoskopi WHERE datums='"+DateTime.Now.ToString("MM-dd-yyyy")+"'";
    OdbcDataReader Horo = cad.ExecuteReader();
    while (Horo.Read())
    {
    string respmsg = Horo.GetString(0);
    }
    string destnum = Reader.GetString(0);
    string resptype = "SMS:TEXT";
    string resp = "{"+resptype+"}{}{}{"+destnum+"}{"+respmsg+"}";
    Response.Write(resp);
    Horo.Close();
    cad.Dispose();
    }
    Reader.Close();
    cmd.Dispose();
    conn.Close();
    %>

     

    Atgrieztā kļūda:

    Line 53: string resp = "{"+resptype+"}{}{}{"+destnum+"}{"+respmsg+"}";

    Source File: bla-bla-bla\sample.aspx Line: 53

    respmsg does not exist in this context

     

    Izmēģinātās lietas:

    *Gramatikas pārbaude mainīgajos un datubāze

    *Datuma funkcijas aizstāšana, to ievadot ar roku

    *horoskops sql query`ā ievadīts ar roku

    *izveidots atkārtots savienojums otrajam query`am

     

    Par googli rakājoties atradu šo:

    http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24558049.html

    Negribās viņiem atstāt savas kredītkartes datus lai iegūtu informāciju. Varbūt kāds ir tur reģistrējies.

  13. Man vajag izveidot topu pēc vidējā punktu skaita.

     

    Tabula, piemēram, ir šāda

     

    id______lietotāja_id_____punkti

    1__________5___________3

    2__________5___________1

    3__________4___________2

    4__________1___________3

    5__________2___________5

    6__________3___________4

    7__________2___________4

     

    Kā lai uzzinu kuram ir labākais vidējo punktu skaits, ja tabula visu laiku tiek papildināta un datu skaits ir pāris tūkstoši?

    Vai var, lūdzu, kāds palīdzēt?

  14. Netaisot jaunu topic`u vēlējos vēl lūgt palīdzību ar *.js failu.

     

     

    		var defaults = { 
    		'ys-input-nickname': self.prefs.defaultNickname, 
    		'ys-input-message': self.prefs.defaultMessage
    	};

     

     

    self.prefs.defaultNickname vietā man vajadzētu dabūt šo te

     

    global $lietotajs;
    
    $lietotajs['vards]'

     

    Kā lai to pareizi uzraksta? Rakājos googlē, tur konkrētu par šo lietu neko neatradu.

  15. nav ne jausmas. Katrā gadījumā vienā failā bija rakstīts kaut kas par utf-16

     

    Lūk faila satrs

     

    <?php
     function replace(&$item, $key) {
    $item = str_replace('|', '-', $item);
     }
    
     if (!function_exists('file_put_contents')) {
    	function file_put_contents($fileName, $data) {
    		if (is_array($data)) {
    			$data = join('', $data);
    		}
    		$res = @fopen($fileName, 'w+b');
    		if ($res) {
    			$write = @fwrite($res, $data);
    			if($write === false) {
    				return false;
    			} else {
    				return $write;
    			}
    		}
    	}
    }
    
     //file_put_contents('debug.txt', print_r($_GET, true));
     switch($_GET['action']) {
    case 'add':
      array_walk($_POST, 'replace');
      $arr = file('messages.txt');
    
      if(count($arr) > 10)
    	array_shift($arr);
    
      $_POST['nickname'] = htmlentities($_POST['nickname']);
      $_POST['message'] = htmlentities($_POST['message']);
      $time = time();
      $arr[] = $time.'|'.$_POST['nickname'].'|'.$_POST['message'].'|'.$_SERVER['REMOTE_ADDR']."\n";
      file_put_contents('messages.txt', implode('', $arr));
    
      $data['response'] = 'Good work';
      $data['nickname'] = $_POST['nickname'];
      $data['message'] = $_POST['message'];
      $data['time'] = $time;
    break;
    
    case 'view':
      $data = array();
      $arr = file('messages.txt');
      if(!$_GET['time'])
    	$_GET['time'] = 0;
      foreach($arr as $row) {
    	$aTemp = null;
    	list($aTemp['time'], $aTemp['nickname'], $aTemp['message']) = explode('|', $row); 
    	if($aTemp['message'] AND $aTemp['time'] > $_GET['time'])
    	  $data[] = $aTemp;
      }
      //file_put_contents('debug.txt', print_r($data, true));
    break;
     }
    
     require_once('JSON.php');
     $json = new Services_JSON();
     $out = $json->encode($data);
     print $out;
    ?>

×
×
  • Create New...