<?php include dirname(__FILE__) . "/config.php"; include dirname(__FILE__) . "/notorm/NotORM.php"; $connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']); $software = new NotORM($connection); $sonnets = $software->sonnets(); ?> <html> <head> <title> غزلیات حافظ </title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link rel="publisher" href="https://plus.google.com/100862670780242731884"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://hafez.apps.rastasoft.ir/rss.php" /> <link rel="index" title="Hafez" href="http://hafez.apps.rastasoft.ir/list.php" /> <link rel="alternate" href="http://hafez.apps.rastasoft.ir" hreflang="fa-ir" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" > <!-- Bootstrap core CSS --> <link href="dist/css/bootstrap.min.css" rel="stylesheet"> <link href="assets/css/style.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body>
<?php include dirname(__FILE__) . "/config.php"; include dirname(__FILE__) . "/notorm/NotORM.php"; $connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']); $software = new NotORM($connection); $sid = (int) $_GET['sid']; $url = "http://www.1doost.com/hafez/phrase/{$sid}.htm"; $html = file_get_contents($url); libxml_use_internal_errors(true); // Yeah if you are so worried about using @ with warnings $doc = new DomDocument(); $doc->loadHTML($html); $xpath = new DOMXPath($doc); $verses = $xpath->query('//*/div[@class="hfzpsBoxHolder"]/div'); $number = 1; foreach ($verses as $verse) { $parts = $verse->getElementsByTagName('div'); $hemistich_first = $parts->item(0)->nodeValue; $hemistich_second = $parts->item(1)->nodeValue; $software->verses()->insert(array("sid" => $sid, "number" => $number++, "hemistich_first" => $hemistich_first, "hemistich_second" => $hemistich_second)); } $phrase = $xpath->query('//*/div[@class="hzPoeamPhraseHolder"]/p')->item(0)->nodeValue; $software->sonnets()->insert_update(array("sid" => $sid), array("phrase" => $phrase)); $sound = file_get_contents("http://hafez.pichak.net/mp3/{$sid}.mp3"); file_put_contents("sounds/{$sid}.mp3", $sound); $sid3 = strlen($sid) == 3 ? $sid : (strlen($sid) == 2 ? "0{$sid}" : "00{$sid}"); $image = file_get_contents("http://www.1doost.com/Files/Hafez/png/{$sid3}.png"); file_put_contents("images/{$sid}.png", $image); print 'done';