Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - MultiformeIngegno
16
Off-topic / Zend OPCache & APC
« on March 29th, 2013, 01:05 AM »
Today PHP 5.5 beta 2 has been released. In beta 1 Zend OPCache was added although disabled by default (I think for the beta period only). It looks firmly like this will be the replacement for APC going forward as it is included in the core, and will have to be maintained for each new release.

Any thought? :)
17
Off-topic / Unknown Action
« on March 27th, 2013, 01:31 PM »
I always wondered: what's doing the user whom in Users Online is reported as "Unknown Action"?
18
Off-topic / Strange behavior of jap chars on title="" tooltip
« on February 15th, 2013, 04:31 PM »
On my site I have a script that pulls the entries of an RSS feed and displays them (this is a portion):
Code: [Select]
            <li>
                <a href="<?php echo $item->get_permalink(); ?>" title="<?php echo esc_html$item->get_title() ); ?>" rel="external"><?php echo esc_html$item->get_title() ); ?></a>
            </li>

It works like a charm, the only oddity I noticed is when I deal with "special" chars. They're displayed just fine in the page, but the title="" tooltip replaces them with □□□□ (not encoded properly):



The problem is that the code that outputs text and title="" is the same. And the page is UTF-8. AND (last oddity :P) browsing the source code I can see the chars properly!


Any clue?
I'm writing this just for curiosity.. I don't care much about this "glitch"! :D
19
Off-topic / jQuery: .on() instead of .live()
« on February 3rd, 2013, 03:30 PM »
This is my .live() script I need to update because it's deprecated:
http://jsfiddle.net/wtz5f/1/

This is my tentative to use .on() for the same behavior (but nothing happens..):
http://jsfiddle.net/PjQ3N/1/

What's wrong with the latter example? :)
20
Off-topic / Should I add a cache to this script?
« on February 2nd, 2013, 01:49 PM »
I have this script that authenticates with Twitter API 1.1 and retrieves the last 6 tweets from my timeline.

Code: [Select]
<?php
function buildBaseString($baseURI$method$params)
{
    
$r = array();
    
ksort($params);
    foreach(
$params as $key=>$value){
        
$r[] = "$key=" rawurlencode($value);
    }

    return 
$method."&" rawurlencode($baseURI) . '&' rawurlencode(implode('&'$r)); //return complete base string
}

function 
buildAuthorizationHeader($oauth)
{
    
$r 'Authorization: OAuth ';
    
$values = array();
    foreach(
$oauth as $key=>$value)
        
$values[] = "$key=\"" rawurlencode($value) . "\"";

    
$r .= implode(', '$values);
    return 
$r;
}

$url "https://api.twitter.com/1.1/statuses/user_timeline.json";

$oauth_access_token "INSERIRE TOKEN";
$oauth_access_token_secret "INSERIRE TOKEN";
$consumer_key "INSERIRE KEY";
$consumer_secret "INSERIRE KEY";

$oauth = array( 'oauth_consumer_key' => $consumer_key,
    
'oauth_nonce' => time(),
    
'oauth_signature_method' => 'HMAC-SHA1',
    
'oauth_token' => $oauth_access_token,
    
'oauth_timestamp' => time(),
    
'count' => 6,
    
'oauth_version' => '1.0');

$base_info buildBaseString($url'GET'$oauth);
$composite_key rawurlencode($consumer_secret) . '&' rawurlencode($oauth_access_token_secret);
$oauth_signature base64_encode(hash_hmac('sha1'$base_info$composite_keytrue));
$oauth['oauth_signature'] = $oauth_signature;


$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
    
CURLOPT_HEADER => false,
    
CURLOPT_URL => $url '?count=6',
    
CURLOPT_RETURNTRANSFER => true,
    
CURLOPT_SSL_VERIFYPEER => false);

$feed curl_init();
curl_setopt_array($feed$options);
$json curl_exec($feed);
curl_close($feed);

$twitter_data json_decode($json);

    echo 
"<ul style='color:#6E6E6E'>";
    foreach (
$twitter_data as $tweet)
    {
        if (!empty(
$tweet)) {
            
$text $tweet->text;
$text_in_tooltip str_replace('"'''$text); // replace " to avoid conflicts with title="" opening tags
            
$id $tweet->id;
            
$time strftime('%d %B'strtotime($tweet->created_at));
            
$username $tweet->user->name;
        }
        echo 
'<li><span title="'; echo $text_in_tooltip; echo '">'; echo $text "</span><br>
<a href=\"http://twitter.com/"
; echo $username ; echo '/status/'; echo $id ; echo '"><small>'; echo $time; echo ' </small></a> - 
<a href="http://twitter.com/intent/tweet?in_reply_to='
; echo $id; echo '"><small>rispondi</small></a> - 
<a href="http://twitter.com/intent/retweet?tweet_id='
; echo $id; echo '"><small>retweet</small></a> - 
<a href="http://twitter.com/intent/favorite?tweet_id='
; echo $id; echo '"><small>preferito</small></a></li>';
    }

    echo 
'</ul>';
    
?>


Should I add a cache mechanism? That maybe stores in a file the JSON fetched and updates it only if it's older than X minutes. Without caching does this impact much on server load?
21
Need a little help with this jQuery portfolio-style gallery.
As you can see there is a main image with a related caption and other small images below. If you click one of them the main image/caption changes to display the one you selected. If you notice when you hover the pointer on any of the images below the big one you get a link like test.php/#image3 or test.php/#image6.

I'm looking for a way to have that if you visit test.php/#image3 (directly, not through the onClick event) you have the #image3 as main image (so without having to click on it). The same for test.php/#image4 / #image5, etc.

The gallery uses the Galleriffic plugin for jQuery...

This is a small piece of the code:
Code: [Select]
// Global function that looks up an image by its hash and displays the image.
// Returns false when an image is not found for the specified hash.
// @param {String} hash This is the unique hash value assigned to an image.
gotoImage: function(hash) {
var imageData = $.galleriffic.getImage(hash);
if (!imageData)
return false;

var gallery = imageData.gallery;
gallery.gotoImage(imageData);

return true;
},

I think I need a script that adds onLoad the same even that happens onClick, using window.location.hash; to match the part after the # with the image.
23
Off-topic / Help with PHP syntax
« on November 19th, 2012, 10:30 PM »
So, this is a link I have on a page (page1.php):
Code: [Select]
<a href="page2.php?t=<?php echo md5($_SERVER['REMOTE_ADDR']); ?>">Click here</a>

On page2.php I have something like this:
Code: [Select]
<?php
if (isset($_GET['t']) && $_GET['t'] == md5($_SERVER['REMOTE_ADDR'])) {
echo 
'You\'ve gone through the hoops';
}
else echo 
'Please go back to page1';
?>


It works perfectly (displays "You've gone through the hoops" only if users passes through page1). The problem is that instead of that line of text I should display a complex page (mixed php and html): http://pastebin.com/XQdw64hB
How can I insert that page within that if (isset($_GET['t']) && $_GET['t'] ..?

P.S.: don't blame me for $_GET being spoof-able.. informations in page2 aren't state secrets.. no one would be interested in spoofing it! :D
24
The Pub / Infinite Scroll
« on November 17th, 2012, 02:03 AM »
Idea for a plugin (or a theme...): infinite scroll for posts with a fixed small footer (if needed).

Something like http://jetpack.me/support/infinite-scroll/

Example: http://2010dev.wordpress.com/
25
The Pub / Troubles during installation
« on November 6th, 2012, 06:50 PM »
Alpha 2. I uploaded everything in a /forum/ dir owned by www-data (that runs PHP) and chmodded 777. Moved /forum/root files to /forum
When I go to /forum/install.php I get the error:
This installer was unable to find the installer's language file or files. They should be found under:
/forum/Themes/default/languages

They're there. I can even access via browser the file (for example) /forum/Themes/default/languages/Admin.french.php (of course a white page, but no 404 error).
PHP logs are blank

Setup:
PHP 5.4.8
nginx: 1.3.8
APC: 3.1.13
mysql: 5.5.28
26
Off-topic / Meaning of usernames
« on October 11th, 2012, 07:26 PM »
I'm interested in knowing what your usernames mean and where they come from!! :D
Let's start from mine. "Multiforme Ingegno" is the italian translation of πολυτρόπως (polytropos), the first epithet Homer gives Odysseus in the Odyssey (in english it's something like "ingenious" or more precisely "ingenious in many ways"). :)
27
What about storing those variables in a MD5 encrypted file? Or - if this is too complex to setup for a "normal" user - we could give the possibility to manually set that method for "experienced" users..
29
Off-topic / Aeva Media and Nginx
« on June 18th, 2012, 01:49 AM »
I switched from Apache2 to Nginx. Everything works fine except aeva media, files don't show up! :(
It's not the problem of FileZilla + ASCII files (I downloaded and uploaded 'em with WinSCP), it has to do with rewrites I presume.. Maybe I should add some rewrites in vhost declaration in order to have these links to work..:
index.php?action=media;sa=media;in=XXX;preview

If I try to visit that link I get "File not found".

A strange thing is that attachments/avatar work.. and they have links like:
index.php?action=dlattach;attach=XXX;type=avatar

Not so different!

P.S.: Of course mgal_data path set is correct!
30
Off-topic / Help with apache2
« on June 1st, 2012, 02:08 AM »
I'm setting up a (remote) virtual server with Ubuntu Server 12.04. I installed apache2, php5, mysql, etc..
I need to host several websites on this server, that has just 1 IP. So I need to create virtual hosts. I read Apache documentation and many posts here and there..

The problem is that I get the warning "NameVirtualHost *:80 has no VirtualHosts" every time I restart Apache.

These are the files I have:

etc/apache2/apache2.conf
Code: [Select]
#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned. 
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "foo.log"
# with ServerRoot set to "/etc/apache2" will be interpreted by the
# server as "/etc/apache2/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
LockFile ${APACHE_LOCK_DIR}/accept.lock

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
# It is also possible to omit any default MIME type and let the
# client's browser guess an appropriate action instead. Typically the
# browser will decide based on the file's extension then. In cases
# where no good assumption can be made, letting the default MIME type
# unset is suggested  instead of forcing the browser to accept
# incorrect  metadata.
#
DefaultType None


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., [url=http://www.apache.org]www.apache.org[/url] (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/

ServerSignature Off
ServerTokens Prod

httpd.conf is blank

ports.conf:
Code: [Select]
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

/etc/apache2/sites-enabled/000-default
Code: [Select]
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

/etc/apache2/sites-available/default:
same as /etc/apache2/sites-enabled/000-default

/etc/apache2/sites-available/www.example.com:
Code: [Select]
#
#  Example.com (/etc/apache2/sites-available/www.example.com)
#
<VirtualHost *>
        ServerAdmin webmaster@example.com
        ServerName  [url=http://www.example.com]www.example.com[/url]
        ServerAlias example.com

        # Indexes + Directory Root.
        DirectoryIndex index.html
        DocumentRoot /home/www/www.example.com/htdocs/

        # CGI Directory
        ScriptAlias /cgi-bin/ /home/www/www.example.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /home/www/www.example.com/logs/error.log
        CustomLog /home/www/www.example.com/logs/access.log combined
</VirtualHost>

/etc/apache2/sites-available/www.example.net:
same as example.com with dirs changed

/etc/apache2/sites-available/www.example.org:
same as example.com with dirs changed

Of course I enabled the sites with the a2ensite command.

Do you know what can cause the problem? :o