Below code was written in test.php to make sure that I can connect to the database server via SSL
<?php
$mysqli = mysqli_init();
if (!$mysqli) {
die("mysqli_init failed");
}
$mysqli -> ssl_set("<<home_dir_user>>/.ssh/client-key.pem", "<<home_dir_user>>/.ssh/client-cert.pem", "<<home_dir_user>>/.ssh/server-ca.pem", NULL, NULL);
if (!$mysqli -> real_connect("<<google_cloud_public_ip>>","<<dbuser>>","<<dbpassword>>","<<dbname>>")) {
die("Connect Error: " . mysqli_connect_error());
}
echo "Connected";
?>
The code looks perfectly OK!
But unfortunately, this did not work as expected.
The first error I received was “<<dbuser>>@localip Access denied”. I was 200% sure that the credentials were correct. I had no idea what to do!
Googling did not give any useful result! [That’s the reason for this post too :)]. There were several thoughts made and tried. But the one that worked was to copy the certificate files to a folder within the project folder. For testing purposes, it was kept in the same folder where the connection was established. So, the code was changed to below
<?php
$mysqli = mysqli_init();
if (!$mysqli) {
die("mysqli_init failed");
}
$mysqli -> ssl_set("client-key.pem", "client-cert.pem", "server-ca.pem", NULL, NULL);
if (!$mysqli -> real_connect("<<google_cloud_public_ip>>","<<dbuser>>","<<dbpassword>>","<<dbname>>")) {
die("Connect Error: " . mysqli_connect_error());
}
echo "Connected";
?>
Now, Access denied problem disappeared & I came across another issue.. “Peer certificate CN=[google-project:instance_id] did not match expected CN=[google-cloud-sql-public-ip]“
Started googling again.. Client certificates generated in Google Cloud will have instance name. However, we cannot use the instance name to connect to MySQL. Therefore, these certificates become useless. We cannot generate certificates with IP address in Google Cloud. I felt like standing at a dead end!!
The only option that many had implemented is Google Cloud Proxy SQL. I started reading Google help to implement the same. Then came another thought and wanted to check it out before I start implementing proxy. The idea was to add google-cloud-instance-name in /etc/hosts file. The entry was like this
xx.xx.xx.xx google-cloud-project:instance-name #Added for Google Cloud SQL
Now.. tried to connect again.. and Tada.. It worked!
I would like to also update about other options errors that I faced, and how I fixed them…
$db = mysqli_init();
mysqli_options($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
At some point, I received the error SSL certificate cannot be verified. Therefore, added this option before ssl_set call. Later I removed this & it made no difference
$mysqli -> real_connect("<<google_cloud_public_ip>>","<<dbuser>>","<<dbpassword>>","<<dbname>>", null, null, MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
Remember, you can use MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT option only when it exists in your PHP configuration. I later, removed this code and it still worked.
Good.. Now it works. But the ultimate goal was to setup SSL connection in CodeIgniter project. The config in database.php was written like below
$db['default'] = array(
'dsn' => '',
'hostname' => '<<google_cloud_ip>>',
'username' => '<<dbuser>>',
'password' => '<<dbpassword>>',
'database' => '<<dbname>>',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => array(
'ssl_key' => '<<folder_within_project_folder>>/client-key.pem',
'ssl_cert' => '<<folder_within_project_folder>>/client-cert.pem',
'ssl_ca' => '<<folder_within_project_folder>>/server-ca.pem',
'ssl_verify' => FALSE,
),
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
Note, although you put it in “encrypt” array, nothing is encrypted in codeigniter. The option MYSQLI_CLIENT_SSL is being set, which takes care of client encryption.
]]>Since Today morning, this issue popped up for any page that I would tried to access. It became a very annoying problem and I had to fix it immediately or just forget about using APEX until the issue is fixed. I already knew that it has to do with permissions. A little google search took me to apexexplorer.com. I know the admin “Md. Kamam Hossain”. He is an early bird APEX Certified expert. So, I was confident about this solution and wanted to try that instead of searching at other urls.
However, the script which he published has some syntax errors. So, I am publishing the working script here.
DECLARE
l_configxml XMLTYPE;
l_value VARCHAR2(5) := 'true'; --(true/false)
BEGIN
l_configxml := DBMS_XDB.cfg_get();
IF l_configxml.existsNode('/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access') = 0 THEN
-- Add missing element.
SELECT insertChildXML
(
l_configxml,
'/xdbconfig/sysconfig/protocolconfig/httpconfig',
'allow-repository-anonymous-access',
XMLType('<allow-repository-anonymous-access xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">' ||
l_value ||
'</allow-repository-anonymous-access>'),
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_configxml
FROM dual;
DBMS_OUTPUT.put_line('Element inserted');
ELSE
-- Update existing element.
SELECT updateXML
(
DBMS_XDB.cfg_get(),
'/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access/text()',
l_value,
'xmlns=”http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_configxml
FROM dual;
DBMS_OUTPUT.put_line('Element updated.');
END IF;
DBMS_XDB.cfg_update(l_configxml);
DBMS_XDB.cfg_refresh;
END;
/
You can download the script here
Apart from executing the script, you need to also unlock XDB & Anonymous account. Use the command below for it.
SQL > ALTER USER ANONYMOUS IDENTIFIED BY anonymous;
SQL> ALTER USER ANONYMOUS ACCOUNT UNLOCK;
SQL> ALTER USER XDB IDENTIFIED BY xdb;
SQL> ALTER USER XDB ACCOUNT UNLOCK;
The error was “Bad Request or Invalid Hostname”. It did not work for address .. meaning, even loopback address did not work. I tried the following
1. Loopback address 127.0.0.1
2. localhost
3. Server IP Address
4. Server Name
“Invalid Hostname” tells me clearly that the hostnames which I am referring to is not found somewhere & therefore it could not resolve it. Many results from google search were centralized on 80 port not visible in TNSListener. For me, it did not sound like the actual problem. Then I had a thought of going to hosts file & check it there. So, I opened hosts file from c:\windows\system32\drivers\etc folder. I added an entry for my server ipaddress with sername as
<<serveripaddress>> <<servername>>
Saved it & to be sure, restarted the server.
After restarting, I tried to browse Oracle Get Help page & it worked. Now moving to my next issue with Oracle installation.. Hope this information was useful to you.
]]>
I downloaded & installed Oracle11g XE 64 bit on my 64bit virtual server. Installation was successful. But Oracle TNSListener windows service is not starting. Through Windows Service (services.msc), I do not get a proper error message. Initially it was “TNSListener is configured as interactive service. The dependent service is not started”. So I started “Interactive Services”. But still, this issue was not solved.
There was also no useful information in Event Log (eventvwr).
After some thinking, I decided to start listener service from command prompt. So, go to command prompt & type “lsnrctl start”. Now here, I could see the proper error message
With “No Message” data, I made a google search & found this link http://pavandba.com/tag/no-message-file-for-productnetwork/. Here, he is referring to Solaris server. But that doesn’t matter. What was more important was the Environment Variables “ORACLE_HOME” & “ORACLE_SID” that he was referring to.
I created them as System Environment Variables.
ORACLE_HOME=C:\oraclexe\app\oracle\product\11.2.0\server
ORACLE_SID=xe
Now, closed command prompt & opened a new instance and tried the same command – “lsnrctl start”. BINGO. IT WORKED
]]>
$('.yellow').on('mouseenter', function () {
$(this).glow({ radius: "20", color: "#D7CD3A" });
})
.on('mouseout', function () {
$(this).glow({ radius: "20", color: "#D7CD3A", disable: true });
});
$('.purple').on('mouseenter', function () {
$(this).glow({ radius: "20", color: "#a354bb" });
})
.on('mouseout', function () {
$(this).glow({ radius: "30", color: "#a354bb", disable: true });
});
$('.green').on('mouseenter', function () {
$(this).glow({ radius: "30", color: "#538b73" });
})
.on('mouseout', function () {
$(this).glow({ radius: "20", color: "#538b73", disable: true });
});
I basically have 2-5 products in each category. Every category products are in a specific color. For ex, yellow, green, blue and purple. I used JQuery Plugin (https://github.com/MisterDr/JQuery-Glow) to implement this glow effect for my different products in my website. This worked like a charm in Chrome. However, in Firefox there was an issue. The glow color was permanently set to the first product which I would hover. For ex, if I do, mouseenter event for a yellow product & then do mouseenter for a green product, the glow color for green product would be yellow.
Though, I was setting “disable: true” in mouseout event, it was not considered. I checked out several options and it did not work out. Thanks to Keshav Pandit, who took some time to look into Glow JQuery Plugin api code & he told me that the code refers to “id” and not “class” attribute value to identify an element. I was just wondering, if it is so, how it is working in Chrome & also in Firefox, glow in & out was also working. Just that the specified color was not used.
Anyway, I took his comment, added “id” attribute to all products and also changed the above code to reference to “id” rather than “class”. Viola!!! It worked. Though I have duplicate content now, the expected feature is there & I am happy..
If you look at plugin example, they have also used only “id” attribute. I didn’t think about trying it that way at all, until Keshav suggested me to check it. By this time, I was out-of-energy and couldn’t think. I just did what he said & again Thanks to him.. it worked.. Now the code looks like below
$('#yellow1').on('mouseenter',function(){
$(this).glow({ radius:"20", color:"#D7CD3A"});}).on('mouseout',function(){//$(this).glow({ radius: "20", color: "#D7CD3A", disable: true });
$(this).glow({ disable:true});});
]]>
//Scrolling Event
if (document.addEventListener) {
// IE9, Chrome, Safari, Opera
document.addEventListener("mousewheel", ScrollBegin, false);
// Firefox
document.addEventListener("DOMMouseScroll", ScrollBegin, false);
}
// IE 6/7/8
else document.attachEvent("onmousewheel", ScrollBegin);
ScrollBegin function was like below
function ScrollBegin(e) {
if (document.removeEventListener) {
// IE9, Chrome, Safari, Opera
document.removeEventListener("mousewheel", ScrollBegin, false);
// Firefox
document.removeEventListener("DOMMouseScroll", ScrollBegin, false);
}
// IE 6/7/8
else document.detachEvent("onmousewheel", ScrollBegin);
// cross-browser wheel delta
var e = window.event || e; // old IE support
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
//if the delta value is negative, the user is scrolling down
if (delta < 0) {
timer = setTimeout(function () {
MoveScreen('down');
clearTimeout(timer);
if (document.addEventListener) {
// IE9, Chrome, Safari, Opera
document.addEventListener("mousewheel", ScrollBegin, false);
// Firefox
document.addEventListener("DOMMouseScroll", ScrollBegin, false);
}
// IE 6/7/8
else document.attachEvent("onmousewheel", ScrollBegin);
}, 800);
}
else {
timer = setTimeout(function () {
MoveScreen('up');
clearTimeout(timer);
if (document.addEventListener) {
// IE9, Chrome, Safari, Opera
document.addEventListener("mousewheel", ScrollBegin, false);
// Firefox
document.addEventListener("DOMMouseScroll", ScrollBegin, false);
}
// IE 6/7/8
else document.attachEvent("onmousewheel", ScrollBegin);
}, 800);
}
}
On a windows PC with scrollable mouse, the function was working perfect. But on a Mac with Apple MagicMouse it was too fast. So, then I started thinking about controlling mouse speed. One option was to retrieve mousespeed in eventhandler and reduce it. After some research and with help from stackoverflow.com, I came across underscore.js jQuery Plugin. This plugin is cool.
Now, I changed my function to be like below
<script src="http://underscorejs.org/underscore-min.js"></script>
$(document).on("mousewheel", _.debounce(MouseWheelHandler, 150, false));
function MouseWheelHandler(event, delta) {
if(delta<0)
{
direction='down';
}
else
{
direction='up';
}
MoveScreen(direction);
};
The second parameter in _.debounce function is time interval in milliseconds to wait after event has ended. The default value is 1000ms. But this was too slow for me. So, I set it to 150ms.
The most important point to note is that it has the same behavior across browsers and mouse devices. Super cool plugin.
]]>
The first problem was that any URL that you click will always show all the posts. For ex, Post URL, Specific Page URL, Specific Category, Specific Tag – everything was showing me the same response with all the recent posts. In the beginning, I never thought about permalinks. I understood that there was some redirection happening and since it failed, the default response with recent posts was displayed. I could not track the redirects using HTTP Analyzer. So this is happening within WordPress. This is when I opened the ERROR Log File & found the below log.
[Tue Jun 10 09:56:09 2014] [error] [client 130.75.69.111] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/category/mediathek/gallerie-uk-videos/
[Tue Jun 10 09:56:09 2014] [error] [client 130.75.69.111] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/category/mediathek/gallerie-uk-videos/
[Tue Jun 10 10:01:18 2014] [error] [client 66.249.67.47] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:01:18 2014] [error] [client 66.249.67.47] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:01:51 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:01:51 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:01:51 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:01:51 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Jun 10 10:02:37 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:02:37 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:02:42 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:02:42 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:05 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:05 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:12 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:12 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:15 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
[Tue Jun 10 10:03:15 2014] [error] [client 93.220.45.28] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.hechtundbarsch.de/
I started googling & also checked in WordPress support. Everyone were discussing about .htaccess file. I did not see any strange settings in .htaccess file. So was sure that there is no problem with it. Now the idea clicked, I went into wp-admin & permalinks section. Here I figured out that the permalink structure couldn’t be saved in .htaccess file since the file has lost write permission. Cool.. Found the root cause.
Solution
Edit permission settings of .htaccess file & give write permission to it. Go back to permalink structure & refresh it. Now you can see everything is saved and it works fine.
Related Links:
http://wordpress.org/support/topic/all-url-is-showing-all-posts
http://stackoverflow.com/questions/24130146/all-url-is-showing-all-posts
]]>
I added this code in my .phtml file
[PHP CODE - CHECK IF $_COOKIE['lang_code'] IS SET]
[SCRIPT CODE START]
$(document).ready(function(){
oTable = $('#example, #subscribed_docs_table, #changed_subscribed_docs_table').dataTable({
"oLanguage": {
"sUrl": "baseUrl();?>/media/language/.txt"
},
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
});
[SCRIPT END]
[PHP CONDN BLOCK END]
It was simply loading for unlimited time. I couldn’t figure the issue and did not do what to do. I moved this code to the bottom after