quickfw-git Mailing List for QuickFramework (Page 5)
Brought to you by:
ivan1986,
seriousdron
You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
(9) |
Apr
(25) |
May
(22) |
Jun
(22) |
Jul
(15) |
Aug
(16) |
Sep
(4) |
Oct
(9) |
Nov
(9) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(5) |
Feb
(3) |
Mar
(2) |
Apr
(11) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: Ivan1986 <iva...@us...> - 2010-06-21 13:53:44
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via c8e7843959370e2207228f2760c5552ee29b5feb (commit) from 07da8658a0698e65a4be9da195033392da7ce013 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c8e7843959370e2207228f2760c5552ee29b5feb Author: Ivan1986 <iva...@li...> Date: Mon Jun 21 17:53:10 2010 +0400 Обновил xmpphp diff --git a/lib/jabber/XMPPHP/BOSH.php b/lib/jabber/XMPPHP/BOSH.php index befaf60..49e977d 100644 --- a/lib/jabber/XMPPHP/BOSH.php +++ b/lib/jabber/XMPPHP/BOSH.php @@ -27,7 +27,7 @@ */ /** XMPPHP_XMLStream */ -require_once dirname(__FILE__) . "/XMPP.php"; +require_once dirname(__FILE__) . '/XMPP.php'; /** * XMPPHP Main Class diff --git a/lib/jabber/XMPPHP/DIGEST-MD5.patch b/lib/jabber/XMPPHP/DIGEST-MD5.patch deleted file mode 100644 index 898f5c5..0000000 --- a/lib/jabber/XMPPHP/DIGEST-MD5.patch +++ /dev/null @@ -1,132 +0,0 @@ ---- XMPP.php.old 2009-08-27 15:05:34.000000000 +0400 -+++ XMPP.php 2009-11-19 16:56:19.000000000 +0300 -@@ -99,6 +99,21 @@ - public $roster; - - /** -+ * @var array supported auth mechanisms -+ */ -+ protected $auth_mechanism_supported = array('PLAIN', 'DIGEST-MD5'); -+ -+ /** -+ * @var string default auth mechanism -+ */ -+ protected $auth_mechanism_default = 'PLAIN'; -+ -+ /** -+ * @var string prefered auth mechanism -+ */ -+ protected $auth_mechanism_preferred = 'DIGEST-MD5'; -+ -+ /** - * Constructor - * - * @param string $host -@@ -117,6 +132,7 @@ - $this->password = $password; - $this->resource = $resource; - if(!$server) $server = $host; -+ $this->server = $server; - $this->basejid = $this->user . '@' . $this->host; - - $this->roster = new Roster(); -@@ -132,6 +148,8 @@ - $this->addXPathHandler('{jabber:client}message', 'message_handler'); - $this->addXPathHandler('{jabber:client}presence', 'presence_handler'); - $this->addXPathHandler('iq/{jabber:iq:roster}query', 'roster_iq_handler'); -+ // For DIGEST-MD5 auth : -+ $this->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}challenge', 'sasl_challenge_handler'); - } - - /** -@@ -326,7 +344,33 @@ - } else { - $this->log->log("Attempting Auth..."); - if ($this->password) { -- $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->user . "\x00" . $this->password) . "</auth>"); -+ $mechanism = 'PLAIN'; // default; -+ if ($xml->hasSub('mechanisms') && $xml->sub('mechanisms')->hasSub('mechanism')) { -+ // Get the list of all available auth mechanism that we can use -+ $available = array(); -+ foreach ($xml->sub('mechanisms')->subs as $sub) { -+ if ($sub->name == 'mechanism') { -+ if (in_array($sub->data, $this->auth_mechanism_supported)) { -+ $available[$sub->data] = $sub->data; -+ } -+ } -+ } -+ if (isset($available[$this->auth_mechanism_preferred])) { -+ $mechanism = $this->auth_mechanism_preferred; -+ } else { -+ // use the first available -+ $mechanism = reset($available); -+ } -+ $this->log->log("Trying $mechanism (available : " . implode(',', $available) . ')'); -+ } -+ switch ($mechanism) { -+ case 'PLAIN': -+ $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->user . "\x00" . $this->password) . "</auth>"); -+ break; -+ case 'DIGEST-MD5': -+ $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5' />"); -+ break; -+ } - } else { - $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>"); - } -@@ -357,6 +401,55 @@ - } - - /** -+ * Handle challenges for DIGEST-MD5 auth -+ * -+ * @param string $xml -+ */ -+ protected function sasl_challenge_handler($xml) { -+ // Decode and parse the challenge string -+ // (may be something like foo="bar",foo2="bar2,bar3,bar4",foo3=bar5 ) -+ $challenge = base64_decode($xml->data); -+ $vars = array(); -+ $matches = array(); -+ preg_match_all('/(\w+)=(?:"([^"]*)|([^,]*))/', $challenge, $matches); -+ $res = array(); -+ foreach ($matches[1] as $k => $v) { -+ $vars[$v] = (empty($matches[2][$k])?$matches[3][$k]:$matches[2][$k]); -+ } -+ -+ if (isset($vars['nonce'])) { -+ // First step -+ $vars['cnonce'] = uniqid(mt_rand(), false); -+ $vars['nc'] = '00000001'; -+ $vars['qop'] = 'auth'; // Force qop to auth -+ if (!isset($vars['digest-uri'])) $vars['digest-uri'] = 'xmpp/' . $this->server; -+ -+ // now, the magic... -+ $a1 = sprintf('%s:%s:%s', $this->user, $vars['realm'], $this->password); -+ if ($vars['algorithm'] == 'md5-sess') { -+ $a1 = pack('H32',md5($a1)) . ':' . $vars['nonce'] . ':' . $vars['cnonce']; -+ } -+ $a2 = "AUTHENTICATE:" . $vars['digest-uri']; -+ $password = md5($a1) . ':' . $vars['nonce'] . ':' . $vars['nc'] . ':' . $vars['cnonce'] . ':' . $vars['qop'] . ':' .md5($a2); -+ $password = md5($password); -+ $response = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc=%s,qop=%s,digest-uri="%s",response=%s,charset=utf-8', -+ $this->user, $vars['realm'], $vars['nonce'], $vars['cnonce'], $vars['nc'], $vars['qop'], $vars['digest-uri'], $password); -+ -+ // Send the response -+ $response = base64_encode($response); -+ $this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>$response</response>"); -+ } else { -+ if (isset($vars['rspauth'])) { -+ // Second step -+ $this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"); -+ } else { -+ $this->log->log("ERROR receiving challenge : " . $challenge, XMPPHP_Log::LEVEL_ERROR); -+ } -+ -+ } -+ } -+ -+ /** - * Resource bind handler - * - * @param string $xml diff --git a/lib/jabber/XMPPHP/Roster.php b/lib/jabber/XMPPHP/Roster.php index cea9a95..30117bb 100644 --- a/lib/jabber/XMPPHP/Roster.php +++ b/lib/jabber/XMPPHP/Roster.php @@ -3,22 +3,22 @@ * XMPPHP: The PHP XMPP Library * Copyright (C) 2008 Nathanael C. Fritz * This file is part of SleekXMPP. - * + * * XMPPHP is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * XMPPHP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with XMPPHP; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - * @category xmpphp + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -28,8 +28,8 @@ /** * XMPPHP Roster Object - * - * @category xmpphp + * + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -47,7 +47,7 @@ class Roster { protected $roster_array = array(); /** * Constructor - * + * */ public function __construct($roster_array = array()) { if ($this->verifyRoster($roster_array)) { @@ -87,7 +87,7 @@ class Roster { } /** - * + * * Retrieve contact via jid * * @param string $jid @@ -127,6 +127,7 @@ class Roster { } $this->roster_array[$jid]['presence'][$resource] = array('priority' => $priority, 'show' => $show, 'status' => $status); } else { //Nuke unavailable resources to save memory + unset($this->roster_array[$jid]['resource'][$resource]); unset($this->roster_array[$jid]['presence'][$resource]); } } diff --git a/lib/jabber/XMPPHP/XMLStream.php b/lib/jabber/XMPPHP/XMLStream.php index 4214ea2..d818881 100644 --- a/lib/jabber/XMPPHP/XMLStream.php +++ b/lib/jabber/XMPPHP/XMLStream.php @@ -3,22 +3,22 @@ * XMPPHP: The PHP XMPP Library * Copyright (C) 2008 Nathanael C. Fritz * This file is part of SleekXMPP. - * + * * XMPPHP is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * XMPPHP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with XMPPHP; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - * @category xmpphp + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -33,12 +33,12 @@ require_once dirname(__FILE__) . '/Exception.php'; require_once dirname(__FILE__) . '/XMLObj.php'; /** XMPPHP_Log */ -require_once dirname(__FILE__) . '/XMPPHP_Log.php'; +require_once dirname(__FILE__) . '/Log.php'; /** * XMPPHP XML Stream - * - * @category xmpphp + * + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -195,7 +195,7 @@ class XMPPHP_XMLStream { $this->disconnect(); } } - + /** * Return the log instance * @@ -204,7 +204,7 @@ class XMPPHP_XMLStream { public function getLog() { return $this->log; } - + /** * Get next ID * @@ -288,14 +288,17 @@ class XMPPHP_XMLStream { /** * Connect to XMPP Host * - * @param integer $timeout + * @param integer $timeout Timeout in seconds * @param boolean $persistent - * @param boolean $sendinit + * @param boolean $sendinit Send XMPP starting sequence after connect + * automatically + * + * @throws XMPPHP_Exception When the connection fails */ public function connect($timeout = 30, $persistent = false, $sendinit = true) { $this->sent_disconnect = false; $starttime = time(); - + do { $this->disconnected = false; $this->sent_disconnect = false; @@ -319,7 +322,7 @@ class XMPPHP_XMLStream { sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); - + if ($this->socket) { stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); @@ -330,6 +333,10 @@ class XMPPHP_XMLStream { /** * Reconnect XMPP Host + * + * @throws XMPPHP_Exception When the connection fails + * @uses $reconnectTimeout + * @see setReconnectTimeout() */ public function doReconnect() { if(!$this->is_server) { @@ -343,7 +350,7 @@ class XMPPHP_XMLStream { public function setReconnectTimeout($timeout) { $this->reconnectTimeout = $timeout; } - + /** * Disconnect from XMPP Host */ @@ -369,16 +376,59 @@ class XMPPHP_XMLStream { } /** - * Core reading tool - * 0 -> only read if data is immediately ready - * NULL -> wait forever and ever - * integer -> process for this amount of time + * Checks if the given string is closed with the same tag as it is + * opened. We try to be as fast as possible here. + * + * @param string $buff Read buffer of __process() + * + * @return boolean true if the buffer seems to be complete */ + protected function bufferComplete($buff) + { + if (substr($buff, -1) != '>') { + return false; + } + //we always have a space since the namespace needs to be + //declared. could be a tab, though + $start = substr( + $buff, 1, + min(strpos($buff, '>', 2), strpos($buff, ' ', 2)) - 1 + ); + $stop = substr($buff, -strlen($start) - 3); + + if ($start == '?xml') { + //starting with an xml tag. this means a stream is being + // opened, which is not much of data, so no fear it's + // not complete + return true; + } + if (substr($stop, -2) == '/>') { + //one tag, i.e. <success /> + return true; + } + if ('</' . $start . '>' == $stop) { + return true; + } - private function __process($maximum=0) { + return false; + } + /** + * Core reading tool + * + * @param mixed $maximum Limit when to return + * - 0: only read if data is immediately ready + * - NULL: wait forever and ever + * - integer: process for this amount of microseconds + * @param boolean $return_when_received Immediately return when data have been + * received + * + * @return boolean True when all goes well, false when something fails + */ + private function __process($maximum = 5, $return_when_received = false) + { $remaining = $maximum; - + do { $starttime = (microtime(true) * 1000000); $read = array($this->socket); @@ -387,13 +437,16 @@ class XMPPHP_XMLStream { if (is_null($maximum)) { $secs = NULL; $usecs = NULL; + } else if ($maximum == 0) { + $secs = 0; + $usecs = 0; } else { $usecs = $remaining % 1000000; - $secs = floor($remaining / 1000000); + $secs = floor(($remaining - $usecs) / 1000000); } - $updated = stream_select($read, $write, $except, $secs, $usecs); + $updated = @stream_select($read, $write, $except, $secs, $usecs); if ($updated === false) { - $this->log->log("Error on stream_select()", XMPPHP_Log::LEVEL_VERBOSE); + $this->log->log("Error on stream_select()", XMPPHP_Log::LEVEL_VERBOSE); if ($this->reconnect) { $this->doReconnect(); } else { @@ -402,19 +455,33 @@ class XMPPHP_XMLStream { return false; } } else if ($updated > 0) { - # XXX: Is this big enough? - $buff = @fread($this->socket, 4096); - if(!$buff) { - if($this->reconnect) { - $this->doReconnect(); - } else { - fclose($this->socket); - $this->socket = NULL; - return false; + $buff = ''; + do { + if ($buff != '') { + //disable blocking for now because fread() will + // block until the 4k are full if we already + // read a part of the packet + stream_set_blocking($this->socket, 0); } - } - $this->log->log("RECV: $buff", XMPPHP_Log::LEVEL_VERBOSE); + $part = fread($this->socket, 4096); + stream_set_blocking($this->socket, 1); + if ($part === false) { + if($this->reconnect) { + $this->doReconnect(); + } else { + fclose($this->socket); + $this->socket = NULL; + return false; + } + } + $this->log->log("RECV: $part", XMPPHP_Log::LEVEL_VERBOSE); + $buff .= $part; + } while (!$this->bufferComplete($buff)); + xml_parse($this->parser, $buff, false); + if ($return_when_received) { + return true; + } } else { # $updated == 0 means no changes during timeout. } @@ -424,7 +491,7 @@ class XMPPHP_XMLStream { } while (is_null($maximum) || $remaining > 0); return true; } - + /** * Process * @@ -437,8 +504,11 @@ class XMPPHP_XMLStream { /** * Process until a timeout occurs * - * @param integer $timeout + * @param integer $timeout Time in seconds + * * @return string + * + * @see __process() */ public function processTime($timeout=NULL) { if (is_null($timeout)) { @@ -451,26 +521,47 @@ class XMPPHP_XMLStream { /** * Process until a specified event or a timeout occurs * - * @param string|array $event - * @param integer $timeout - * @return string + * @param string|array $event Event name or array of event names + * @param integer $timeout Timeout in seconds + * + * @return array Payload */ - public function processUntil($event, $timeout=null) { + public function processUntil($event, $timeout = -1) + { $start = time(); - if(!is_array($event)) $event = array($event); + if (!is_array($event)) { + $event = array($event); + } + $this->until[] = $event; end($this->until); $event_key = key($this->until); reset($this->until); + $this->until_count[$event_key] = 0; $updated = ''; - while(!$this->disconnected and $this->until_count[$event_key] < 1 and (time() - $start < $timeout or $timeout == null)) { - $this->__process($timeout); + while (!$this->disconnected + && $this->until_count[$event_key] < 1 + && ($timeout == -1 || time() - $start < $timeout) + ) { + $maximum = $timeout == -1 + ? NULL + : ($timeout - (time() - $start)) * 1000000; + $ret = $this->__process($maximum, true); + if (!$ret) { + break; + } + } + + if (array_key_exists($event_key, $this->until_payload)) { + $payload = $this->until_payload[$event_key]; + unset($this->until_payload[$event_key]); + unset($this->until_count[$event_key]); + unset($this->until[$event_key]); + } else { + $payload = array(); } - $payload = array_key_exists($event_key, $this->until_payload)?$this->until_payload[$event_key]:array(); - unset($this->until_payload[$event_key]); - unset($this->until_count[$event_key]); - unset($this->until[$event_key]); + return $payload; } @@ -483,7 +574,7 @@ class XMPPHP_XMLStream { /** * XML start callback - * + * * @see xml_set_element_handler * * @param resource $parser @@ -524,7 +615,7 @@ class XMPPHP_XMLStream { /** * XML end callback - * + * * @see xml_set_element_handler * * @param resource $parser @@ -655,7 +746,7 @@ class XMPPHP_XMLStream { */ public function read() { $buff = @fread($this->socket, 1024); - if(!$buff) { + if(!$buff) { if($this->reconnect) { $this->doReconnect(); } else { @@ -685,13 +776,13 @@ class XMPPHP_XMLStream { $usecs = $maximum % 1000000; $secs = floor(($maximum - $usecs) / 1000000); } - + $read = array(); $write = array($this->socket); $except = array(); - + $select = @stream_select($read, $write, $except, $secs, $usecs); - + if($select === False) { $this->log->log("ERROR sending message; reconnecting."); $this->doReconnect(); @@ -703,7 +794,7 @@ class XMPPHP_XMLStream { $this->log->log("Socket is not ready; break.", XMPPHP_Log::LEVEL_ERROR); return false; } - + $sentbytes = @fwrite($this->socket, $msg); $this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), XMPPHP_Log::LEVEL_VERBOSE); if($sentbytes === FALSE) { diff --git a/lib/jabber/XMPPHP/XMPP.php b/lib/jabber/XMPPHP/XMPP.php index acbcc49..eed8f69 100644 --- a/lib/jabber/XMPPHP/XMPP.php +++ b/lib/jabber/XMPPHP/XMPP.php @@ -3,22 +3,22 @@ * XMPPHP: The PHP XMPP Library * Copyright (C) 2008 Nathanael C. Fritz * This file is part of SleekXMPP. - * + * * XMPPHP is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * XMPPHP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with XMPPHP; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - * @category xmpphp + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -27,13 +27,13 @@ */ /** XMPPHP_XMLStream */ -require_once dirname(__FILE__) . "/XMLStream.php"; -require_once dirname(__FILE__) . "/Roster.php"; +require_once dirname(__FILE__) . '/XMLStream.php'; +require_once dirname(__FILE__) . '/Roster.php'; /** * XMPPHP Main Class - * - * @category xmpphp + * + * @category xmpphp * @package XMPPHP * @author Nathanael C. Fritz <JID: fr...@ne...> * @author Stephan Wentz <JID: st...@ja...> @@ -45,60 +45,75 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { /** * @var string */ - protected $server; + public $server; /** * @var string */ - protected $user; - + public $user; + /** * @var string */ protected $password; - + /** * @var string */ protected $resource; - + /** * @var string */ protected $fulljid; - + /** * @var string */ protected $basejid; - + /** * @var boolean */ protected $authed = false; protected $session_started = false; - + /** * @var boolean */ protected $auto_subscribe = false; - + /** * @var boolean */ protected $use_encryption = true; - + /** * @var boolean */ public $track_presence = true; - + /** * @var object */ public $roster; /** + * @var array supported auth mechanisms + */ + protected $auth_mechanism_supported = array('PLAIN', 'DIGEST-MD5'); + + /** + * @var string default auth mechanism + */ + protected $auth_mechanism_default = 'PLAIN'; + + /** + * @var string prefered auth mechanism + */ + protected $auth_mechanism_preferred = 'DIGEST-MD5'; + + /** * Constructor * * @param string $host @@ -112,19 +127,21 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { */ public function __construct($host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null) { parent::__construct($host, $port, $printlog, $loglevel); - + $this->user = $user; $this->password = $password; $this->resource = $resource; if(!$server) $server = $host; + $this->server = $server; $this->basejid = $this->user . '@' . $this->host; $this->roster = new Roster(); + $this->track_presence = true; $this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0">'; $this->stream_end = '</stream:stream>'; $this->default_ns = 'jabber:client'; - + $this->addXPathHandler('{http://etherx.jabber.org/streams}features', 'features_handler'); $this->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}success', 'sasl_success_handler'); $this->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}failure', 'sasl_failure_handler'); @@ -132,6 +149,8 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { $this->addXPathHandler('{jabber:client}message', 'message_handler'); $this->addXPathHandler('{jabber:client}presence', 'presence_handler'); $this->addXPathHandler('iq/{jabber:iq:roster}query', 'roster_iq_handler'); + // For DIGEST-MD5 auth : + $this->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}challenge', 'sasl_challenge_handler'); } /** @@ -142,7 +161,7 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { public function useEncryption($useEncryption = true) { $this->use_encryption = $useEncryption; } - + /** * Turn on auto-authorization of subscription requests. * @@ -153,15 +172,6 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } /** - * Turn on track-presence of subscription requests. - * - * @param boolean $trackPresence - */ - public function trackPresence($trackPresence = true) { - $this->track_presence = $trackPresence; - } - - /** * Send XMPP Message * * @param string $to @@ -174,17 +184,17 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { { $type = 'chat'; } - + $to = htmlspecialchars($to); $body = htmlspecialchars($body); $subject = htmlspecialchars($subject); - - $out = "<message from='{$this->fulljid}' to='$to' type='$type'>"; + + $out = "<message from=\"{$this->fulljid}\" to=\"$to\" type='$type'>"; if($subject) $out .= "<subject>$subject</subject>"; $out .= "<body>$body</body>"; if($payload) $out .= $payload; $out .= "</message>"; - + $this->send($out); } @@ -195,16 +205,16 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { * @param string $show * @param string $to */ - public function presence($status = null, $show = 'available', $to = null, $type='available', $priority = null) { + public function presence($status = null, $show = 'available', $to = null, $type='available', $priority=null) { if($type == 'available') $type = ''; $to = htmlspecialchars($to); $status = htmlspecialchars($status); if($show == 'unavailable') $type = 'unavailable'; - + $out = "<presence"; - if($to) $out .= " to='$to'"; + if($to) $out .= " to=\"$to\""; if($type) $out .= " type='$type'"; - if($show == 'available' and !$status) { + if($show == 'available' and !$status and $priority !== null) { $out .= "/>"; } else { $out .= ">"; @@ -213,7 +223,7 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { if($priority !== null) $out .= "<priority>$priority</priority>"; $out .= "</presence>"; } - + $this->send($out); } /** @@ -227,6 +237,42 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } /** + * Add user to Roster + * + * @param string $jid user jid + * @param string $name user nickname + * @param string $group group to add + */ + public function RosterAddUser($jid, $name=null, $group=null) { + $payload = "<item jid='$jid'".($name ? " name='" . htmlspecialchars($name) . "'" : '')."/>\n". + ($group?'<group>'.htmlspecialchars($group, ENT_QUOTES, 'UTF-8').'</group>':''); + $this->SendIq(NULL, 'set', "jabber:iq:roster", $payload); + } + + /** + * Send ID action + * + * @param string $to to jid + * @param string $type type of ID + * @param string $xmlns xmlns name + * @param string $payload payload string + * @param string $from from jid + */ + private function sendIq($to = NULL, $type = 'get', $xmlns = NULL, $payload = NULL, $from = NULL) + { + $id = $this->getID(); + $xml = "<iq type='$type' id='$id'". + ($to ? " to='$to'" : ''). + ($from ? " from='$from'" : ''). + "> + <query xmlns='$xmlns'> + $payload + </query> + </iq>"; + return $this->send($xml); + } + + /** * Message handler * * @param string $xml @@ -237,14 +283,11 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } else { $payload['type'] = 'chat'; } + $body = $xml->sub('body'); $payload['from'] = $xml->attrs['from']; - if (!$xml->hasSub('body')) - $payload['body'] = ''; - else - { - $payload['body'] = $xml->sub('body')->data; - $this->log->log('Message: '.$xml->sub('body')->data, XMPPHP_Log::LEVEL_DEBUG); - } + $payload['body'] = is_object($body) ? $body->data : FALSE; // $xml->sub('body')->data; + $payload['xml'] = $xml; + $this->log->log("Message: {$payload['body']}", XMPPHP_Log::LEVEL_DEBUG); $this->event('message', $payload); } @@ -260,8 +303,9 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { $payload['status'] = (isset($xml->sub('status')->data)) ? $xml->sub('status')->data : ''; $payload['priority'] = (isset($xml->sub('priority')->data)) ? intval($xml->sub('priority')->data) : 0; $payload['xml'] = $xml; - if($this->track_presence) + if($this->track_presence) { $this->roster->setPresence($payload['from'], $payload['priority'], $payload['show'], $payload['status']); + } $this->log->log("Presence: {$payload['from']} [{$payload['show']}] {$payload['status']}", XMPPHP_Log::LEVEL_DEBUG); if(array_key_exists('type', $xml->attrs) and $xml->attrs['type'] == 'subscribe') { if($this->auto_subscribe) { @@ -291,10 +335,36 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } else { $this->log->log("Attempting Auth..."); if ($this->password) { - $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->user . "\x00" . $this->password) . "</auth>"); + $mechanism = 'PLAIN'; // default; + if ($xml->hasSub('mechanisms') && $xml->sub('mechanisms')->hasSub('mechanism')) { + // Get the list of all available auth mechanism that we can use + $available = array(); + foreach ($xml->sub('mechanisms')->subs as $sub) { + if ($sub->name == 'mechanism') { + if (in_array($sub->data, $this->auth_mechanism_supported)) { + $available[$sub->data] = $sub->data; + } + } + } + if (isset($available[$this->auth_mechanism_preferred])) { + $mechanism = $this->auth_mechanism_preferred; + } else { + // use the first available + $mechanism = reset($available); + } + $this->log->log("Trying $mechanism (available : " . implode(',', $available) . ')'); + } + switch ($mechanism) { + case 'PLAIN': + $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->user . "\x00" . $this->password) . "</auth>"); + break; + case 'DIGEST-MD5': + $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5' />"); + break; + } } else { - $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>"); - } + $this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>"); + } } } @@ -308,7 +378,7 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { $this->authed = true; $this->reset(); } - + /** * SASL feature handler * @@ -317,11 +387,61 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { protected function sasl_failure_handler($xml) { $this->log->log("Auth failed!", XMPPHP_Log::LEVEL_ERROR); $this->disconnect(); - + throw new XMPPHP_Exception('Auth failed!'); } /** + * Handle challenges for DIGEST-MD5 auth + * + * @param string $xml + */ + protected function sasl_challenge_handler($xml) { + // Decode and parse the challenge string + // (may be something like foo="bar",foo2="bar2,bar3,bar4",foo3=bar5 ) + $challenge = base64_decode($xml->data); + $vars = array(); + $matches = array(); + preg_match_all('/(\w+)=(?:"([^"]*)|([^,]*))/', $challenge, $matches); + $res = array(); + foreach ($matches[1] as $k => $v) { + $vars[$v] = (empty($matches[2][$k])?$matches[3][$k]:$matches[2][$k]); + } + + if (isset($vars['nonce'])) { + // First step + $vars['cnonce'] = uniqid(mt_rand(), false); + $vars['nc'] = '00000001'; + $vars['qop'] = 'auth'; // Force qop to auth + if (!isset($vars['digest-uri'])) $vars['digest-uri'] = 'xmpp/' . $this->server; + if (!isset($vars['realm'])) $vars['realm'] = ''; + + // now, the magic... + $a1 = sprintf('%s:%s:%s', $this->user, $vars['realm'], $this->password); + if ($vars['algorithm'] == 'md5-sess') { + $a1 = pack('H32',md5($a1)) . ':' . $vars['nonce'] . ':' . $vars['cnonce']; + } + $a2 = "AUTHENTICATE:" . $vars['digest-uri']; + $password = md5($a1) . ':' . $vars['nonce'] . ':' . $vars['nc'] . ':' . $vars['cnonce'] . ':' . $vars['qop'] . ':' .md5($a2); + $password = md5($password); + $response = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc=%s,qop=%s,digest-uri="%s",response=%s,charset=utf-8', + $this->user, $vars['realm'], $vars['nonce'], $vars['cnonce'], $vars['nc'], $vars['qop'], $vars['digest-uri'], $password); + + // Send the response + $response = base64_encode($response); + $this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>$response</response>"); + } else { + if (isset($vars['rspauth'])) { + // Second step + $this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"); + } else { + $this->log->log("ERROR receiving challenge : " . $challenge, XMPPHP_Log::LEVEL_ERROR); + } + + } + } + + /** * Resource bind handler * * @param string $xml @@ -339,20 +459,20 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } /** - * Retrieves the roster - * - */ + * Retrieves the roster + * + */ public function getRoster() { $id = $this->getID(); $this->send("<iq xmlns='jabber:client' type='get' id='$id'><query xmlns='jabber:iq:roster' /></iq>"); } /** - * Roster iq handler - * Gets all packets matching XPath "iq/{jabber:iq:roster}query' - * - * @param string $xml - */ + * Roster iq handler + * Gets all packets matching XPath "iq/{jabber:iq:roster}query' + * + * @param string $xml + */ protected function roster_iq_handler($xml) { $status = "result"; $xmlroster = $xml->sub('query'); @@ -405,9 +525,9 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } /** - * Retrieves the vcard - * - */ + * Retrieves the vcard + * + */ public function getVCard($jid = Null) { $id = $this->getID(); $this->addIdHandler($id, 'vcard_get_handler'); @@ -419,10 +539,10 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { } /** - * VCard retrieval handler - * - * @param XML Object $xml - */ + * VCard retrieval handler + * + * @param XML Object $xml + */ protected function vcard_get_handler($xml) { $vcard_array = array(); $vcard = $xml->sub('vcard'); diff --git a/lib/jabber/XMPPHP/XMPPHP_Log.php b/lib/jabber/XMPPHP/XMPPHP_Log.php deleted file mode 100644 index b1593f5..0000000 --- a/lib/jabber/XMPPHP/XMPPHP_Log.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * XMPPHP: The PHP XMPP Library - * Copyright (C) 2008 Nathanael C. Fritz - * This file is part of SleekXMPP. - * - * XMPPHP is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * XMPPHP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XMPPHP; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * @category xmpphp - * @package XMPPHP - * @author Nathanael C. Fritz <JID: fr...@ne...> - * @author Stephan Wentz <JID: st...@ja...> - * @author Michael Garvin <JID: ga...@ne...> - * @copyright 2008 Nathanael C. Fritz - */ - -/** - * XMPPHP Log - * - * @package XMPPHP - * @author Nathanael C. Fritz <JID: fr...@ne...> - * @author Stephan Wentz <JID: st...@ja...> - * @author Michael Garvin <JID: ga...@ne...> - * @copyright 2008 Nathanael C. Fritz - * @version $Id$ - */ -class XMPPHP_Log { - - const LEVEL_ERROR = 0; - const LEVEL_WARNING = 1; - const LEVEL_INFO = 2; - const LEVEL_DEBUG = 3; - const LEVEL_VERBOSE = 4; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var array - */ - protected $names = array('ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE'); - - /** - * @var integer - */ - protected $runlevel; - - /** - * @var boolean - */ - protected $printout; - - /** - * Constructor - * - * @param boolean $printout - * @param string $runlevel - */ - public function __construct($printout = false, $runlevel = self::LEVEL_INFO) { - $this->printout = (boolean)$printout; - $this->runlevel = (int)$runlevel; - } - - /** - * Add a message to the log data array - * If printout in this instance is set to true, directly output the message - * - * @param string $msg - * @param integer $runlevel - */ - public function log($msg, $runlevel = self::LEVEL_INFO) { - $time = time(); - //$this->data[] = array($this->runlevel, $msg, $time); - if($this->printout and $runlevel <= $this->runlevel) { - $this->writeLine($msg, $runlevel, $time); - } - } - - /** - * Output the complete log. - * Log will be cleared if $clear = true - * - * @param boolean $clear - * @param integer $runlevel - */ - public function printout($clear = true, $runlevel = null) { - if($runlevel === null) { - $runlevel = $this->runlevel; - } - foreach($this->data as $data) { - if($runlevel <= $data[0]) { - $this->writeLine($data[1], $runlevel, $data[2]); - } - } - if($clear) { - $this->data = array(); - } - } - - protected function writeLine($msg, $runlevel, $time) { - //echo date('Y-m-d H:i:s', $time)." [".$this->names[$runlevel]."]: ".$msg."\n"; - echo $time." [".$this->names[$runlevel]."]: ".$msg."\n"; - flush(); - } -} diff --git a/lib/jabber/XMPPHP/XMPP_Old.php b/lib/jabber/XMPPHP/XMPP_Old.php index 43f56b1..6083dad 100644 --- a/lib/jabber/XMPPHP/XMPP_Old.php +++ b/lib/jabber/XMPPHP/XMPP_Old.php @@ -33,7 +33,7 @@ * The old Jabber protocol wasn't standardized, so use at your own risk. * */ -require_once "XMPP.php"; +require_once dirname(__FILE__) . '/XMPP.php'; class XMPPHP_XMPPOld extends XMPPHP_XMPP { /** ----------------------------------------------------------------------- Summary of changes: lib/jabber/XMPPHP/BOSH.php | 2 +- lib/jabber/XMPPHP/DIGEST-MD5.patch | 132 ------------------ lib/jabber/XMPPHP/Roster.php | 17 ++- lib/jabber/XMPPHP/XMLStream.php | 199 ++++++++++++++++++++-------- lib/jabber/XMPPHP/XMPP.php | 256 ++++++++++++++++++++++++++---------- lib/jabber/XMPPHP/XMPPHP_Log.php | 119 ----------------- lib/jabber/XMPPHP/XMPP_Old.php | 2 +- 7 files changed, 344 insertions(+), 383 deletions(-) delete mode 100644 lib/jabber/XMPPHP/DIGEST-MD5.patch delete mode 100644 lib/jabber/XMPPHP/XMPPHP_Log.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-17 12:24:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 07da8658a0698e65a4be9da195033392da7ce013 (commit) from 32a7203e2796d9bf46791d9aa344451d29997b36 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 07da8658a0698e65a4be9da195033392da7ce013 Author: Ivan1986 <iva...@li...> Date: Thu Jun 17 16:23:55 2010 +0400 Ушло лишнее diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index db6a7d6..738f195 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -128,15 +128,7 @@ class DbSimple_Connect { // Если использовалась @, ничего не делать. if (!error_reporting()) return; - if (!empty($GLOBALS['prod']) || (defined('IN_CRON') && IN_CRON) ) - { - error_log(date('Y-m-d H:i:s').': '.$msg."\n", - 3, ROOTPATH.'/log/sql.log'); - error_log(date('Y-m-d H:i:s').': '.print_r($info, true)."\n", - 3, ROOTPATH.'/log/sql.log'); - redirect('/forum/'); - } - if (class_exists('QFW') && QFW::$config['QFW']['release']) + if (QFW::$config['QFW']['release']) { require_once LIBPATH.'/Log.php'; Log::log('SQL Error - '.$msg,'sql'); ----------------------------------------------------------------------- Summary of changes: lib/DbSimple/Connect.php | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-17 12:19:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 32a7203e2796d9bf46791d9aa344451d29997b36 (commit) from e1e9653c58c06c2f156578e320d98017a08cfce1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 32a7203e2796d9bf46791d9aa344451d29997b36 Author: Ivan1986 <iva...@li...> Date: Thu Jun 17 16:18:29 2010 +0400 Убрана ненужная проверка на наличие файла из симплы diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index f74bee8..db6a7d6 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -106,17 +106,17 @@ class DbSimple_Connect { $parsed = $this->parseDSN($dsn); if (!$parsed) - $this->errorHandler('Ошибка разбора строки DSN',$dsn); + $this->errorHandler('Ошибка разбора строки DSN', $dsn); + if (!isset($parsed['scheme'])) + $this->errorHandler('Невозможно загрузить драйвер базы данных', $parsed); $this->shema = ucfirst($parsed['scheme']); - if (!isset($parsed['scheme']) || !is_file(dirname(__FILE__).'/'.$this->shema.'.php')) - $this->errorHandler('Невозможно загрузить драйвер базы данных',$parsed); require_once dirname(__FILE__).'/'.$this->shema.'.php'; $class = 'DbSimple_'.$this->shema; $this->DbSimple = new $class($parsed); if (isset($parsed['prefix'])) $this->DbSimple->setIdentPrefix($parsed['prefix']); $this->DbSimple->setCachePrefix('db_'.md5($parsed['dsn']).'_'); - $this->DbSimple->setErrorHandler(array(&$this, 'errorHandler'), QFW::$config['QFW']['ErrorStack']); + $this->DbSimple->setErrorHandler(array(&$this, 'errorHandler'), false); } /** @@ -128,7 +128,15 @@ class DbSimple_Connect { // Если использовалась @, ничего не делать. if (!error_reporting()) return; - if (QFW::$config['QFW']['release']) + if (!empty($GLOBALS['prod']) || (defined('IN_CRON') && IN_CRON) ) + { + error_log(date('Y-m-d H:i:s').': '.$msg."\n", + 3, ROOTPATH.'/log/sql.log'); + error_log(date('Y-m-d H:i:s').': '.print_r($info, true)."\n", + 3, ROOTPATH.'/log/sql.log'); + redirect('/forum/'); + } + if (class_exists('QFW') && QFW::$config['QFW']['release']) { require_once LIBPATH.'/Log.php'; Log::log('SQL Error - '.$msg,'sql'); ----------------------------------------------------------------------- Summary of changes: lib/DbSimple/Connect.php | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-16 13:24:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via e1e9653c58c06c2f156578e320d98017a08cfce1 (commit) via 7fc9165e805a3e572ae0449efbee5d8ee36d2b5a (commit) from afd9295222fefd7d41673eca494b2998794aa54d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e1e9653c58c06c2f156578e320d98017a08cfce1 Author: Ivan1986 <iva...@li...> Date: Wed Jun 16 17:23:12 2010 +0400 Добавлен класс генерации CSS из SCSS (нужен sass) diff --git a/application/default/controllers/CssController.php b/application/default/controllers/CssController.php new file mode 100644 index 0000000..9dbf2ca --- /dev/null +++ b/application/default/controllers/CssController.php @@ -0,0 +1,81 @@ +<?php +/** + * Преобразование scss в css + * + * <br>Необходимо установить sass версии не ниже 3.0 + * + * @author ivan1986 + */ +class CssController +{ + /** Путь к sass */ + const SASS = 'sass -C'; + + /** + * Генерирует несуществующую css по scss если он есть + * + * @return string сгенерированная css + */ + public function indexAction() + { + QFW::$view->mainTemplate = ''; + $args = func_get_args(); + $css = implode('/', $args); + $scss = str_replace('.css', '.scss', $css); + if (!is_file(DOC_ROOT.'/css/'.$scss)) + QFW::$router->show404(); + + header('Content-Type: text/css'); + $out = array(); + $ret = false; + //запускаем преобразования - по умолчанию без кеша и выводим ошибки в основной поток + exec(self::SASS.' 2>&1 '.DOC_ROOT.'/css/'.$scss, $out, $ret); + $out = implode("\n", $out); + + if ($ret) + { //если у нас в scss ошибка, то выводим ее + $out = str_replace('Use --trace for backtrace.', '', $out); + $out = trim(str_replace("\n", ' ', $out)); + $out = 'body:before { content: \''.addslashes($out).'\'; }'; + } + return $out; + } + + /** + * Преобразует все файлы scss в css + */ + public function genCli() + { + $out = array(); + $ret = false; + exec('find '.DOC_ROOT.'/css -name \'*.scss\'', $out, $ret); + if ($ret) + return; + foreach ($out as $file) + { + $css = str_replace('.scss', '.css', $file); + exec(self::SASS.' 2>&1 '.$file.' | unexpand -t2 --first-only >'.$css, $out, $ret); + } + } + + /** + * Удаляет автоматически сгенерированные css + */ + public function cleanCli() + { + $out = array(); + $ret = false; + exec('find '.DOC_ROOT.'/css -name \'*.scss\'', $out, $ret); + if ($ret) + return; + foreach ($out as $file) + { + $css = str_replace('.scss', '.css', $file); + if (is_file($css)) + unlink($css); + } + } + +} + +?> commit 7fc9165e805a3e572ae0449efbee5d8ee36d2b5a Author: Ivan1986 <iva...@li...> Date: Wed Jun 16 17:22:27 2010 +0400 Изменено определение DOC_ROOT в cron diff --git a/cron/start.php b/cron/start.php index 7b6f671..b1cbc95 100644 --- a/cron/start.php +++ b/cron/start.php @@ -1,6 +1,6 @@ <?php - define ('DOC_ROOT', realpath(dirname(__FILE__).'../www')); - define ('ROOTPATH', realpath(dirname(__FILE__).'/../')); + define ('DOC_ROOT', dirname(dirname(__FILE__)).'/www'); + define ('ROOTPATH', dirname(dirname(__FILE__))); define ('APPPATH', ROOTPATH . '/application'); define ('TMPPATH', ROOTPATH . '/tmp'); define ('QFWPATH', ROOTPATH . '/QFW'); ----------------------------------------------------------------------- Summary of changes: application/default/controllers/CssController.php | 81 +++++++++++++++++++++ cron/start.php | 4 +- 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 application/default/controllers/CssController.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-11 14:23:31
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The tag, 1.5.1 has been created at afd9295222fefd7d41673eca494b2998794aa54d (commit) - Log ----------------------------------------------------------------- commit afd9295222fefd7d41673eca494b2998794aa54d Author: Ivan1986 <iva...@li...> Date: Fri Jun 11 17:54:07 2010 +0400 Исправлена ошибка в сессиях ----------------------------------------------------------------------- hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-11 13:54:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via afd9295222fefd7d41673eca494b2998794aa54d (commit) from 3cb2a6436df81212e9297fd170df4ce77807a3e1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit afd9295222fefd7d41673eca494b2998794aa54d Author: Ivan1986 <iva...@li...> Date: Fri Jun 11 17:54:07 2010 +0400 Исправлена ошибка в сессиях diff --git a/QFW/QuickFW/Session.php b/QFW/QuickFW/Session.php index 255a40c..4ce813a 100644 --- a/QFW/QuickFW/Session.php +++ b/QFW/QuickFW/Session.php @@ -63,21 +63,29 @@ class QuickFW_Session } /** + * Уничтожение сессии + */ + public static function destroy() + { + if (!session_id()) + return; + self::dest(session_id()); + session_destroy(); + } + + /** * Уничтожение сесии для session_set_save_handler * * @param string $id идентификатор сесии */ - public static function destroy($id) + private static function dest($id) { - if (!session_id()) - return; setcookie(session_name(), '', 1, '/', isset(QFW::$config['session']['domain']) ? QFW::$config['session']['domain'] : ''); unset($_COOKIE[session_name()]); if (self::$cache) self::$cache->remove('sess_'.$id); $_SESSION = array(); - session_destroy(); } /** @@ -157,7 +165,7 @@ class QuickFW_Session array('QuickFW_Session','close'), array('QuickFW_Session','read'), array('QuickFW_Session','write'), - array('QuickFW_Session','destroy'), + array('QuickFW_Session','dest'), array('QuickFW_Session','gc') ); } ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Session.php | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-07 07:38:34
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The tag, 1.5 has been created at 3cb2a6436df81212e9297fd170df4ce77807a3e1 (commit) - Log ----------------------------------------------------------------- commit 3cb2a6436df81212e9297fd170df4ce77807a3e1 Author: Ivan1986 <iva...@li...> Date: Fri Jun 4 14:54:02 2010 +0400 Скафолдинг переписан с использованием класса Url ----------------------------------------------------------------------- hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-04 10:54:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 3cb2a6436df81212e9297fd170df4ce77807a3e1 (commit) from 124e3d88ebc3f6d1ede8a4afcb65644291c1c3c7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3cb2a6436df81212e9297fd170df4ce77807a3e1 Author: Ivan1986 <iva...@li...> Date: Fri Jun 4 14:54:02 2010 +0400 Скафолдинг переписан с использованием класса Url diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 64259a1..494ba9e 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -36,8 +36,6 @@ abstract class ScafoldController extends Controller /** @var array Эта таблица зависимая - данные о родительской */ protected $parentData = false; - /** @var string Адрес контроллера */ - private $ControllerUrl; /** @var array Массив методов */ private $methods; /** @var boolean Флаг окончания настройки */ @@ -98,7 +96,6 @@ abstract class ScafoldController extends Controller QFW::$view->P->addCSS('buildin/scafold.css'); $this->setup = true; parent::__construct(); - $this->ControllerUrl = QFW::$router->module.'/'.QFW::$router->controller; $this->methods = array_flip(get_class_methods($this)); //Получаем данные о полях @@ -116,10 +113,7 @@ abstract class ScafoldController extends Controller QFW::$view->assign(array( 'methods' => $this->methods, 'class' => get_class($this), - 'info' => array( - 'ControllerUrl' => $this->ControllerUrl, - 'primaryKey' => $this->primaryKey, - ), + 'primaryKey' => $this->primaryKey, 'fields' => $this->fields, 'actions' => $this->actions, 'table' => str_replace('?_', '', $this->table), @@ -149,7 +143,7 @@ abstract class ScafoldController extends Controller if (isset($_POST['parent'])) { $_SESSION['scafold'][$this->table]['parent'] = $_POST['parent']; - QFW::$router->redirectMCA(QFW::$router->module.'/'.QFW::$router->controller.'/index'); + QFW::$router->redirect(Url::A()); } if (empty($_SESSION['scafold'][$this->table]['parent'])) $_SESSION['scafold'][$this->table]['parent'] = count($parent) ? key($parent) : 0; @@ -183,9 +177,8 @@ abstract class ScafoldController extends Controller QFW::$view->assign('filter', $filter['form']); } //получаем пагинатор - $curUrl = QFW::$view->P->siteUrl($this->ControllerUrl.'/index/$'); $pages = ceil($count/$this->pageSize); - $pager=QFW::$router->blockRoute('helper.nav.pager('.$curUrl.','.$pages.','.($page+1).')'); + $pager=QFW::$router->blockRoute('helper.nav.pager', Url::A('$'), $pages, $page+1); return QFW::$view->assign(array( 'data' => $data, @@ -247,7 +240,7 @@ abstract class ScafoldController extends Controller QFW::$router->redirect($url); } else - QFW::$router->redirect('/'.$this->ControllerUrl.'/index/'); + QFW::$router->redirect(Url::C('index')); } } @@ -294,7 +287,7 @@ abstract class ScafoldController extends Controller $v->proccess($id, false); QFW::$db->query('DELETE FROM ?# WHERE ?#=?', $this->table, $this->primaryKey, $id); - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); } /** @@ -309,7 +302,7 @@ abstract class ScafoldController extends Controller array_shift($args); if (isset($this->fields[$name])) call_user_func_array(array($this->fields[$name], 'action'), $args); - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); } /** @@ -321,13 +314,13 @@ abstract class ScafoldController extends Controller if (!empty($_POST['clear'])) { $_SESSION['scafold'][$this->table]['filter'] = array(); - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); } if (empty($_POST['filter']) || empty($_POST['apply'])) - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); $_SESSION['scafold'][$this->table]['filter'] = $_POST['filter']; - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); } /** @@ -340,7 +333,7 @@ abstract class ScafoldController extends Controller $this->session(); //такого поля нету if (!isset($this->fields[$field])) - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); if (isset($_SESSION['scafold'][$this->table]['sort']) && $_SESSION['scafold'][$this->table]['sort']['field'] == $field) $r = array( @@ -354,7 +347,7 @@ abstract class ScafoldController extends Controller 'direction' => 'ASC', ); $_SESSION['scafold'][$this->table]['sort'] = $r; - QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + QFW::$router->redirect(Url::C('index'), true); } //////////////////////////////////////////////////////////// diff --git a/lib/Modules/Scafold/scafold/edit.html b/lib/Modules/Scafold/scafold/edit.html index 0c14992..5877e6b 100644 --- a/lib/Modules/Scafold/scafold/edit.html +++ b/lib/Modules/Scafold/scafold/edit.html @@ -3,7 +3,7 @@ Поле <?php echo $fields[$k]->title ?> имеет некорректное значение<br /> <?php } ?> <?php } ?> -<form action="<?php echo $P->siteUrl($info['ControllerUrl'].'/edit/'.$id) ?>" class="scafoldEdit" +<form action="<?php echo Url::C('edit/'.$id) ?>" class="scafoldEdit" method="post" id="form_<?php echo $table ?>" enctype="multipart/form-data"> <dl> <?php foreach($data as $k=>$v) { diff --git a/lib/Modules/Scafold/scafold/filterForm.html b/lib/Modules/Scafold/scafold/filterForm.html index 44152a9..59b0d90 100644 --- a/lib/Modules/Scafold/scafold/filterForm.html +++ b/lib/Modules/Scafold/scafold/filterForm.html @@ -1,4 +1,4 @@ -<form action="<?php echo $P->siteUrl($info['ControllerUrl'].'/filter') ?>" +<form action="<?php echo Url::C('filter') ?>" method="post" id="filter_<?php echo $table ?>" class="scafoldFilter"> <?php foreach ($filter as $v) {?> <?php echo $v; ?> diff --git a/lib/Modules/Scafold/scafold/index.html b/lib/Modules/Scafold/scafold/index.html index ff3d096..d5e4354 100644 --- a/lib/Modules/Scafold/scafold/index.html +++ b/lib/Modules/Scafold/scafold/index.html @@ -14,8 +14,7 @@ if ($i->hide) continue; ?> - <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. - '/sort/'.$key) ?>"><?php echo $i->title ?></a> + <th><a href="<?php echo Url::C('sort/'.$key) ?>"><?php echo $i->title ?></a> <?php if (isset($order) && $order['field'] == $key) { ?><span class="scafoldSort"> <span><?php echo $order['direction']=='ASC' ? '↓' : '↑' ?></span> <?php /*<img src="/buildin/<?php echo $order['direction']=='ASC' ? 'az' : 'za' ?>.png" @@ -23,8 +22,7 @@ </span><?php } ?> </th> <?php } ?> - <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. - '/edit/-1') ?>">доб.</a></th> + <th><a href="<?php echo Url::C('edit/-1') ?>">доб.</a></th> <th> </th> <?php if (count($actions)) { ?><th>действия</th><?php } ?> </tr> @@ -42,20 +40,18 @@ echo $i->display($id, $v); ?></td> <?php } ?> - <td><a href="<?php echo $P->siteUrl($info['ControllerUrl']. - '/edit/'.$row[$info['primaryKey']]) ?>">ред.</a></td> - <td><a onclick="return confirm('Удалить?')" href="<?php echo $P->siteUrl($info['ControllerUrl']. - '/delete/'.$row[$info['primaryKey']]) ?>">уд.</a></td> + <td><a href="<?php echo Url::C('edit/'.$row[$primaryKey]) ?>">ред.</a></td> + <td><a onclick="return confirm('Удалить?')" href="<?php echo + Url::C('delete/'.$row[$primaryKey]) ?>">уд.</a></td> <?php if (count($actions)) {?><td><?php foreach ($actions as $tit => $uri) { ?> - <a href="<?php echo $P->siteUrl($info['ControllerUrl']. - '/'.$uri.'/'.$row[$info['primaryKey']]) ?>"><?php echo $tit ?></a> + <a href="<?php echo Url::C($uri.'/'.$row[$primaryKey]) ?>"><?php echo $tit ?></a> <?php } ?></td><?php } ?> </tr> <?php } ?> </table> <?php } else { ?> Записей нет - <a href="<?php echo $P->siteUrl($info['ControllerUrl'].'/edit/-1') ?>">добавить</a> + <a href="<?php echo Url::C('edit/-1') ?>">добавить</a> <?php } ?> <?php echo $pager; ?> \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/ScafoldController.php | 29 ++++++++++---------------- lib/Modules/Scafold/scafold/edit.html | 2 +- lib/Modules/Scafold/scafold/filterForm.html | 2 +- lib/Modules/Scafold/scafold/index.html | 18 ++++++---------- 4 files changed, 20 insertions(+), 31 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-04 06:41:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 124e3d88ebc3f6d1ede8a4afcb65644291c1c3c7 (commit) from 883348e1864aada2009f824c6a83ca37e9f64890 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 124e3d88ebc3f6d1ede8a4afcb65644291c1c3c7 Author: Ivan1986 <iva...@li...> Date: Fri Jun 4 10:41:08 2010 +0400 Удалена папка ClassTemplates за ненадобностью diff --git a/ClassTemplates/Cacher.php b/ClassTemplates/Cacher.php deleted file mode 100644 index 4b24730..0000000 --- a/ClassTemplates/Cacher.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -class Cacher_Class implements Zend_Cache_Backend_Interface -{ - /** - * Set the frontend directives - * - * @param array $directives assoc of directives - */ - public function setDirectives($directives); - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * Note : return value is always "string" (unserialization is done by the core not by the backend) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTest = false); - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id); - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false); - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id); - - /** - * Clean some cache records - * - * Available modes are : - * CACHE_CLR_ALL (default) => remove all cache entries ($tags is not used) - * CACHE_CLR_OLD => remove too old cache entries ($tags is not used) - * CACHE_CLR_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * CACHE_CLR_NOT_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem - */ - public function clean($mode = CACHE_CLR_ALL, $tags = array()); - -} - -?> \ No newline at end of file diff --git a/ClassTemplates/Readme.txt b/ClassTemplates/Readme.txt deleted file mode 100644 index 0d83601..0000000 --- a/ClassTemplates/Readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -В этой директории находятся шаблоны для написания классов шаблонизаторов, кешеров, прочей хрени :) -Взять, дописать функциональность к интерфейсу и положить в -шаблонизатор - QFW/Templater/ - класс должен лежать в файле QFW/Templater/<имя>.php и называться Templater_<имя> -кешер - QFW/Cacher/ - класс должен лежать в файле QFW/Cacher/<имя>.php и называться Cacher_<имя> - -Если накасячите с интерфейсами - сами виноваты :) \ No newline at end of file diff --git a/ClassTemplates/Templater.php b/ClassTemplates/Templater.php deleted file mode 100644 index e4876be..0000000 --- a/ClassTemplates/Templater.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -class Templater_Templater -{ - /** @var QuickFW_Plugs Плагины фреймворка */ - public $P; - - /** @var String Основной шаблон (путь относительно директории шаблонов) */ - public $mainTemplate; - - - /** - * Constructor - * - * @param string $tmplPath - директория шаблонов - * @param string $mainTpl - основной шаблон - * @return void - */ - public function __construct($tmplPath, $mainTpl) - { - $this->mainTemplate = $mainTpl; - $this->P = QuickFW_Plugs::getInstance(); - } - - /** - * Set the path to the templates - * - * @param string $path The directory to set as the path. - * @return void - */ - public function setScriptPath($path) - { - } - - /** - * Retrieve the current template directory - * - * @return string - */ - public function getScriptPath() - { - } - - /** - * Assign variables to the template - * - * Allows setting a specific key to the specified value, OR passing an array - * of key => value pairs to set en masse. - * - * @see __set() - * @param string|array $spec The assignment strategy to use (key or array of key - * => value pairs) - * @param mixed $value (Optional) If assigning a named variable, use this - * as the value. - * @return void - */ - public function assign($spec, $value = null) - { - return $this; - } - - /** - * Clear assigned variable - * - * @param string|array - * @return void - */ - public function delete($key) - { - } - - /** - * Clear all assigned variables - * - * @return void - */ - public function clearVars() - { - } - - public function getTemplateVars($var = null) - { - } - - public function block($block) - { - //TODO: убрать ненужную переменную после перехода на php 5.3 - $args = func_get_args(); - return call_user_func_array(array(&QFW::$router, 'blockRoute'), $args); - } - - /** - * Processes a template and returns the output. - * - * @param string $name The template to process. - * @return string The output. - */ - public function render($name) - { - return $this->fetch($name); - } - - public function fetch($name) - { - } - - /** - * Выводит основной шаблон, обрабатывает функцией HeaderFilter - * - * @param string $name The template to process. - * @return string The output. - */ - public function displayMain($content) - { - if (isset($this->mainTemplate) && $this->mainTemplate!="") - { - //Необходимо для установки флага CSS - $this->P->startDisplayMain(); - $this->assign('content',$content); - $content = $this->fetch($this->mainTemplate); - } - //Необходимо для вызовов всех деструкторов - QFW::$router->startDisplayMain(); - return $this->P->HeaderFilter($content); - } - -} -?> \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: ClassTemplates/Cacher.php | 72 ----------------------- ClassTemplates/Readme.txt | 6 -- ClassTemplates/Templater.php | 128 ------------------------------------------ 3 files changed, 0 insertions(+), 206 deletions(-) delete mode 100644 ClassTemplates/Cacher.php delete mode 100644 ClassTemplates/Readme.txt delete mode 100644 ClassTemplates/Templater.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-03 14:17:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 883348e1864aada2009f824c6a83ca37e9f64890 (commit) from 171791fb99feef38de70f67bb0223b3781685f9d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 883348e1864aada2009f824c6a83ca37e9f64890 Author: Ivan1986 <iva...@li...> Date: Thu Jun 3 18:17:05 2010 +0400 Мелкопраки роутера diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index adfef02..2d4b511 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -161,11 +161,6 @@ class QuickFW_Router $MCA['Params'] = $this->parseParams($data); } - $Params = func_get_args(); - array_shift($Params); - if ($Params) - $MCA['Params'] = array_merge($MCA['Params'], $Params); - if (isset($MCA['Error'])) { if (QFW::$config['QFW']['release']) @@ -174,6 +169,11 @@ class QuickFW_Router $MCA['Path']."\n".$MCA['Error']; } + $Params = func_get_args(); + array_shift($Params); + if ($Params) + $MCA['Params'] = array_merge($MCA['Params'], $Params); + //сохраняем пути вызова list($lpPath, $this->ParentPath, $this->CurPath) = array($this->ParentPath, $this->CurPath, $MCA['Path']); @@ -290,7 +290,7 @@ class QuickFW_Router if ($ref && isset($_SERVER['HTTP_REFERER'])) $url = $_SERVER['HTTP_REFERER']; else - $url = $url ? $url : Url::site($this->RequestUri);; + $url = $url ? $url : Url::site($this->RequestUri); header('Location: '.$url); exit(); } @@ -472,7 +472,7 @@ SREG; $this->cAction = $this->action = $aname; $this->type = $type; } - + $this->classes[$class_key] = array( 'i' => new $class, 'defA' => isset($vars['defA']) ? $vars['defA'] : $this->defA, ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Router.php | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-02 10:45:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 171791fb99feef38de70f67bb0223b3781685f9d (commit) from 87a14bd519095238326b0fe3bd412e827c0b79e0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 171791fb99feef38de70f67bb0223b3781685f9d Author: Ivan1986 <iva...@li...> Date: Wed Jun 2 14:44:24 2010 +0400 Исправлена ошибка в роутере - параметры в блоке diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index b00f72f..adfef02 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -146,16 +146,9 @@ class QuickFW_Router { $data = array_slice($patt,1,3); $MCA = $this->loadMCA($data,'Block'); - if (isset($patt[4])) - { - // Если вы все еще сидите на PHP 5.2 то раскомментируйте старый вариант - $MCA['Params'] = str_getcsv($patt[4],',',"'",'\\'); // $this->parseScobParams($patt[4]); - } - else - { - $MCA['Params'] = func_get_args(); - array_shift($MCA['Params']); - } + // Если вы все еще сидите на PHP 5.2 то раскомментируйте старый вариант + $MCA['Params'] = empty($patt[4]) ? array() : + $this->parseScobParams($patt[4]); // str_getcsv($patt[4],',',"'",'\\'); } else { @@ -165,8 +158,14 @@ class QuickFW_Router // module/controller/action/p1/p2/p3/... $data = explode(self::PATH_SEPARATOR, $Uri); $MCA = $this->loadMCA($data,'Block'); - $MCA['Params']=$this->parseParams($data); + $MCA['Params'] = $this->parseParams($data); } + + $Params = func_get_args(); + array_shift($Params); + if ($Params) + $MCA['Params'] = array_merge($MCA['Params'], $Params); + if (isset($MCA['Error'])) { if (QFW::$config['QFW']['release']) ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Router.php | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-06-02 08:55:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 87a14bd519095238326b0fe3bd412e827c0b79e0 (commit) via 38b2ca67cf4314dfa5335b428759dac383d0dc4c (commit) from 7833f01427ce29bd4b207d91ec6ad4ce733ef538 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 87a14bd519095238326b0fe3bd412e827c0b79e0 Author: Ivan1986 <iva...@li...> Date: Wed Jun 2 12:54:40 2010 +0400 Исправлена ошибка при редиректе на самого себя при включенном index.php из nginx diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index 70b946a..b00f72f 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -291,7 +291,7 @@ class QuickFW_Router if ($ref && isset($_SERVER['HTTP_REFERER'])) $url = $_SERVER['HTTP_REFERER']; else - $url = $url ? $url : $_SERVER['REQUEST_URI']; + $url = $url ? $url : Url::site($this->RequestUri);; header('Location: '.$url); exit(); } commit 38b2ca67cf4314dfa5335b428759dac383d0dc4c Author: Ivan1986 <iva...@li...> Date: Wed Jun 2 12:52:43 2010 +0400 Добавлена картинка сортировки в скафолдинг diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 65b3259..64259a1 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -95,7 +95,7 @@ abstract class ScafoldController extends Controller */ public function __construct() { - QFW::$view->P->addCSS('css/buildin/scafold.css'); + QFW::$view->P->addCSS('buildin/scafold.css'); $this->setup = true; parent::__construct(); $this->ControllerUrl = QFW::$router->module.'/'.QFW::$router->controller; diff --git a/lib/Modules/Scafold/scafold/index.html b/lib/Modules/Scafold/scafold/index.html index 5f4ede6..ff3d096 100644 --- a/lib/Modules/Scafold/scafold/index.html +++ b/lib/Modules/Scafold/scafold/index.html @@ -16,8 +16,12 @@ ?> <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. '/sort/'.$key) ?>"><?php echo $i->title ?></a> - <span class="scafoldSort"><span><?php if (isset($order) && $order['field'] == $key) - echo $order['direction']=='ASC' ? 'А->Я' : 'Я->А' ?></span></span></th> + <?php if (isset($order) && $order['field'] == $key) { ?><span class="scafoldSort"> + <span><?php echo $order['direction']=='ASC' ? '↓' : '↑' ?></span> + <?php /*<img src="/buildin/<?php echo $order['direction']=='ASC' ? 'az' : 'za' ?>.png" + alt="<?php echo $order['direction']=='ASC' ? '↓' : '↑' ?>" />*/?> + </span><?php } ?> + </th> <?php } ?> <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. '/edit/-1') ?>">доб.</a></th> diff --git a/www/buildin/az.png b/www/buildin/az.png new file mode 100644 index 0000000..9385bbc Binary files /dev/null and b/www/buildin/az.png differ diff --git a/www/css/buildin/scafold.css b/www/buildin/scafold.css similarity index 95% rename from www/css/buildin/scafold.css rename to www/buildin/scafold.css index 5a9c5e7..24bc8bb 100644 --- a/www/css/buildin/scafold.css +++ b/www/buildin/scafold.css @@ -30,9 +30,8 @@ table.scafoldTable position: relative; } -.scafoldTable .scafoldSort span { +.scafoldTable .scafoldSort * { position: absolute; - white-space: nowrap; } form.scafoldEdit .err {color: red;} diff --git a/www/buildin/za.png b/www/buildin/za.png new file mode 100644 index 0000000..372cb07 Binary files /dev/null and b/www/buildin/za.png differ ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Router.php | 2 +- lib/Modules/Scafold/ScafoldController.php | 2 +- lib/Modules/Scafold/scafold/index.html | 8 ++++++-- www/buildin/az.png | Bin 0 -> 601 bytes www/{css => }/buildin/scafold.css | 3 +-- www/buildin/za.png | Bin 0 -> 613 bytes 6 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 www/buildin/az.png rename www/{css => }/buildin/scafold.css (95%) create mode 100644 www/buildin/za.png hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-27 07:55:11
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 7833f01427ce29bd4b207d91ec6ad4ce733ef538 (commit) from b27c22f5fbf5503dc61a0ad1185619d9044569fc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7833f01427ce29bd4b207d91ec6ad4ce733ef538 Author: Ivan1986 <iva...@li...> Date: Thu May 27 11:54:20 2010 +0400 Исправлена ошибка в checkbox в скафолдинге diff --git a/lib/Modules/Scafold/Fields.php b/lib/Modules/Scafold/Fields.php index 2f4f056..fd7a874 100644 --- a/lib/Modules/Scafold/Fields.php +++ b/lib/Modules/Scafold/Fields.php @@ -361,7 +361,8 @@ class Scafold_Checkbox extends Scafold_Field public function editor($id, $value) { return '<input type="hidden" name="data['.$this->name.']" value="0" /> - <input type="checkbox" name="data['.$this->name.']" value="1" label="'.$this->title.'" />'; + <input type="checkbox" name="data['.$this->name.']" value="1" label="'.$this->title.'" + default="'.($value?'checked':'').'" />'; } } @@ -405,7 +406,8 @@ class Scafold_File extends Scafold_Field { return '<input type="file" name="file['.$this->name.']" /> <input type="hidden" name="data['.$this->name.']" value="0" /> - <input type="checkbox" name="data['.$this->name.']" value="1" label="Удалить" />'; + <input type="checkbox" name="data['.$this->name.']" value="1" label="Удалить" /> '. + $this->display($id, $value); } public function validator($id, $value) ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/Fields.php | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-25 13:09:05
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via b27c22f5fbf5503dc61a0ad1185619d9044569fc (commit) from 4736419bdf19013a5a7aca28cc07ddb998910f04 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b27c22f5fbf5503dc61a0ad1185619d9044569fc Author: Ivan1986 <iva...@li...> Date: Tue May 25 17:08:31 2010 +0400 Удалена неиспользуемая опция diff --git a/QFW/config.php b/QFW/config.php index 2a2a486..6b10fe4 100644 --- a/QFW/config.php +++ b/QFW/config.php @@ -34,7 +34,6 @@ $config['redirection']=array( */ $config['QFW'] = array( 'release' => false, /* статус проекта на данном хосте - отладка и всякие быстрые компиляции */ - 'catchFE' => false, /* перехват ошибок как исключений, исключений как логов и фатальных ошибок */ 'ErrorStack' => false, /* вывод стека вызовов в сообщении об ошибке в БД */ 'cacheSessions' => false, /* Хранить сессии в кеше, не использовать стандартный механизм */ 'autoload' => false, /* включить автолоад false|true|string */ diff --git a/application/default.php b/application/default.php index 433c974..b1f6abf 100644 --- a/application/default.php +++ b/application/default.php @@ -81,7 +81,6 @@ $config['cache'] = array( */ $config['QFW'] = array( 'release' => false, /* статус проекта на данном хосте - отладка и всякие быстрые компиляции */ - 'catchFE' => false, /* перехват ошибок как исключений, исключений как логов и фатальных ошибок */ 'ErrorStack' => false, /* вывод стека вызовов в сообщении об ошибке в БД */ 'cacheSessions' => false, /* Хранить сессии в кеше, не использовать стандартный механизм */ 'autoload' => true, /* включить автолоад false|true|string */ ----------------------------------------------------------------------- Summary of changes: QFW/config.php | 1 - application/default.php | 1 - 2 files changed, 0 insertions(+), 2 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-25 13:06:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 4736419bdf19013a5a7aca28cc07ddb998910f04 (commit) from 6c578872e8c8f59a141c01b87c78e214e96f7045 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4736419bdf19013a5a7aca28cc07ddb998910f04 Author: Ivan1986 <iva...@li...> Date: Tue May 25 17:05:03 2010 +0400 В качестве обработчика ошибок - Dklab_ErrorHook diff --git a/QFW/Init.php b/QFW/Init.php index 5ecfde7..3078def 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -92,8 +92,12 @@ class QFW static public function modules() { //Включаем обработку фатальных ошибок, если в конфиге указано - if (!empty(self::$config['QFW']['catchFE'])) - require QFWPATH.'/QuickFW/Error.php'; + if (!empty(self::$config['error'])) + { + require_once QFWPATH.'/QuickFW/Error.php'; + foreach(self::$config['error'] as $handler) + QFW_Listener::addFromConfig($handler); + } //автолоад if (!empty(self::$config['QFW']['autoload'])) diff --git a/QFW/QuickFW/Error.php b/QFW/QuickFW/Error.php index 7004293..d25e409 100644 --- a/QFW/QuickFW/Error.php +++ b/QFW/QuickFW/Error.php @@ -1,71 +1,44 @@ <?php -/** - * Функция - обработчик ошибок - * На продакшене записывает в лог - * На тестовом вылетает как эксепшн - */ -function exception_error_handler($errno, $errstr, $errfile, $errline ) -{ - if (QFW::$config['QFW']['release']) - { - require_once LIBPATH.'/Log.php'; - Log::log($errstr.' in '.$errfile.' on line '.$errline,'debug'); - return false; - } - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); -} -set_error_handler("exception_error_handler"); +require_once LIBPATH.'/ErrorHook/Listener.php'; -/** - * Обработка исключений - * Обрабатывает исключение неавторизованности как нормальное - показом контента - * Исключение 404 - показывает ошибку 404 - * Остальные - на продакшене 404 и в лог - * в дебаге - на страницу - */ -function exception_handler(Exception $exception) +class QFW_Listener extends Debug_ErrorHook_Listener { - $GLOBALS['DONE'] = 1; - if ($exception instanceof AuthException) - echo $exception->getMessage(); - elseif ($exception instanceof S404Exception) - QFW::$router->show404(); - elseif (QFW::$config['QFW']['release']) + private static $Instance; + + /** + * Добавляет обработчик из конфига + * + * @param array $handler данные из конфига + */ + public static function addFromConfig($handler) { - require_once LIBPATH.'/Log.php'; - Log::log("Uncaught exception: " . $exception->getMessage(),'debug'); - QFW::$router->show404(); - } - else - echo "Uncaught exception: " , $exception->getMessage(), "\n"; -} -set_exception_handler('exception_handler'); + if (!self::$Instance) + self::$Instance = new self();; -/** - * Классы исключений - * - */ -class AuthException extends Exception {} -class S404Exception extends Exception {} + $name = ucfirst($handler['name']); + require_once LIBPATH.'/ErrorHook/'.$name.'Notifier.php'; + //пока так, потом возможно придется переделать + if ($name == 'Mail') + { + $i = new Debug_ErrorHook_MailNotifier( + $handler['options']['to'], $handler['options']['whatToSend'], + $handler['options']['subjPrefix'], $handler['options']['charset']); + } + else + { + $class = 'Debug_ErrorHook_'.$name.'Notifier'; + $i = new $class($handler['options']['whatToSend']); + } + if ($handler['RemoveDups']) + { + require_once LIBPATH.'/ErrorHook/RemoveDupsWrapper.php'; + $i = new Debug_ErrorHook_RemoveDupsWrapper($i, + TMPPATH.'/errors', $handler['RemoveDups']); + } + self::$Instance->addNotifier($i); -/** - * Перехватчик фатальных ошибок - * В случае фатальной ошибки может что-то сделать - * TODO: Дописать коммент - */ -function FatalErrorHandler($text) -{ - //тут определим что жопа не случилась - if ($GLOBALS['DONE']) - return false; - // Случилась жопа, начинаем обработку ошибок - QFW::Init(); - require_once LIBPATH.'/Log.php'; - Log::log("Fatal Error" ,'critical'); - //TODO: Выдирать лог ошибок и отправлять последние куда-то - return $text; + } } -ob_start('FatalErrorHandler'); ?> \ No newline at end of file diff --git a/QFW/config.php b/QFW/config.php index 186f569..2a2a486 100644 --- a/QFW/config.php +++ b/QFW/config.php @@ -42,6 +42,21 @@ $config['QFW'] = array( ); /** + * Настройки обработчика ошибок + */ +$config['error'] = array(); +/*$config['error'][] = array( + 'name' => 'mail', + 'RemoveDups' => 300, //секунд или false + 'options' => array( + 'to' => 'user@localhost', + 'whatToSend' => 65535, // LOG_ALL (look in TextNotifier) + 'subjPrefix' => '[ERROR] ', + 'charset' => 'UTF-8', + ), +);*/ + +/** * С этими параметрами вызывается функция * session_set_cookie_params * Менять порядок нельзя - отломается, дописывать можно diff --git a/application/default.php b/application/default.php index b6f670b..433c974 100644 --- a/application/default.php +++ b/application/default.php @@ -34,6 +34,21 @@ $config['redirection']=array( ); /** + * Настройки обработчика ошибок + */ +$config['error'] = array(); +$config['error'][] = array( + 'name' => 'mail', + 'RemoveDups' => 300, //секунд или false + 'options' => array( + 'to' => 'ivan1986@localhost', + 'whatToSend' => 65535, // LOG_ALL (look in TextNotifier) + 'subjPrefix' => '[ERROR] ', + 'charset' => 'UTF-8', + ), +); + +/** * Настройки кешера (класс бекенда и дополнительные параметры, если есть) * * @deprecated лучше юзайте новый кешер diff --git a/lib/ErrorHook/Catcher.php b/lib/ErrorHook/Catcher.php new file mode 100644 index 0000000..b191d50 --- /dev/null +++ b/lib/ErrorHook/Catcher.php @@ -0,0 +1,97 @@ +<?php +/** + * Auxilary class. + * It performs all work with notification catching. + */ +class Debug_ErrorHook_Catcher +{ + private $_notifiers = array(); + private $_active = true; + private $_prevHdl = null; + private $_types = array( + "E_ERROR", "E_WARNING", "E_PARSE", "E_NOTICE", "E_CORE_ERROR", + "E_CORE_WARNING", "E_COMPILE_ERROR", "E_COMPILE_WARNING", + "E_USER_ERROR", "E_USER_WARNING", "E_USER_NOTICE", "E_STRICT", + "E_RECOVERABLE_ERROR" + ); + + public function __construct() + { + $this->_prevHdl = set_error_handler(array($this, "_handleNotice")); + register_shutdown_function(array($this, "_handleFatal")); + } + + public function remove() + { + restore_error_handler(); + $this->_prevHdl = null; + // There is no unregister_shutdown_function(), so we emulate it via flag. + $this->_active = false; + } + + public function addNotifier(Debug_ErrorHook_INotifier $notifier) + { + $this->_notifiers[] = $notifier; + } + + public function _handleNotice($errno, $errstr, $errfile, $errline) + { + if (!($errno & error_reporting())) { + return $this->_callPrevHdl($errno, $errstr, $errfile, $errline); + } + $trace = debug_backtrace(); + array_shift($trace); + if ($this->_notify($errno, $errstr, $errfile, $errline, $trace) === false) { + return $this->_callPrevHdl($errno, $errstr, $errfile, $errline, $trace); + } + } + + public function _handleFatal() + { + $error = error_get_last(); + if (!$this->_active || !is_array($error) || !in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR))) { + return; + } + $this->_notify($error['type'], $error['message'], $error['file'], $error['line'], null); + } + + /** + * Processes a notification. + * + * @param mixed $errno + * @param string $errstr + * @param string $errfile + * @param int $errline + * @param array $trace + * @return bool True if we need to stop the processing. + */ + private function _notify($errno, $errstr, $errfile, $errline, $trace) + { + // Translate error number to error name. + if (is_numeric($errno)) { + foreach ($this->_types as $t) { + $e = constant($t); + if ($errno == $e) { + $errno = $t; + break; + } + } + } + // Send data to all notifiers. + foreach ($this->_notifiers as $notifier) { + if ($notifier->notify($errno, $errstr, $errfile, $errline, $trace) === true) { + return true; + } + } + return false; + } + + private function _callPrevHdl() + { + if ($this->_prevHdl) { + $args = func_get_args(); + return call_user_func_array($this->_prevHdl, $args); + } + return false; + } +} diff --git a/lib/ErrorHook/INotifier.php b/lib/ErrorHook/INotifier.php new file mode 100644 index 0000000..f255275 --- /dev/null +++ b/lib/ErrorHook/INotifier.php @@ -0,0 +1,19 @@ +<?php +/** + * Notifier interface. + * Should be implemented by all notifiers in the stack. + */ +interface Debug_ErrorHook_INotifier +{ + /** + * Called when an error occurred. + * + * @param string $errno + * @param string $errstr + * @param string $errfile + * @param string $errline + * @param array $trace + * @return void + */ + public function notify($errno, $errstr, $errfile, $errline, $trace); +} diff --git a/lib/ErrorHook/Listener.php b/lib/ErrorHook/Listener.php new file mode 100644 index 0000000..25f7b16 --- /dev/null +++ b/lib/ErrorHook/Listener.php @@ -0,0 +1,50 @@ +<?php +/** + * Class to catch notices, warnings and even fatal errors + * and push them to a number of notifiers (e.g. - to email). + * + * A Listener object is kind of a guard object. + * + * @version 1.00 + */ + +require_once dirname(__FILE__).'/Catcher.php'; +require_once dirname(__FILE__).'/INotifier.php'; + +class Debug_ErrorHook_Listener +{ + private $_catcher = null; + + /** + * Creates a new listener object. + * When this object is destroyed, all hooks are removed. + * + * @return Debug_ErrorHook_Listener + */ + public function __construct() + { + $this->_catcher = new Debug_ErrorHook_Catcher(); + } + + /** + * Destructor. Cancels all listenings. + * + * @return void + */ + public function __destruct() + { + $this->_catcher->remove(); + } + + /** + * Adds a new notifier to the list. Notifiers are called in case + * of notices and even fatal errors. + * + * @param Debug_ErrorHook_INotifier $notifier + * @return void + */ + public function addNotifier(Debug_ErrorHook_INotifier $notifier) + { + $this->_catcher->addNotifier($notifier); + } +} diff --git a/lib/ErrorHook/MailNotifier.php b/lib/ErrorHook/MailNotifier.php new file mode 100644 index 0000000..f26f32b --- /dev/null +++ b/lib/ErrorHook/MailNotifier.php @@ -0,0 +1,60 @@ +<?php +/** + * Sends all notifications to a specified email. + * + * Consider using this class together with Debug_ErrorHook_RemoveDupsWrapper + * to avoid mail server flooding when a lot of errors arrives. + */ + +require_once dirname(__FILE__).'/Util.php'; +require_once dirname(__FILE__).'/TextNotifier.php'; + +class Debug_ErrorHook_MailNotifier extends Debug_ErrorHook_TextNotifier +{ + private $_to; + private $_charset; + private $_whatToSend; + private $_subjPrefix; + + public function __construct($to, $whatToSend, $subjPrefix = "[ERROR] ", $charset = "UTF-8") + { + parent::__construct($whatToSend); + $this->_to = $to; + $this->_subjPrefix = $subjPrefix; + $this->_charset = $charset; + } + + protected function _notifyText($subject, $body) + { + $this->_mail( + $this->_to, + $this->_encodeMailHeader($this->_subjPrefix . $subject), + $body, + join("\r\n", array( + "From: {$this->_to}", + "Content-Type: text/plain; charset={$this->_charset}" + )) + ); + } + + protected function _mail() + { + $args = func_get_args(); + @call_user_func_array("mail", $args); + } + + private function _encodeMailHeader($header) + { + return preg_replace_callback( + '/((?:^|>)\s*)([^<>]*?[^\w\s.][^<>]*?)(\s*(?:<|$))/s', + array(__CLASS__, '_encodeMailHeaderCallback'), + $header + ); + } + + private function _encodeMailHeaderCallback($p) + { + $encoding = $this->_charset; + return $p[1] . "=?$encoding?B?" . base64_encode($p[2]) . "?=" . $p[3]; + } +} diff --git a/lib/ErrorHook/RemoveDupsWrapper.php b/lib/ErrorHook/RemoveDupsWrapper.php new file mode 100644 index 0000000..4d223e9 --- /dev/null +++ b/lib/ErrorHook/RemoveDupsWrapper.php @@ -0,0 +1,89 @@ +<?php +/** + * Wrapper which denies duplicated notifications to be + * processed again and again. It is needed to lower the + * traffic to mail server in case the site is down. + * + * This class stores meta-informations in filesystem. + * It takes care about garbage collecting. + */ + +require_once dirname(__FILE__).'/INotifier.php'; + +class Debug_ErrorHook_RemoveDupsWrapper implements Debug_ErrorHook_INotifier +{ + const DEFAULT_PERIOD = 300; + const ERROR_FILE_SUFFIX = ".error"; + const GC_PROBABILITY = 0.01; + + private $_notifier; + private $_tmpPath; + private $_period; + private $_gcExecuted = false; + + public function __construct(Debug_ErrorHook_INotifier $notifier, $tmpPath = null, $period = null) + { + $this->_tmpPath = $tmpPath? $tmpPath : $this->_getDefaultTmpPath(); + $this->_period = $period? $period : self::DEFAULT_PERIOD; + $this->_notifier = $notifier; + if (!@is_dir($this->_tmpPath)) { + if (!@mkdir($this->_tmpPath, 0777, true)) { + $error = error_get_last(); + throw new Exception("Cannot create '{$this->_tmpPath}': {$error['message']}"); + } + } + } + + public function notify($errno, $errstr, $errfile, $errline, $trace) + { + $hash = md5(join(":", array($errno, $errfile, $errline))); + if ($this->_isExpired($hash)) { + $this->_notifier->notify($errno, $errstr, $errfile, $errline, $trace); + } + // Touch always, even if we did not send anything. Else same errors will + // be mailed again and again after $period (e.g. once per 5 minutes). + $this->_touch($hash, $errfile, $errline); + } + + protected function _getDefaultTmpPath() + { + return sys_get_temp_dir() . "/" . get_class($this); + } + + protected function _getGcProbability() + { + return self::GC_PROBABILITY; + } + + private function _getLockFname($hash) + { + return $this->_tmpPath . '/' . $hash . self::ERROR_FILE_SUFFIX; + } + + private function _isExpired($hash) + { + $file = $this->_getLockFname($hash); + return !file_exists($file) || filemtime($file) < time() - $this->_period; + } + + private function _touch($hash, $errfile, $errline) + { + $file = $this->_getLockFname($hash); + file_put_contents($file, "$errfile:$errline"); + chmod($file, 0777); + $this->_gc(); + } + + private function _gc() + { + if ($this->_gcExecuted || mt_rand(0, 10000) >= $this->_getGcProbability() * 10000) { + return; + } + foreach (glob("{$this->_tmpPath}/*" . self::ERROR_FILE_SUFFIX) as $file) { + if (filemtime($file) <= time() - $this->_period * 2) { + @unlink($file); + } + } + $this->_gcExecuted = true; + } +} diff --git a/lib/ErrorHook/TextNotifier.php b/lib/ErrorHook/TextNotifier.php new file mode 100644 index 0000000..a02e670 --- /dev/null +++ b/lib/ErrorHook/TextNotifier.php @@ -0,0 +1,81 @@ +<?php +/** + * Generic notifier wrapper. Converts notification + * to a human-readable text representation. + */ + +require_once dirname(__FILE__).'/Util.php'; +require_once dirname(__FILE__).'/INotifier.php'; + +abstract class Debug_ErrorHook_TextNotifier implements Debug_ErrorHook_INotifier +{ + const LOG_SERVER = 1; + const LOG_TRACE = 2; + const LOG_COOKIE = 4; + const LOG_GET = 8; + const LOG_POST = 16; + const LOG_SESSION = 32; + const LOG_ALL = 65535; + + private $_whatToLog; + private $_bodySuffix; + + public function __construct($whatToLog) + { + $this->_whatToLog = $whatToLog; + } + + public function setBodySuffixTest($text) + { + $this->_bodySuffix = $text; + } + + public function notify($errno, $errstr, $errfile, $errline, $trace) + { + $body = array(); + $body[] = $this->_makeSection( + "", + join("\n", array( + (@$_SERVER['GATEWAY_INTERFACE']? "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" : ""), + "$errno: $errstr", + "at $errfile on line $errline", + )) + ); + if ($this->_whatToLog & self::LOG_TRACE && $trace) { + $body[] = $this->_makeSection("TRACE", Debug_ErrorHook_Util::backtraceToString($trace)); + } + if ($this->_whatToLog & self::LOG_SERVER) { + $body[] = $this->_makeSection("SERVER", Debug_ErrorHook_Util::varExport($_SERVER)); + } + if ($this->_whatToLog & self::LOG_COOKIE) { + $body[] = $this->_makeSection("COOKIES", Debug_ErrorHook_Util::varExport($_COOKIE)); + } + if ($this->_whatToLog & self::LOG_GET) { + $body[] = $this->_makeSection("GET", Debug_ErrorHook_Util::varExport($_GET)); + } + if ($this->_whatToLog & self::LOG_POST) { + $body[] = $this->_makeSection("POST", Debug_ErrorHook_Util::varExport($_POST)); + } + if ($this->_whatToLog & self::LOG_SESSION) { + $body[] = $this->_makeSection("SESSION", Debug_ErrorHook_Util::varExport(@$_SESSION)); + } + // Append body suffix? + $suffix = $this->_bodySuffix && is_callable($this->_bodySuffix)? call_user_func($this->_bodySuffix) : $this->_bodySuffix; + if ($suffix) { + $body[] = $this->_makeSection("ADDITIONAL INFO", $suffix); + } + // Remain only 1st line for subject. + $errstr = preg_replace("/\r?\n.*/s", '', $errstr); + $this->_notifyText("$errno: $errstr at $errfile on line $errline", join("\n", $body)); + } + + private function _makeSection($name, $body) + { + $body = rtrim($body); + if ($name) $body = preg_replace('/^/m', ' ', $body); + $body = preg_replace('/^([ \t\r]*\n)+/s', '', $body); + return ($name? $name . ":\n" : "") . $body . "\n"; + } + + abstract protected function _notifyText($subject, $body); +} diff --git a/lib/ErrorHook/Util.php b/lib/ErrorHook/Util.php new file mode 100644 index 0000000..02f35ce --- /dev/null +++ b/lib/ErrorHook/Util.php @@ -0,0 +1,102 @@ +<?php +class Debug_ErrorHook_Util +{ + /** + * var_export clone, without using output buffering. + * (For calls in ob_handler) + * + * @param mixed $var to be exported + * @param integer $maxLevel (recursion protect) + * @param integer $level of current indent + * @return string + */ + public static function varExport($var, $maxLevel = 10, $level = 0) + { + $escapes = "\"\r\t\x00\$"; + $tab = ' '; + + if (is_bool($var)) { + return $var ? 'TRUE' : 'FALSE'; + } elseif (is_string($var)) { + return '"' . addcslashes($var, $escapes) . '"'; + } elseif (is_float($var) || is_int($var)) { + return $var; + } elseif (is_null($var)) { + return 'NULL'; + } elseif (is_resource($var)) { + return 'NULL /* ' . $var . ' */'; + } + + if ($maxLevel < $level) { + return 'NULL /* ' . (string) $var . ' MAX LEVEL ' . $maxLevel . " REACHED*/"; + } + + if (is_array($var)) { + $return = "array(\n"; + } else { + $return = get_class($var) . "::__set_state(array(\n"; + } + + $offset = str_repeat($tab, $level + 1); + + foreach ((array) $var as $key => $value) { + $return .= $offset; + if (is_int($key)) { + $return .= $key; + } else { + $return .= '"' . addcslashes($key, $escapes). '"'; + } + $return .= ' => ' . self::varExport($value, $maxLevel, $level + 1) . ",\n"; + } + + return $return + . str_repeat($tab, $level) + . (is_array($var) ? ')' : '))'); + } + + /** + * Analog for debug_print_backtrace(), but returns string. + * + * @return string + */ + public static function backtraceToString($backtrace) + { + // Iterate backtrace + $calls = array(); + foreach ($backtrace as $i => $call) { + if (!isset($call['file'])) { + $call['file'] = '(null)'; + } + if (!isset($call['line'])) { + $call['line'] = '0'; + } + $location = $call['file'] . ':' . $call['line']; + $function = (isset($call['class'])) ? + $call['class'] . (isset($call['type']) ? $call['type'] : '.') . $call['function'] : + $call['function']; + + $params = ''; + if (isset($call['args']) && is_array($call['args'])) { + $args = array(); + foreach ($call['args'] as $arg) { + if (is_array($arg)) { + $args[] = "Array(...)"; + } elseif (is_object($arg)) { + $args[] = get_class($arg); + } else { + $args[] = $arg; + } + } + $params = implode(', ', $args); + } + + $calls[] = sprintf('#%d %s(%s) called at [%s]', + $i, + $function, + $params, + $location); + } + + return implode("\n", $calls) . "\n"; + } +} ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 8 ++- QFW/QuickFW/Error.php | 95 ++++++++++++--------------------- QFW/config.php | 15 +++++ application/default.php | 15 +++++ lib/ErrorHook/Catcher.php | 97 +++++++++++++++++++++++++++++++++ lib/ErrorHook/INotifier.php | 19 +++++++ lib/ErrorHook/Listener.php | 50 +++++++++++++++++ lib/ErrorHook/MailNotifier.php | 60 ++++++++++++++++++++ lib/ErrorHook/RemoveDupsWrapper.php | 89 ++++++++++++++++++++++++++++++ lib/ErrorHook/TextNotifier.php | 81 +++++++++++++++++++++++++++ lib/ErrorHook/Util.php | 102 +++++++++++++++++++++++++++++++++++ 11 files changed, 568 insertions(+), 63 deletions(-) create mode 100644 lib/ErrorHook/Catcher.php create mode 100644 lib/ErrorHook/INotifier.php create mode 100644 lib/ErrorHook/Listener.php create mode 100644 lib/ErrorHook/MailNotifier.php create mode 100644 lib/ErrorHook/RemoveDupsWrapper.php create mode 100644 lib/ErrorHook/TextNotifier.php create mode 100644 lib/ErrorHook/Util.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-25 11:28:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 6c578872e8c8f59a141c01b87c78e214e96f7045 (commit) from 2abeb977bdbd63c9e7f7b88598ef640732110795 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6c578872e8c8f59a141c01b87c78e214e96f7045 Author: Ivan1986 <iva...@li...> Date: Tue May 25 15:27:55 2010 +0400 Убрана условная инициализация БД diff --git a/QFW/Init.php b/QFW/Init.php index c213fbd..5ecfde7 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -63,6 +63,10 @@ class QFW if (!empty(self::$config['host']['encoding'])) header("Content-Type: text/html; charset=".self::$config['host']['encoding']); + //Инициализируем класс базы данных + require LIBPATH.'/DbSimple/Connect.php'; + self::$db = new DbSimple_Connect(self::$config['database']); + //Подключаем шаблонизатор $templ = ucfirst(self::$config['templater']['name']); $class = 'Templater_'.$templ; @@ -87,13 +91,6 @@ class QFW */ static public function modules() { - //Инициализируем класс базы данных - if (!empty(self::$config['database'])) - { - require LIBPATH.'/DbSimple/Connect.php'; - self::$db = new DbSimple_Connect(self::$config['database']); - } - //Включаем обработку фатальных ошибок, если в конфиге указано if (!empty(self::$config['QFW']['catchFE'])) require QFWPATH.'/QuickFW/Error.php'; ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-25 09:35:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 2abeb977bdbd63c9e7f7b88598ef640732110795 (commit) from f7c33ff284b9d0ecfc96127fd4bac96dfc536b71 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2abeb977bdbd63c9e7f7b88598ef640732110795 Author: Ivan1986 <iva...@li...> Date: Tue May 25 13:34:43 2010 +0400 Поддержка проверки null в зависимом поле diff --git a/lib/Modules/Scafold/Fields.php b/lib/Modules/Scafold/Fields.php index cc6dd17..2f4f056 100644 --- a/lib/Modules/Scafold/Fields.php +++ b/lib/Modules/Scafold/Fields.php @@ -213,10 +213,14 @@ class Scafold_Foreign extends Scafold_Field /** @var array Зависимые поля */ protected $lookup; + /** @var bool Может ли быть нулевое значение */ + protected $isnull; + public function __construct($info, $where = DBSIMPLE_SKIP) { if (!empty($info->typeParams)) $where = $info->typeParams; + $this->isnull = $info->foreign['null']; parent::__construct($info); $this->lookup = QFW::$db->selectCol('SELECT ?# AS ARRAY_KEY_1, ?# FROM ?# {WHERE ?s}', $info->foreign['key'], $info->foreign['field'], $info->foreign['table'], $where); @@ -227,6 +231,11 @@ class Scafold_Foreign extends Scafold_Field return $this->selectBuild($this->lookup, $value); } + public function validator($id, $value) + { + return $this->isnull || !empty($value); + } + } /** ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/Fields.php | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-25 08:32:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via f7c33ff284b9d0ecfc96127fd4bac96dfc536b71 (commit) from 7d80383c4791c4e3b41684708c702d852190af66 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f7c33ff284b9d0ecfc96127fd4bac96dfc536b71 Author: Ivan1986 <iva...@li...> Date: Tue May 25 12:31:21 2010 +0400 Условие where в зависимом поле diff --git a/lib/Modules/Scafold/Fields.php b/lib/Modules/Scafold/Fields.php index 4bb373e..cc6dd17 100644 --- a/lib/Modules/Scafold/Fields.php +++ b/lib/Modules/Scafold/Fields.php @@ -213,11 +213,13 @@ class Scafold_Foreign extends Scafold_Field /** @var array Зависимые поля */ protected $lookup; - public function __construct($info) + public function __construct($info, $where = DBSIMPLE_SKIP) { + if (!empty($info->typeParams)) + $where = $info->typeParams; parent::__construct($info); - $this->lookup = QFW::$db->selectCol('SELECT ?# AS ARRAY_KEY_1, ?# FROM ?#', - $info->foreign['key'], $info->foreign['field'], $info->foreign['table']); + $this->lookup = QFW::$db->selectCol('SELECT ?# AS ARRAY_KEY_1, ?# FROM ?# {WHERE ?s}', + $info->foreign['key'], $info->foreign['field'], $info->foreign['table'], $where); } public function editor($id, $value) ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/Fields.php | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-24 19:56:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 7d80383c4791c4e3b41684708c702d852190af66 (commit) via e5c43509adb8f46b29c6d3bd4d6273489f38e804 (commit) from 28954c12d93a7c8d03e14ca0646f6ebbe6f61e02 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7d80383c4791c4e3b41684708c702d852190af66 Author: Ivan Borzenkov <iva...@li...> Date: Mon May 24 23:48:09 2010 +0400 Обработка случая, когда PATH_SEPARATOR не / - замена слешей diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index e6d97d5..2703879 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -111,6 +111,9 @@ class Url $this->ancor = $ancor ? ltrim($ancor, '#') : $url->ancor; return; } + //Заменяем / на QuickFW_Router::PATH_SEPARATOR + if (QuickFW_Router::PATH_SEPARATOR != '/') + $url = strtr($url, '/', QuickFW_Router::PATH_SEPARATOR); $this->u = trim($begin.$url, QuickFW_Router::PATH_SEPARATOR); $this->get = $get; $this->ancor = ltrim($ancor, '#'); @@ -135,7 +138,7 @@ class Url public function __toString() { return self::$config['base'].$this->u. - ($this->u!==''?self::$config['ext']:''). + ($this->u!=='' ? self::$config['ext'] : ''). ($this->get ? '?' . $this->get : ''). ($this->ancor ? '#' . $this->ancor : ''); commit e5c43509adb8f46b29c6d3bd4d6273489f38e804 Author: Ivan Borzenkov <iva...@li...> Date: Mon May 24 23:41:46 2010 +0400 Если PATH_SEPARATOR не / - не добавляется в конце урла diff --git a/QFW/Init.php b/QFW/Init.php index 8caad4d..c213fbd 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -59,10 +59,6 @@ class QFW require QFWPATH.'/QuickFW/Cache.php'; require QFWPATH.'/QuickFW/Plugs.php'; - //хелпер для урлов - require QFWPATH.'/QuickFW/Url.php'; - Url::Init(); - //выставляем заголовок с нужной кодировкой if (!empty(self::$config['host']['encoding'])) header("Content-Type: text/html; charset=".self::$config['host']['encoding']); @@ -80,6 +76,9 @@ class QFW require QFWPATH.'/QuickFW/Router.php'; self::$router = new QuickFW_Router(APPPATH); + //хелпер для урлов (зависит от QuickFW_Router) + require QFWPATH.'/QuickFW/Url.php'; + Url::Init(); } /** diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index 4dbd8ea..e6d97d5 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -85,8 +85,8 @@ class Url self::$config = QFW::$config['redirection']; self::$config['base'] = self::$config['baseUrl']. (self::$config['useIndex'] ? 'index.php/' : ''); - self::$config['ext'] = self::$config['defExt'] ? - self::$config['defExt'] : '/'; + self::$config['ext'] = self::$config['defExt'] ? self::$config['defExt'] : + (QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); } /** @var array QFW::$config['redirection'] */ ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 7 +++---- QFW/QuickFW/Url.php | 9 ++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-24 19:01:20
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 28954c12d93a7c8d03e14ca0646f6ebbe6f61e02 (commit) from f73a62133f91945a849f5b616075bb6bbf91941f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 28954c12d93a7c8d03e14ca0646f6ebbe6f61e02 Author: Ivan Borzenkov <iva...@li...> Date: Mon May 24 22:53:59 2010 +0400 В скафолдинг добавлена сортировка diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 8a66a8f..65b3259 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -42,7 +42,7 @@ abstract class ScafoldController extends Controller private $methods; /** @var boolean Флаг окончания настройки */ private $setup = false; - /** @var array Порядок сортировки */ + /** @var array Порядок столбцев */ private $order = array(); /** @@ -169,10 +169,11 @@ abstract class ScafoldController extends Controller $foreign = $this->getForeign(); $data = QFW::$db->select('SELECT ?# ?s FROM ?# ?s - WHERE ?s ?s '.$this->where.' LIMIT ?d, ?d', + WHERE ?s ?s '.$this->where.' ?s LIMIT ?d, ?d', array($this->table=>array_merge($this->order, array('*'))), $foreign['field'], $this->table, $foreign['join'], $filter['where'], $parentWhere, + $this->getSort(), $page*$this->pageSize, $this->pageSize); if (count($filter['form'])) @@ -329,6 +330,33 @@ abstract class ScafoldController extends Controller QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); } + /** + * Устанавливает порядок сортировки + * + * @param string $field Имя поля + */ + public function sortAction($field='') + { + $this->session(); + //такого поля нету + if (!isset($this->fields[$field])) + QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + if (isset($_SESSION['scafold'][$this->table]['sort']) && + $_SESSION['scafold'][$this->table]['sort']['field'] == $field) + $r = array( + 'field' => $field, + 'direction' => $_SESSION['scafold'][$this->table]['sort']['direction'] == 'ASC' ? + 'DESC' : 'ASC', + ); + else + $r = array( + 'field' => $field, + 'direction' => 'ASC', + ); + $_SESSION['scafold'][$this->table]['sort'] = $r; + QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); + } + //////////////////////////////////////////////////////////// //Функции для упращения настройки таблицы - удобные сеттеры //////////////////////////////////////////////////////////// @@ -560,6 +588,21 @@ abstract class ScafoldController extends Controller } /** + * Генерирует сортировку + * + * @return DbSimple_SubQuery Подзапрос сортировки + */ + private function getSort() + { + if (!isset($_SESSION['scafold'][$this->table]['sort'])) + return DBSIMPLE_SKIP; + $order = $_SESSION['scafold'][$this->table]['sort']; + QFW::$view->assign('order', $order); + return QFW::$db->subquery('order by ?# '.$order['direction'], + array($this->table => $order['field'])); + } + + /** * Получает части запроса для связанных полей * * @return array два объекта subQuery - список полей и список join diff --git a/lib/Modules/Scafold/scafold/index.html b/lib/Modules/Scafold/scafold/index.html index e857452..5f4ede6 100644 --- a/lib/Modules/Scafold/scafold/index.html +++ b/lib/Modules/Scafold/scafold/index.html @@ -14,7 +14,10 @@ if ($i->hide) continue; ?> - <th><?php echo $i->title ?></th> + <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. + '/sort/'.$key) ?>"><?php echo $i->title ?></a> + <span class="scafoldSort"><span><?php if (isset($order) && $order['field'] == $key) + echo $order['direction']=='ASC' ? 'А->Я' : 'Я->А' ?></span></span></th> <?php } ?> <th><a href="<?php echo $P->siteUrl($info['ControllerUrl']. '/edit/-1') ?>">доб.</a></th> diff --git a/www/css/buildin/scafold.css b/www/css/buildin/scafold.css index c1d5f56..5a9c5e7 100644 --- a/www/css/buildin/scafold.css +++ b/www/css/buildin/scafold.css @@ -26,6 +26,15 @@ table.scafoldTable .scafoldTable table.tnone {border: 1px solid black;} .scafoldTable table.tnone td {background-color:#FFF; border: none; padding: 0; margin: 0;} +.scafoldTable .scafoldSort { + position: relative; +} + +.scafoldTable .scafoldSort span { + position: absolute; + white-space: nowrap; +} + form.scafoldEdit .err {color: red;} form.scafoldEdit textarea:focus, input:focus, select:focus { ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/ScafoldController.php | 47 +++++++++++++++++++++++++++- lib/Modules/Scafold/scafold/index.html | 5 ++- www/css/buildin/scafold.css | 9 +++++ 3 files changed, 58 insertions(+), 3 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-24 17:53:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via f73a62133f91945a849f5b616075bb6bbf91941f (commit) from f19729b58a64fb8f392ef5064bc2353d8fd7010a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f73a62133f91945a849f5b616075bb6bbf91941f Author: Ivan Borzenkov <iva...@li...> Date: Mon May 24 21:52:25 2010 +0400 Поправил PhpDoc в скафолде diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 3d84e3e..8a66a8f 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -334,7 +334,7 @@ abstract class ScafoldController extends Controller //////////////////////////////////////////////////////////// /** - * Скрывает при выводе и редактировании указанные колонки + * Указывает порядок сортировки столбцев * * <br><br> Вызывается только в конструкторе * ----------------------------------------------------------------------- Summary of changes: lib/Modules/Scafold/ScafoldController.php | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-24 13:23:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via f19729b58a64fb8f392ef5064bc2353d8fd7010a (commit) from b92c178fa206f6cd2eaf4cf26a0a318f0e079cbd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f19729b58a64fb8f392ef5064bc2353d8fd7010a Author: Ivan1986 <iva...@li...> Date: Mon May 24 17:22:23 2010 +0400 Исправлена ошибка с текущем урлом в Nav хелпере diff --git a/application/helper/controllers/NavController.php b/application/helper/controllers/NavController.php index d32e38c..7b0c95f 100644 --- a/application/helper/controllers/NavController.php +++ b/application/helper/controllers/NavController.php @@ -49,10 +49,14 @@ class NavController $result.='<li>'; if ($v === false) $result.=$k; - elseif ($cur == $v) - $result.='<b>'.$k.'</b>'; else - $result.='<a href="'.$v.'">'.$k.'</a>'; + { + if ($v instanceof Url) + $self = $cur == $v->intern(); + else + $self = $cur == $v; + $result.= $self ? '<b>'.$k.'</b>' : '<a href="'.$v.'">'.$k.'</a>'; + } $result.="</li>\n"; } $result.= '</ul>'; ----------------------------------------------------------------------- Summary of changes: application/helper/controllers/NavController.php | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-24 11:43:20
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via b92c178fa206f6cd2eaf4cf26a0a318f0e079cbd (commit) from 3ae7582099befdcbdedc899114b5118d2f75152c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b92c178fa206f6cd2eaf4cf26a0a318f0e079cbd Author: Ivan1986 <iva...@li...> Date: Mon May 24 15:42:16 2010 +0400 Исправлена ошибка в Url - в случае передачи на деф. экшен двойной / diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index 5a6cd2d..4dbd8ea 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -111,7 +111,7 @@ class Url $this->ancor = $ancor ? ltrim($ancor, '#') : $url->ancor; return; } - $this->u = $begin.trim($url, QuickFW_Router::PATH_SEPARATOR); + $this->u = trim($begin.$url, QuickFW_Router::PATH_SEPARATOR); $this->get = $get; $this->ancor = ltrim($ancor, '#'); if (self::$config['delDef']) ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Url.php | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-23 20:42:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 3ae7582099befdcbdedc899114b5118d2f75152c (commit) via b9af15c502a2c25823279e44a6985d3bb975ae3d (commit) via fb11dca4dd186f1d866454197cb6f2292b5e7ad9 (commit) via a0b0a5d092c70e2a1b40b3cb144748798bba8eea (commit) via ec7604792b02897382fda8c1857f279a4a62bd5e (commit) from 35cb8d420b9cdea86df7d2df3ac955fb77434847 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3ae7582099befdcbdedc899114b5118d2f75152c Author: Ivan Borzenkov <iva...@li...> Date: Sun May 23 19:48:05 2010 +0400 Функция order для установки порядка полей diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 8cf29d8..3d84e3e 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -42,6 +42,8 @@ abstract class ScafoldController extends Controller private $methods; /** @var boolean Флаг окончания настройки */ private $setup = false; + /** @var array Порядок сортировки */ + private $order = array(); /** * Получает данные о полях @@ -105,6 +107,11 @@ abstract class ScafoldController extends Controller if (get_class($field) == 'Scafold_Field_Info') unset($this->fields[$k]); + //порядок сортировки полей + foreach($this->order as $k=>$v) + if (!isset($this->fields[$v])) + unset($this->order[$k]); + //Общая информация о таблице QFW::$view->assign(array( 'methods' => $this->methods, @@ -163,7 +170,7 @@ abstract class ScafoldController extends Controller $foreign = $this->getForeign(); $data = QFW::$db->select('SELECT ?# ?s FROM ?# ?s WHERE ?s ?s '.$this->where.' LIMIT ?d, ?d', - array($this->table=>'*'), + array($this->table=>array_merge($this->order, array('*'))), $foreign['field'], $this->table, $foreign['join'], $filter['where'], $parentWhere, $page*$this->pageSize, $this->pageSize); @@ -251,11 +258,15 @@ abstract class ScafoldController extends Controller { //получение дефолтовых значений для новой записи $data = array(); + foreach($this->order as $f) + $data[$f] = $this->fields[$f]->def(); foreach ($this->fields as $f=>$info) - $data[$f] = $info->def(); + if (!isset($data[$f])) + $data[$f] = $info->def(); } else - $data = QFW::$db->selectRow('SELECT * FROM ?# WHERE ?#=?', + $data = QFW::$db->selectRow('SELECT ?# FROM ?# WHERE ?#=?', + array($this->table=>array_merge($this->order, array('*'))), $this->table, $this->primaryKey, $id); $state = new TemplaterState(QFW::$view); @@ -323,6 +334,21 @@ abstract class ScafoldController extends Controller //////////////////////////////////////////////////////////// /** + * Скрывает при выводе и редактировании указанные колонки + * + * <br><br> Вызывается только в конструкторе + * + * @param array $fieldList массив с именами полей + * @return ScafoldController + */ + protected function order($fieldList) + { + $this->endTest(); + $this->order = $fieldList; + return $this; + } + + /** * Устанавливает таблицу как подчиненную * * <br><br> Вызывается только в конструкторе commit b9af15c502a2c25823279e44a6985d3bb975ae3d Author: Ivan Borzenkov <iva...@li...> Date: Sun May 23 19:10:53 2010 +0400 Исправлена ошибка с фильтром - не работал diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index e85747c..8cf29d8 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -308,12 +308,12 @@ abstract class ScafoldController extends Controller $this->session(); if (!empty($_POST['clear'])) { - $_SESSION['scafold']['filter'] = array(); + $_SESSION['scafold'][$this->table]['filter'] = array(); QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); } if (empty($_POST['filter']) || empty($_POST['apply'])) QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); - $_SESSION['scafold']['filter'] = $_POST['filter']; + $_SESSION['scafold'][$this->table]['filter'] = $_POST['filter']; QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true); } commit fb11dca4dd186f1d866454197cb6f2292b5e7ad9 Author: Ivan Borzenkov <iva...@li...> Date: Sun May 23 18:56:53 2010 +0400 В varchar можно передавать размер diff --git a/lib/Modules/Scafold/Fields.php b/lib/Modules/Scafold/Fields.php index 533c810..4bb373e 100644 --- a/lib/Modules/Scafold/Fields.php +++ b/lib/Modules/Scafold/Fields.php @@ -296,8 +296,10 @@ class Scafold_Varchar extends Scafold_Field /** @var integer размер поля в базе */ private $size; - public function __construct($info, $size) + public function __construct($info, $size = 100) { + if (!empty($info->typeParams) && is_numeric($info->typeParams)) + $size = $info->typeParams; parent::__construct($info); $this->size = $size; } diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index e6402cd..e85747c 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -81,7 +81,6 @@ abstract class ScafoldController extends Controller 'Null' => 'NO', 'Default' => null, 'Extra' => '', - ); $f[$field[0]] = $this->getFieldClass($c, $info); } commit a0b0a5d092c70e2a1b40b3cb144748798bba8eea Author: Ivan Borzenkov <iva...@li...> Date: Sun May 23 16:45:43 2010 +0400 Скафолдинг - работа с sqlite diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php index 703174b..e6402cd 100644 --- a/lib/Modules/Scafold/ScafoldController.php +++ b/lib/Modules/Scafold/ScafoldController.php @@ -44,6 +44,52 @@ abstract class ScafoldController extends Controller private $setup = false; /** + * Получает данные о полях + * + * @return array Данные + */ + private function fields() + { + $f = array(); + $shema = QFW::$db->getShema(); + if ($shema == 'Mypdo' || $shema == 'Mysql') + { //Mysql + $fields = QFW::$db->select('SHOW FIELDS IN ?#', $this->table); + foreach($fields as $field) + { + $c = $this->getInfoClass($field['Field']); + $c->primaryKey = $field['Key'] == 'PRI'; + $f[$field['Field']] = $this->getFieldClass($c, $field); + } + } + else if ($shema == 'Litepdo' || $shema == 'Sqlite') + { //Sqlite + $sql = QFW::$db->selectCell('SELECT sql FROM sqlite_master + WHERE type=? AND name=?', 'table', str_replace('?_', + QFW::$db->setIdentPrefix(null), $this->table)); + //выделяем то что в скобках + $sql = substr($sql, strpos($sql, '(')+1, -1); + $fields = explode(',', $sql); + foreach($fields as $field) + { + $field = explode(' ', trim($field), 2); + $c = $this->getInfoClass($field[0]); + $c->primaryKey = strpos($field[1], 'PRIMARY KEY') !== false; + $info = array( + 'Field' => $field[0], + 'Type' => $field[1], + 'Null' => 'NO', + 'Default' => null, + 'Extra' => '', + + ); + $f[$field[0]] = $this->getFieldClass($c, $info); + } + } + return $f; + } + + /** * Конструктор вызывать только после настройки таблицы */ public function __construct() @@ -55,14 +101,7 @@ abstract class ScafoldController extends Controller $this->methods = array_flip(get_class_methods($this)); //Получаем данные о полях - $fields = QFW::$db->select('SHOW FIELDS IN ?#', $this->table); - foreach($fields as $field) - { - $c = $this->getInfoClass($field['Field']); - $c->primaryKey = $field['Key'] == 'PRI'; - $this->fields[$field['Field']] = - $this->getFieldClass($c, $field); - } + $this->fields = $this->fields(); foreach($this->fields as $k=>$field) if (get_class($field) == 'Scafold_Field_Info') unset($this->fields[$k]); commit ec7604792b02897382fda8c1857f279a4a62bd5e Author: Ivan Borzenkov <iva...@li...> Date: Sun May 23 16:45:13 2010 +0400 Dbsimple - получение информации о типе базы diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index e474467..f74bee8 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -34,7 +34,12 @@ define('DBSIMPLE_PARENT_KEY', 'PARENT_KEY'); // forrest-based resultset support */ class DbSimple_Connect { - protected $DbSimple, $DSN; + /** @var DbSimple_Generic_Database База данных */ + protected $DbSimple; + /** @var string DSN подключения */ + protected $DSN; + /** @var string Тип базы данных */ + protected $shema; /** * Конструктор только запоминает переданный DSN @@ -44,8 +49,9 @@ class DbSimple_Connect */ public function __construct($dsn) { - $this->DbSimple = null; - $this->DSN = $dsn; + $this->DbSimple = null; + $this->DSN = $dsn; + $this->shema = ucfirst(substr($dsn, 0, strpos($dsn, ':'))); } /** @@ -61,6 +67,16 @@ class DbSimple_Connect } /** + * Возвращает тип базы данных + * + * @return string имя типа БД + */ + public function getShema() + { + return $this->shema; + } + + /** * Коннект при первом запросе к базе данных */ public function __call($method, $params) @@ -91,10 +107,11 @@ class DbSimple_Connect $parsed = $this->parseDSN($dsn); if (!$parsed) $this->errorHandler('Ошибка разбора строки DSN',$dsn); - if (!isset($parsed['scheme']) || !is_file(dirname(__FILE__).'/'.ucfirst($parsed['scheme']).'.php')) + $this->shema = ucfirst($parsed['scheme']); + if (!isset($parsed['scheme']) || !is_file(dirname(__FILE__).'/'.$this->shema.'.php')) $this->errorHandler('Невозможно загрузить драйвер базы данных',$parsed); - require_once dirname(__FILE__).'/'.ucfirst($parsed['scheme']).'.php'; - $class = 'DbSimple_'.ucfirst($parsed['scheme']); + require_once dirname(__FILE__).'/'.$this->shema.'.php'; + $class = 'DbSimple_'.$this->shema; $this->DbSimple = new $class($parsed); if (isset($parsed['prefix'])) $this->DbSimple->setIdentPrefix($parsed['prefix']); ----------------------------------------------------------------------- Summary of changes: lib/DbSimple/Connect.php | 29 +++++++-- lib/Modules/Scafold/Fields.php | 4 +- lib/Modules/Scafold/ScafoldController.php | 90 ++++++++++++++++++++++++---- 3 files changed, 103 insertions(+), 20 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2010-05-21 07:43:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 35cb8d420b9cdea86df7d2df3ac955fb77434847 (commit) from ae6209fc73ef21aff5a38ff2a72699086b50b095 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 35cb8d420b9cdea86df7d2df3ac955fb77434847 Author: Ivan1986 <iva...@li...> Date: Fri May 21 11:42:54 2010 +0400 Обертка для preg_match diff --git a/lib/utils.php b/lib/utils.php index 3d5f679..1248a4c 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -293,4 +293,24 @@ function pluralForm($n, $form1, $form2, $form5) return $form5; } +/** + * Вызывает preg_match(_all) и + * <br>возвращается данные в удобном формате + * <br>с использованием флага PREG_SET_ORDER + * + * @param string $pattern регулярное выражение + * @param string $subject строка для поиска + * @param bool $all вызывать preg_match_all + * @return array найденные паттерны + */ +function preg($pattern, $subject, $all = true) +{ + $m = array(); + if ($all) + preg_match_all($pattern, $subject, $m, PREG_SET_ORDER); + else + preg_match($pattern, $subject, $m); + return $m; +} + ?> ----------------------------------------------------------------------- Summary of changes: lib/utils.php | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) hooks/post-receive -- quickfw |