All posts with PHP tag

To comply with the e-Privacy directive it is necessary for sites to obtain consent prior to delivering cookies.

There are many scripts available to present site visitors with a prompt prior to cookie delivery.

The cPrompt plugin wrappers the cPrompt script. Simply install into Flatpress and enable the Plugin.

Once installed the cPrompt object can be used to enable / disable cookie related functionality within the site.

Full instructions on the use of cPrompt library can be found on Michael Wright's site. Using these instructions the GoogleSearchBox plugin can be made compliant with the directve with the following change to plugin.googlesearchbox.php:


    if (typeof(cPrompt) == "undefined"  
        &#124;&#124; cPrompt.checkCookie() == 1 
        &#124;&#124; cPrompt.checkCookie() == 2) {


    To try and dissuade spam comments from FlatPress blogs it is worth adding a nofollow rel attribute to the web address associated with a comment.

    To achieve this it is necessary to modify the comments.tpl file found in the root folder for the theme you currently have selected, i.e. fp-interface/themes/ramblingross/comments.tpl

    Within the ordered list with an id of "comments" there is a single list item. This list item contains a link when the $url variable contains something. Modify this link to contain a rel="nofollow" attribute, e.g.

    <strong class='comment-name'>
        using this tag combo, the name is displayed as a link only
        if user entered a URL.
        Syntax is quite intuitive:
        "if $url is not empty, show $name between a tags, 
        else default fallback on displaying plain $name"        
    {$url&#124;notempty:"<a rel=\"nofollow\" href=\"$url\" title=\"Permalink to $name's comment\">$name</a>"&#124;default:$name}

      Currently the sitemap plugin for FlatPress only pings google with changes.

      To add additional ping targets two steps are required.

      First generate a new class in the /class folder of the sitemap plugin to represent the ping target. For example to ping bing create a file called pingbingsitemaps.php and copy the following code into it...

      function pingBingSitemaps( $url_xml )
         $status = 0;
         $bing = '';
         if( [email protected]($bing, 80) )
            $req =  'GET /webmaster/ping.aspx?sitemap=' .
                    urlencode( $url_xml ) . " HTTP/1.1\r\n" .
                    "Host: $bing\r\n" .
                    "User-Agent: Mozilla/5.0 (compatible; " .
                    PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
                    "Connection: Close\r\n\r\n";
            fwrite( $fp, $req );
            while( !feof($fp) )
               if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) )
                  $status = intval( $m[1] );
            fclose( $fp );
         return( $status );

      Second, update the plugin.sitemap.php file in the sitemap folder. Two changes are required. The first is to load the class just created.

              // PHP google_sitemap Generator
              require_once( "class/pingbingsitemaps.php" );
              require_once( "class/pinggooglesitemaps.php" );
              require_once( "class/google_sitemap.class.php" ); 

      Whilst the second is to call the new class.

          // Once the sitemaps are ready, we ping Google...
          if( 200 === ($status=pingGoogleSitemaps($website_url.$sitemap_name)) ) $status = "OK";
          //   print( "Ping to Google Sitemaps successful.\r\n\r\nStatus code: $status." );
            // print( "Cannot ping/connect to Google Sitemaps.\r\n\r\nStatus code: $status."  );
          $status = "KO";
          if( 200 === ($status=pingBingSitemaps($website_url.$sitemap_name)) ) 
              if( "OK" === $status )  
                  $status = "OK";
              $status = "KO";
          // end the script.