On my eZDB I’ve found two different scenarios of corrupt objects, they must have become corrupt when not having transaction enabled, and eZp or the user breaks out of a content object creation, og content object edit:
This script report, and does the required job:
<?php
// Script for finding and handling content_objects that are not completely created
// That may occur under some circustances when using a database without transations enabled
//
//
// 2007.09.20, jonny.bergkvist@hit.no
// $doUpdate, true or false. Set to false for at dry test-run
$doUpdate = true;
include_once( 'kernel/common/template.php' );
include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/ezscript.php' );
include_once( 'lib/ezdb/classes/ezdb.php' );
$cli =& eZCLI::instance();
$script =& eZScript::instance();
$script->initialize();
$db =& eZDB::instance();
set_time_limit( 0 );
$arrayResult1 = $db->arrayQuery( "SELECT id, current_version FROM ezcontentobject" );
echo "First checking for content objects that has no contentobject_attributes at all...n";
$i = 0;
foreach( $arrayResult1 as $item) {
//check if object has no attributes of any version stored
$hasAttribute = $db->arrayQuery( "SELECT contentobject_id FROM ezcontentobject_attribute WHERE contentobject_id = " . $item['id'] );
if ( empty( $hasAttribute ) ) {
echo "Corrupt object: " . $item['id'] . ". ";
if ( $doUpdate ) {
echo "Deleting corrupt object with no attributes...n";
$db->query( "DELETE FROM ezcontentobject WHERE ezcontentobject.id = " . $item['id'] );
}
$i++;
}
}
echo "Total corrupt objects with no attributes: " . $i . "nn";
$arrayResult2 = $db->arrayQuery( "SELECT id, current_version FROM ezcontentobject" );
echo "Then checking for content objects that has contentobject_attributes, but not of the current_version...n";
$i = 0;
foreach( $arrayResult2 as $item) {
//check if current_version has content attributes
$hasAttribute = $db->arrayQuery( "SELECT contentobject_id FROM ezcontentobject_attribute WHERE contentobject_id = " . $item['id'] . " AND version = " . $item['current_version'] );
if ( empty( $hasAttribute ) ) {
echo "Corrupt object: " . $item['id'] . ", current_version: " . $item['current_version'] . ". ";
if ( $doUpdate ) {
$previousCurrentVersion = $item['current_version'] - 1;
echo "Setting back to version: " . $previousCurrentVersion . "n";
$db->query( "UPDATE ezcontentobject SET current_version = " . $previousCurrentVersion . " WHERE id = " . $item['id'] );
}
$i++;
}
}
echo "Total objects with wrong current_version: " . $i . "n";
$script->shutdown();
?>
Source: http://ez.no/developer/forum/general/problem_corrupt_contentobjects
Tags: Apache, eZ Publish, Flau Bris, PHP
Posted by Hans-Henry Jakobsen
With the introduction of the Apache2 packages in Debian it is much simpler to create and use a secure SSL protected webserver than in the old days with Apache 1.3, here we’ll show how it is done. If you have Apache 2.x installed already then you’re good to go as you don’t need anything extra installed.
If you haven’t got it installed then you can do so easily:
earth:~# apt-get install apache2 Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: apache2-common apache2-mpm-worker apache2-utils openssl ssl-cert Suggested packages: apache2-doc ca-certificates The following NEW packages will be installed: apache2 apache2-common apache2-mpm-worker apache2-utils openssl ssl-cert 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 2040kB of archives. After unpacking 6218kB of additional disk space will be used. Do you want to continue? [Y/n]
Once the server is installed you need to do three things to get a working SSL setup:
Generating A Certificate
Generating a certificate from scratch will give you something which will be used to protect the traffic exchanged between clients and your server, however it will be unsigned by a trusted certificate authority so it will generate warnings.
Importing a paid and “trusted” certificate will avoid this problem, but that is beyond the scope of this simple introduction.
Generating an SSL certificate for Apache2 may be accomplished using the apache2-ssl-certificate script. This will ask you questions interactively then generate the certificate file appropriately.
Here’s a sample session:
earth:~# apache2-ssl-certificate creating selfsigned certificate replace it with one signed by a certification authority (CA) enter your ServerName at the Common Name prompt If you want your certificate to expire after x days call this programm with -days x Generating a 1024 bit RSA private key ............++++++ ..........................++++++ writing new private key to '/etc/apache2/ssl/apache.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [GB]: State or Province Name (full name) [Some-State]:Scotland Locality Name (eg, city) []:Edinburgh Organization Name (eg, company; recommended) []:Steve Kemp Organizational Unit Name (eg, section) []: server name (eg. ssl.domain.tld; required!!!) []:earth Email Address []: earth-admin@steve.org.uk
Enabling SSL Support
To use the SSL facilities of Apache2 you must enable the module mod_ssl, this can be achieved using the helper tool a2enmod (We’ve previously discussed the Apache2 helper scripts.)
As root run:
earth:~# a2enmod ssl Module ssl installed; run /etc/init.d/apache2 force-reload to enable.
Once this is done you’ll have Apache setup to accept SSL connections, but the server will still only be listening for incoming HTTP requests on port 80 – and not SSL connections on port 443. To fix this you must add a line to the file /etc/apache2/ports.conf:
Listen 443
With these two steps out of the way you now have an Apache setup which will listen for and accept SSL connections. The next step is to modify your virtualhosts to use it.
Configuring your SSL Hosts
With a certificate setup, and the server updated to load and listen for incoming SSL connections you’re almost finished. The final step is to ensure that your virtual hosts, or main host, will accept SSL options.
I use virtual hosts upon my machine and this just means adding a couple of options to each one I wish to use SSL:
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem
For reference here is a complete example which should be easy to modify/understand:
NameVirtualHost *:443
NameVirtualHost *:80
<VirtualHost *:80>
ServerName earth.my.flat
DocumentRoot /var/www/
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName earth.my.flat
DocumentRoot /var/www/
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
</VirtualHost>
Tags: a2enmod, Apache, apt-get, Debian, SSL, virtual domains
Posted by Hans-Henry Jakobsen
You can stop others from hotlinking your site’s files by placing a file called .htaccess in your Apache site root (main) directory. The period before the name means the file is hidden, so you may want to edit your file as htaccess.txt, upload it to your server, then rename the txt file to .htaccess in your directory or Apache config file httpd.conf
Contact your web host on how to access your directories and configure your .htaccess file.
(more…)
Posted by Hans-Henry Jakobsen
Using mod_rewrite to redirect all pages to one central PHP page’.
On my site, I decided to use an all-index structure, as that’s how I prefer to do things – it means that the scripting language is more hidden from the end user than if you linked to pages such as “something-bizarre.jsp” and means that if the scripting language used to create the pages was changed the names of the pages wouldn’t have to be. (more…)
Tags: Apache
Posted by Hans-Henry Jakobsen
mod_rewrite is used for rewriting a URL at the server level, giving the user output for that final page. So, for example, a user may ask for http://www.somesite.com/widgets/blue/, but will really be given http://www.somesite.com/widgets.php?colour=blue by the server.
(more…)
Tags: Apache
Posted by Hans-Henry Jakobsen