Forum poświęcone PHP
Mam w głowie dobre wspomnienia z pewnej gry ale nie mogę sobie przypomnieć co to było. Podpowiedzi mile widziane ;) Był to symulator lotu, latało się po mieszkaniu, czasem w ogródku małymi modelami samolotów, był podział na aliantów i państwa OSI. Samoloty z II wojny światowej...
Tue,06 Jan 2009 16:40:56 +0100
Witam Od kilku dni uczę się obsługi Socketów. Jako pierwszy program postanowiłem stworzyc namiastkę komunikatora. Do tej pory mój program składa sie z serwera i klienta. Po połączeniu serwer wysyła wiadomość powitalna , którą odbiera klient, dalej klient wysyła wczytany z klawiatury text, a w odpowiedzi dostaje echo tej wiadomości z serwera. Problem w tym że chciałbym, żeby z serwera była możliwość wczytania z klawiatury wiadomości i odesłania jej do klienta. Od paru dni z tym walczę i nie bardzo mi to wychodzi. Jeśli mogę prosić o jaką kolwiek pomoc lub podpowiedz to z góry dziękuje. Poniżej zamieszczam kod serwera i klienta: package server; import java.util.*; import java.io.*; import java.net.*; /** * * @author piotrek */ public class Server { public static void main(String[] args) { // TODO code application logic here try { ServerSocket s=new ServerSocket(8190); Socket socket=s.accept(); BufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream())); PrintWriter out=new PrintWriter(socket.getOutputStream(),true); out.println("Hello! Enter BYE to exit."); boolean done=false; while(!done) { String line=in.readLine(); //String msg=wej.nextLine(); if(line==null) { done=true; } else { System.out.println("Ktos powiedział:"+line); out.println("Echo-zwrot z serwera:"+line); out.flush(); if(line.trim().equals("BYE")) { done=true; } } } socket.close(); } catch(Exception e) { e.printStackTrace(); } } } Klient: import java.io.*; import java.net.*; import java.util.*; /** * * @author piotrek */ public class Klient { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try { byte[] ip={(byte)195, (byte)242,(byte)91,(byte)105}; String nazwa=InetAddress.getByAddress(ip).getHostName(); Socket sock=new Socket(nazwa,8190); BufferedReader in=new BufferedReader(new InputStreamReader(sock.getInputStream())); Scanner wej=new Scanner(System.in); PrintWriter out=new PrintWriter(sock.getOutputStream(),true); boolean done=false; System.out.println("Nawiązano połączenie:n"); while(!done) { String text=in.readLine(); System.out.println(text); System.out.println("Napisz coś:"); String msg=wej.nextLine(); if(msg==null) { done=true; } else { out.println(msg); out.flush(); if(msg.trim().equals("BYE")) { done=true; } } } sock.close(); } catch(Exception e) { e.printStackTrace(); } /*catch(ConnectException ex) { System.err.println("Nie nawiązano połaczenia"); }*/ } }
Tue,06 Jan 2009 16:11:48 +0100
Hej :) Mam Jtable, z moim TableModel, oraz z TableRowSorterem. I teraz chcialbym aby program po zaznaczeniu wiersza w tabeli, wyswietlal poszczegolne wartosci z zaznaczonego wiersza w textfieldach ponizej tabeli, graficznie to juz sobie zrobilem, chodzi o sam kod... mam cos takiego w klasie z narysowana tabelą: private void jTable2MouseClicked(java.awt.event.MouseEvent evt) { int row = jTable2.getSelectedRow(); int i=0; while(i
Tue,06 Jan 2009 16:07:12 +0100
Witam, mam taki problem. Potrzebuję zrobić sobie obiekt, którego właściwościami będą zdolności do zmiany koloru. Ten obiekt to ma być po prostu kreska. Pomyślałem, że zrobię to tak, że stworzę sobię panel, na którym (na przekątnej) narysuję kreskę. Oczywiście zależy mi na kreskach łączących dowolne punktu - stąd ich dlugość ma być różna oraz kąt (tak jakby współczynnik nachylenia) również. No i mam funkcję, która zmienia kolor owej kreski - obiektu... Ja będę sobie te obiekciki ładował w różne miejsca na inny panel - taki główny w moim malutkim programiku :) i one będą zmieniać kolory (sterować tym będą inne obieky - wątki). Problem jest tu,że kreski sie przecinają, i że jak zmieniam kolor danego obiektu, to oprócz przekątnej, odrysuje mi się cały ten mały panelik zamazujc tłem inne kreski... Mam nadzieję, że wiadomo o co chodzi :) Czy da się jakoś łatwo zaradzić ? Chodzi mi po głowie sprawdzanie kolorów po i przed odrysowaniem danego obszaru, odejmowanie wartości i podjęcie odpowiednich działań, ale czuję, że da się łatwiej :) Z góry dziękuję.
Tue,06 Jan 2009 15:15:24 +0100
Cześć Wszystkim używam do zarządzania bazami narz. Microsoftu- Managment Studio 2005, gdzie utworzyłem procedurę. Wcześniej utworzyłem użytkownika i hasło nadając mu prawa do zapisu i odczytu (db_datareader, db_datawriter, jest też db_owner). Wszystko jest ok do momentu gdy z poziomu PHP; próbuje odpalić procedure, ale nie mam dostępu : mssql_query("EXEC main_proced {$param_ID}"); W MSSQL 2000 nie było problemu, wszystko było intuicyjne i jasne, otwierało się procedurkę i we właściwościach zaznaczało się checkbox exec, dla danego utworzonego usera, a tutaj masło maślane....
Tue,06 Jan 2009 15:07:32 +0100
CXXXVII. runkit Functions
Wstęp
The runkit extension provides means to modify constants, user-defined functions, and user-defined classes. It also provides for custom superglobal variables and embeddable sub-interpreters via sandboxing.
Informacje na temat instalacji tego rozszerzenia PECL można znaleźć w podręczniku w rozdziale zatytułowanym Instalacja rozszerzeń PECL. Dodatkowe informacje, takie jak nowe wersje, pliki do pobrania, pliki źródłowe, informacje o opiekunach czy rejestr zmian, można znaleźć tutaj: http://pecl.php.net/package/runkit.
This package is meant as a feature added replacement for the classkit package. When compiled with the --enable-runkit=classkit option to ./configure, it will export classkit compatible function definitions and constants.
Instalacja
To rozszerzenie PECL nie jest dołączane do PHP.
Informacje na temat instalacji tego rozszerzenia PECL można znaleźć w podręczniku w rozdziale zatytułowanym Instalacja rozszerzeń PECL. Dodatkowe informacje, takie jak nowe wersje, pliki do pobrania, pliki źródłowe, informacje o opiekunach czy rejestr zmian, można znaleźć tutaj: http://pecl.php.net/package/runkit.
DLL z tym rozszerzeniem PECL można pobrać ze strony PHP Downloads lub http://snaps.php.net/.
Wymagania
Modifying Constants, Functions, Classes, and Methods works with all releases of PHP 4 and PHP 5. No special requirements are necessary.
Custom Superglobals are only available in PHP 4.2.0 or later.
Sandboxing requires PHP 5.1.0 or later, or PHP 5.0.0 with a special TSRM patch applied. Regardless of which version of PHP is in use it must be compiled with the --enable-maintainer-zts option. See the README file in the runkit package for additional information.
Konfiguracja uruchomieniowa
Na działanie tych funcji wpływają ustawienia zawarte w pliku php.ini.
Tabela 1. Runkit Configuration Options
| Name | Default | Changeable | Changelog |
|---|---|---|---|
| runkit.superglobal | "" | PHP_INI_PERDIR | |
| runkit.internal_override | "0" | PHP_INI_SYSTEM |
Oto krótkie wyjaśnienie dyrektyw konfiguracji.
runkit.superglobalstringComma-separated list of variable names to be treated as superglobals. This value should be set in the systemwide php.ini file, but may work in perdir configuration contexts depending on your SAPI.
Stałe predefiniowane
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
- RUNKIT_IMPORT_FUNCTIONS (integer)
runkit_import() flag indicating that normal functions should be imported from the specified file.
- RUNKIT_IMPORT_CLASS_METHODS (integer)
runkit_import() flag indicating that class methods should be imported from the specified file.
- RUNKIT_IMPORT_CLASS_CONSTS (integer)
runkit_import() flag indicating that class constants should be imported from the specified file. Note that this flag is only meaningful in PHP versions 5.1.0 and above.
- RUNKIT_IMPORT_CLASS_PROPS (integer)
runkit_import() flag indicating that class standard properties should be imported from the specified file.
- RUNKIT_IMPORT_CLASSES (integer)
runkit_import() flag representing a bitwise OR of the RUNKIT_IMPORT_CLASS_* constants.
- RUNKIT_IMPORT_OVERRIDE (integer)
runkit_import() flag indicating that if any of the imported functions, methods, constants, or properties already exist, they should be replaced with the new definitions. If this flag is not set, then any imported definitions which already exist will be discarded.
- RUNKIT_ACC_PUBLIC (integer)
PHP 5 specific flag to runkit_method_add()
- RUNKIT_ACC_PROTECTED (integer)
PHP 5 specific flag to runkit_method_add()
- RUNKIT_ACC_PRIVATE (integer)
PHP 5 specific flag to runkit_method_add()
- CLASSKIT_ACC_PUBLIC (integer)
PHP 5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled.
- CLASSKIT_ACC_PROTECTED (integer)
PHP 5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled.
- CLASSKIT_ACC_PRIVATE (integer)
PHP 5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled.
- CLASSKIT_AGGREGATE_OVERRIDE (integer)
PHP 5 specific flag to classkit_import() Only defined when classkit compatibility is enabled.
- RUNKIT_VERSION (string)
Defined to the current version of the runkit package.
- CLASSKIT_VERSION (string)
Defined to the current version of the runkit package. Only defined when classkit compatibility is enabled.
- Spis treści
- Runkit_Sandbox -- Runkit Sandbox Class -- PHP Virtual Machine
- Runkit_Sandbox_Parent -- Runkit Anti-Sandbox Class
- runkit_class_adopt -- Convert a base class to an inherited class, add ancestral methods when appropriate
- runkit_class_emancipate -- Convert an inherited class to a base class, removes any method whose scope is ancestral
- runkit_constant_add -- Similar to define(), but allows defining in class definitions as well
- runkit_constant_redefine -- Redefine an already defined constant
- runkit_constant_remove -- Remove/Delete an already defined constant
- runkit_function_add -- Add a new function, similar to create_function()
- runkit_function_copy -- Copy a function to a new function name
- runkit_function_redefine -- Replace a function definition with a new implementation
- runkit_function_remove -- Remove a function definition
- runkit_function_rename -- Change a function's name
- runkit_import -- Process a PHP file importing function and class definitions, overwriting where appropriate
- runkit_lint_file -- Check the PHP syntax of the specified file
- runkit_lint -- Check the PHP syntax of the specified php code
- runkit_method_add -- Dynamically adds a new method to a given class
- runkit_method_copy -- Copies a method from class to another
- runkit_method_redefine -- Dynamically changes the code of the given method
- runkit_method_remove -- Dynamically removes the given method
- runkit_method_rename -- Dynamically changes the name of the given method
- runkit_return_value_used -- Determines if the current functions return value will be used
- runkit_sandbox_output_handler -- Specify a function to capture and/or process output from a runkit sandbox
- runkit_superglobals -- Return numerically indexed array of registered superglobals
| Poprzedni | Spis treści | Następny |
| rpm_version | Początek rozdziału | Runkit_Sandbox |