Website Development in ahmedabad, php expert in ahmedabad, software development in ahmedabad, web development in ahmedabad, domain and hosting in ahmedabad
“You dream it… We blueprint it!”
Advancement, creativeness, excellent, promptness and sufficient are the main mantras of I365 Design and these are shown in our performance.
I365 Design provides wide range of digital solutions that include web page styles, website development, E-commerce Development, mobile development, custom web development, social development, graphic designing, animation development that allow the development of a natural and smooth on the internet experience. Company Based in Gujarat, India & Nairobi, Kenya. I365 design is a Web Development Company worldwide recommended for its professional approach and excellent of performance.
We at I365 Design ensure a perfect combination of innovative perspective, efficient specialized knowledge and strong Objective of Success while creating tailor-made market alternatives for our customers.
It requires an individual only for a few moments to gauge the geniality of a website! And 8 out of 10 folks assess the reliability of a web page depending on its design!
In easier conditions, it is important that your web page performs as hard as you do, for your business. An excellent style improves the transformation by huge margin and provides a user-friendly encounter that obliges the guest to become client. Excellent web page is just like your smart Creativity. It forms your Identity with your clients, improves your product and cultivates your main objective.
What We Do
-
Website Design
-
Creative Web Design
-
Web Design Studio
-
Flash Website Design
-
Online Video Sites
-
Multilingual Websites
-
Web Application Development
-
Social Network Systems
-
Enterprise Application Development
-
Microsoft Sharepoint Server Consulting
-
Biz Talk Server Development
-
Customized Web Applications
-
Dashboards
-
Business Intelligence
-
CMS
-
E-Learning Solutions
-
Software Development
-
Software as a Service – Saas
-
Flash Game Development
-
CRM
-
ERP
-
Ecommerce Web Design
-
Ecommerce Web Development
-
Ecommerce Shopping Cart
-
Magento Development
-
Secure Online Shopping
-
Multilingual Ecommerce
-
Multi-Currency Ecommerce
-
Multiple Payment Gateways
-
OSCommerce
-
Mobile Application & Website
-
Iphone Application Development
-
Ipad Application Development
-
Android Application Development
-
Windows Mobile Application Development
-
QR (Quick Response Code Reader)
-
Customized Sales Application
-
Social Commerce
-
Graphic Design
-
Logo Design
-
Banners
-
Print Design
-
Brochure Design
-
Newsletters
-
Corporate Identity
-
Strategic Design
-
Brand Building
-
Customized Software
How To Create a File With PHP And Write Content To It
One of my tasks for a project was to create an XML file with simple XML fields to be able to index content in to a Solr Search Core.
So today I will teach you how to create an file with php and write content to it.
Lets get started.
Step 1
Write a function / method that will create the file and write content to it.
function
my_file_writer(
$filename
){
// Code goes here
}
Step 2
In this step I want to grab content from my mysql database tables.
function
my_file_writer(
$filename
){
// connect to db.
echo
"connecting...
";
$con
= mysql_connect(
"localhost"
,
"username"
,
"password"
);
if
(!
$con
)
{
die
(
'Could not connect: '
. mysql_error());
}
mysql_select_db(
"database_name"
,
$con
)
or
die
(
'Could not connect: '
. mysql_error());
echo
"Connected
";
// select latest articles.
echo
"Selecting data...
";
$result
= mysql_query(
"SELECT id, title, content FROM table"
)
or
die
(
'Could not select data: '
. mysql_error());
echo
"Selected
";
}
Step 3
Here we are going to add a while loop to grab the mysql data we selected and put it into the right format for writing it to our file.
function
my_file_writer(
$filename
){
// connect to db.
echo
"connecting...
";
$con
= mysql_connect(
"localhost"
,
"username"
,
"password"
);
if
(!
$con
)
{
die
(
'Could not connect: '
. mysql_error());
}
mysql_select_db(
"database_name"
,
$con
)
or
die
(
'Could not connect: '
. mysql_error());
echo
"Connected
";
// select latest articles.
echo
"Selecting data...
";
$result
= mysql_query(
"SELECT id, title, content FROM table"
)
or
die
(
'Could not select data: '
. mysql_error());
echo
"Selected"
;
$stringData
=
""
;
// we put the first part of the $stringData variable outside the loop
while
(
$row
= mysql_fetch_array(
$result
))
{
// set variables
$page_id
=
$row
[
'id'
];
$page_url
=
$row
[
'url'
];
$pagetitle
=
$row
[
'title'
];
$bodytext
=
$row
[
'content'
];
$bodytext
=
strip_tags
(
$bodytext
);
// Here we strip all html tags from the body text
$stringData
.= "
$page_id
http:
//your-url-here.com/pagename
$pagetitle
$bodytext
\n\n";
}
// end of while loop
$stringData
.=
""
;
// we put the final part of the $stringData variable at the end outside of the while loop
}
?>
Step 4
In this step we start creating and writing to the file.
$fh
=
fopen
(
$filename
,
'w'
);
// we create the file, notice the 'w'. This is to be able to write to the file once.
fwrite(
$fh
,
$stringData
);
// here we write the data to the file.
echo
"Writing file...
";
echo
"Closing file...
";
fclose(
$fh
);
//here we close our file
echo
'Finished!'
;
Step 5
all thats left to do is to close the mysql connection.
mysql_close(
$con
);
// close the connection
Step 6
Now you can create your file and run the script.
my_file_writer(
"Your_File_Name.xml"
);
Conclusion
As you can see it’s really easy to create a file and add any content you want to it. You should be able to see a file with the name you gave it after you ran your script. Any suggestion is welcome.
PHP API Development: Dreaming Of Your Own API? Make It Possible Today!
I have often dreamed of creating an API for one of my sites but I’ve always set it aside as I thought it would be too much work to do. One day I just decided it’s time to do the research and get started with building my own API and it wasn’t as difficult as I thought.
So you are probably eager to start with this one? OK I’ll show you how!
First thing, you need to have a database in place with data. I’m not going to show you how to build a database with tables as it’s one of the basics you need to know. I’m sure most of you are past the basics.
The first part of the code
if
(
$_GET
[
'q'
] ==
"all"
&&
$_GET
[
'type'
] ==
'json'
){
//get a connection to mysql
$con
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"could not connect"
.mysql_error());
//select your database table
mysql_select_db(
"android_maps"
,
$con
)
or
die
(
"Could not select database"
.mysql_error());
//get your results with a mysql query
$result
= mysql_query(
"SELECT gmaps.*, urls.* FROM gmaps, urls WHERE urls.idgmaps = gmaps.idgmaps"
)
or
die
(mysql_error());
//run a while loop get your data.
while
(
$place
= mysql_fetch_array(
$result
, MYSQL_ASSOC)) {
$places
[] =
array
(
'location'
=>
$place
);
}
$output
= json_encode(
array
(
'map'
=>
$places
));
echo
$output
;
mysql_close(
$con
);
}
First off we select all data from our database. You can set search criteria for different results for example for getting particular users details from your social network, but in this example we select everything.
In the example above I select all data from my android maps app database for locations and places. We then do some JSON encoding to put the data in the correct format. All you need to do to use the output data is to grab it and use a JSON decode method
The output of the data in JSON format.
{“map”:[{"location":{"idgmaps":"15","lat":"-25.926813935317035","lon":"27.828453713378963","address":"cradle of human kind","title":"Cradle of Humankind","description":"The 47 000-hectare Cradle of Humankind is blessed with a greater wealth of early human history than almost any other place on earth. \r\n\r\nThe Cradle contains more than twelve major fossil sites and dozens of minor ones. The Maropeng Visitors Centre at the Cradle of Humankind (near Johannesburg) was opened in 2005. The tumular building is designed to look like an ancient burial mound, though from the rear it looks like a modern structure. \r\n\r\nInside, a journey through the evolution of life is presented, and the architecture is symbolic of this journey. Maropeng means returning to the place of origin in Setswana, the local indigenous language. It is a reminder that the ancestors of all humans, wherever they live today, originally came from Africa.","tags":"Maropeng, Cradle of Human Kind, Early Humans","idurls":"17","url_name":"Early humans","url":"http:\/\/newhistory.co.za\/part-1-chapter-1-early-humans\/"}}
The second part of the code
In this part we switch the data format to output XML.
elseif
(
$_GET
[
'q'
] ==
"all"
&&
$_GET
[
'type'
] ==
'xml'
){
//get a connection to mysql
$con
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"could not connect"
.mysql_error());
//select your database table
mysql_select_db(
"android_maps"
,
$con
)
or
die
(
"Could not select database"
.mysql_error());
//get your results with a mysql query
$result
= mysql_query(
"SELECT gmaps.*, urls.* FROM gmaps, urls WHERE urls.idgmaps = gmaps.idgmaps"
)
or
die
(mysql_error());
//run a while loop get your data.
while
(
$location
= mysql_fetch_array(
$result
)) {
$output
=
'<?xml version="1.0" encoding="utf-8"?>'
;
$output
.=
'<data>'
;
$output
.=
"<lat>"
.
$location
[
'lat'
].
"</lat>"
;
$output
.=
"<long>."
.
$location
[
'lon'
].
"</long>"
;
$output
.=
"<description>."
.
$location
[
'description'
].
"</description>"
;
$output
.=
'</data>'
;
print
$output
;
}
mysql_close(
$con
);
}
else
{
echo
"<h1>No results to show for you query</h1>"
;
}
The second par t of the code we switched over to XML output. The only big difference is the elseif and the XML tags I added in the while loop.
Here’s the complete code.
<?php
if
(
$_GET
[
'q'
] ==
"all"
&&
$_GET
[
'type'
] ==
'json'
){
//get a connection to mysql
$con
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"could not connect"
.mysql_error());
//select your database table
mysql_select_db(
"android_maps"
,
$con
)
or
die
(
"Could not select database"
.mysql_error());
//get your results with a mysql query
$result
= mysql_query(
"SELECT gmaps.*, urls.* FROM gmaps, urls WHERE urls.idgmaps = gmaps.idgmaps"
)
or
die
(mysql_error());
//run a while loop get your data.
while
(
$place
= mysql_fetch_array(
$result
, MYSQL_ASSOC)) {
$places
[] =
array
(
'location'
=>
$place
);
}
$output
= json_encode(
array
(
'map'
=>
$places
));
echo
$output
;
mysql_close(
$con
);
}
elseif
(
$_GET
[
'q'
] ==
"all"
&&
$_GET
[
'type'
] ==
'xml'
){
//get a connection to mysql
$con
= mysql_connect(
"localhost"
,
"root"
,
"root"
)
or
die
(
"could not connect"
.mysql_error());
//select your database table
mysql_select_db(
"android_maps"
,
$con
)
or
die
(
"Could not select database"
.mysql_error());
//get your results with a mysql query
$result2
= mysql_query(
"SELECT gmaps.*, urls.* FROM gmaps, urls WHERE urls.idgmaps = gmaps.idgmaps"
)
or
die
(mysql_error());
//run a while loop get your data.
while
(
$location
= mysql_fetch_array(
$result2
)) {
$output
=
'<?xml version="1.0" encoding="utf-8"?>'
;
$output
.=
'<data>'
;
$output
.=
"<lat>"
.
$location
[
'lat'
].
"</lat>"
;
$output
.=
"<long>."
.
$location
[
'lon'
].
"</long>"
;
$output
.=
"<description>."
.
$location
[
'description'
].
"</description>"
;
$output
.=
'</data>'
;
echo
$output
;
}
mysql_close(
$con
);
}
else
{
echo
"<h1>No results to show for you query</h1>"
;
}
?>
Appending data to a MySQL database field that already has data in it
Need to “add” data to a field that already contains data without erasing whats currently there. For example if the field contains HTML, I need to add additional HTML to the field. Is there a SQL call that will do this or do I need to call the data in that field, concatenate the new data to the existing data, and reload it into the database?
Yes you can use the following query to append data to database field.
UPDATE Table SET Field=CONCAT(Field,'your extra html');
and you can also do it with specific where condition
UPDATE myTable SET html=concat(html,'<b>More HTML</b>') WHERE
CSS Triangle
HTML
You can make them with a single div. It’s nice to have classes for each direction possibility.
<div class="arrow-up"></div><div class="arrow-down"></div><div class="arrow-left"></div><div class="arrow-right"></div>
CSS
The idea is a box with zero width and height. The actual width and height of the arrow is determined by the width of the border. In an up arrow, for example, the bottom border is colored while the left and right are transparent, which forms the triangle.
.arrow-up { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid black;}.arrow-down { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #f00;}.arrow-right { width: 0; height: 0; border-top: 60px solid transparent; border-bottom: 60px solid transparent; border-left: 60px solid green;}.arrow-left { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-right:10px solid blue;}
Save your website bandwidth with PHProxy and ip2nation
What is ip2nation?
There is currently numerous companies on the net charging for databases or files containing knowledge about where an IP is apportioned (as in which country). This knowledge is in fact obtainable free at ARIN, APNIC, RIPE etcetera. Though, those files are not in any way optimized for queries & are indeed very slow. This is where ip2nation.com comes in.
We utilitize these files to generate a MySQL database table with the appropriate indexes. We have also optimized the table & removed unneccesary information in order to make queries lightning speedy. In order to utilitize the table you may find help in the PHP examples under “Sample scripts”.
What is PHPProxy?
PHProxy is a web HTTP proxy programmed in PHP meant to bypass firewalls and access otherwise inaccessible resources (i.e. blocked sites). If the server this script is run on can access a resource, so are you able to!
With the proxy script PHProxy and the information IP location database from ip2nation it is simple to block visitors which are coming from other countries then your target group. In this tutorial you will learn how to add the necessary code to your PHProxy powered proxy web-site.
Step 1
Download ip2nation and import the sql file into your database (test).
Step 2
Download PHPProxy and add the following code to the index.php file
$DBHOST = 'localhost';
$DBUSER = 'user';
$DBPASS = 'password';
$DATABASE = 'test';
$my_countries = array('in', 'us');
$use_ip2nation = true; //true for blocking countries
Step 3
Find the following code in index.php
function proxify_css_url($url)
{
$url = trim($url);
$delim = strpos($url, ‘”‘) === 0 ? ‘”‘ : (strpos($url, “‘”) === 0 ? “‘” : ”);
return $delim . preg_replace(‘#([\(\),\s\'"\\\])#’, ‘\\$1′, complete_url(trim(preg_replace(‘#\\\(.)#’, ‘$1′, trim($url, $delim))))) . $delim;
}
Add the following code after that to check if the resulting country is in our list or not. if its in our list it will go ahead.
if ($use_ip2nation) {
$db = mysql_connect($DBHOST, $DBUSER, $DBPASS);
mysql_select_db($DATABASE);
$sql = "SELECT country FROM ip2nation WHERE ip < INET_ATON('".$_SERVER['REMOTE_ADDR']."') ORDER BY ip DESC LIMIT 0,1";
$res = mysql_query($sql);
$country = mysql_result($res, 0, 'country');
mysql_free_result($res);
if (!in_array($country, $my_countries)) {
show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'otherthan_in_us'));
}
}
Step 4
Add the following code in index.inc.php.
$show_web_form = true;
Find the following code index.inc.php (near line 83)
case ‘hotlinking’:
$message = ‘It appears that you are trying to access a resource through this proxy from a remote Website.<br />’
. ‘For security reasons, please use the form below to do so.’;
break;
Add the following code after that
case 'otherthan_in_us':
$message = 'Sorry this service is only for india and us.
Click topsite in the footer part.';
$show_web_form = false;
break;
Add the following code to allow user to view form or not before starting of <form> tag in index.inc.php
if ($show_web_form) {
and add this code after </form> tag to show alternate stuff to user.
} else {
// show custom content for blocked user to tell that they are blocked for the content
};
Source : mishilpatel[dot]wordpress[dot]com
0 comments:
Post a Comment