100% found this document useful (1 vote)
30 views

AJAX and PHP Building Modern Web Applications 2nd Edition Bogdan Brinzareadownload

The document provides information about various ebooks and textbooks available for download on ebookultra.com, focusing on topics related to AJAX and PHP for building modern web applications. It highlights the second edition of 'AJAX and PHP: Building Modern Web Applications' by Bogdan Brinzarea and Cristian Darie, along with other related titles. The document includes links to download these resources and a brief overview of the authors and content covered in the featured book.

Uploaded by

alatatsanic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
30 views

AJAX and PHP Building Modern Web Applications 2nd Edition Bogdan Brinzareadownload

The document provides information about various ebooks and textbooks available for download on ebookultra.com, focusing on topics related to AJAX and PHP for building modern web applications. It highlights the second edition of 'AJAX and PHP: Building Modern Web Applications' by Bogdan Brinzarea and Cristian Darie, along with other related titles. The document includes links to download these resources and a brief overview of the authors and content covered in the featured book.

Uploaded by

alatatsanic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Download the full version and explore a variety of ebooks

or textbooks at https://ebookultra.com

AJAX and PHP Building Modern Web Applications 2nd


Edition Bogdan Brinzarea

_____ Follow the link below to get your download now _____

https://ebookultra.com/download/ajax-and-php-building-
modern-web-applications-2nd-edition-bogdan-brinzarea/

Access ebookultra.com now to download high-quality


ebooks or textbooks
We have selected some products that you may be interested in
Click the link to download now or visit ebookultra.com
for more options!.

Web Database Applications with PHP MySQL 2nd Edition Hugh


E. Williams

https://ebookultra.com/download/web-database-applications-with-php-
mysql-2nd-edition-hugh-e-williams/

Laravel a Framework for Building Modern PHP Apps 2nd ed


Edition Stauffer

https://ebookultra.com/download/laravel-a-framework-for-building-
modern-php-apps-2nd-ed-edition-stauffer/

Build Your Own AJAX Web Applications 1st Edition Matthew


Eernisse

https://ebookultra.com/download/build-your-own-ajax-web-
applications-1st-edition-matthew-eernisse/

PHP and MySQL Web Development 2nd Edition Luke Welling

https://ebookultra.com/download/php-and-mysql-web-development-2nd-
edition-luke-welling/
Developing Responsive Web Applications with AJAX and
jQuery 1st Edition Sandeep Kumar Patel

https://ebookultra.com/download/developing-responsive-web-
applications-with-ajax-and-jquery-1st-edition-sandeep-kumar-patel/

Go Building Web Applications 1st Edition Kozyra

https://ebookultra.com/download/go-building-web-applications-1st-
edition-kozyra/

Beginning Google Maps Applications with PHP and Ajax From


Novice to Professional 1st ed. 2006. Corr. 2nd printing
Edition Michael Purvis
https://ebookultra.com/download/beginning-google-maps-applications-
with-php-and-ajax-from-novice-to-professional-1st-ed-2006-corr-2nd-
printing-edition-michael-purvis/

Practical Web 2 0 Applications with PHP 1st Edition


Quentin Zervaas

https://ebookultra.com/download/practical-web-2-0-applications-with-
php-1st-edition-quentin-zervaas/

PHP Solutions Dynamic Web Design Made Easy 2nd Edition

https://ebookultra.com/download/php-solutions-dynamic-web-design-made-
easy-2nd-edition/
AJAX and PHP Building Modern Web Applications 2nd
Edition Bogdan Brinzarea Digital Instant Download
Author(s): Bogdan Brinzarea, Cristian Darie
ISBN(s): 9781847192660, 1847190987
File Details: PDF, 5.04 MB
Year: 2009
Language: english
AJAX and PHP
Building Modern Web Applications – Second
Edition

Build user-friendly Web 2.0 Applications with JavaScript


and PHP

Bogdan Brinzarea-Iamandi
Cristian Darie
Audra Hendrix

BIRMINGHAM - MUMBAI
AJAX and PHP
Building Modern Web Applications – Second Edition

Copyright © 2009 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: December 2009

Production Reference: 1101209

Published by Packt Publishing Ltd.


32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.

ISBN 978-1-847197-72-6

www.packtpub.com

Cover Image by Parag Kadam (paragvkadam@gmail.com)


Credits

Authors Editorial Team Leader


Bogdan Brinzarea-Iamandi Gagandeep Singh
Cristian Darie
Project Team Leader
Audra Hendrix
Lata Basantani

Reviewer
Project Coordinators
Kalpesh Barot
Srimoyee Ghoshal

Acquisition Editor Rajashree Hamine


Douglas Paterson
Proofreader
Development Editor Sandra Hopper
Dhiraj Chandiramani
Graphics
Technical Editor Nilesh Mohite
Aanchal Kumar
Production Coordinators
Indexer Adline Swetha Jesuthas
Rekha Nair Dolly Dasilva

Cover Work
Dolly Dasilva
About the Authors

Bogdan Brinzarea-Iamandi is a software engineer having a strong background


in Computer Science. He holds a Master and Bachelor Degree from the Automatic
Control and Computers Faculty at the Politehnica University of Bucharest, Romania.
He also has an Auditor diploma from the Computer Science department at Ecole
Polytechnique, Paris, France.

His main interests include software architecture, web technologies, distributed


computing, and software methodologies. Currently, he is the Software Development
Manager at a Romanian bank, Banca Romaneasca, a member of the National Bank
of Greece, where he coordinates the development and implementation of enterprise
software for the banking industry.

He is also the author of the books AJAX and PHP: Building Responsive Web Applications
and Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained.

Cristian Darie is a software engineer with experience in a wide range of modern


technologies, and is the author of numerous books, which are all listed on his
homepage at http://www.cristiandarie.ro. Cristian is the manager and the
former technical architect of http://www.okazii.ro, the largest Romanian
e-commerce website.
Audra Hendrix was educated at Northwestern University. She works as a
consultant in applied technology and marketing to small and medium-sized
businesses. While her client list includes Fortune 500 companies, she prefers the
flexibility, agility, and challenges of small to medium-sized businesses. She has
consulted both in the United States and France for businesses seeking to better
utilize their resources and maximize their gains by reinventing and reapplying
back office and Internet applications, data management, cost-effective marketing
strategies, staffing requirements, and planning and deployment of new or emerging
product lines.

A special thanks goes out to my daughter, Zsa Zsa—an unending


and joyful source of inspiration and boundless love. You are, by far,
my greatest achievement.
About the Reviewer

Kalpesh Barot has about five years of experience in the world of PHP. He has
worked extensively on small- and large-scale social networking websites developed
in PHP. He has been involved in varied projects, from planning and developing
websites to creating custom modules on big social networking websites.

He received a Masters degree in Enterprise Software Engineering from University


of Greenwich, UK. There he learned the theory behind his computer experience and
became a much more efficient computer programmer.

He has worked actively in the IT sector since his freshman year at the university.
He has been a PHP developer since then and has developed his skills in this field.

Through his increasing responsibilities, he has learned to prioritize needs and wants,
and applies this ability to his projects. He has acted as a technical reviewer for
OOP with PHP for Packt Publishing.

I would like to thank my wife, Bansari Barot, for her continued


support in all my projects and Rajashree Hamine for her constant
efforts in reminding me to review the chapters on time.
Table of Contents
Preface 1
Chapter 1: The World of AJAX and PHP 7
The big picture 8
AJAX and Web 2.0 9
Building websites since 1990 10
HTTP and HTML 10
PHP and other server-side technologies 11
JavaScript and other client-side technologies 12
What's missing? 13
The world of AJAX 14
What is AJAX made of? 16
Uses and misuses of AJAX 17
Resources and tools 19
Setting up your environment 19
Building a simple application with AJAX and PHP 20
Summary 34
Chapter 2: JavaScript and the AJAX Client 35
JavaScript and the Document Object Model 36
JavaScript events and the DOM 41
Even more DOM 46
JavaScript, DOM, and CSS 50
Using the XMLHttpRequest object 54
Creating the XMLHttpRequest object 55
JavaScript exception handling 56
Creating better objects for Internet Explorer 6 59
Initiating server requests using XMLHttpRequest 60
Handling server response 63
Table of Contents

Working with XML structures 71


Handling more errors and throwing exceptions 78
Creating XML structures 79
Summary 80
Chapter 3: Object Oriented JavaScript 81
Why is OOP in JavaScript important? 82
Object-oriented programming concepts 82
Encapsulation 83
Inheritance 84
Polymorphism 85
Object-oriented programming with JavaScript 85
JavaScript objects are dictionaries 86
JavaScript functions 88
JavaScript functions are first-class objects 89
Inner functions 91
Closures 92
JavaScript classes 93
Constructors 93
Class diagrams 95
Referencing external functions 97
Prototype objects 98
Instance methods and properties 99
Static methods and properties 100
Private members 101
The JavaScript execution context 102
var x, this.x, and x 104
Using the right context 105
JavaScript OOP in practice: Introducing JSON 107
JSON concepts 109
A simple JSON example 109
Summary 112
Chapter 4: Using PHP and MySQL on the Server 113
PHP, DOM, and XML 113
PHP and JSON 119
Passing parameters and handling PHP errors 123
Working with MySQL 134
Creating database tables 135
Manipulating data 137
Connecting to your database and executing queries 139
Summary 144

[ ii ]
Table of Contents

Chapter 5: AJAX Form Validation 145


Implementing AJAX form validation 146
XMLHttpRequest, version 2 150
AJAX form validation 159
Summary 182
Chapter 6: Debugging and Profiling AJAX Applications 183
Debugging and profiling with Internet Explorer 184
Enabling debugging in Internet Explorer 6 and 7 184
Debugging in Internet Explorer 8 186
Other Internet Explorer debugging tools 193
Debugging and profiling with Firefox 194
Firebug 195
Venkman JavaScript debugger 197
Web Developer 199
Summary 199
Chapter 7: Advanced Patterns and Techniques 201
Predictive fetching pattern 204
Progress indicator pattern 204
Unobtrusive JavaScript 205
Progressive enhancement and graceful degradation 207
Asynchronous file upload with AJAX 208
HTTP and how file upload works 208
Iframe for asynchronous file upload with AJAX 209
Cross-domain calls 216
Cross-domain calls using a server proxy 216
Cross-domain calls using Flash 216
Cross-domain calls using iframes 217
Cross-domain calls using JSONP 217
Cross-site request forgery 218
JSON hijacking 219
Mitigations of CSRF 219
Cross-site scripting 219
Exploits 220
Non-persistent XSS 220
Persistent XSS 220
Mitigations of XSS 221
Input validation 221
Escaping 221
Cookies security 222
Summary 222

[ iii ]
Table of Contents

Chapter 8: AJAX Chat with jQuery 223


Chatting using AJAX 223
jQuery 224
Before we get started 225
The first steps 225
jQuery DOM Selectors 225
jQuery wrapper object 226
Method chaining 227
Event handling 227
A simple example 228
Basic concepts 229
AJAX chat 230
The chat application 231
Summary 259
Chapter 9: AJAX Grid 261
Implementing the AJAX data grid 262
Code overview 263
The database 264
Styles and colors 265
The server side 267
Creating the grid, step by step 268
Summary 277
Appendix: Preparing Your Working Environment 279
Installing XAMPP 280
Installing XAMPP on Windows 280
Installing XAMPP on Linux 283
Preparing the AJAX database 284
Index 287

[ iv ]
Preface
AJAX is a complex phenomenon that means different things to different people.
Computer users appreciate that their favorite websites are now friendlier and feel
more responsive. Web developers learn new skills that empower them to create sleek
web applications with little effort. Indeed, everything sounds good about AJAX!

At its roots, AJAX is a mix of technologies that lets you get rid of the evil page
reload, which represents the dead time when navigating from one page to another.
Eliminating page reloads is just one step away from enabling more complex features
into websites, such as real-time data validation, drag-and-drop, and other tasks
that weren't traditionally associated with web applications. Although the AJAX
ingredients are mature (the XMLHttpRequest object, which is the heart of AJAX,
was created by Microsoft in 1999), their new role in the new wave of web trends is
very young, and we'll witness a number of changes before these technologies will be
properly used to the best benefit of the end users.

AJAX isn't, of course, the answer to all the Web's problems, as the current hype
around it may suggest. As with any other technology, AJAX can be overused, or
used the wrong way. AJAX also comes with problems of its own: you need to fight
with browser inconsistencies, AJAX-specific pages don't work on browsers without
JavaScript, they can't be easily bookmarked by users, and search engines don't
always know how to parse them. Also, not everyone likes AJAX. While some are
developing enterprise architectures using JavaScript, others prefer not to use it at all.
When the hype is over, most will probably agree that the middle way is the wisest
way to go for most scenarios.

In AJAX and PHP: Building Modern Web Applications – Second Edition, we take a
pragmatic and safe approach by teaching relevant patterns and best practices that we
think any web developer will need sooner or later. We teach you how to avoid the
common pitfalls, how to write efficient AJAX code, and how to achieve functionality
that is easy to integrate into current and future web applications, without requiring
you to rebuild the whole solution around AJAX. You'll be able to use the knowledge
you learn from this book right away, in your PHP web applications.
Preface

What this book covers


Chapter 1: The World of AJAX and PHP is all about a quick introduction to the
world of AJAX. In order to proceed with learning how to build AJAX applications,
it's important to understand why and where they are useful. It describes the
XMLHttpRequest object, which is the key element that enables the client-side
JavaScript code to call a page on the server asynchronously.

Chapter 2: JavaScript and the AJAX Client walks you through many fields such as
working with HTML, JavaScript, CSS, the DOM, XML, and XMLHttpRequest.
It discusses the theory (and practice) that you will need to know to make these
components come together smoothly, and form a solid foundation for your future
AJAX applications. It also shows you how to implement simple error-handling
techniques, and how to write code efficiently.

Chapter 3: Object Oriented JavaScript covers a large area of what object-oriented


programming means in the world of JavaScript starting from basic features and
going far into the execution context of functions. It teaches you the basic OOP
concepts—encapsulation, polymorphism, and inheritance, how to work with
JavaScript objects, functions, classes, and prototypes, how to simulate private,
instance, and static class members in JavaScript, what the JavaScript execution
context is, how to implement inheritance by using constructor functions and
prototyping, and the basics of JSON.

Chapter 4: Using PHP and MySQL on the Server starts putting the server to work, using
PHP to generate dynamic output, and MySQL to manipulate and store the backend
data. This chapter shows you how to use XML and JSON with PHP (so that you
can create server-side code that communicates with your JavaScript client), how to
implement error-handling code in your server-side PHP code, and how to work with
MySQL databases.

Chapter 5: AJAX Form Validation creates a form validation application that


implements traditional techniques with added AJAX flavor, thereby making the form
more user-friendly, responsive, and pleasing. The intention of this chapter isn't to
build the perfect validation technique but, rather, a working proof of concept that
takes care of user input and ensures its validity.

Chapter 6: Debugging and Profiling AJAX Applications teaches how to enable and use
Internet Explorer's debugging capabilities. It shows how you can work with Web
Development Helper, Developer Toolbar, and other Internet Explorer tools and with
Firefox plugins such as Firebug, Venkman JavaScript Debugger, and Web Developer.

[2]
Preface

Chapter 7: Advanced Patterns and Techniques briefly covers some of the most important
patterns and techniques covering usability, security, and techniques. Looking at
methods, patterns, and techniques is so important that it has developed into its
own science and has created a set of guidelines for typical problems that offer us
predictable results.

Chapter 8: AJAX Chat with jQuery teaches how to use AJAX to easily implement
an online chat solution. This will also be your opportunity to use one of the most
important JavaScript frameworks around—jQuery. More precisely, this chapter will
explain the basics of jQuery and show how to create a simple, yet efficient client-
server chat mechanism using AJAX.

Chapter 9: AJAX Grid explains the usage of an AJAX-enabled data grid plugin, jqGrid.

Appendix: Preparing Your Working Environment covers the installation instructions


that set up your machine for the exercises in this book. It also covers preparing the
database that is used in many examples throughout the book.

What you need for this book


To go through the examples in this book you need PHP 5, a web server, and a
database server. We have tested the code under several environments, but mostly
with the Apache 2 web server, and MySQL 4.1 and MySQL 5 databases.

You can choose, however, to use another web server, or another database product, in
which case the procedures presented in the chapters might not be 100% accurate. It
is important to have PHP 5 or newer, because we use some features, such as Object
Oriented Programming support, which aren't available in older versions.

Please read the appendix for more details about setting up your machine. If your
machine already has the required software, you still need to read the final part of
appendix, where you are instructed about creating a database that is used for the
examples in this book.

Who this book is for


This book is written for PHP developers who want to learn how to use PHP,
JavaScript, MySQL, and jQuery to implement Web 2.0 applications, are looking
for a step-by-step, example-driven AJAX tutorial, want to learn advanced AJAX
coding patterns and techniques, and want to be able to assess the security and SEO
implications of their code.

[3]
Preface

Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the
use of the include directive."

A block of code is set as follows:


// create the second <ui> element and add a text node to it
oLiOrange = document.createElement("li");
oOrange = document.createTextNode("Orange");
oLiOrange.appendChild(oOrange);

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
// create the second <ui> element and add a text node to it
oLiOrange = document.createElement("li");
oOrange = document.createTextNode("Orange");
oLiOrange.appendChild(oOrange);

Any command-line input or output is written as follows:


tar xvfz xampp-linux-X.Y.Z.tar.gz -C /opt

New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: "Now click
on the Start Debugging button. If you receive a confirmation window like that in the
following screenshot, click on OK".

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

[4]
Exploring the Variety of Random
Documents with Different Content
The removal of the Jesuits was so far beneficial, that on the 14th
March, a Statute was issued which appeared to us to regard our
necessities, and to give evidence of your surpassing liberality. It was
read with avidity, and we asked ourselves if the government had
really become constitutional. Many reports were spread. The more
credulous were transported with extravagant enthusiastic delight;
the more sagacious, before they gave way to hope, required time, to
see the fulfilment of the promise; long, and sad experience had
taught them to distrust the specious professions of a pope. With
sincerity and right feeling you might have conducted us to a
Republic, but such was not accordant to your character nor to the
innate genius of your caste. A republic to be proclaimed by a pope in
his own States, would be as impossible as for the devil to turn
Christian. You were right, therefore, to exclaim against those who, to
tell you what they had fondly dreamed, broke in upon your
slumbers, with so little ceremony. You too have had your dream,
conjured up through an association of ideas very different from
theirs, which you have confided not to their ears alone, but to the
hearing of the public at large, when you state that the Republic they
wished for "had no other object in view than perpetual agitation, the
removal of every principle of justice, virtue, honour, and religion; and
to introduce and spread abroad on every side, with loss and ruin to
all human society, the fatal and horrible system of Socialism,
contrary to all natural right and reason."
This was an ugly dream, and, doubtless, arose from a diseased
imagination. But that was no dream which you have since related to
us with such satisfaction, how you had, to our injury, opposed the
Italian cause, secretly at first, and afterwards more openly. Our
youth who flew to arms in the righteous cause, assured you of their
intention to seek the sanguinary Croat, where the battle raged the
fiercest. And you feigned to approve of their holy design, blessing
their banners, and auguring from heaven itself auspicious omens for
their victory. Was it not you who expressed to Charles Albert your
grief that you could not assist him as you wished? And when was it
that Rome discovered your real intentions, and your secret orders
not to pass the confines, if not when they heard from your own lips
your celebrated Allocution of the 29th April, 1848? Bitter
remembrance of an act that destroyed all the hopes of a people, at
that time, devoted to you! It is evident, then, that your love for the
Italian cause, and all your speeches and professions, were priestly
and royal deception. And you dare bring to our recollection those
times in the past and the present year; when, in the former, you
abhorred to shed the blood of the Croat, and in the latter you
thirsted for that of the Romans!
On the 29th of April last, the army of Louis Buonaparte displayed
itself beneath the walls of Rome, with a direful train of artillery, of
cannon and of bombs, to slaughter in your name all those Romans
who should maintain that you, a Christian prelate, ought not to
govern them as king. A fatal day was that for Rome; the most
disastrous in our annals; the most disgraceful to the Papacy!
Since matters are in this state, strike out from your Allocution
words that you have no right to utter: "that you, elevated, although
most unworthily," (most true,) "through the inscrutable decree of
Divine Providence, to the summit of apostolic dignity, to exercise
upon earth the office of Vicar to Jesus Christ," (a false and
blasphemous assertion,) "you receive from God, the fountain of
Charity and Love, your mission to regard with paternal affection, all
mankind, of whatever country or race, to watch over and to promote
their safety, and not to impel them to slaughter and to death." That
these words are false is evident from your own confession that you
have yourself brought and impelled against us, in fratricidal war,
Austria, France, Spain, and a portion of Italy.
To whom are to be attributed the slaughters at Bologna, at
Ancona, and beneath the walls at Rome? You were averse to a just
war, for the safety of Italy; not so to that most unjust one which had
for its object the replacing of yourself, the most abhorred of
sovereigns, upon a throne which you had yourself deserted, and
from which, "through the inscrutable decree of Divine Providence,"
rather than through any effort of ours, you had been removed.
Who will pardon your mis-statement of facts, your outrage upon
individuals? Language has no words more abusive or scornful than
those you have employed against us, who, you assert, are guilty of
the heavy offence of despoiling you of your territory, and that, too,
after having constrained you in so many ways to grant a reform
which was true, stable, and conformable to our wants. But it is not
the empty name of a republic that satisfies us; it is a wise, a
provident, and a just government, that we require. Call our present
one what you will; it is that which we have always wished for, and to
which we have a just right. It is one which we endeavoured to urge
upon you, because the Papal Government removed you too far from
us. Some who fancied you a wise and considerate prince, believed
your influence might be beneficial, and without delay proposed that
you should rule the destinies of Italy. You, however, it appears,
considered this proposition as extremely insulting. In fact, it was not
from a pope that Italy could hope for her redemption. The popes, at
the head even of a republic, would have finished by subjecting the
whole of the country, as they did at Rome, where the Church
became the incubus of the State, although at one time denominated
a republic,—Sancta Dei Ecclesia et Respublica Romanorum.
This attempt, then, having been made as a last proof of devotion
towards your person, it was inevitably forced upon our conviction
that no other hope remained for us than what might arise from the
separation of the priestly and royal functions. The Church was to be
the sole empire for the priests; Rome and Italy would together
arrange a form of government for themselves. But this simple act,
full of justice and moderation, you stigmatise as the fruit of "the
most unbridled licentiousness, audacity, and depravity," and they
who are actuated by love for their country and mankind are
stigmatised by you as "enemies both of God and man." ...
How entirely has the spirit of falsehood possessed you! When
have "the streets" as you say, "been sprinkled with human blood?"
when have "the most deplorable sacrileges taken place, and the
most outrageous violence been offered to your person in your own
house?" What infamy for the Head of our Church to be guilty of such
scandalous untruths! You declare also that "traitors, infuriated, and
threatening, indulged in all sorts of deceit and violence to terrify the
good, already sufficiently intimidated." We ask you, Who were these
traitors, and when were these intimidations employed? All the world
knows that you were not yourself more legally chosen pope, than
the Constituent Government was authorized by the whole of the
Roman people, in fair and unbiassed freedom of election....
The love of empire, that sways the base and ignoble mind, is more
present with you than the love of the people or a regard for
humanity. It is in vain you endeavour to hide it; nevertheless, it is
ridiculous in our days to talk of a temporal throne in the apostolic
seat, in the Holy Roman Church. The Apostles possessed none, and
could consequently give no right to inherit any. The words of our
Divine Master are moreover in direct opposition to such possession,
enjoining them to arrogate to themselves no titles of authority.
"After these things do the Gentiles seek;" "but be ye not like them;"
and many more passages might be adduced to the same effect....
If, however, it be alleged that our progenitors gave to the High-
Priest of Rome the office of governor, we, by the same right, have
power to take it away. In like manner, the sister Churches of France,
Austria, and Spain, may, if they choose, make either a king, an
emperor, or a president, of their chief-priest. We have no right to
object to their doing so, and all we ask in return is that they should
not trouble their heads about us.
Your dethronement was occasioned by your ill-government and
oppression, in which you followed the example of other despots; and
moreover, you did so in the name of St. Peter, and even of Christ.
And all the temporal power and trust you placed in the hands of the
clergy, a measure injurious alike to the interests of the Church and
of the people. The most talented were employed in the service of
the State, the most ignorant in that of the Church; the former were
active and rapacious in acquiring wealth, and the latter supine and
superstitious in the duties of their calling; the one party rolling in
luxury, and the other poor and needy, so that by degrees they began
mutually to hate each other.
This monstrous union of Church and State has thus gone on until
the present period. Profane and sacred things have been so jumbled
together that good sense and right feeling with respect to them have
altogether been lost. The progress of civilization on every side
except among ourselves, rendered our situation still less endurable,
so that among all classes the two powers were held in slight and
derision. In proportion as they ceased to love the prince they began
to despise the priest. By the one the laws were transgressed, by the
other the offices of religion neglected. The sovereign laid his snares,
and the priest through his negligence brought the Church into
discredit. Meanwhile, the obstinacy of the popes, to keep the two
powers united in their own person, threatened them not only with
the loss of the State, but of the Church also. It was, therefore, a
kindliness towards yourself, and a love for religion, that induced us
to decree, that in order to guarantee the Roman pontiff in the free
exercise of his spiritual power he should no longer wield the
temporal sceptre. It is necessary when the whole body is threatened
with gangrene to cut off the morbid portion....
We ardently desire to see established the religion of Christ, as holy
and saving, and this, we conceive, may exist without bishops or
priests;—the invisible and universal Church, which includes believers
in all parts of the world; of which Christ alone is high-priest and
Head. And this invisible Church does not do away with a visible and
material one, which is divided among all people and nations, and of
which every one has a right to choose that form which appears to
him the best. Many of these Churches have no bishops, as the
German, the Scotch, the Helvetic, and the evangelical Churches of
France and Italy. Who is the bishop of the Church of the Waldenses?
No one. And yet it is full of zeal, has existed from the eleventh
century, and after so many fierce persecutions and massacres still
presents a body of twenty-four thousand believers.
It is possible, then, to be good Christians, and to form a visible
national Church on such a model without the aid of bishops. At any
rate, you cannot deny that a Church can change its bishop for a
sufficient cause. Do you think it then absurd or contrary to the
precepts of the gospel that the people of Rome, who may be termed
the whole Romish Church, should repudiate you as an apostate-
bishop, a traitor, a bombarder, and that they should elect another,
faithful, true, and beneficent?
Those who were asleep have now awakened, and they no longer
trust your words. When you went out from Rome, the Bible entered
in; the Bible, persecuted by the popes! and the gospel of Christ and
the holy writings of the Apostles, faithfully translated into the Italian
language, are now in the hands of the people, who read them, and
find there neither popery nor the pope.
Take care that it does not happen to yourself in Italy, as it
happened to your predecessors out of it, who, desirous to obtain
more, lost all. They who last February took from you the temporal
power, intended by so doing to guarantee and ameliorate your
spiritual authority. From the 30th April to the present period, you
have rejected every friendly advance, and violated every law in
presenting yourself before the walls of Rome, surrounded by
bayonets and cannon; and you announced to this city your return
and your solemn entry with bomb-shells and incendiary acts among
the wounded and the dying. Is this the entry of a bishop? Is it in
such a manner that the pretended Vicar of Jesus Christ returns to his
people?...
Let us suppose, by way of argument, that you, environed by
thousands of bayonets, should effect your return to a city
overpowered by foreign violence, what would you find at Rome?—a
people capable of loving you and serving you as formerly? No,
indeed; you would find a desert. The city which has abhorred you as
a prince, and through you has learned to despise the whole race
from which the popes have descended, is no longer disposed to
receive your laws, to pay you tribute. Over whom do you expect to
reign? Over the few who followed you to Gaëta? or those who here
and there have remained favourable to the old system? Even of
these there are none that really love you; it is to the system, and not
to yourself personally, that they are attached....
It is in vain you exaggerate the disorders of our government, and
in disgraceful language descend to the lowest scurrilities, calling
Rome "a den of furious beasts" and those who dwell there
"apostates, heretics, communists, and socialists—bent on
disseminating their pestiferous doctrines, and corrupting every heart,
and possessed with a daring and sacrilegious desire of seizing upon
the property and revenues of the Church." If this property and these
revenues belong, as you say, to the Church, then we have done no
other than restore them to their rightful owner, rescuing them from
the hands of lawless spoilers. The people constitute the Church; the
property of the Church then is the property of the people. And the
priests and bishops, considered as servants to the Church, are to be
maintained by the people. By divine command the tribe of Levi was
supported by the other tribes. Christ also directs that the ministers
of his Gospel are to be maintained by the faithful, when he says, "for
the labourer is worthy of his hire." This was the practice in the early
times of Christianity, and to them we must return. If our former
ministers are content to return to the Church under this new
arrangement, we are willing once more to receive them; otherwise,
we must look out for servants who will be more zealous for heavenly
riches, and less greedy after the wealth of this world.
Is it because these doctrines have been established for more than
eighteen centuries, and are based on the Gospel and the writings of
the Apostles, that you call those who profess them apostates and
heretics?
We have "despoiled the temples of their ornaments!" That is, we
have taken their superfluous silver to coin into money, to supply the
place of that which you and yours have concealed or carried away.
We have "turned religious houses to profane uses!" Yes; some of the
haunts of the lazy and the worthless we have given as habitations
for the industrious poor, who live as God has commanded them to
do, by the sweat of their brow. In the eyes of those to whom
idleness is sacred and labour profane, we have certainly committed a
crime, but for us heretics and apostates, we imagine we have done a
holy work.
We have ill treated "the sacred virgins!" The chronicle does not
say so. They have never been more safe and more respected than
by ourselves and our government. Who it was that ill treated the
sacred virgins under your own government, is well known to you,
without our taking the trouble to repeat it. Pay a little more regard
to truth, and be silent on these matters, unless you wish us to reveal
what for the sake of charity we do not mention.
We have "most cruelly persecuted, imprisoned, and put to death
the most worthy and excellent ecclesiastics and holy monks;
venerable and esteemed bishops, even such as were elevated to the
degree of Cardinal, we have barbarously driven from their flocks,
and thrust into prison!" You accuse us of what, for reasons of state,
we ought to have done, but which, through too great consideration,
we abstained from doing. All wicked and insidious traitors, spies and
conspirators, whether priests, monks, bishops, or cardinals, who
sought to bring ruin upon the people, we ought undoubtedly to have
hanged, in reward for their infamy. That we did not do so was,
perhaps, through an overweening regard for their persons. Pope
Gregory, and his cardinal, Lambruschini, on the slightest suspicion of
liberalism, tore from the bosom of their families citizens far more
useful and respectable than these priests and monks, consigned
them to horrible dungeons, or after a mock trial, handed them over
to the public executioner. All the vengeance we took, was, on the
commencement of our revolution, to pardon all those accursed
wretches who did not die with Pope Gregory; and our government
calmed the fury of the populace, who, on account of their crimes,
were eager for their destruction. It was a grief to us when some of
those who had received pardon at our hands again sought to irritate
the people, who then knew themselves to be masters. Certain death
would have been their fate had not our government shut them up in
confinement.
Certainly, when any one was taken with arms in his hands, and
firing upon our people, as the curate of Monte Mario, the priest
Racchetti, and another or two were, the people conceived they had
a perfect right to take the law into their own hands, and get rid of
their enemies, without writing to you to ask leave to do so. You may
thank Providence that our people are so mild and so obedient to
their governors as they are, or you would have had some of your
monasteries visited, and the ribald monks turned out to pay you a
visit at Gäeta. In the provinces likewise, every here and there, a
band of factious insurgents roamed about, headed by a priest or a
monk, and protected by a bishop or a cardinal. Was it not an
unheard-of act of mercy to spare the lives of such wretches? And is
it on account of such acts that you complain of the Republican
government?
We felt an extreme repugnance, which the government of the
priests never felt, to shed the blood of the citizens, considering them
not in the light of subjects, but as brethren. And we grieve that all
do not share with us in these fraternal feelings.
As to the exhausted treasury, to whom was it owing, if not to
yourselves? We, on the contrary, in a short space of time, restored
the finances, and put the administration of them into the best
possible order. Who paralysed the exertions of commerce, and with
unjust laws and enormous duties forced all the capital of the
provinces to the seat of government? Who, on the other hand,
reformed the laws, reduced the duties, and gave encouragement to
commerce, if not the Republic? Certainly, commerce greatly suffered,
and still continues to do so, in consequence of the siege and
bombardment, by your favourites, of Bologna, Ancona, and Rome.
What falsehoods you state with respect to "heavy contributions
imposed upon the nobility, property plundered from individuals!"
Many of the nobility never contributed a single farthing, whilst many,
not noble, paid large sums into the treasury. Is it not yourselves who
teach that the superfluity of the rich is the patrimony of the poor?
But who was ever plundered by us? Can you bring a single example
to justify your assertion? If not, we have a right to stigmatize you as
a calumniator. Neither can you bring any proof of your other most
injurious assertion, that we "interfered with the personal liberty of all
good people, destroying their peace, and even threatening their very
lives with the dagger of the assassin." The audacious nature of this
falsehood is apparent. Have we not abundant testimony of the good
character and conduct of our government, from persons of every
nation, from the representatives of foreign powers, who are ready to
certify that none of these excesses were ever perpetrated under the
Roman Republic? How frequently they took place under the
government of the popes, I need not relate; how many innocent
individuals were torn from the bosom of their families, how many
lives sacrificed, it were painful to disclose. The reign of the late
Gregory furnished numberless examples, and your own reign, too, is
not without its share in these enormities.
Let us now advert to that glorious confession of yours, of having
sought from foreign powers an armed intervention to replace you on
that throne from which you were removed more through your own
weakness and folly than through any act of ours: and which you
have had the simplicity to publish, in order, as it seems, that history
may hand down to posterity this last ignominy of the papacy. Four
foreign armies were invited to Rome to place the last of the popes
upon a throne which is renowned for having the early pages in its
history marked by fraud and usurpation; the succeeding ones by
extortions, deceits, civil wars, the barbarities of the Croats, and the
horrors of the Inquisition; and the last with the destruction of liberty,
with parricide, and the bombardment of Rome, the great act on
which you pride yourself. Do you, then, imagine it possible that you
can return to fill a throne, so abhorred by Rome, and by all Italy? It
is only possible through the support of foreign armies, bayonets,
cannon, and all warlike means! It is only to be effected by the
shedding of blood, and slaughter of thousands sacrificed to
sacerdotal fury and ambition! Can you return to Rome to hear the
cries of mothers, deprived by you of their dearest hopes, of widows
whose husbands have been slain through your agency? And in the
midst of such universal grief will you return smiling and joyful? How
long, John Mastai, will you continue to insult our country, and how
long is she to endure your presence? The presence of one who has
allied himself with kings to betray the people, who united in
friendship with the Bourbon of Naples, in order to devise the best
means of oppressing every generous mind, of eradicating from the
sons of Italy every noble sentiment! O insensate men that we were,
to believe you, to trust in your deceitful promises, to the
disappointment of your hopes, to the ruin of our happiness! Do you
not believe that the Almighty is the judge of our cause; that he is
powerful to abase the rich and the proud, and to exalt the poor and
the oppressed? If you make an appeal to the canonical laws, we
refer to those of the Gospel.
Christ has taught us to bless those who curse us, to do good to
those who hate us, and to pray for those who despitefully use us
and persecute us. But you begin to curse those who have always
blessed you, to hate those who have done good to you, and to
persecute those who have prayed for you. You who alone could have
preserved the country, and have restored what was lost, joined
yourself to our enemies to ruin and destroy us.
And you dare to call yourself the Vicar of Christ! Is Christ then
divided? is there a Christ opposed to the gospel? If so, you doubtless
are his Vicar, and we have nothing more in common with you;
neither the country which you have betrayed, nor the faith which
you have denied. Keep possession of your Church; it is no longer
ours: and enjoy your kingdom, since we are no longer your subjects.
Go where your wishes lead you; but dare not again to place foot in a
city which accuses, judges, and condemns you. Who could endure to
raise their eyes to encounter those of a traitor? Who could receive a
benediction from a hand yet stained with blood? No one, indeed,
could consent to enter the temple with a hypocrite, who at the very
time he was planning by the basest means to wreak upon us his
cruel vengeance with fire and slaughter, had the assurance to give
breath to the following words, which, to undeceive the present and
to warn the future generation, not without a sensation of extreme
horror and disgust, we venture to repeat;—
"Lastly, venerable brethren, resigning ourselves entirely to the
inscrutable decrees of the wisdom of God, with which he operates
his glory, while in the humility of our heart we render Him infinite
thanks for having made us worthy of so great suffering for the name
of Jesus, and for having rendered us, in a degree, similar to Himself
in His passion, we are ready in faith, hope, patience, and in
gentleness, to suffer the most severe pains and trials, and, for the
sake of the Church, to give even our very life, if by the shedding of
our blood her calamities could be remedied."
Such impudence of declamation amid such atrocious deeds, for
ever closes the page whereon, in characters of blood, is registered
the perpetual downfall of the Roman Pontificate.

FINIS.
R. CLAY, PRINTER, BREAD
STREET HILL.
FOOTNOTES:
[125] Jer. xxiii.

[126] Unhappily, this prediction has not been verified.


New Edition, in fcap. 8vo. cloth, price 6s.
LECTURES FOR THE TIMES:
OR,
ILLUSTRATIONS AND REFUTATIONS
OF
THE ERRORS OF ROMANISM AND TRACTARIANISM.
BY THE
REV. JOHN CUMMING, D.D.

CONTENTS.

1. The Teaching of Cardinal Wiseman.


2. Cardinal Wiseman: "his Oath and its Obligations." Two Lectures delivered in the Hanover
Square Rooms, in November 1850.
3. What is Popery?
4. Is Tractarianism Popery?
5. Romish Plausible Pretensions.
6. Apostolical Succession.
7. The Unity of the Church.
8. The Fathers.
9. The Nicene Creed.
10. The Bible, not Tradition.
11. The Invocation of Saints.
12. Transubstantiation.
13. The Sacrifice of the Mass.
14. Purgatory.

NOTICES OF THE WORK.

"In these Lectures Dr. Cumming gives the fullest scope to all his high powers. Careful
research, acute argument, brilliant illustration, graphic description, eloquent appeal, all
unite in enriching and embellishing his pages, alluring the most indifferent to read, and
compelling the most prejudiced against his views to pause and consider."—Edinburgh
Ecclesiastical Review.
"Dr. Cumming exhibits an extensive knowledge of the subject, great powers of
reasoning, and a wish to proceed to a right conclusion. The volume is both interesting and
instructive, and it unquestionably deals with matters of the highest importance, in which
all mankind are deeply and permanently interested."—Newcastle Courant.
"These Lectures embrace the most prominent errors of Romanism; and we need not
add that the subjects are discussed with ability, and the victory over Popish
misrepresentation complete."—Edinburgh Advertiser.
"Happy specimens of eloquence. It meets most of the difficulties suggested by
Romanists and sceptics, and may be regarded as a suitable work to be placed in the
hands of those who are wavering on the brink of error, and will be hailed as such by all
lovers of Protestant truth."—Kitto's Journal.

ARTHUR HALL, VIRTUE & CO. 25, PATERNOSTER ROW.


Transcriber's Note.
Variable spelling and hyphenation have been retained. Minor punctuation inconsistencies
have been silently corrected.
Two instances of unpaired double quotation marks could not be corrected.

Corrections:

The first line indicates the original, the second the correction.
p. 17:

to maintain such a sytsem,


to maintain such a system,

p. 55:

no compassion fom the servants of God


no compassion from the servants of God

p. 61:

with a little more secresy


with a little more secrecy

p. 64:

to ask of her her name,


to ask of her name,

p. 71:

in saving my honour and my consience


in saving my honour and my conscience

p. 85:

owed its origin to Guiseppe Calassanzio.


owed its origin to Giuseppe Calassanzio.

p. 94:

what part her enemy asailed her.


what part her enemy assailed her.

p. 130:

from the bishop, the Prelator Governatore,


from the bishop, the Prelato Governatore,

p. 131:

The Cardinal Camberini, to whom


The Cardinal Gamberini, to whom

p. 140:

and the most perfect familarity


and the most perfect familiarity

p. 185:

the popish sanhedrim


the popish sanhedrin

p. 190:

"No, my friend," repled Parchetti


"No, my friend," replied Parchetti

p. 234:

that you will acknowlege


that you will acknowledge

alone to the the see of the Ionian Islands


alone to the see of the Ionian Islands

p. 280

are not subject to ths pains


are not subject to the pains

p. 366:

But are you not aware that it it is


But are you not aware that it is

p. 387:

what do we see around us? Infifidelity


what do we see around us? Infidelity

p. 394:

public buring of fifty thousand Moors


public burning of fifty thousand Moors

p. 400:

every hour they recal to your mind


every hour they recall to your mind

p. 421:

the perpetual downfal of the Roman Pontificate.


the perpetual downfall of the Roman Pontificate.

p. 422:

and compelling the most prejudiced againt his views


and compelling the most prejudiced against his views
*** END OF THE PROJECT GUTENBERG EBOOK DEALINGS WITH
THE INQUISITION; OR, PAPAL ROME, HER PRIESTS, AND HER
JESUITS ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like