<?xml version="1.0" encoding="us-ascii"?><InstanceReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Version>2.4.0.8</Version><ReportLongName>0010 - Disclosure - 4. COMMITMENTS AND CONTINGENCIES</ReportLongName><DisplayLabelColumn>true</DisplayLabelColumn><ShowElementNames>false</ShowElementNames><RoundingOption /><HasEmbeddedReports>false</HasEmbeddedReports><Columns><Column FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><CurrencyCode /><FootnoteIndexer /><hasSegments>false</hasSegments><hasScenarios>false</hasScenarios><MCU><KeyName /><CurrencySymbol /><contextRef><ContextID>From2013-01-01to2013-06-30</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001113513</EntityValue><PeriodDisplayName /><PeriodType>duration</PeriodType><PeriodStartDate>2013-01-01T00:00:00</PeriodStartDate><PeriodEndDate>2013-06-30T00:00:00</PeriodEndDate><Segments /><Scenarios /></contextRef><UPS /><CurrencyCode /><OriginalCurrencyCode /></MCU><CurrencySymbol /><Labels><Label Key="CalendarSupplement" Id="0" Label="6 Months Ended" /><Label Key="Calendar" Id="1" Label="Jun. 30, 2013" /></Labels></Column></Columns><Rows><Row FlagID="0"><Id>1</Id><IsAbstractGroupTitle>true</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>1</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureAbstract</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText /><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>xbrli:stringItemType</ElementDataType><SimpleDataType>string</SimpleDataType><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments and Contingencies Disclosure [Abstract]</Label></Row><Row FlagID="0"><Id>2</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>2</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureTextBlock</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="From2013-01-01to2013-06-30" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;&lt;b&gt;4. COMMITMENTS AND CONTINGENCIES&lt;/b&gt;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;&lt;b&gt;&lt;i&gt;Aggregate future lease commitments&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;The Company leases computers, office equipment and office furniture
under capital lease agreements that expire through August 2019. Total amounts financed under these capital leases were $141,375
and $150,072 at June 30, 2013 and December 31, 2012, respectively. These obligations are included within the Company's total debt.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;The Company rents its office space pursuant to a lease that expires
on November 15, 2013. Current monthly rent is $15,780. The Company is currently evaluating lease renewal and relocation options.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;&lt;b&gt;&lt;i&gt;Legal Proceedings&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;The Company may be subject to legal proceedings and litigation arising
in the ordinary course of business, including, but not limited to, certain pending patent and privacy matters, including class
action lawsuits, as well as inquiries, investigations, audits and other regulatory proceedings.&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;The Company will record a liability when it believes that it is both
probable that a loss has been incurred and the amount can be reasonably estimated.&amp;#160;The Company periodically evaluates developments
in its legal matters that could affect the amount of liability that it has previously accrued, if any, and makes adjustments as
appropriate.&amp;#160;Significant judgment is required to determine both the likelihood of there being, and the estimated amount of,
a loss related to such matters, and the Company's judgment may be incorrect. The outcome of any proceeding is not determinable
in advance. Until the final resolution of any such matters that the Company may be required to accrue for, there may be an exposure
to loss in excess of the amount accrued, and such amounts could be material.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-align: center; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;On June 18, 2010, the Company entered into a Stipulation and Agreement
of Settlement (the &amp;#34;Stipulation&amp;#34;) with the lead plaintiff in the securities class action involving the Company in the
case captioned&amp;#160;&lt;i&gt;Mary Jane Beauregard vs. Smart Online, Inc., et al.&lt;/i&gt;, filed in the District Court (the &amp;#34;Class Action&amp;#34;).&amp;#160;The
Stipulation provides for the settlement of the Class Action on the terms described below. The District Court issued an order preliminarily
approving the settlement on January 13, 2011. The final settlement hearing was held on May 11, 2011. As of the date of this report,
the 1,475,000 shares of Common Stock had not been issued and, according to GAAP, the Company now carries the obligation as a financial
instrument on its balance sheet.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;The Stipulation provides for the certification of a class consisting
of all persons who purchased the Company's publicly traded securities between May 2, 2005 and September 28, 2007, inclusive. As
per the terms of the Stipulation, the settlement class has received total consideration of a cash payment of $350,000 made by the
Company, and a cash payment of $112,500 made by Maxim Group. In addition, Henry Nouri is required to transfer 25,000 shares of
Company Common Stock&amp;#160;to the settlement class and the Company is required to issue 1,475,000 shares of Company Common Stock
to the class. Under the terms of the Stipulation, counsel for the settlement class may sell some or all of the Common Stock received
in the settlement before distribution to the class, subject to the limitation that it cannot sell more than 10,000 shares in one
day or 50,000 shares in 30 calendar days. Subject to the terms of the Stipulation, we paid the lead plaintiff $75,000 on July 14,
2010, $100,000 on September 15, 2010, $100,000 on December 14, 2010 and $75,000 on March 14, 2011. On July 1, 2011, the District
Court issued the Final Judgment and Order of Partial Dismissal with Prejudice in the Class Action case. The Court approved the
Stipulation and directed the terms of how the Stipulation should be consummated&lt;b&gt;. &lt;/b&gt;On July 1, 2011, we recorded the Class
Action obligation as a financial instrument liability.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0"&gt;On January 13, 2011 (the &amp;#34;Effective Date&amp;#34;), the District
Court&amp;#160;issued the Order Preliminarily Approving Settlement and Providing Notice. Based upon the Settlement Agreement and the
January 13, 2011 District Court Order Preliminarily Approving Settlement and Providing Notice, we paid for the benefit of&amp;#160;the
Dennis Michael Nouri, Reza Eric Nouri, Henry Nouri and Ronna Loprete Nouri, collectively, the Nouri Parties, a total of $1,332,773
between January 2011 and February 2012. The Company was ordered by a court of proper jurisdiction to withhold $67,227 for future
payment of adjudicated debt owed by the Nouri Parties'.&amp;#160;Under the terms of the Settlement Agreement, to the extent the Nouri
Parties' legal costs are less than $300,000, the Company is owed the difference. The Settlement Agreement also provides for the
exchange of mutual releases by the parties.&lt;/p&gt;

&lt;p style="font: 8pt Times New Roman, Times, Serif; margin: 0; text-indent: 0.5in"&gt;&amp;#160;&lt;/p&gt;</NonNumbericText><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>nonnum:textBlockItemType</ElementDataType><SimpleDataType>na</SimpleDataType><ElementDefenition>The entire disclosure for commitments and contingencies.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 210

 -SubTopic 10

 -Section S99

 -Paragraph 1

 -Subparagraph (SX 210.5-02.25)

 -URI http://asc.fasb.org/extlink&amp;oid=6877327&amp;loc=d3e13212-122682



Reference 2: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 825

 -SubTopic 20

 -Section 50

 -Paragraph 1

 -URI http://asc.fasb.org/extlink&amp;oid=6449706&amp;loc=d3e16207-108621



Reference 3: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 460

 -SubTopic 10

 -Section 50

 -Paragraph 8

 -URI http://asc.fasb.org/extlink&amp;oid=6398077&amp;loc=d3e12565-110249



Reference 4: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 450

 -SubTopic 20

 -Section 50

 -Paragraph 4

 -URI http://asc.fasb.org/extlink&amp;oid=25496072&amp;loc=d3e14435-108349



Reference 5: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 440

 -SubTopic 10

 -Section 50

 -Paragraph 2

 -URI http://asc.fasb.org/extlink&amp;oid=6394976&amp;loc=d3e25287-109308



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>4. COMMITMENTS AND CONTINGENCIES</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>4. COMMITMENTS AND CONTINGENCIES</ReportName><MonetaryRoundingLevel>UnKnown</MonetaryRoundingLevel><SharesRoundingLevel>UnKnown</SharesRoundingLevel><PerShareRoundingLevel>UnKnown</PerShareRoundingLevel><ExchangeRateRoundingLevel>UnKnown</ExchangeRateRoundingLevel><HasCustomUnits>true</HasCustomUnits><IsEmbedReport>false</IsEmbedReport><IsMultiCurrency>false</IsMultiCurrency><ReportType>Sheet</ReportType><RoleURI>http://smartonline.com/role/CommitmentsAndContingencies</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>2</NumberOfRows></InstanceReport>
