<?php
{
include_once __DIR__ . '/defines.php' ;
}
{
define ( 'JPATH_BASE' , __DIR__
) ; require_once JPATH_BASE . '/includes/defines.php' ;
}
require_once JPATH_BASE . '/includes/framework.php' ;
require_once JPATH_BASE . '/libraries/joomla/factory.php' ;
$db = JFactory:: getDbo ( ) ;
$query = $db -> getQuery ( true ) ;
$qr_result = $db -> setQuery ( 'SELECT * FROM ' . $db -> quoteName ( '#__content' ) . ' WHERE 1' ) ;
$list = $db -> loadObjectList ( ) ;
for ( $i = 0 ; $i < count ( $list ) ; $i ++ ) {
$title = $list [ $i ] -> title ;
$fulltext = $list [ $i ] -> fulltext ;
$dom = new DOMDocument( '1.0' , 'UTF-8' ) ;
$doc -> preserveWhiteSpace = false ;
if ( $fulltext != "" ) {
}
$items = $dom -> getElementsByTagName ( "img" ) ;
foreach ( $items as $img ) {
if ( $img -> getAttribute ( 'alt' ) == "" ) {
$img -> setAttribute ( 'alt' , $title ) ;
}
if ( $img -> getAttribute ( 'title' ) == "" ) {
$img -> setAttribute ( 'title' , $title ) ;
}
}
$res = $dom -> saveHTML ( $dom -> documentElement ) ;
$res = preg_replace ( '~<(?:!DOCTYPE|/?(?:html|head|meta|body))[^>]*>\s*~i' , '' , $res ) ;
$qr_result = $db -> setQuery (
'UPDATE ' . $db -> quoteName ( '#__content' ) .
' SET ' . $db -> quoteName ( 'fulltext' ) . ' = ' . $db -> quote ( $res ) .
' WHERE ' . $db -> quoteName ( 'title' ) . ' = ' . $db -> quote ( $title ) ) ;
$result = $db -> query ( ) ;
}
PD9waHAKCm1iX2ludGVybmFsX2VuY29kaW5nKCJVVEYtOCIpOwoKZGVmaW5lKCdfSkVYRUMnLCAxKTsKCmlmIChmaWxlX2V4aXN0cyhfX0RJUl9fIC4gJy9kZWZpbmVzLnBocCcpKQp7CiAgaW5jbHVkZV9vbmNlIF9fRElSX18gLiAnL2RlZmluZXMucGhwJzsKfQoKaWYgKCFkZWZpbmVkKCdfSkRFRklORVMnKSkKewogIGRlZmluZ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