Thursday, 3 October 2013

setcookie() do not set value in chrome

setcookie() do not set value in chrome

hi all i am facing problem with setcookie() in chrome only. It is working
fine in firefox. this is my function where i am using cookie
function step3($voice_choice = null)
{
if (!empty($voice_choice)) {
setcookie("voice_choice", $voice_choice, time() + 2000, "/");
}
}
when I print $_COOKIE output is
Array ( [CAKEPHP] => s247c7mlagt5am6h323cm7pqj0 [voice_choice] =>
favicon.ico ).
the value of "voice_choice" is not what i set in above function.

Wednesday, 2 October 2013

Bad RPM Signatures

Bad RPM Signatures

I'm trying to set up a repo that contains both CentOS 6.4 and 5.9
packages. The machine itself is 6.4.
I've created a GPG key and have been able to sign my 6.4 packages no
problem. When I create them for 5.9 though I get header errors. I realize
that the versions of RPM are different, so I installed 4.2 (the version
that ships with 5.9) and tried signing with that... it still doesn't work.
[root@usch1ksv01 RPMS]# /usr/local/bin/rpm --version
RPM version 4.4.2.3
[root@usch1ksv01 RPMS]# rpm --version
RPM version 4.8.0
[root@usch1ksv01 RPMS]# /usr/local/bin/rpm --checksig
ypserv-2.19-10.el5_9.1.x86_64.rpm
ypserv-2.19-10.el5_9.1.x86_64.rpm: RSA sha1 (MD5) (PGP) md5 NOT OK
(MISSING KEYS: PGP#a8228ab5)
[root@usch1ksv01 RPMS]# rpm --checksig ypserv-2.19-10.el5_9.1.x86_64.rpm
ypserv-2.19-10.el5_9.1.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
I don't understand why the signatures aren't working for the older version
of RPM... I'm just doing an rpmsign --addsign , which clearly works for
the new version but not the old. I've used both versions of RPM to try
signing too.
I'm totally out of ideas, so any help would be greatly appreciated! Thanks!

Importing a class into another class in Python

Importing a class into another class in Python

as I'm still learning python I came up to a problem.
Why does this work:
class SomeOtherClass(object):
def __init__(self):
self.number = 10
print(self.number)
def increase(self):
self.number += 1
print(self.number)
class MyMainClass(object):
def __init__(self):
self.otherClass = MyClass()
app = MyMainClass() #Output: 10
app.otherclass.increase() #Output: 11
but this doesn't:
from tkinter import *
class MyMainClass(object):
def __init__(self):
self.tk = Tkinter() # <-- Error: see below.
app = MyMainClass()
app.tk.title("My window")
...
Both times I include a class, but in the second example it says:
NameError: global name 'Tkinter' is not defined
Where's the difference between those examples and how can I solve this, so
I'm able to use tkinter in my class?
Thanks for your help.

Tuesday, 1 October 2013

Putting text into a textarea via a jQuery click event?

Putting text into a textarea via a jQuery click event?

Say I have a text area like this:
<textarea id="comment_mc" name="comment" class="comment" rows="4"
cols="30"></textarea>
And divs like this:
<div class="fees-item fees-item-odd">
Ó†»é,šwŒŽ»òÑaÕˆÎçÑç,ÍíÑç<br />
Šyǰ±£ðB<br />
ÔìÐ͸Ä׃2Ì×<br />
ÉÏË®·Û,…fÖúnu bra´©Öø<br />
Ñç¿ÍÑaŠy<br />
&lsqauo;Œ&lsqauo;ŒŠy1 ÓHÓѵ­Šy1(²»º¬óŒÐÍ)<br />
ÐÂÀɵ­Šy(º¬óŒÐÍ)</p>
<h4>16000NTD</h4>
<a class="fees-purchase" href="">Purchase</a>
</div>
<div class="fees-item fees-item-even">
½Y»éÈ«³Ì(ÈýÌ×ÔìÐÍ)<br />
Šyǰ±£ðB<br />
Ó­È¢ÔìÐÍ<br />
ßMˆöÔìÐÍ2Ì×<br />
ÉÏË®·Û…fÖúNU Bra´©Öø<br />
Ñç¿ÍÑaŠy<br />
&lsqauo;Œ&lsqauo;ŒŠy1 (²»º¬óŒÐÍ)<br />
ÐÂÀɵ­Šy(º¬óŒÐÍ) </p>
<h4>18000NTD</h4>
<a class="fees-purchase" href="">Purchase</a>
</div>
Is there anyway to put the text of a .fees-item div into the textarea when
the user clicks on its fees-purchase link?

Why is "if" not working?

Why is "if" not working?

my $trefer = $ENV{HTTP_REFERER};
my $gk1 = substr($trefer, -4);
my $gk2 = ".swf";
my $antigk = $gk1;
if ($gk1 = $gk2) {
$antigk = $trefer;
}
else
{
$antigk = $link;
}
so whats wrong with this code? if is not working for example referal is
site.com/2nujroj49lni, it should show me the $link but instead it shows me
the $refer
why ? i dont get it
as long as it is not .swf i should get link not the referal i searched
over the internet and it looks legit . no errors as far as i can see but
still not working

NAT Gateway - Maximum connection limit

NAT Gateway - Maximum connection limit

I know just enough networking to be dangerous. The nitty gritty low level
details of NAT are not something I am particularly knowledgeable about.
I accidentally found myself in a discussion earlier today about placing a
bunch of our nodes behind a NAT Gateway. (1 public IP address and X
private LAN addresses). I called up the 16 bit limit to source and
destination port fields in the TCP protocol,
(http://www.ietf.org/rfc/rfc793.txt - page 15) and mentioned that it would
limit us to some 65,000 connections (65536). -- I am not so confident
about that answer anymore. Can you help me with some details?
I understand that an incoming port (server port) on our side can accept as
many connections as there are sourceIP x SourcePort combinations. Let's
discount those for the time being and focus on connections originating in
the LAN, traveling through the NAT Gateway, and ending on a random host at
a random port.
On a normal [Linux] system, outgoing connections I believe are limited to
1 per port per Source IP. If we pretend that we live in a simple world
where each system only has 1 IP address, then a 'normal system' would be
limited to an absolute maximum of 65536 connections.
1) In TCP is a single source IP limited to 65536 MAX theoretical outgoing
connections?
2) Or is the limit actually 65536 connections for each Remote Host?
2) [Written another way]: Can the same source port be used for a different
remoteHostIP:RemotePort combination?
For example: (Is the following OK?)
Source IP |Source Port |Remote IP|Remote Port
192.168.0.20:36500 --> 8.8.8.8:23
192.168.0.20:36500 --> 8.8.4.4:23
3) Are the answers to questions 1 and 2 different for a ...'not normal
system' [Cisco router acting as a NAT Gateway]?
Ex: A specialized networking device that has one public facing IP and up
to ~65,000 Lan IPs [or more] behind it? Is there magic at place or is the
answer to question 2 just always: yes? (or no)
4) The above questions all assume a stateful TCP connection. Is the story
any different with a stateless conection like UDP?
And Ultimately:
5) Will our LAN be limited to 65536 (or some other theoretical limit)
concurrent connections to the outside world through a single public IP
address?
Thank you! :)



For purposes of this question, we are behind very BEEFY AND BRAND NEW
Cisco Nexus gear (7000 series I think). It may be better to ignore
memory/etc limitations unless they can be specifically quantified.

Monday, 30 September 2013

No internet on VIrtual Machines and external (physical) network is unreachable from VM's

No internet on VIrtual Machines and external (physical) network is
unreachable from VM's

I have installed openstack (packstack) on centos 6.4 with neutron. The
openstack is installed on single virtual machine using vmware.
First i have created external network using following command
quantum net-create public --router:external=True
Then i added my external network subnet (ip pool not used in external
network)
Then i created router
Then i set my router gateway to external network
I created security group to allow ssh and icmp.
On second step i created private network with dhcp enabled
Then created router interface and attach it to my private network
On third step i launched the instance with private network
On fourth step i generated floating ip of external network and associates
it to instance
Problem Statement:
Virtual machines are getting IP's (private network) from dhcp and
communicating with each other but there is No internet on VM's
VM's cannot ping any external network device.
I am using Centos 6.4. Ip route shows
192.168.186.0/24 dev eth1 proto kernel scope link src 192.168.186.166
metric 1
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
10.16.48.0/22 dev br-ex proto kernel scope link src 10.16.51.208
169.254.0.0/16 dev eth0 scope link metric 1002
169.254.0.0/16 dev br-ex scope link metric 1017
default via 10.16.48.1 dev br-ex
Where 10.16.48.0/22 is my external network on eth0 (for internet)
10.16.186.0/24 is my anoother interface on eth1
quantum agent-list shows ----+-------+----------------+
| id | agent_type | host | alive | admin_state_up |
+--------------------------------------+--------------------+-----------------------+-------+----------------+
| 4c709a4c-bf0c-4e03-a0f5-2d938fee7ae1 | L3 agent | localhost.localdomain
| :-) | True |
| 960a7806-dc4d-4ab1-99b0-a79dbc31600f | Open vSwitch agent |
localhost.localdomain | :-) | True |
| d9f545e2-4a6c-43f4-8037-b807cbe27fc5 | DHCP agent |
localhost.localdomain | :-) | True |
+--------------------------------------+--------------------+-----------------------+-------+----------------+