Tag Archives: synapseindia reviews

How To Check Valid or Invalid URL:PHP

<?php

if(isset($_POST[‘check’]))
{

$web= test_input($_POST[“web”]);
if(!preg_match(“/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i”,$web))
{

$Err = “Invalid URL”;
}
else
{
echo “valid URL”;
}
}

?>

<html>
<body>
<form method=”post” action=””>
<table>
<tr>
<td>Enter URL</td>
<td><input type=”text” name=”web”/></td>
</tr>
<tr>
<td><input type=”submit” name=”check” value=”check url”/></td>
</tr>
</table>
</form>
</body>
</html>

SynapseIndia claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.You can check feedback and reviews given by clients on various projects completed by us.

The Employment Bond is basically an agreement which the company and the employee enter into which among the other terms contained therein states that in consideration of the training given to the Employee and the money spent by the company in imparting such training, the Employee will remain in the services of the company for a particular period.

How To Include Files Without Using Include/Require

It is one of the magical method(method which doesnot needs to be get called) which simplify the programmer job by including classes automatically without using number of include statements.

Let us understand it through a program :

<?php

function _autoload($classname){

require_once $classname.’.php’;

}

$obj=new mysqli();

?>

SynapseIndia claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.You can check feedback and reviews given by clients on various projects completed by us.

The Employment Bond is basically an agreement which the company and the employee enter into which among the other terms contained therein states that in consideration of the training given to the Employee and the money spent by the company in imparting such training, the Employee will remain in the services of the company for a particular period.

Create PDF files in PHP without PDFlib library

If you want to generate PDF files with PHP code you have to use FPDF which is a PHP class,it allows you to create pdf files without using PDFlib library.

<?php
require(./fpdf.php’);

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont(‘Arial’,’B’,16);
$pdf->Cell(40,10,’Hello World!’);
$pdf->Output();
?>

SynapseIndia claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.You can check feedback and reviews given by clients on various projects completed by us.
The Employment Bond is basically an agreement which the company and the employee enter into which among the other terms contained therein states that in consideration of the training given to the Employee and the money spent by the company in imparting such training, the Employee will remain in the services of the company for a particular period.

SynapseIndia Php Development-The Case Against Drupal Base Themes

When it comes to Drupal base themes, it seems the conversation is often limited to which one you should choose, rather than discussing whether you should be using one at all.

As someone who has spent a lot of time extolling the virtues of various base themes, I thought I’d share the other side of the argument and ask if we should be using contributed base themes – those available from drupal.org – in our projects. For the purposes of this post, the distinction between contributed base themes and one you might build yourself is important as we’ll see in a moment.

This discussion is really part of a larger debate that front-end developers are having about CSS and grid frameworks in general (see here and here), but it seems particularly relevant when discussing Drupal base themes because all of the issues are magnified due to added complexity.

Why We Use Base Themes

Why do so many of us use base themes? The easy answer is that they can save us time and potentially make us more efficient. Sometimes they can also act as common ground for development teams. But I think a more complete answer is that they act as a useful crutch, particularly when first learning Drupal theming or responsive design.

At some point we all had to build our first Drupal site or our first responsive site – probably under deadline – and we looked to a base theme or framework for help. It allowed us to get the job done on time and within budget, but perhaps without fully understanding everything that was going on under the hood.

Over time we probably learned most of the base theme and developed a deeper understanding of responsive design, but the framework eventually became a comfortable place. We stuck with it, happily soldiering on until one day…

When the Shortcut Becomes the Long Way

If you’ve been working with base themes for a while, the moment has certainly come when you have found yourself fighting with it. By design, base themes and other frameworks are opinionated – they make decisions about how to solve certain problems. Most of the time this is a good thing. It can help you accomplish things more quickly. Until it doesn’t, and then your base theme is actually slowing you down and causing problems.

Part of the reason why this happens is that the developer doesn’t have full mastery of the base theme –  or underlying concepts  – and therefore doesn’t know why something is happening. This is bound to happen with base themes like Omega and Zen that are complex and have a very granular file structure, lots of hooks, etc. It can take some effort to track issues down.

Other times it’s not mastery as much as the choices being made by the base theme don’t match up with the project at hand. You find yourself at cross purposes with the base theme, possibly even trying to sort out incompatibilities between the base theme and a module you want to use.

And all the hacks you add to sort things out? More kilobytes that have to be downloaded by a user on a mobile device.

Fast Sites Win the Day

This leads us to another reason you might not want to use a base theme – it will probably slow down your site vs a theme that is tailored for a specific project. The case has been definitively made that faster sites are more successful sites (see here and here). In most cases, base themes are going to include a lot of stuff that you are not going to need on a given project. The ‘extra’ stuff is bloat that will end up slowing your site down.

This isn’t a slam on base themes. Most of them are akin to a Swiss army knife. They have things in them that help accomodate a lot of different scenarios – they’re flexible. This can be a big help if you’re a beginner, but what if you’re a seasoned front-end developer tasked with building a high performance site?

In that case, maybe a base theme isn’t the way to go.

The Role for Base Themes

Some will sing the praises of Mothership or Tao or their favorite lean base theme of choice, insisting it solves all of the issues I’ve mentioned. I certainly have no quarrel with using those base themes on projects if you’ve mastered them and find them useful. It can also be helpful to employ Zen or Omega. It really depends on the specific project. This isn’t a post bashing base themes.

My own thinking on the topic, however, has shifted. I’ve decided to move away from base themes whenever possible. My decision stems from wanting lean code that helps me build fast, mobile-first sites. It also allows me to understand exactly what is happening with the code because I’m the one who wrote it. Ultimately, I think this practice makes me better at my job as a front-end developer, and importantly, I’m also delivering a better product to my clients. I came to this place after spending so much time hacking apart base themes that they were no longer recognizable. It made more sense to just chuck them entirely and start fresh.

Of course, I haven’t thrown efficiency considerations aside. I have my own starter theme to make my work easier, and this is what I would advise others who are considering a base theme to do as well. Create your own bag of tricks. If there ends up being things in it that don’t fit a particular project, you’ll know exactly where they are so that you can easily discard them.

One last tangential thought on this topic – a fantastic development for Drupal 8 would be for core to add no CSS whatsoever, minimal markup and then let themes in contrib add commonly requested bells and whistles. This is a philosophical approach that would be hugely positive for Drupal as a mobile-first approach takes hold as the standard for front-end development.

SynapseIndia Smarty PHP Template Engine: Building PHP Apps in a Flash Development

Smarty is a template engine for PHP whose main goal is to facilitate a very useful way to separate the business logic from the presentation logic. This article introduces Smarty and demonstrates how to install the template, create an application from scratch and interact with a database.

Installing the Smarty Template Engine

The Smarty template engine can be downloaded from the official website. At this site you will also find complete documentation that will help you to learn more about working with Smarty templates.

To install and use Smarty you should go through the following steps:

  1. Unzip the Smarty archive to the proper directory. I put the Smarty library into theD:/Apache2.2/htdocs/php/ path. You should see the structure below in the Smarty directory.

    Click here for larger image

    Figure 1. The Structure of Smarty/libs Folder
  2. Now, to test if Smarty is correctly installed, you should put the code below into the index.phpscript. As you can see from the listing below, before checking if all the required working folders can be accessed (using the testInstall() method) , you should create a new Smarty variable:
    <?php
    
    //Put full path to Smarty.class.php
    require('D:/Apache2.2/htdocs/php/Smarty/libs/Smarty.class.php');
    
    //Create new variable $smarty from the class Smarty
    $smarty = new Smarty();
    
    //Verifies that all required working folders of the Smarty installation can //be accessed
    $smarty->testInstall();
    
    ?>
  3. To see the output of the test, write http://localhost/php/Smarty/demo/index.php into the browser. You should get something like this:
    Smarty Installation test...
    Testing template directory...
    .\templates\ is OK.
    Testing compile directory...
    .\templates_c\ is OK.
    Testing plugins directory...
    D:\Apache2.2\htdocs\php\Smarty\libs\plugins\ is OK.
    Testing cache directory...
    .\cache\ is OK.
    Testing configs directory...
    .\configs\ is OK.
    Tests complete.

Creating a New Simple Smarty Application

In this section you will see how to create your own “Hello World” application. To do that, you should first create a new folder (I named it Smarty_example) in theD:/Apache2.2/htdocs/php/ directory, set the template directory for use with different templates (as you will see below in the index.php script), assign a variable (in this case,name) and then compile and display the template file, index.tpl.

<?php

//Put the full path to Smarty.class.php
require('D:/Apache2.2/htdocs/php/Smarty/libs/Smarty.class.php');

//Create new variable $smarty from the class Smarty
$smarty = new Smarty();

//Set the template directory used for different templates
$smarty->setTemplateDir('/ Smarty_example /templates');
//Set the compile directory 
$smarty->setCompileDir('/ Smarty_example /templates_c');
//Set the cache directory
$smarty->setCacheDir('/ Smarty_example /cache');
//Set the configs directory
$smarty->setConfigDir('/ Smarty_example /configs');

//Set the name variable variables
$smarty->assign('name', 'WORLD');

//Compile and display output of the template file
$smarty->display('index.tpl');

?>

The template file, index.tpl, looks like this:

<html>
  <head>
    <title>Smarty</title>
  </head>
  <body>
    Hello, {$name}!
  </body>
</html>

The output of the “Hello World” application is:



Click here for larger image

Figure 2. The Output of the First Simple Application “Hello World”

SynapseIndia PHP OOP Class for count down to any date or event Development

Calendars/Dates    GNU General Public License

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**************************************************************
# TITLE : Object Oriented Approach to countdown to any particular date or event           *
# Same procedural snipped is posted in Help Manual ---> date()
# If you compare both snippets, It would be easy to understand PHP-OOPs!
***************************************************************/
//Any of following input can be retrieved by GET OR POST.
//Input is set for New Year event.
$year = '2009';
$month= '01';
$day = '01';
$hour = '00';
$minute = '00';
$second = '00';
$date = array($hour,$minute,$second,$month,$day,$year);
//Defining class bt keyword class
class DateCountDown {
//Class member definition - Easy to remember class members
var $year = "";
var $month= "";
var $day = "";
var $hour = "";
var $minute = "";
var $second = "";
var $date = "";
var $dl = "";
var $hl = "";
var $ml = "";
var $sl = "";
var $return = "";
//Countdown to particular Function
function countdown(){
  global $return;
  global $countdown_date;
  global $date;
  list ($hour, $minute, $second, $month, $day, $year)= $date;
  $countdown_date = mktime($hour, $minute, $second, $month, $day, $year);
  $today = time();
  $diff = $countdown_date - $today;
  if ($diff < 0)$diff = 0;
  $dl = floor($diff/60/60/24);
  $hl = floor(($diff - $dl*60*60*24)/60/60);
  $ml = floor(($diff - $dl*60*60*24 - $hl*60*60)/60);
  $sl = floor(($diff - $dl*60*60*24 - $hl*60*60 - $ml*60));
// OUTPUT
$return = array($dl, $hl, $ml, $sl);
return ($return);
}
}
//Making New Object for the class CountDownDate
$date_obj = new DateCountDown($date);
//Function (Method) call by an object to function countdown
$date_obj -> countdown();
//Making varialbes $dl => Days Left, $hl => Hours Left and so on from $return array
list($dl,$hl,$ml,$sl) = $return;
//Browser Output
echo "Today's date ".date("F j, Y, g:i:s A")."<br/>";
echo "Countdown date ".date("F j, Y, g:i:s A",$countdown_date)."<br/>";
echo "\n<br>";
echo "Countdown ".$dl." days ".$hl." hours ".$ml." minutes ".$sl." seconds left"."\n<br>";
/*
Above snippet produces following output:
Today's date February 11, 2008, XX:XX:XX PM
Countdown date January 1, 2009, 12:00:00 AM
Countdown 324 days XX hours XX minutes XX seconds left
*/
?>

SynapseIndia Reading RSS feeds in PHP Development : Part 1

I’m sure everyone who calls themselves a PHP coder has heard of RSS. I have to include the disclaimer, as I’m always surprised how little penetration concepts I take for granted have in the rest of the world. Recently, a colleague in the music industry started a blog. I saw there were no RSS feeds available, and asked him when they’d be ready. He had no clue what I was talking about. I shouldn’t really have been surprised. Nevertheless, RSS feeds are starting to take the world by storm.
Recently I was looking for an RSS aggregator. I was having surprising difficulty finding one that did exactly what I wanted. Being quite impatient, especially when I’d spent more time looking than it would have taken me to write one had I started immediately, I began seriously considering writing my own. This month, I show you how to create a basic RSS reader yourself.
What is RSS?
I’m not interested in getting into the debate as to whether RSS stands for Really Simple Syndication, Rich Site Summary, RDF Site Summary, or anything else. Nor which of the RSS versions are ‘better’. This article is not going to investigate the differences between the various RSS versions either. If we’re going to be using PHP to read RSS, we need to rather know some of the basic technical details of what an RSS feed comprises of.
RSS is most simply understood as an implementation of XML. It contains (roughly, as versions differ!) the following elements (full specifications can be found at http://web.resource.org/rss/1.0/spec and http://blogs.law.harvard.edu/tech/rss:

* <title>, the feed title, or the name of the channel.
* <description>, a short piece of text describing the feed.
* <link>, the URL of the corresponding web page.
* <language>, the language used for the content (for more details see RFC1766, Tags for the Identification of Languages.
* <lastBuildDate>, the date and time the feed was updated.
* <pubDate>, the date and time the content was published.
* <copyright>, any copyright information.
* <generator>, the software used to generate the RSS.
* <docs>, a URL pointing to documentation for the format used in the RSS file (usually one of the specification links above).
* <ttl>, time to live, or how long the feed can be cached, in minutes.
* <image> An image related to the RSS feed. This in turn contains up to 6 sub-elements, the first three being mandatory:
o <title> Same function on the channel’s title, and usually contains the same string.
o <url> Image URL.
o <link> Same function on the channel’s image, and usually contains the same string.
o <width> In pixels, maximum of 144, default of 88.
o <height> In pixels, maximum of 400, default of 31.
o <description> The HTML title attribute.
* <rating> The PICS rating, originally designed for access control for parents and teachers. See the W3C specification.
* <cloud> Specifies a cloud web service which allows notification of updates.
* <textInput> Used to specify a text input box, which isn’t usually that useful, and we don’t look at here.
* <skipHours> This tells well-behaved aggregators when not to read the feed, reducing unecessary reads when nothing has changed. It consists of up to 24 <hour> elements, each containing a number from 0 to 23, representing an hour to be skipped.
* <skipDays> Similar to <skipHours>, this consists of <day> sub-elements, each listing a day to be skipped (written in full, such as Saturday).
* <webmaster> If you enjoy harvesting spam, you may also want to put the email address of the person responsible for technical issues.
* <managingEditor> Another spam harvester, this time the email of the editor responsible for the content.
* <item> Most importantly, it also contains a number of items, which are usually the articles, stories or posts you’re interested in reading. It contains a number of sub-elements, all of which are optional, although one of either title or description must be present.
o <title> Usually the article headline.
o <description> Usually a short blurb, although it can contain the entire contents.
o <link> URL to the item.
o <author> More potential spam gathering, this one is for the email address of the item’s author
o <category> String identifying the category
o <comments> URL for item comments
o <enclosure> Used for attached video or audio files. It has 3 attributes – URL, length (in bytes) and type.
o <guid> A unique identifier (Globally Unique Identifier). Usually a URL. Has an attribute, is PermaLink, which tells the reader whether the guid is a URL to the item (it defaults to true).
o <pubDate> Date and time when the item was published
o <source> Text string of the source, it also has a required attribute, url, which links to the source’s XMLization

After all that’s let’s look at a sample, loosely based on that of the PHPBuilder website. For simplicity I’ve included just two items. It’s in RSS 0.91 format.

<?xml version=”1.0″?>
<rss version=”0.91″>
<channel>
<pubDate>Thu, 29 Sep 2006 15:16:13 GMT</pubDate>
<description>Newest Articles and How-To’s on PHPBuilder.com</description>
<link>http://phpbuilder.com</link&gt;
<title>PHPBuilder.com New Articles</title>
<webMaster>staff@phpbuilder.com</webMaster>
<language>en-us</language>  <item>
<title>In Case You Missed It…The Week of September 26, 2006</title>
<link>http://www.phpbuilder.com/columns/weeklyroundup20060926.php3</link&gt;
<description>This week Elizabeth brings us news of an upcoming free
webcast called Design Patterns in PHP, the schedule for the Fall Zend conference,
security alerts for Moveable Type and phpBB, the release of Zend Platform 2,
XAMPP for Linux, the latest PEAR/PECL releases and much more!
</description>  </item>  <item>
<title>In Case You Missed It…The Week of September 19, 2006</title>
<link>http://www.phpbuilder.com/columns/weeklyroundup20060919.php3</link&gt;
<description>This week Elizabeth brings us news of the release of PEAR 1.4,
Zend Studio 5 Beta, a security vulnerability with PHP-Nuke, the release of a
SimpleTest plugin for PHPEclipse, a patch for phpMyAdmin, the latest PEAR/PECL
releases and much, much more!</description>
</item>
</channel>
</rss>