define('TUVAL', '1'); require 'app/lib/init.php'; ini_set('max_execution_time', 0); // unlimited execution time, because of large amount of comments ini_set('memory_limit', '2048M'); $file = 'disqus.xml'; $doc = new DOMDocument(); $doc->load($file); $thread_list = array(); $threads = $doc->getElementsByTagName('thread'); foreach($threads as $thread) { if (!isset($thread->getElementsByTagName('link')->item(0)->textContent)) continue; $comment = array(); $comment['thread_id'] = $thread->getAttribute('dsq:id'); $comment['url'] = $thread->getElementsByTagName('link')->item(0)->textContent; $path = parse_url($comment['url'], PHP_URL_PATH); $path = preg_replace("/(/){2,}/", "/", $path); // remove multiple slashes $thread_list[$comment['thread_id']] = $comment; } $post_list = array(); $posts = $doc->getElementsByTagName('post'); foreach($posts as $post) { $comment = array(); $comment['comment_id'] = $post->getAttribute('dsq:id'); $comment['thread_id'] = $post->getElementsByTagName('thread')->item(0)->getAttribute('dsq:id'); $comment['comment'] = $post->getElementsByTagName('message')->item(0)->nodeValue; $comment['created_at'] = $post->getElementsByTagName('createdAt')->item(0)->nodeValue; $comment['email'] = $post->getElementsByTagName('author')->item(0)->getElementsByTagName('email')->item(0)->nodeValue; $comment['name'] = $post->getElementsByTagName('author')->item(0)->getElementsByTagName('name')->item(0)->nodeValue; $comment['isDeleted'] = $post->getElementsByTagName('isDeleted')->item(0)->nodeValue; $comment['ipAddress'] = $post->getElementsByTagName('ipAddress')->item(0)->nodeValue; $comment['url'] = $thread_list[$comment['thread_id']]['url']; print_r($comment); $record = array( 'comment_content' => 1, 'comment_author' => $comment['name'], 'comment_email' => $comment['email'], 'comment_text' => n2br($comment['comment']), 'comment_ip' => $comment['ipAddress'], 'create_time' => $comment['created_at'], 'comment_status' => 2, 'isDeleted' => $comment['isDeleted'], 'comment_url' => $comment['url'], ); $rs = $conn->AutoExecute(T_COMMENTS, $record, 'INSERT'); if($rs == false) { throw new Exception($conn->ErrorMsg()); } //döngü ile burdaki dataları veritabanına alacağız }