How can i convert IPv6 to long like we do for IPv4 using ip2long? I have IP database for a certain country. I have paid version of Ip2Lcoation and i got all the IPv6 ranges and IPv4. In my web app I am converting all the IPs to long using ip2long function. It works perfectly with IPv4 but with IPv6 it fails? i searched and found few functions which didn't work. My Code is as follows if (!empty($_SERVER['HTTP_CLIENT_IP'])) {         $ip = $_SERVER['HTTP_CLIENT_IP'];     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];     } else {         $ip = $_SERVER['REMOTE_ADDR'];     }               $long = ip2long($ip);// fails at IPv6     //mysql query to check the ip ranges     $cri= new CDbCriteria();     $cri-&gt;condition=&quot;$long&gt;=ip_range_start AND $long&lt;=ip_range_end&quot;;     if (UsaIps::model()-&gt;exists($cri))     {        return true;     }     else     {         return false;     }  How can i achieve this ?? Any guide any help??
Working with IPv6 Addresses in PHP After searching around somewhat thoroughly, I noticed a slight lack of functions in PHP for handling . For my own personal satisfaction I created a few functions to help the transition.  The IPv6ToLong() function is a temporary solution to that brought up here: . It will split the IP in to two integers and return them in an array.  /**  * Convert an IPv4 address to IPv6  *  * @param string IP Address in dot notation (192.168.1.100)  * @return string IPv6 formatted address or false if invalid input  */ function IPv4To6($Ip) {     static $Mask = '::ffff:'; // This tells IPv6 it has an IPv4 address     $IPv6 = (strpos($Ip, '::') === 0);     $IPv4 = (strpos($Ip, '.') &gt; 0);      if (!$IPv4 &amp;&amp; !$IPv6) return false;     if ($IPv6 &amp;&amp; $IPv4) $Ip = substr($Ip, strrpos($Ip, ':')+1); // Strip IPv4 Compatibility notation     elseif (!$IPv4) return $Ip; // Seems to be IPv6 already?     $Ip = array_pad(explode('.', $Ip), 4, 0);     if (count($Ip) &gt; 4) return false;     for ($i = 0; $i &lt; 4; $i++) if ($Ip[$i] &gt; 255) return false;      $Part7 = base_convert(($Ip[0] * 256) + $Ip[1], 10, 16);     $Part8 = base_convert(($Ip[2] * 256) + $Ip[3], 10, 16);     return $Mask.$Part7.':'.$Part8; }  /**  * Replace '::' with appropriate number of ':0'  */ function ExpandIPv6Notation($Ip) {     if (strpos($Ip, '::') !== false)         $Ip = str_replace('::', str_repeat(':0', 8 - substr_count($Ip, ':')).':', $Ip);     if (strpos($Ip, ':') === 0) $Ip = '0'.$Ip;     return $Ip; }  /**  * Convert IPv6 address to an integer  *  * Optionally split in to two parts.  *  * @see https://stackoverflow.com/questions/420680/  */ function IPv6ToLong($Ip, $DatabaseParts= 2) {     $Ip = ExpandIPv6Notation($Ip);     $Parts = explode(':', $Ip);     $Ip = array('', '');     for ($i = 0; $i &lt; 4; $i++) $Ip[0] .= str_pad(base_convert($Parts[$i], 16, 2), 16, 0, STR_PAD_LEFT);     for ($i = 4; $i &lt; 8; $i++) $Ip[1] .= str_pad(base_convert($Parts[$i], 16, 2), 16, 0, STR_PAD_LEFT);      if ($DatabaseParts == 2)             return array(base_convert($Ip[0], 2, 10), base_convert($Ip[1], 2, 10));     else    return base_convert($Ip[0], 2, 10) + base_convert($Ip[1], 2, 10); }   For these functions I typically implement them by calling this function first:  /**  * Attempt to find the client's IP Address  *  * @param bool Should the IP be converted using ip2long?  * @return string|long The IP Address  */ function GetRealRemoteIp($ForDatabase= false, $DatabaseParts= 2) {     $Ip = '0.0.0.0';     if (isset($_SERVER['HTTP_CLIENT_IP']) &amp;&amp; $_SERVER['HTTP_CLIENT_IP'] != '')         $Ip = $_SERVER['HTTP_CLIENT_IP'];     elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) &amp;&amp; $_SERVER['HTTP_X_FORWARDED_FOR'] != '')         $Ip = $_SERVER['HTTP_X_FORWARDED_FOR'];     elseif (isset($_SERVER['REMOTE_ADDR']) &amp;&amp; $_SERVER['REMOTE_ADDR'] != '')         $Ip = $_SERVER['REMOTE_ADDR'];     if (($CommaPos = strpos($Ip, ',')) &gt; 0)         $Ip = substr($Ip, 0, ($CommaPos - 1));      $Ip = IPv4To6($Ip);     return ($ForDatabase ? IPv6ToLong($Ip, $DatabaseParts) : $Ip); }   Someone please tell me if I'm reinventing the wheel here or I've done something wrong.  This implementation converts IPv4 to IPv6. Any IPv6 address it doesn't touch.
If you are hurrying to reply, System → Administration → StartUp Disk Creator -- no, that's not what I'm talking about.   I want to try Ubuntu 11.04's Unity without touching my existing Ubuntu install.  To do this, I need to install the nVidia drivers first (sigh).  To do this, I need changes to persist a reboot.  To do this, I need to really install Ubuntu on a USB key.  How do you do that?    What I tried   I tried to make a USB key from , then boot from it, then choose "Install Ubuntu." The installer refused to install to the installation media itself. I tried, from my installed copy of Ubuntu:  sudo kvm /dev/sdb --cdrom .cache/testdrive/iso/ubuntu_natty-desktop-i386.iso   ...but the installer didn't detect the disk properly. Visual design changes to the review queues What is the longest word you can come up with that the letters are all in alphabetical order? It's Friday again, how about some fun to get us into the weekend?  What is the longest word you can come up with for which all the letters in that word are in alphabetical order?   Rules:   English words only    Can't be a name of a place, person or other proper noun.   if it contains the same letter twice in a row, that does not disqualify it.   No fair looking it up on Google!   Update: One more rule to help you guys out.   The word can be in either ascending or descending alphabetical order. Using CLI, how do I change the user's profile picture? A similar task for changing the desktop background, can be achieved using the following script:   FILE="/backgrounds/background.png" gsettings set org.gnome.desktop.background picture-uri "$FILE"   How would I achieve the same result, but with the user's avatar/profile picture? Possible Duplicate:           What book would you recommend for an undergraduate wanting to learn the basics of topology? I've come across several books that claim to give an introduction to the subject, but I wasn't sure which one(s) to pick.  Here are some of the books I came across:   Introduction to Topology - Bert Mendelson Basic Topology - M.A. Armstrong First Concepts of Topology - William G. Chinn Topology Without Tears - Sidney A. Morris Topology - James Munkres   They don't go over the exact same topics, some are more in-depth than others, some seem to target slightly different audiences etc. What would be right for me (not necessarily from that list)? To give some more background, I want to learn topology because I feel it will be somewhat helpful in the field of Computer Vision. Do 'learn by heart' & 'learn by rote' mean the same? Here in India, both the phrases learning by heart and learning by rote are taken to have the same meaning, i.e., blind memorisation without true understanding.    However, some sources say that to learn something by heart implies that one knows something so well that it has been thoroughly internalised and imbibed.    So is it wrong to conflate the two? Forgot which email I used, can't login I forgot what email I used for my other ploxtic id: how do you find out what my email was?   The account is user:2078229. How do I dynamically invoke a class method in PHP? How can I dynamically invoke a class method in PHP? The class method is not static. It appears that   call_user_func(...)   only works with static functions?  Thanks. Drush PHP syntax error when running I am following the instructions to install Drush that are listed on this page:   I seem to be getting a syntax error within the code:  [user@localhost ~]$ wget https://github.com/drush-ops/drush/releases/download/8.0.0-rc4/drush.phar --2015-11-16 16:23:02--  https://github.com/drush-ops/drush/releases/download/8.0.0-rc4/drush.phar Resolving github.com (github.com)... 192.30.252.131 Connecting to github.com (github.com)|192.30.252.131|:443... connected. HTTP request sent, awaiting response... 302 Found 2015-11-16 16:23:05 (1.47 MB/s) - drush.phar saved [3496991/3496991]  [user@localhost ~]$ php drush.phar core-status  Parse error: syntax error, unexpected '[' in phar:///home/user/drush.phar/includes/output.inc on line 188   I am not seeing this error on Google. Any idea how to fix it? Why is $(0, 0)$ not a minimum of $f(x, y) = (y-3x^2)(y-x^2)$? There is an exercise in my lists about those functions: $$f(x, y) = (y-3x^2)(y-x^2) = 3 x^4-4 x^2 y+y^2$$  $$g(t) = f(vt) = f(at, bt); a, b \in \mathbf{R}$$  It asks me to prove that $t = 0$ is a local minimum of $g$ for all $a, b \in \mathbf{R}$  I did it easily: $$g(t) = 3 a^4 t^4-4 a^2 t^2 b t+b^2 t^2$$ $$g&#39;(t) = 2 b^2 t-12 a^2 b t^2+12 a^4 t^3$$ $$g&#39;&#39;(t) = 2 b^2-24 a^2 b t+36 a^4 t^2$$  It is a critical point: $$g&#39;(0) = 0; \forall a, b$$  Its increasing for all a, b: $$g&#39;&#39;(0) = 2b^2 &gt; 0; \forall b \ne 0$$ and $$b = 0 \implies g(t) = 3 a^4 t^4$$ which has only one minimum, at $0$, and no maximum  However, it also asks me to prove that $(0, 0)$ is not a local minimum of $f$.  How can this be possible? I mean, if $(0, 0)$ is a minimum over every straight line that passes through it, then, in this point, $f$ should be increasing in all directions, no? Does this exist: software for noise cancellation Is this mold? Black? White? Linked and Related sections contain duplicate links to questions Homotopy equivalence of universal cover As part of am exam question (Q21F ), I'm trying to prove that if $X$ and $Y$ are path-connected, locally path-connected spaces with universal covers $\widetilde{X}$ and $\widetilde{Y}$, respectively, then if $X \simeq Y$ then $\widetilde{X} \simeq \widetilde{Y}$.  My attempt might be correct, but it seems too complicated and amongst the jumble I may have made some incorrect assumptions. So what I'm looking for is (a) verification or correction; and (b) ideas as to how I could simplify my argument.    My argument:  Let $p:\widetilde{X} \to X$ and $q:\widetilde{Y} \to Y$ be the covering maps, and let $X \overset{f}{\underset{g}{\leftrightarrows}} Y$ be a homotopy equivalence.  Fix a point $\widetilde{x} \in \widetilde{X}$, let $x=p(x) \in X$ and $y=f(x) \in Y$, and fix $\widetilde{y} \in q^{-1}(\{y\}) \subseteq \widetilde{Y}$. Also let $x' = g(y) \in X$ and fix $\widetilde{x'} \in p^{-1}(\{x'\}) \subseteq \widetilde{X}$.  Define a map $\widetilde{f} : \widetilde{X} \to \widetilde{Y}$ as follows. For $\widetilde{z} \in \widetilde{X}$ let $\widetilde{u}:[0,1] \to \widetilde{X}$ be a path from $\widetilde{x}$ to $\widetilde{z}$. Let $z=p(z)$ so that $u=p\widetilde{u}$ is a path in $X$ from $x$ to $z$. Let $v=fu$, so that $v$ is a path in $Y$ from $y$ to $f(z)$. Lift $v$ to a path $\widetilde{v}$ in $\widetilde{Y}$ with $\widetilde{v}(0) = \widetilde{y}$. Define $\widetilde{f}(\widetilde{z}) = \widetilde{v}(1)$.  Notice that $q\widetilde{v}=v$ so that $q\widetilde{f} = fp$.  Define $\widetilde{g}:Y \to X$ analogously: For $\widetilde{z} \in \widetilde{Y}$ let $\widetilde{a}:[0,1] \to \widetilde{Y}$ be a path from $\widetilde{y}$ to $\widetilde{z}$. Let $z=q(z)$ so that $a=q\widetilde{a}$ is a path in $Y$ from $y$ to $z$. Let $b=fa$, so that $b$ is a path in $X$ from $x'$ to $g(z)$. Lift $b$ to a path $\widetilde{b}$ in $\widetilde{X}$ with $\widetilde{b}(0) = \widetilde{x'}$. Define $\widetilde{g}(\widetilde{z}) = \widetilde{b}(1)$.  Likewise, notice that $p\widetilde{g}=gq$.  Claim: $\widetilde{X} \overset{\widetilde{f}}{\underset{\widetilde{g}}{\leftrightarrows}} \widetilde{Y}$ is a homotopy equivalence.  We have $p\widetilde{g}\widetilde{f} = gq\widetilde{f}=gfp \simeq p$ and $q\widetilde{f}\widetilde{g} = fp\widetilde{g} = fgq \simeq q$.  This shows that $\widetilde{g}\widetilde{f}$ and $\widetilde{f}\widetilde{g}$ are covering translations (deck transformations) and are therefore homotopic to the respective identity maps. So we have a homotopy equivalence.    Any comments would be appreciated. When editing a profile’s “About me” section, or a tag wiki, and hitting CtrlG, or clicking the “Image” button from the formatting bar to insert an image, the Imgur upload modal dialog will appear. The same modal will also appear when uploading a profile picture. This is different from questions and answers where an uploader overlay bar (technically referred to as inline-dialog) appears. This modal dialog has an × button for closing, but it does nothing when clicked. I also can’t try tabbing to it and hit Enter, because it’s a regular &lt;div&gt; with no tabindex attribute, so it’s not tabbable and not an interactive element. (After manually inserting a tabindex and pressing Enter, it also did nothing, of course.)  There are no errors produced in the console of any browser. It doesn’t even seem to have any event listener bound to it. Pressing the Esc key or clicking outside of the modal dialog will dismiss the dialog, but the × button is currently useless. An obvious possible  would be to unify all Imgur upload dialogs to the way they appear on questions and answers, as an inline-dialog. But for the profile picture uploader, this dialog doesn’t have an obvious alternative, so in this instance, it’s necessary to redesign the close button so that it acts as a normal button (interactive element, tabbable) and closes the modal popup.  Related   and  — showing this modal in action; closing it used to work.  — for an older dialog design. I can't install Rainlendar 2 on my Ubuntu 18.04, I found this solution for 16.04 (), followed it, seems to work, but after install, there's no Rainlendar in my Show Apps, so I'm not sure what went wrong. When I issued sudo dpkg -i rainlendar2-pro_2.12.2.b138-1_amd64.deb, I got this:   Selecting previously unselected package rainlendar2-pro. (Reading database ... 190677 files and directories currently installed.) Preparing to unpack rainlendar2-pro_2.12.2.b138-1_amd64.deb ... Unpacking rainlendar2-pro (2.12.2.b138-1) ... dpkg: dependency problems prevent configuration of rainlendar2-pro:  rainlendar2-pro depends on libpng12-0; however:   Package libpng12-0 is not installed.  rainlendar2-pro depends on tofrodos; however:   Package tofrodos is not installed.  rainlendar2-pro depends on libjpeg62; however:   Package libjpeg62 is not installed.  rainlendar2-pro depends on libwebkitgtk-1.0-0; however:   Package libwebkitgtk-1.0-0 is not installed.  dpkg: error processing package rainlendar2-pro (--install):  dependency problems - leaving unconfigured Processing triggers for gnome-menus (3.13.3-11ubuntu1) ... Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.1) ... Processing triggers for mime-support (3.60ubuntu1) ... Errors were encountered while processing:  rainlendar2-pro   I got this after issuing this command in terminal sudo apt-get -f install  Reading package lists... Done Building dependency tree        Reading state information... Done Correcting dependencies... Done The following packages will be REMOVED:   rainlendar2-pro 0 upgraded, 0 newly installed, 1 to remove and 35 not upgraded. 1 not fully installed or removed. After this operation, 20.5 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 191316 files and directories currently installed.) Removing rainlendar2-pro (2.12.2.b138-1) ... Processing triggers for mime-support (3.60ubuntu1) ... Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.1) ... Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...   What I'm doing wrong? After the last command it just removed Rainlendar and not installing dependencies as stated in the original post? TIA Properties vs Methods Quick question: When do you decide to use properties (in C#) and when do you decide to use methods?  We are busy having this debate and have found some areas where it is debatable whether we should use a property or a method. One example is this:  public void SetLabel(string text) {     Label.Text = text; }   In the example, Label is a control on a ASPX page. Is there a principle that can govern the decision (in this case) whether to make this a method or a property.  I'll accept the answer that is most general and comprehensive, but that also touches on the example that I have given. What tense should I use after the conjunction 'lest'? Must it always be an infinitive? Limit of $s_n = \int\limits_0^1 \frac{nx^{n-1}}{1+x} dx$ as $n \to \infty$ Let $s_n$ be a sequence defined as given below for $n \geq 1$. Then find out $\lim\limits_{n \to \infty} s_n$.   \begin{align}   s_n = \int\limits_0^1 \frac{nx^{n-1}}{1+x} dx  \end{align}  I have written a solution of my own, but I would like to know it is completely correct, and also I would like if people post more alternative solutions. How do I print bold text in Python?