Ejemplo n.º 1
0
function addTimesLoaded($theRes, $sqlconn)
{
    $mixids = array();
    $mixnames = array();
    $owners = array();
    $published = array();
    $mixesLoaded = array();
    $theRes = new SimpleXMLElement($theRes);
    foreach ($theRes->children() as $header) {
        foreach ($header->children() as $child) {
            if ($child->getName() == 'mixid') {
                $mixids[] = $child;
                $mixesLoaded[] = getMixesLoadedCount($child, $sqlconn);
            }
            if ($child->getName() == 'mixname') {
                $mixnames[] = $child;
            }
            if ($child->getName() == 'owner') {
                $owners[] = $child;
            }
            if ($child->getName() == 'published') {
                $published[] = $child;
            }
        }
    }
    $table = 'Mixes';
    $args = array('mixid' => $mixids, 'mixname' => $mixnames, 'owner' => $owners, 'published' => $published, 'mixesLoaded' => $mixesLoaded);
    $xml = createXML($table, $args);
    return $xml;
}
Ejemplo n.º 2
0
function getPassword($fEmail, $sqlconn)
{
    $table = 'UserInfo';
    $queryType = 'Select';
    $condition = array('Email', $fEmail, 'text');
    $types = array('text');
    $columns = array('Password');
    $values = array(null);
    $args = array('column' => $columns, 'value' => $values, 'type' => $types);
    $xml = createXML($table, $args);
    $res = $sqlconn->query($xml, $queryType, $condition);
    $thepassword = getValue($res);
    if ($thepassword == '') {
        echo 'Account does not exist';
    } else {
        $mail = new PHPMailer(true);
        //New instance, with exceptions enabled
        $body = "Password: "******"\r\nReturn to site: http://www.you-mix.com";
        $body = preg_replace('/\\\\/', '', $body);
        //Strip backslashes
        $mail->IsSMTP();
        // telling the class to use SMTP
        //$mail->Host       = "mail.you-mix.com"; // SMTP server
        $mail->Host = "smtp.sendgrid.net";
        //$mail->Host       = "smtp.mail.me.com"; // SMTP server
        $mail->SMTPDebug = 1;
        // enables SMTP debug information (for testing)
        // 1 = errors and messages
        // 2 = messages only                           // tell the class to use SMTP
        $mail->SMTPAuth = true;
        // enable SMTP authentication
        $mail->Port = 25;
        // set the SMTP server port
        //$mail->Port       = 587;                    // set the SMTP server port
        $mail->Username = "******";
        // SMTP server username
        //$mail->Username   = "******";     // SMTP server username
        $config = new config();
        $mail->Password = $config->getSMTPPass();
        // SMTP server password
        $mail->AddReplyTo("*****@*****.**", "YouMix");
        $mail->From = "*****@*****.**";
        $mail->FromName = "YouMix";
        //$to = "*****@*****.**";
        $mail->AddAddress($fEmail);
        $mail->Subject = "you-mix.com: Password retrieval";
        $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
        // optional, comment out and test
        $mail->WordWrap = 80;
        // set word wrap
        $mail->MsgHTML($body);
        $mail->IsHTML(true);
        // send as HTML
        $mail->Send();
        echo 'Password has been sent.';
    }
}
Ejemplo n.º 3
0
function getPublishedValue($sqlconn, $theMixName)
{
    $table = 'Mixes';
    $queryType = 'Select';
    $condition = array('MixName', $theMixName, 'text');
    $types = array('text');
    $columns = array('Published');
    $values = array(null);
    $args = array('column' => $columns, 'value' => $values, 'type' => $types);
    $xml = createXML($table, $args);
    $res = $sqlconn->query($xml, $queryType, $condition);
    $publishedValue = getValue($res);
    return $publishedValue;
}
Ejemplo n.º 4
0
function getMix($sqlconn, $theMixId)
{
    $table = 'Mixes';
    $queryType = 'Select';
    $condition = array('MixId', $theMixId, 'text');
    $types = array('text');
    $columns = array('MixName');
    $values = array(null);
    $args = array('column' => $columns, 'value' => $values, 'type' => $types);
    $xml = createXML($table, $args);
    $res = $sqlconn->query($xml, $queryType, $condition);
    $mixName = getValue($res);
    if ($mixName == '') {
        $mixName = 'Mix not found';
    }
    return $mixName;
}
Ejemplo n.º 5
0
function getSongs($songsMixTitle, $sqlconn)
{
    $songs = array();
    $startTimes = array();
    $songsMixTitle = str_replace("'", "\\'", $songsMixTitle);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$songsMixTitle}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}' ORDER BY SongId", 'MixSongs');
    $songids = getSongIds($res);
    foreach ($songids as $songid) {
        $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE SongId = '{$songid}'", 'Songs');
        $songs[] = getSong($res);
        $startTimes[] = getStartTime($res);
    }
    $args = array('VideoId' => $songs, 'StartTime' => $startTimes);
    $xml = createXML('Songs', $args);
    return $xml;
}
Ejemplo n.º 6
0
/**
 * 获取每一页中的产品名称和url3
 * @param $pageUrl
 */
function getProductUrls($pageUrl, $brandsArray, $keyword, $withoutFilementKeywordXMLName)
{
    ob_start();
    //打开输出控制缓冲
    ob_end_flush();
    //输出缓冲区内容并关闭缓冲
    ob_implicit_flush(1);
    //立即输出
    $xmlFileName = 'xml/' . $withoutFilementKeywordXMLName . '.xml';
    $html = file_get_html($pageUrl);
    $ulsdiv = $html->find('.s-result-item');
    //获取ul
    // $productUrls = array();
    $index = 0;
    foreach ($ulsdiv as $li) {
        $title = $li->find('h2', 0)->plaintext;
        $productUrl = $li->find('a', 0)->href;
        $brand = trim($li->find('.a-color-secondary', 1)->plaintext);
        echo $brand . '-----' . $title . '<br/>';
        //存在关键词则认为是打印材料,添加到对应品牌xml文件,否则添加到丢弃文件
        if (containsKeyword($title, $keyword)) {
            //品牌存在,则说明该品牌的xml文件已经存在,直接将该产品添加到对应的xml文件中,否则新建品牌xml文件
            if (in_array($brand, $brandsArray)) {
                addToXML($brand, $brand, $title, $productUrl);
            } else {
                createXML($brand, $brand, $title, $productUrl);
                $brandsArray[$brand] = $brand;
            }
        } else {
            if (file_exists($xmlFileName)) {
                addToXML($withoutFilementKeywordXMLName, $brand, $title, $productUrl);
            } else {
                createXML($withoutFilementKeywordXMLName, $brand, $title, $productUrl);
            }
        }
        // $productUrls[$index] = $productUrl;
        sleep(1);
        ob_flush();
        //输出缓冲区中的内容
        flush();
        //刷新输出缓冲
    }
    return $brandsArray;
}
Ejemplo n.º 7
0
function syncMixAndSongs($sqlconn, $titleSync, $emailSync, $datetimeSync)
{
    $titleSync = str_replace("'", "\\'", $titleSync);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE Owner = '{$emailSync}' AND MixName = '{$titleSync}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE TimeAdded = '{$datetimeSync}'", 'Songs');
    $songids = getSongIds($res);
    $table = 'MixSongs';
    $queryType = 'Insert';
    $condition = null;
    $types = array('integer', 'integer');
    $columns = array('MixId', 'SongId');
    for ($x = 0; $x < count($songids); $x++) {
        $values = array($mixid, $songids[$x]);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml2 = createXML($table, $args);
        $res = $sqlconn->query($xml2, $queryType, $condition);
    }
    echo "Mix created!<br/>";
    echo "Go to the <a href='' class='linkbutton' id='myMixesLinkFromCreate'>My Mixes</a> page to play your mix.";
}
Ejemplo n.º 8
0
function syncMixAndSongs($sqlconn, $titleSync, $emailSync, $datetimeSync)
{
    $titleSync = str_replace("'", "\\'", $titleSync);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE Owner = '{$emailSync}' AND MixName = '{$titleSync}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE TimeAdded = '{$datetimeSync}'", 'Songs');
    $songids = getSongIds($res);
    $table = 'MixSongs';
    $queryType = 'Insert';
    $condition = null;
    $types = array('integer', 'integer');
    $columns = array('MixId', 'SongId');
    for ($x = 0; $x < count($songids); $x++) {
        $values = array($mixid, $songids[$x]);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml2 = createXML($table, $args);
        $res = $sqlconn->query($xml2, $queryType, $condition);
    }
}
Ejemplo n.º 9
0
function deleteValuesFromTempTable($emailDelete, $sql)
{
    $table = 'TempUser';
    $queryType = 'Delete';
    $condition = array('Email', $emailDelete, 'text');
    $types = array('text');
    $columns = array('Email');
    $somevalues = array(null);
    $args = array('column' => $columns, 'value' => $somevalues, 'type' => $types);
    $xml = createXML($table, $args);
    $res = $sql->query($xml, $queryType, $condition);
}
Ejemplo n.º 10
0
function writeXML()
{
    $datei = fopen("authors.xml", "w");
    $result = createXML();
    fwrite($datei, $result);
    $ref = $_SERVER['HTTP_REFERER'];
    header("Location:" . $ref);
}
Ejemplo n.º 11
0
function checkIfUserExists($emailCheck, $sqlconn)
{
    $table = 'UserInfo';
    $queryType = 'Select';
    $condition = array('Email', $emailCheck, 'text');
    $types = array('text');
    $columns = array('Email');
    $values = array(null);
    $args = array('column' => $columns, 'value' => $values, 'type' => $types);
    $xml = createXML($table, $args);
    $res = $sqlconn->query($xml, $queryType, $condition);
    $checkValues = getValues($res);
    if ($checkValues . "" == strtolower($emailCheck) . "") {
        return true;
    } else {
        return false;
    }
}