| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace app\models;
- use app\models\Entry;
- use \phpQuery;
- use \Archive\Tar
- use app\utils\Gzip.php;
- class contentList extends \lithium\data\Model {
- public function update()
- {
-
- }
- public function add($entity, $data)
- {
- $updateData = array('$push' => array(''
- $conditions = array('_id' => $user['_id']);
- $result = User::update($updateData, $conditions, array('atomic' => false));
- }
- public function importManga() {
-
- }
- public static function importAnimeXML{$user, $file}
- {
- $xml = ungzip($file);
- $list = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
- foreach ($list->animelist as $entry)
- {
- $user->animelist[] = Entry::create($entry);
- }
- return $user->save(null, array('validate' => false));
- }
- /* public function importAnime($user, $malun, $malpass) {
- //This method assumes we are importing from mal at the moment.
- //1. Parse Mal for the download link
- //1.1 Login to MAL
- $cmd = "curl -c cookie.txt -d \"username=$malun&password=$malpass\" http://myanimelist.net/login.php";
- $result = shell_exec($cmd);
- //If the request went ok
- if (empty($result)) {
- //1.2 Request a list export
- $cmd_getList = "curl -b cookie.txt -d \"value=1&subexport=Export My List\" http://myanimelist.net/panel.php?go=export";
-
- $malreturn = shell_exec($cmd_getList);
- //Initate a new document for phpQuery.
- $doc = phpQuery::newDocument($malreturn);
- //Grab the div with the content in it, (should be goodresult actually <div class=goodresult>)
- $mal = pq('#content');
- //If everything goes to plan, the only link the the body will be the one we want,
- $link = $mal->find('a')->attr('href');
-
- $cmd = "curl -b cookie.txt $link";
- $data = shell_exec($cmd);
- $xml_source = gzdecode($data);
- $list = simplexml_load_string($xml_source, 'SimpleXMLElement', LIBXML_NOCDATA);
- foreach($list as $entry) {
- print_r($entry);
- }
- }
-
-
- //2. Download the linked file
- //3. Extract and unzip it
- //4. Take the XML and parse it
- $xml_source; //<-- the XML code
- $xml = simplexml_load_string($xml_source, 'SimpleXMLElement', LIBXML_NOCDATA);
- if (!isset($user->animelist))
- {
- $user->animelist = array();
- }
- //Create entries
- foreach($xml->anime as $entry)
- {
- $user->animelist[] = Entry::create($entry);
- }
- //Store the entries to the database
- return $user->save(null, array('validate' => false));
- }*/
- }
|