Esempio n. 1
0
function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location)
{
    $domain = 'exchangecore.com';
    //Create Email Headers
    $mime_boundary = "----Meeting Booking----" . MD5(TIME());
    $headers = "From: " . $from_name . " <" . $from_address . ">\n";
    $headers .= "Reply-To: " . $from_name . " <" . $from_address . ">\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\n";
    $headers .= "Content-class: urn:content-classes:calendarmessage\n";
    //Create Email Body (HTML)
    $message = "--{$mime_boundary}\r\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= '<p>Dear ' . $to_name . ',</p>';
    $message .= '<p>' . $description . '</p>';
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--{$mime_boundary}\r\n";
    $ical = 'BEGIN:VCALENDAR' . "\r\n" . 'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" . 'VERSION:2.0' . "\r\n" . 'METHOD:REQUEST' . "\r\n" . 'BEGIN:VTIMEZONE' . "\r\n" . 'TZID:Eastern Time' . "\r\n" . 'BEGIN:STANDARD' . "\r\n" . 'DTSTART:20091101T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" . 'TZOFFSETFROM:-0400' . "\r\n" . 'TZOFFSETTO:-0500' . "\r\n" . 'TZNAME:EST' . "\r\n" . 'END:STANDARD' . "\r\n" . 'BEGIN:DAYLIGHT' . "\r\n" . 'DTSTART:20090301T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" . 'TZOFFSETFROM:-0500' . "\r\n" . 'TZOFFSETTO:-0400' . "\r\n" . 'TZNAME:EDST' . "\r\n" . 'END:DAYLIGHT' . "\r\n" . 'END:VTIMEZONE' . "\r\n" . 'BEGIN:VEVENT' . "\r\n" . 'ORGANIZER;CN="' . $from_name . '":MAILTO:' . $from_address . "\r\n" . 'ATTENDEE;CN="' . $to_name . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $to_address . "\r\n" . 'LAST-MODIFIED:' . date("Ymd\\TGis") . "\r\n" . 'UID:' . date("Ymd\\TGis", strtotime($startTime)) . rand() . "@" . $domain . "\r\n" . 'DTSTAMP:' . date("Ymd\\TGis") . "\r\n" . 'DTSTART;TZID="Eastern Time":' . date("Ymd\\THis", strtotime($startTime)) . "\r\n" . 'DTEND;TZID="Eastern Time":' . date("Ymd\\THis", strtotime($endTime)) . "\r\n" . 'TRANSP:OPAQUE' . "\r\n" . 'SEQUENCE:1' . "\r\n" . 'SUMMARY:' . $subject . "\r\n" . 'LOCATION:' . $location . "\r\n" . 'CLASS:PUBLIC' . "\r\n" . 'PRIORITY:5' . "\r\n" . 'BEGIN:VALARM' . "\r\n" . 'TRIGGER:-PT15M' . "\r\n" . 'ACTION:DISPLAY' . "\r\n" . 'DESCRIPTION:Reminder' . "\r\n" . 'END:VALARM' . "\r\n" . 'END:VEVENT' . "\r\n" . 'END:VCALENDAR' . "\r\n";
    $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST' . "\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= $ical;
    $mailsent = mail($to_address, $subject, $message, $headers);
    return $mailsent ? true : false;
}
Esempio n. 2
0
 /**
  * @param Schedule $schedule
  * @return bool
  * @throws \yii\web\BadRequestHttpException
  */
 public static function sendCalendarInvite($schedule)
 {
     if ($schedule->className() !== Schedule::className()) {
         throw new BadRequestHttpException('Invalid request');
     }
     //Create Email Headers
     $mime_boundary = '----Meeting Booking----' . MD5(TIME());
     $headers = "From: " . self::$from_name . " <" . self::$from_address . ">\n";
     $headers .= "Reply-To: " . self::$from_name . " <" . self::$from_address . ">\n";
     $headers .= "MIME-Version: 1.0\n";
     $headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\n";
     $headers .= "Content-class: urn:content-classes:calendarmessage\n";
     //Create Email Body (HTML)
     $message = "--{$mime_boundary}\r\n";
     $message .= "Content-Type: text/html; charset=UTF-8\n";
     $message .= "Content-Transfer-Encoding: 8bit\n\n";
     $message .= "<html>\n";
     $message .= "<body>\n";
     $message .= '<p>' . $schedule->description . '</p>';
     $message .= "<h4>Tickets:</h4>\n";
     $message .= "<ul>\n";
     foreach ($schedule->notes as $note) {
         $message .= '<li>' . Html::a($note->ticket->fullName, Url::base(true) . Url::to(['/ticket/view', 'id' => $note->ticket_id])) . "</li>\n";
     }
     $message .= "</ul>\n";
     $message .= '(' . Html::a('view calendar event', Url::to(['/schedule/view', 'id' => $schedule->id], true)) . ")\n";
     $message .= "</body>\n";
     $message .= "</html>\n";
     $message .= "--{$mime_boundary}\r\n";
     $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST' . "\n";
     $message .= "Content-Transfer-Encoding: 8bit\n\n";
     $message .= 'BEGIN:VCALENDAR' . "\r\n" . 'METHOD:REQUEST' . "\r\n" . 'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" . 'VERSION:2.0' . "\r\n" . 'BEGIN:VTIMEZONE' . "\r\n" . 'TZID:Pacific Standard Time' . "\r\n" . 'BEGIN:STANDARD' . "\r\n" . 'DTSTART:16010101T020000' . "\r\n" . 'TZOFFSETFROM:-0700' . "\r\n" . 'TZOFFSETTO:-0800' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" . 'END:STANDARD' . "\r\n" . 'BEGIN:DAYLIGHT' . "\r\n" . 'DTSTART:16010101T020000' . "\r\n" . 'TZOFFSETFROM:-0800' . "\r\n" . 'TZOFFSETTO:-0700' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" . 'END:DAYLIGHT' . "\r\n" . 'END:VTIMEZONE' . "\r\n" . 'BEGIN:VEVENT' . "\r\n" . 'ORGANIZER;CN="' . $schedule->createdBy->name . '":MAILTO:' . self::$from_address . "\r\n" . 'ATTENDEE;CN="' . $schedule->tech->name . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $schedule->tech->email . "\r\n" . 'LAST-MODIFIED:' . date("Ymd\\TGis") . "\r\n" . 'UID:' . date("Ymd\\TGis", strtotime($schedule->start_time)) . rand() . "@" . self::$domain . "\r\n" . 'DTSTAMP:' . date("Ymd\\TGis") . "\r\n" . 'DTSTART;TZID="Pacific Standard Time":' . date("Ymd\\THis", strtotime($schedule->start_time)) . "\r\n" . 'DTEND;TZID="Pacific Standard Time":' . date("Ymd\\THis", strtotime($schedule->endTime)) . "\r\n" . 'TRANSP:OPAQUE' . "\r\n" . 'SEQUENCE:1' . "\r\n" . 'SUMMARY:' . $schedule->invoice->location->fullName . "\r\n" . 'LOCATION:' . $schedule->invoice->location->address . "\r\n" . 'CLASS:PUBLIC' . "\r\n" . 'PRIORITY:5' . "\r\n" . 'BEGIN:VALARM' . "\r\n" . 'TRIGGER:-PT60M' . "\r\n" . 'ACTION:DISPLAY' . "\r\n" . 'DESCRIPTION:Reminder' . "\r\n" . 'END:VALARM' . "\r\n" . 'END:VEVENT' . "\r\n" . 'END:VCALENDAR' . "\r\n";
     return self::send($schedule->tech->email, $schedule->invoice->location->fullName, $message, $headers);
 }
Esempio n. 3
0
 public function closeSession()
 {
     $_SESSION["user"] = new CocoasUser();
     foreach ($_COOKIE as $key => $value) {
         SETCOOKIE($key, $value, TIME() - 10000);
     }
 }
Esempio n. 4
0
 public static function TIME_AGO($T, $R)
 {
     if (STRPOS($T, ':') !== FALSE) {
         $T = STRTOTIME($T);
     }
     $C = TIME();
     $D = $C - $T;
     $P = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
     $L = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
     for ($V = SIZEOF($L) - 1; $V >= 0 && ($N = $D / $L[$V]) <= 1; $V--) {
     }
     if ($V < 0) {
         $V = 0;
     }
     $_T = $C - $D % $L[$V];
     $N = FLOOR($N);
     if ($N != 1) {
         $P[$V] .= 's';
     }
     $X = SPRINTF("%d %s ", $N, $P[$V]);
     if ($R == 1 && $V >= 1 && $C - $_T > 0) {
         $X .= self::TIME_AGO($_T);
     }
     return $X;
 }
 /**
  * Tests case insensitive mocks.
  *
  * @param string $mockName  The mock function name.
  *
  * @test
  * @dataProvider provideTestCaseSensitivity
  */
 public function testCaseSensitivity($mockName)
 {
     $builder = new MockBuilder();
     $builder->setNamespace(__NAMESPACE__)->setName($mockName)->setFunctionProvider(new FixedValueFunction(1234));
     $this->mock = $builder->build();
     $this->mock->enable();
     $this->assertEquals(1234, time(), "time() is not mocked");
     $this->assertEquals(1234, Time(), "Time() is not mocked");
     $this->assertEquals(1234, TIME(), "TIME() is not mocked");
 }
Esempio n. 6
0
function getPreName($argv)
{
    global $pdo;
    $timestart = time();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $namefixer = new NameFixer(['Settings' => $pdo, 'ConsoleTools' => $consoletools]);
    $res = false;
    if (isset($argv[1]) && $argv[1] === "all") {
        $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE prehashid = 0 AND ishashed = 1');
    } else {
        if (isset($argv[1]) && $argv[1] === "full") {
            $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE categoryid = 8020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0');
        } else {
            if (isset($argv[1]) && is_numeric($argv[1])) {
                $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE categoryid = 8020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT ' . $argv[1]);
            }
        }
    }
    $counter = $counted = $total = 0;
    if ($res !== false) {
        $total = $res->rowCount();
    }
    $show = !isset($argv[2]) || $argv[2] !== 'show' ? 0 : 1;
    if ($total > 0) {
        echo $pdo->log->header("\n" . number_format($total) . ' releases to process.');
        sleep(2);
        foreach ($res as $row) {
            $success = 0;
            if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
            } else {
                if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['searchname'], $matches)) {
                    $success = $namefixer->matchPredbHash($matches[0], $row, 1, 1, true, $show);
                }
            }
            if ($success === 0) {
                $pdo->queryDirect(sprintf('UPDATE releases SET dehashstatus = dehashstatus - 1 WHERE id = %d', $row['releaseid']));
            } else {
                $counted++;
            }
            if ($show === 0) {
                $consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $consoletools->percentString(++$counter, $total));
            }
        }
    }
    if ($total > 0) {
        echo $pdo->log->header("\nRenamed " . $counted . " releases in " . $consoletools->convertTime(TIME() - $timestart) . ".");
    } else {
        echo $pdo->log->info("\nNothing to do.");
    }
}
Esempio n. 7
0
function reCategorize($argv)
{
    global $pdo;
    $where = '';
    $othercats = Category::getCategoryOthersGroup();
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND group_id = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND group_id IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = sprintf(' AND categoryid IN (%s)', $othercats);
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $pdo->log->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $pdo->log->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease(str_replace(" AND", "WHERE", $where), $update, true);
    } else {
        $chgcount = categorizeRelease('', $update, true);
    }
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $pdo->log->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , using the searchname.\n");
    } else {
        echo $pdo->log->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
Esempio n. 8
0
function reCategorize($argv)
{
    $c = new ColorCLI();
    $where = '';
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND groupid = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND groupid IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = ' AND categoryid IN (1090, 2020, 3050, 4040, 5050, 6050, 7050, 8010)';
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $c->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $c->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $c->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease($update, str_replace(" AND", "WHERE", $where), true);
    } else {
        $chgcount = categorizeRelease($update, "", true);
    }
    $consoletools = new ConsoleTools();
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $c->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , \tusing the searchname.\n");
    } else {
        echo $c->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
Esempio n. 9
0
 public function build_page()
 {
     $fp = fopen("../" . PAGES_DIRECTORY . "/hello-world.php", 'w');
     if ($fp) {
         $content = sprintf($this->file_content, '1');
         fwrite($fp, $content, strlen($content));
         fclose($fp);
     }
     $values = array('page_id' => 1, 'position' => 1, 'module' => "wrapper", 'block' => 1);
     $this->query_str = $this->__build_insert("sections", $values);
     $this->db->query($this->query_str);
     $this->__test_error();
     $values = array('section_id' => 1, 'page_id' => 1, 'url' => $this->url, 'height' => "800");
     $this->query_str = $this->__build_insert("mod_wrapper", $values);
     $this->db->query($this->query_str);
     $this->__test_error();
     $values = array('link' => "/hello-world", 'page_title' => "hello world", 'menu_title' => "hello world", 'page_trail' => 1, 'root_parent' => 1, 'searching' => 1, 'admin_groups' => 1, 'viewing_groups' => 1, 'modified_by' => 1, 'modified_when' => TIME(), 'language' => $this->language, 'visibility' => 'public', 'menu' => '1', 'target' => '_new', 'description' => '', 'keywords' => '', 'admin_users' => '', 'viewing_users' => '');
     $this->query_str = $this->__build_insert("pages", $values);
     $this->db->query($this->query_str);
     $this->__test_error();
 }
Esempio n. 10
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $from = $this->message['from'];
     $message = $this->message['content'];
     $sql = "SELECT * FROM " . tablename($this->tabl_vote) . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $now = TIME();
     $info = json_decode($row['config']);
     $res = json_decode($row['result']);
     if ($now >= $row['start_time'] && $now <= $row['end_time']) {
         if ($this->inContext) {
             if (is_numeric((int) $message) && ((int) $message >= 1 && (int) $message <= count($info))) {
                 $res[$message - 1]++;
                 $_res = json_encode($res);
                 $insert = array('result' => $_res);
                 pdo_update($this->tabl_vote, $insert, array('id' => $row['id']));
                 $this->endContext();
                 $reply = "你投票给了{$message} 共有 ({$res[$message - 1]}) 谢谢您!";
             } else {
                 $reply = "你的投票无效!";
             }
             return $this->respText($reply);
         } else {
             $_info = "本次投票选项:\r\n";
             foreach ($info as $k => $v) {
                 $_info .= $k + 1 . '.' . $v . "({$res[$k]})\r\n";
             }
             $_info .= "回复相应数字进行投票!";
             $reply = $_info;
             $this->beginContext(3600);
             return $this->respText($reply);
         }
     } else {
         $reply = $rid . "亲,投票活动已结束了!";
         return $this->respText($reply);
     }
     // 返回至系统
 }
Esempio n. 11
0
function relativeTime($_time)
{
    $d = array();
    $d[0] = array(1, "sec");
    $d[1] = array(60, "min");
    $d[2] = array(3600, "hr");
    $d[3] = array(86400, "day");
    $d[4] = array(31104000, "yr");
    $w = array();
    $return = "";
    $now = TIME();
    $diff = $now - $_time;
    $secondsLeft = $diff;
    for ($i = 4; $i > -1; $i--) {
        $w[$i] = intval($secondsLeft / $d[$i][0]);
        $secondsLeft -= $w[$i] * $d[$i][0];
        if ($w[$i] != 0) {
            $return .= $w[$i] . " " . $d[$i][1] . ($w[$i] > 1 ? 's' : '') . " ";
        }
    }
    return $return;
}
Esempio n. 12
0
 public function mi($email = '')
 {
     $email = strval($email);
     if (IS_POST) {
         //登录验证
         //检测验证码
         //根据用户名获取用户UID
         $user = Member()->where(array('email' => $email))->find();
         $uid = $user['uid'];
         if (!$uid) {
             $this->error("该邮箱还未注册");
         }
         //生成找回密码的验证码
         $verify = $this->getResetPasswordVerifyCode($uid);
         //发送验证邮箱
         $url = 'http://' . $_SERVER['HTTP_HOST'] . U('member/reset?uid=' . $uid . '&verify=' . $verify);
         $content = C('USER_RESPASS') . "<br/>" . $url . "<br/>" . modC('WEB_SITE_NAME', '音乐人开放平台', 'Config') . "系统自动发送--请勿直接回复<br/>" . date('Y-m-d H:i:s', TIME()) . "</p>";
         send_mail($email, modC('WEB_SITE_NAME', '音乐人开放平台', 'Config') . "密码找回", $content);
         $this->success('重设密码邮件发送成功,请注意查收');
     } else {
         $this->display();
     }
 }
Esempio n. 13
0
    foreach ($collections_rows as $row) {
        $groupName = $groups->getByNameByID($row['group_id']);
        echo $pdo->log->header("Processing {$groupName}");
        //collection
        $pdo->queryExec("INSERT IGNORE INTO collections_" . $row['group_id'] . " (subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid) " . "SELECT subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid FROM collections WHERE group_id = {$row['group_id']}");
        $collections = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM collections where group_id = " . $row['group_id']);
        $ncollections = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM collections_" . $row['group_id']);
        echo $pdo->log->primary("Group {$groupName}, Collections = {$collections['cnt']} [{$ncollections['cnt']}]");
        //binaries
        $pdo->queryExec("INSERT IGNORE INTO binaries_{$row['group_id']} (name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, collection_id) " . "SELECT name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, n.id FROM binaries b " . "INNER JOIN collections c ON b.collection_id = c.id " . "INNER JOIN collections_{$row['group_id']} n ON c.collectionhash = n.collectionhash AND c.group_id = {$row['group_id']}");
        $binaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries b INNER JOIN collections c ON  b.collection_id = c.id where c.group_id = {$row['group_id']}");
        $nbinaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries_{$row['group_id']}");
        echo $pdo->log->primary("Group {$groupName}, Binaries = {$binaries['cnt']} [{$nbinaries['cnt']}]");
        //parts
        $pdo->queryExec("INSERT IGNORE INTO parts_{$row['group_id']} (messageid, number, partnumber, size, binaryid, collection_id) " . "SELECT messageid, number, partnumber, size, n.id, c.id FROM parts p " . "INNER JOIN binaries b ON p.binaryid = b.id " . "INNER JOIN binaries_{$row['group_id']} n ON b.binaryhash = n.binaryhash " . "INNER JOIN collections_{$row['group_id']} c on c.id = n.collection_id AND c.group_id = {$row['group_id']}");
        $parts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts p INNER JOIN binaries b ON p.binaryid = b.id INNER JOIN collections c ON b.collection_id = c.id WHERE c.group_id = {$row['group_id']}");
        $nparts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts_{$row['group_id']}");
        echo $pdo->log->primary("Group {$groupName}, Parts = {$parts['cnt']} [{$nparts['cnt']}]\n");
        $i++;
    }
}
if (isset($argv[2]) && $argv[2] == 'truncate') {
    echo $pdo->log->info("Truncating collections, binaries and parts tables.");
    $pdo->queryExec("TRUNCATE TABLE collections");
    $pdo->queryExec("TRUNCATE TABLE binaries");
    $pdo->queryExec("TRUNCATE TABLE parts");
}
//set tpg active
$pdo->queryExec("UPDATE settings SET value = 1 WHERE setting = 'tablepergroup'");
echo $pdo->log->header("Processed: {$i} groups and " . number_format($parts_count['cnt']) . " parts in " . $consoleTools->convertTimer(TIME() - $start));
Esempio n. 14
0
            @$todo($file);
        }
    }
} catch (UnexpectedValueException $e) {
    echo $pdo->log->error($e->getMessage());
}
echo $pdo->log->header("Deleting all images, previews and samples that still remain.");
try {
    $dirItr = new \RecursiveDirectoryIterator(nZEDb_COVERS);
    $itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($itr as $filePath) {
        if (basename($filePath) != '.gitignore' && basename($filePath) != 'no-cover.jpg' && basename($filePath) != 'no-backdrop.jpg') {
            @unlink($filePath);
        }
    }
} catch (UnexpectedValueException $e) {
    echo $pdo->log->error($e->getMessage());
}
echo $pdo->log->header("Getting Updated List of TV Shows from TVRage.");
$tvshows = @simplexml_load_file('http://services.tvrage.com/feeds/show_list.php');
if ($tvshows !== false) {
    foreach ($tvshows->show as $rage) {
        if (isset($rage->id) && isset($rage->name) && !empty($rage->id) && !empty($rage->name)) {
            $pdo->queryInsert(sprintf('INSERT INTO tvrage_titles (rageid, releasetitle, country) VALUES (%s, %s, %s)', $pdo->escapeString($rage->id), $pdo->escapeString($rage->name), $pdo->escapeString($rage->country)));
        }
    }
} else {
    echo $pdo->log->error("TVRage site has a hard limit of 400 concurrent api requests. At the moment, they have reached that limit. Please wait before retrying again.");
}
echo $pdo->log->header("Deleted all releases, images, previews and samples. This script ran for " . $consoletools->convertTime(TIME() - $timestart));
Esempio n. 15
0
 /**
  * Delete crap releases.
  *
  * @param bool       $delete                 Delete the release or just show the result?
  * @param int|string $time                   Time in hours (to select old releases) or 'full' for no time limit.
  * @param string     $type                   Type of query to run [blacklist, executable, gibberish, hashed, installbin, passworded,
  *                                           passwordurl, sample, scr, short, size, ''] ('' runs against all types)
  * @param string     $blacklistID
  *
  * @return string|bool
  */
 public function removeCrap($delete, $time, $type = '', $blacklistID = '')
 {
     $this->timeStart = time();
     $this->delete = $delete;
     $this->blacklistID = '';
     if (isset($blacklistID) && is_numeric($blacklistID)) {
         $this->blacklistID = sprintf("AND id = %d", $blacklistID);
     }
     $time = trim($time);
     $this->crapTime = '';
     $type = strtolower(trim($type));
     switch ($time) {
         case 'full':
             if ($this->echoCLI) {
                 echo $this->pdo->log->header("Removing " . ($type == '' ? "All crap releases " : $type . " crap releases") . " - no time limit.\n");
             }
             break;
         default:
             if (!is_numeric($time)) {
                 $this->error = 'Error, time must be a number or full.';
                 return $this->returnError();
             }
             if ($this->echoCLI) {
                 echo $this->pdo->log->header("Removing " . ($type == '' ? "All crap releases " : $type . " crap releases") . " from the past " . $time . " hour(s).\n");
             }
             $this->crapTime = ' AND r.adddate > (NOW() - INTERVAL ' . $time . ' HOUR)';
             break;
     }
     $this->deletedCount = 0;
     switch ($type) {
         case 'blacklist':
             $this->removeBlacklist();
             break;
         case 'blfiles':
             $this->removeBlacklistFiles();
             break;
         case 'executable':
             $this->removeExecutable();
             break;
         case 'gibberish':
             $this->removeGibberish();
             break;
         case 'hashed':
             $this->removeHashed();
             break;
         case 'installbin':
             $this->removeInstallBin();
             break;
         case 'passworded':
             $this->removePassworded();
             break;
         case 'passwordurl':
             $this->removePasswordURL();
             break;
         case 'sample':
             $this->removeSample();
             break;
         case 'scr':
             $this->removeSCR();
             break;
         case 'short':
             $this->removeShort();
             break;
         case 'size':
             $this->removeSize();
             break;
         case 'huge':
             $this->removeHuge();
             break;
         case 'codec':
             $this->removeCodecPoster();
             break;
         case 'wmv_all':
             $this->removeWMV();
             break;
         case '':
             $this->removeBlacklist();
             $this->removeBlacklistFiles();
             $this->removeExecutable();
             $this->removeGibberish();
             $this->removeHashed();
             $this->removeInstallBin();
             $this->removePassworded();
             $this->removeSample();
             $this->removeSCR();
             $this->removeShort();
             $this->removeSize();
             $this->removeHuge();
             $this->removeCodecPoster();
             break;
         default:
             $this->error = 'Wrong type: ' . $type;
             return $this->returnError();
     }
     if ($this->echoCLI) {
         echo $this->pdo->log->headerOver(($this->delete ? "Deleted " : "Would have deleted ") . $this->deletedCount . " release(s). This script ran for ");
         echo $this->pdo->log->header($this->consoleTools->convertTime(TIME() - $this->timeStart));
     }
     return $this->browser ? 'Success! ' . ($this->delete ? "Deleted " : "Would have deleted ") . $this->deletedCount . ' release(s) in ' . $this->consoleTools->convertTime(TIME() - $this->timeStart) : true;
 }
Esempio n. 16
0
    public function getPreFileNames($args = [])
    {
        $timestart = time();
        $counter = $counted = 0;
        $limit = $orderby = '';
        $show = isset($args[2]) && $args[2] === 'show' ? 1 : 0;
        if (isset($args[1]) && is_numeric($args[1])) {
            $orderby = "ORDER BY r.id DESC";
            $limit = "LIMIT " . $args[1];
        }
        echo $this->pdo->log->header("\nMatch PreFiles ({$args[1]}) Started at " . date('g:i:s'));
        echo $this->pdo->log->primary("Matching predb filename to cleaned release_files.name.\n");
        $query = $this->pdo->queryDirect(sprintf('
							SELECT r.id AS releaseid, r.name, r.searchname,
								r.group_id, r.categoryid,
								rf.name AS filename
							FROM releases r
							INNER JOIN release_files rf ON r.id = rf.releaseid
							AND rf.name IS NOT NULL
							WHERE r.preid = 0
							GROUP BY r.id
							%s %s', $orderby, $limit));
        if ($query !== false) {
            $total = $query->rowCount();
            if ($total > 0 && $query instanceof \Traversable) {
                echo $this->pdo->log->header("\n" . number_format($total) . ' releases to process.');
                foreach ($query as $row) {
                    $success = $this->matchPredbFiles($row, 1, 1, true, $show);
                    if ($success === 1) {
                        $counted++;
                    }
                    if ($show === 0) {
                        $this->consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $this->consoletools->percentString(++$counter, $total));
                    }
                }
                echo $this->pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $this->consoletools->convertTime(TIME() - $timestart) . ".");
            } else {
                echo $this->pdo->log->info("\nNothing to do.");
            }
        }
    }
Esempio n. 17
0
 public function setFormFlood()
 {
     $this->Session->setValue('Curator_formFlood', TIME());
 }
Esempio n. 18
0
	<div class="table-footer"> 
		<div class="tablerow"> 
            <div class="tableOther footer"><div class="footer-con">
				<div class="ar-news">';
// Suppress the news ticker on the IGB and index pages
if (!(preg_match("/index.php/i", $_SERVER['PHP_SELF']) || preg_match("/igb.php/i", $_SERVER['PHP_SELF']))) {
    echo "<script src='backends/javascript/newsticker.js'></script>\n";
    echo "<div id='news_ticker' class='news-feed-scroller'></div>\n";
    include "fader.php";
}
echo '</div><div class="ar-time-to-update">';
// Update counter
$res = $db->Execute("SELECT last_run FROM {$db->prefix}scheduler LIMIT 1");
db_op_result($db, $res, __LINE__, __FILE__);
$result = $res->fields;
$mySEC = $sched_ticks * 60 - (TIME() - $result['last_run']);
echo "<script src='backends/javascript/updateticker.js.php?mySEC={$mySEC}&amp;sched_ticks={$sched_ticks}'></script>";
echo "  <strong><span id=myx>{$mySEC}</span></strong> " . $l->get('l_footer_until_update') . " <br>\n";
// End update counter
echo '</div><div class="ar-total-users-online">';
if ($online == 1) {
    echo "  ";
    echo $l->get('l_footer_one_player_on');
} else {
    echo "There are " . $online . " players online.";
}
echo '</div></div>

				
				
                    <div class="github"><a href="https://github.com/xgermz/xenoberage"><div class="logo-github"></div></a></div>
 public function mi($username = '', $email = '', $verify = '')
 {
     $username = strval($username);
     $email = strval($email);
     if (IS_POST) {
         //登录验证
         //检测验证码
         if (!check_verify($verify)) {
             $this->error(L('_ERROR_VERIFY_CODE_'));
         }
         //根据用户名获取用户UID
         $user = UCenterMember()->where(array('username' => $username, 'email' => $email, 'status' => 1))->find();
         $uid = $user['id'];
         if (!$uid) {
             $this->error(L('_ERROR_USERNAME_EMAIL_'));
         }
         //生成找回密码的验证码
         $verify = $this->getResetPasswordVerifyCode($uid);
         //发送验证邮箱
         $url = 'http://' . $_SERVER['HTTP_HOST'] . U('Ucenter/member/reset?uid=' . $uid . '&verify=' . $verify);
         $content = C('USER_RESPASS') . "<br/>" . $url . "<br/>" . modC('WEB_SITE_NAME', L('_OPENSNS_'), 'Config') . L('_SEND_MAIL_AUTO_') . "<br/>" . date('Y-m-d H:i:s', TIME()) . "</p>";
         send_mail($email, modC('WEB_SITE_NAME', L('_OPENSNS_'), 'Config') . L('_SEND_MAIL_PASSWORD_FOUND_'), $content);
         $this->success(L('_SUCCESS_SEND_MAIL_'), U('Member/login'));
     } else {
         if (is_login()) {
             redirect(U('Home/Index/index'));
         }
         $this->display();
     }
 }
Esempio n. 20
0
<?php

require "../../frame/engine.php";
ENGINE::START("HASH");
$Hash = new PasswordHash(8, true);
$USER = $_POST['usr'];
$USER_CLEAN = STRTOLOWER($USER);
$PASS = $_POST['pas'];
if (empty($USER) && empty($PASS)) {
    die('e1437');
} else {
    $R = MYSQL::QUERY("SELECT * FROM core_users WHERE username_clean = ? LIMIT 1", array($USER_CLEAN));
    if (empty($R)) {
        die('e1435');
    } else {
        if (!$Hash->CheckPassword($PASS, $R['password'])) {
            die('e1436');
        } else {
            $S = MYSQL::QUERY('SELECT * FROM core_stores WHERE s_id = ? LIMIT 1', array($R['store']));
            DATE_DEFAULT_TIMEZONE_SET($S['s_timezone']);
            USER::LOG("Logged In", $R['user_id']);
            $SES_EXP = TIME() + 43200;
            $SES_GEN = FORMAT::SES(50);
            $params = array($SES_GEN, $R['user_id'], $SES_EXP, $SES_GEN, $SES_EXP);
            MYSQL::QUERY('INSERT INTO core_users_sessions (session_key,session_user,session_experation) VALUES (?,?,?) ON DUPLICATE KEY UPDATE session_key=?,session_experation=?', $params);
            setcookie("core_u", $params[1], $SES_EXP, '/');
            setcookie("core_k", $params[0], $SES_EXP, '/');
            echo 's1434';
        }
    }
}
Esempio n. 21
0
 /**
  * 密码找回页
  */
 public function foundPassWord()
 {
     $aUsername = $username = I('post.username', '', 'op_t');
     $aEmail = $email = I('post.email', '', 'op_t');
     $aVerify = $verify = I('post.verify', '', 'op_t');
     $username = strval($username);
     $email = strval($email);
     if (IS_POST) {
         //登录验证
         //检测验证码
         if (!$aUsername) {
             $this->ajaxReturn(array('status' => 0, 'info' => '请填写用户名'));
         }
         //根据用户名获取用户UID
         $user = UCenterMember()->where(array('username' => $username, 'email' => $email, 'status' => 1))->find();
         $uid = $user['id'];
         if (!$uid) {
             $this->ajaxReturn(array('status' => 0, 'info' => '用户名或邮箱错误'));
         }
         if (!check_verify($verify)) {
             $this->error('验证码输入错误');
         }
         //生成找回密码的验证码
         $verify = $this->getResetPasswordVerifyCode($uid);
         //发送验证邮箱
         $url = 'http://' . $_SERVER['HTTP_HOST'] . U('Ucenter/member/reset?uid=' . $uid . '&verify=' . $verify);
         $content = C('USER_RESPASS') . "<br/>" . $url . "<br/>" . modC('WEB_SITE_NAME', 'OpenSNS开源社交系统', 'Config') . "系统自动发送--请勿直接回复<br/>" . date('Y-m-d H:i:s', TIME()) . "</p>";
         send_mail($email, modC('WEB_SITE_NAME', 'OpenSNS开源社交系统', 'Config') . "密码找回", $content);
         $this->ajaxReturn(array('status' => 1, 'info' => '密码找回邮件已发送,请耐心等待!'));
     } else {
         $this->_top_menu_list = array('left' => array(array('type' => 'back')), 'center' => array('title' => '密码找回'));
         $this->assign('top_menu_list', $this->_top_menu_list);
         $this->display();
     }
 }
 public function mi($username = '', $email = '', $verify = '')
 {
     $username = strval($username);
     $email = strval($email);
     if (IS_POST) {
         //登录验证
         //检测验证码
         if (!check_verify($verify)) {
             $this->error('验证码输入错误');
         }
         //根据用户名获取用户UID
         $user = UCenterMember()->where(array('username' => $username, 'email' => $email, 'status' => 1))->find();
         $uid = $user['id'];
         if (!$uid) {
             $this->error("用户名或邮箱错误");
         }
         //生成找回密码的验证码
         $verify = $this->getResetPasswordVerifyCode($uid);
         //发送验证邮箱
         $url = 'http://' . $_SERVER['HTTP_HOST'] . U('Ucenter/member/reset?uid=' . $uid . '&verify=' . $verify);
         $content = C('USER_RESPASS') . "<br/>" . $url . "<br/>" . modC('WEB_SITE_NAME', 'OpenSNS开源社交系统', 'Config') . "系统自动发送--请勿直接回复<br/>" . date('Y-m-d H:i:s', TIME()) . "</p>";
         send_mail($email, modC('WEB_SITE_NAME', 'OpenSNS开源社交系统', 'Config') . "密码找回", $content);
         $this->success('密码找回邮件发送成功', U('Member/login'));
     } else {
         if (is_login()) {
             redirect(U(C('AFTER_LOGIN_JUMP_URL')));
         }
         $this->display();
     }
 }
Esempio n. 23
0
 // Look for match on name, poster and size
 $dupecheck = $pdo->queryOneRow(sprintf('SELECT id, guid FROM releases WHERE name = %s AND fromname = %s AND size BETWEEN %s AND %s', $pdo->escapeString($subject), $pdo->escapeString($poster), $pdo->escapeString($minsize), $pdo->escapeString($maxsize)));
 if ($dupecheck === false) {
     $relid = $releases->insertRelease(['name' => $pdo->escapeString($subject), 'searchname' => $pdo->escapeString($cleanName), 'totalpart' => $totalFiles, 'group_id' => $groupID, 'guid' => $pdo->escapeString($relguid), 'postdate' => $pdo->escapeString($posteddate), 'fromname' => $pdo->escapeString($poster), 'size' => $pdo->escapeString($totalsize), 'categoryid' => $category, 'isrenamed' => 1, 'reqidstatus' => 0, 'preid' => 0, 'nzbstatus' => NZB::NZB_ADDED]);
 }
 if ($relid === false || $dupecheck === false) {
     $nzbSkipped++;
     @unlink($nzbFile);
     flush();
 }
 if (copyNZBforImport($relguid, $nzba, $nzb, $pdo)) {
     if ($relid !== false) {
         $nzbCount++;
     }
     if ($nzbCount % 100 == 0 && $nzbCount != 0) {
         $seconds = TIME() - $time;
         $nzbsperhour = number_format(round($nzbCount / $seconds * 3600), 0);
     }
     if ($nzbCount >= $maxtoprocess && $maxtoprocess != 0) {
         $nzbsperhour = number_format(round($nzbCount / $seconds * 3600), 0);
         exit($pdo->log->header("\nProcessed " . number_format($nzbCount) . " nzbs in " . relativeTime($time) . "\nAveraged " . $nzbsperhour . " imports per hour from " . $path));
     }
     @unlink($nzbFile);
 } else {
     $pdo->queryExec(sprintf("DELETE FROM releases WHERE guid = %s AND postdate = %s AND size = %d", $pdo->escapeString($relguid), $pdo->escapeString($totalsize)));
     echo $pdo->log->error("\nFailed copying NZB, deleting release from DB.\n");
     @unlink($nzbFile);
     flush();
     $importfailed = true;
 }
 $consoleTools->overWritePrimary('Imported ' . "[" . number_format($nzbSkipped) . "] " . number_format($nzbCount) . " NZBs (" . $nzbsperhour . "iph) in " . relativeTime($time));
Esempio n. 24
0
    if ($titles instanceof \Traversable) {
        foreach ($titles as $row) {
            $matched = 0;
            $searched = 0;
            $matched = $namefixer->matchPredbFT($row, 1, 1, true, $show);
            //echo "Pre Title " . $row['title'] . " is translated to search string: ";
            //echo $pdo->log->header($matched);
            if ($matched > 0) {
                $searched = 1;
                $counted++;
            } elseif ($matched < 0) {
                $searched = -6;
                echo "*";
            } else {
                $searched = $row['searched'] - 1;
                echo ".";
            }
            $pdo->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $row['preid']));
            if (!isset($argv[2]) || $argv[2] !== 'show') {
                $consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $consoletools->percentString(++$counter, $total));
            }
        }
    }
    if ($total > 0) {
        echo $pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $consoletools->convertTime(TIME() - $timestart) . ".");
    } else {
        echo $pdo->log->info("\nNothing to do.");
    }
} else {
    echo $pdo->log->info("No work to process.\n");
}
Esempio n. 25
0
                    $nzbfile = preg_replace('/^[\\r\\n]+<\\?xml/i', '<?xml', $nzbfile);
                    $nzb = preg_replace('/<\\/nzb>.+/i', '</nzb>', $nzbfile);
                    unlink($nzbpath);
                    $fp = gzopen($nzbpath, 'w6');
                    if ($fp) {
                        gzwrite($fp, $nzb, strlen($nzb));
                        gzclose($fp);
                        chmod($nzbpath, 0777);
                    }
                }
                if ($nzbcount % 5000 == 0) {
                    echo $nzbcount . " NZBs scanned. " . $brokencount . " NZBs fixed. " . (TIME() - $timestart) . " seconds.\n";
                } else {
                    if ($nzbcount % 1000 == 0) {
                        echo "\n";
                    } else {
                        if ($nzbcount % 10 == 0) {
                            echo ".";
                        }
                    }
                }
            } else {
                echo $pdo->log->error("\nWrong permissions on NZB file, or it does not exist.\n");
            }
            unset($guid);
        }
    }
    echo $pdo->log->header($nzbcount . " NZB files scanned. in " . TIME() - $timestart . " seconds. " . $brokencount . " NZB files were fixed.");
} else {
    exit($pdo->log->error("\nThis script can be dangerous, if you are sure you want to run this, STOP ALL OTHER nZEDb SCRIPTS.\n\n" . "php {$argv['0']} true     ...: To remove blank lines from all nzbs.\n"));
}
Esempio n. 26
0
function preName($argv, $argc)
{
    global $pdo;
    $groups = new \Groups(['Settings' => $pdo]);
    $category = new \Categorize(['Settings' => $pdo]);
    $internal = $external = $pre = 0;
    $show = 2;
    if ($argv[$argc - 1] === 'show') {
        $show = 1;
    } else {
        if ($argv[$argc - 1] === 'bad') {
            $show = 3;
        }
    }
    $counter = 0;
    $pdo->log = new \ColorCLI();
    $full = $all = $usepre = false;
    $what = $where = '';
    if ($argv[1] === 'full') {
        $full = true;
    } else {
        if ($argv[1] === 'all') {
            $all = true;
        } else {
            if ($argv[1] === 'preid') {
                $usepre = true;
            } else {
                if (is_numeric($argv[1])) {
                    $what = ' AND adddate > NOW() - INTERVAL ' . $argv[1] . ' HOUR';
                }
            }
        }
    }
    if ($usepre === true) {
        $where = '';
        $why = ' WHERE prehashid = 0 AND nzbstatus = 1';
    } else {
        if (isset($argv[1]) && is_numeric($argv[1])) {
            $where = '';
            $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
        } else {
            if (isset($argv[2]) && is_numeric($argv[2]) && $full === true) {
                $where = ' AND groupid = ' . $argv[2];
                $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
            } else {
                if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) {
                    $where = ' AND groupid IN ' . $argv[2];
                    $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
                } else {
                    if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) {
                        $where = ' AND groupid IN ' . $argv[2];
                        $why = ' WHERE nzbstatus = 1';
                    } else {
                        if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) {
                            $where = ' AND groupid = ' . $argv[2];
                            $why = ' WHERE nzbstatus = 1 and prehashid = 0';
                        } else {
                            if (isset($argv[2]) && is_numeric($argv[2])) {
                                $where = ' AND groupid = ' . $argv[2];
                                $why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
                            } else {
                                if ($full === true) {
                                    $why = ' WHERE nzbstatus = 1 AND (isrenamed = 0 OR categoryid between 8000 AND 8999)';
                                } else {
                                    if ($all === true) {
                                        $why = ' WHERE nzbstatus = 1';
                                    } else {
                                        $why = ' WHERE 1=1';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    resetSearchnames();
    echo $pdo->log->header("SELECT id, name, searchname, fromname, size, groupid, categoryid FROM releases" . $why . $what . $where . ";\n");
    $res = $pdo->queryDirect("SELECT id, name, searchname, fromname, size, groupid, categoryid FROM releases" . $why . $what . $where);
    $total = $res->rowCount();
    if ($total > 0) {
        $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
        foreach ($res as $row) {
            $groupname = $groups->getByNameByID($row['groupid']);
            $cleanerName = releaseCleaner($row['name'], $row['fromname'], $row['size'], $groupname, $usepre);
            $preid = 0;
            $predb = $predbfile = $increment = false;
            if (!is_array($cleanerName)) {
                $cleanName = trim((string) $cleanerName);
                $propername = $increment = true;
                if ($cleanName != '' && $cleanerName != false) {
                    $run = $pdo->queryOneRow("SELECT id FROM prehash WHERE title = " . $pdo->escapeString($cleanName));
                    if (isset($run['id'])) {
                        $preid = $run['id'];
                        $predb = true;
                    }
                }
            } else {
                $cleanName = trim($cleanerName["cleansubject"]);
                $propername = $cleanerName["properlynamed"];
                if (isset($cleanerName["increment"])) {
                    $increment = $cleanerName["increment"];
                }
                if (isset($cleanerName["predb"])) {
                    $preid = $cleanerName["predb"];
                    $predb = true;
                }
            }
            if ($cleanName != '') {
                if (preg_match('/alt\\.binaries\\.e\\-?book(\\.[a-z]+)?/', $groupname)) {
                    if (preg_match('/^[0-9]{1,6}-[0-9]{1,6}-[0-9]{1,6}$/', $cleanName, $match)) {
                        $rf = new \ReleaseFiles($pdo);
                        $files = $rf->get($row['id']);
                        foreach ($files as $f) {
                            if (preg_match('/^(?P<title>.+?)(\\[\\w\\[\\]\\(\\). -]+)?\\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', $f["name"], $match)) {
                                $cleanName = $match['title'];
                                break;
                            }
                        }
                    }
                }
                //try to match clean name against predb filename
                $prefile = $pdo->queryOneRow("SELECT id, title FROM prehash WHERE filename = " . $pdo->escapeString($cleanName));
                if (isset($prefile['id'])) {
                    $preid = $prefile['id'];
                    $cleanName = $prefile['title'];
                    $predbfile = true;
                    $propername = true;
                }
                if ($cleanName != $row['name'] && $cleanName != $row['searchname']) {
                    if (strlen(utf8_decode($cleanName)) <= 3) {
                    } else {
                        $determinedcat = $category->determineCategory($row["groupid"], $cleanName);
                        if ($propername == true) {
                            $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']));
                        } else {
                            $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL,  " . "iscategorized = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']));
                        }
                        if ($increment === true) {
                            $internal++;
                        } else {
                            if ($predb === true) {
                                $pre++;
                            } else {
                                if ($predbfile === true) {
                                    $pre++;
                                } else {
                                    if ($propername === true) {
                                        $external++;
                                    }
                                }
                            }
                        }
                        if ($show === 1) {
                            $oldcatname = $category->getNameByID($row["categoryid"]);
                            $newcatname = $category->getNameByID($determinedcat);
                            \NameFixer::echoChangedReleaseName(array('new_name' => $cleanName, 'old_name' => $row["searchname"], 'new_category' => $newcatname, 'old_category' => $oldcatname, 'group' => $groupname, 'release_id' => $row["id"], 'method' => 'lib/testing/Dev/renametopre.php'));
                        }
                    }
                } else {
                    if ($show === 3 && preg_match('/^\\[?\\d*\\].+?yEnc/i', $row['name'])) {
                        echo $pdo->log->primary($row['name']);
                    }
                }
            }
            if ($cleanName == $row['name']) {
                $pdo->queryExec(sprintf("UPDATE releases SET isrenamed = 1, iscategorized = 1 WHERE id = %d", $row['id']));
            }
            if ($show === 2 && $usepre === false) {
                $consoletools->overWritePrimary("Renamed Releases:  [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Predb=" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total));
            } else {
                if ($show === 2 && $usepre === true) {
                    $consoletools->overWritePrimary("Renamed Releases:  [" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total));
                }
            }
        }
    }
    echo $pdo->log->header("\n" . number_format($pre) . " renamed using preDB Match\n" . number_format($external) . " renamed using ReleaseCleaning.php\n" . number_format($internal) . " using renametopre.php\nout of " . number_format($total) . " releases.\n");
    if (isset($argv[1]) && is_numeric($argv[1]) && !isset($argv[2])) {
        echo $pdo->log->header("Categorizing all releases using searchname from the last {$argv[1]} hours. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] !== "all" && isset($argv[2]) && !is_numeric($argv[2]) && !preg_match('/\\([\\d, ]+\\)/', $argv[2])) {
            echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using searchname. This can take a while, be patient.");
        } else {
            if (isset($argv[1]) && isset($argv[2]) && (is_numeric($argv[2]) || preg_match('/\\([\\d, ]+\\)/', $argv[2]))) {
                echo $pdo->log->header("Categorizing all non-categorized releases in {$argv[2]} using searchname. This can take a while, be patient.");
            } else {
                echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient.");
            }
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryid = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true);
    } else {
        if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) {
            $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true);
        } else {
            if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) {
                $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true);
            } else {
                if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "full") {
                    $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true);
                } else {
                    if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "all") {
                        $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true);
                    } else {
                        if (isset($argv[1]) && $argv[1] == "full") {
                            $relcount = catRelease("searchname", "WHERE categoryid = 8010 OR iscategorized = 0", true);
                        } else {
                            if (isset($argv[1]) && $argv[1] == "all") {
                                $relcount = catRelease("searchname", "", true);
                            } else {
                                if (isset($argv[1]) && $argv[1] == "preid") {
                                    $relcount = catRelease("searchname", "WHERE prehashid = 0 AND nzbstatus = 1", true);
                                } else {
                                    $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryid = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
    $time = $consoletools->convertTime(TIME() - $timestart);
    echo $pdo->log->header("Finished categorizing " . number_format($relcount) . " releases in " . $time . " seconds, using the usenet subject.\n");
    resetSearchnames();
}
Esempio n. 27
0
function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
    if ($relrecs) {
        $total = $relrecs->rowCount();
    }
    if ($total > 0) {
        echo $pdo->log->header("Creating nzb_guids for " . number_format($total) . " releases.");
        $releases = new Releases(['Settings' => $pdo]);
        $nzb = new NZB($pdo);
        $releaseImage = new ReleaseImage($pdo);
        $reccnt = 0;
        if ($relrecs instanceof Traversable) {
            foreach ($relrecs as $relrec) {
                $reccnt++;
                $nzbpath = $nzb->NZBPath($relrec['guid']);
                if ($nzbpath !== false) {
                    $nzbfile = nzedb\utility\Utility::unzipGzipFile($nzbpath);
                    if ($nzbfile) {
                        $nzbfile = @simplexml_load_string($nzbfile);
                    }
                    if (!$nzbfile) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." is not a valid xml, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    $binary_names = array();
                    foreach ($nzbfile->file as $file) {
                        $binary_names[] = $file["subject"];
                    }
                    if (count($binary_names) == 0) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." has no binaries, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    asort($binary_names);
                    foreach ($nzbfile->file as $file) {
                        if ($file["subject"] == $binary_names[0]) {
                            $segment = $file->segments->segment;
                            $nzb_guid = md5($segment);
                            $pdo->queryExec("UPDATE releases set nzb_guid = " . $pdo->escapestring($nzb_guid) . " WHERE id = " . $relrec["id"]);
                            $relcount++;
                            $consoletools->overWritePrimary("Created: [" . $deleted . "] " . $consoletools->percentString($reccnt, $total) . " Time:" . $consoletools->convertTimer(TIME() - $timestart));
                            break;
                        }
                    }
                } else {
                    if (isset($delete) && $delete == 'delete') {
                        //echo $pdo->log->primary($nzb->NZBPath($relrec['guid']) . " does not have an nzb, deleting.");
                        $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                    }
                }
            }
        }
        if ($relcount > 0) {
            echo "\n";
        }
        echo $pdo->log->header("Updated " . $relcount . " release(s). This script ran for " . $consoletools->convertTime(TIME() - $timestart));
    } else {
        echo $pdo->log->info('Query time: ' . $consoletools->convertTime(TIME() - $timestart));
        exit($pdo->log->info("No releases are missing the guid."));
    }
}
Esempio n. 28
0
                            $time = $consoletools->convertTime(TIME() - $timestart);
                            echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the usenet subject.");
                        } else {
                            if ($argv[1] == 6 && $argv[2] == 'true') {
                                echo $pdo->log->header("Categorizing releases in all sections using the searchname. This can take a while, be patient.");
                                $timestart = TIME();
                                $relcount = $releases->categorizeRelease('searchname', '');
                                $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
                                $time = $consoletools->convertTime(TIME() - $timestart);
                                echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
                            } else {
                                if ($argv[1] == 6 && $argv[2] == 'false') {
                                    echo $pdo->log->header("Categorizing releases in misc sections using the searchname. This can take a while, be patient.");
                                    $timestart = TIME();
                                    $relcount = $releases->categorizeRelease('searchname', 'WHERE categoryID IN (1090, 2020, 3050, 5050, 6050, 7010)');
                                    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
                                    $time = $consoletools->convertTime(TIME() - $timestart);
                                    echo $pdo->log->primary("\n" . 'Finished categorizing ' . $relcount . ' releases in ' . $time . " seconds, using the search name.");
                                } else {
                                    exit($pdo->log->error("Wrong argument, type php update_releases.php to see a list of valid arguments."));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    exit($pdo->log->error("\nWrong set of arguments.\n" . "php update_releases.php 1 true\t\t\t...: Creates releases and attempts to categorize new releases\n" . "php update_releases.php 2 true\t\t\t...: Creates releases and leaves new releases in other -> misc\n" . "\nYou must pass a second argument whether to post process or not, true or false\n" . "You can pass a third optional argument, a group name (ex.: alt.binaries.multimedia).\n" . "\nExtra commands::\n" . "php update_releases.php 4 true\t\t\t...: Puts all releases in other-> misc (also resets to look like they have never been categorized)\n" . "php update_releases.php 5 true\t\t\t...: Categorizes all releases in other-> misc (which have not been categorized already)\n" . "php update_releases.php 6 false\t\t\t...: Categorizes releases in misc sections using the search name\n" . "php update_releases.php 6 true\t\t\t...: Categorizes releases in all sections using the search name\n"));
}
Esempio n. 29
0
 public function mi()
 {
     $username = I('username');
     $email = I('email');
     if (IS_POST) {
         //登录验证
         //检测验证码
         //根据用户名获取用户UID
         $user = D('User/UcenterMember')->where(array('username' => $username, 'email' => $email, 'status' => 1))->find();
         $uid = $user['id'];
         if (!$uid) {
             $this->error("用户名或邮箱错误");
         }
         $verify = think_encrypt($uid, '', 3000);
         $url = "http://{$_SERVER['HTTP_HOST']}" . U('Home/User/reset', array('uid' => $uid, 'verify' => $verify));
         $body = C('USER_RESPASS') . "<br/>" . $url . "<br/>" . C('WEB_SITE') . "系统自动发送--请勿直接回复<br/>" . date('Y-m-d H:i:s', TIME()) . "</p>";
         $subject = C('WEB_SITE') . "密码找回";
         send_mail($email, $subject, $body);
         $this->success('密码找回邮件发送成功', U('Home/User/login'));
     } else {
         if (is_login()) {
             redirect(U('Index/index'));
         }
         $this->display();
     }
 }
Esempio n. 30
0
echo $pdo->log->header("Getting first/last for all your active groups.");
$data = $nntp->getGroups();
if ($nntp->isError($data)) {
    exit($pdo->log->error("Failed to getGroups() from nntp server."));
}
echo $pdo->log->header("Inserting new values into shortgroups table.");
$pdo->queryExec('TRUNCATE TABLE shortgroups');
// Put into an array all active groups
$res = $pdo->query('SELECT name FROM groups WHERE active = 1 OR backfill = 1');
foreach ($data as $newgroup) {
    if (myInArray($res, $newgroup['group'], 'name')) {
        $pdo->queryInsert(sprintf('INSERT INTO shortgroups (name, first_record, last_record, updated) VALUES (%s, %s, %s, NOW())', $pdo->escapeString($newgroup['group']), $pdo->escapeString($newgroup['first']), $pdo->escapeString($newgroup['last'])));
        echo $pdo->log->primary('Updated ' . $newgroup['group']);
    }
}
echo $pdo->log->header('Running time: ' . $consoleTools->convertTimer(TIME() - $start));
function myInArray($array, $value, $key)
{
    //loop through the array
    foreach ($array as $val) {
        //if $val is an array cal myInArray again with $val as array input
        if (is_array($val)) {
            if (myInArray($val, $value, $key)) {
                return true;
            }
        } else {
            //else check if the given key has $value as value
            if ($array[$key] == $value) {
                return true;
            }
        }