Пример #1
0
function art_insert($album_id, $artist, $album)
{
    mp3act_connect();
    $query = '';
    $image = art_query($artist, $album);
    if ($image != "") {
        $query = "UPDATE mp3act_albums SET album_art=\"{$album_id}.jpg\" WHERE album_id={$album_id}";
        mysql_query($query);
        $tmpimg = _http_get($image);
        $path = $GLOBALS['abs_path'] . "/art/";
        $file = "{$album_id}.jpg";
        $filename = $path . $file;
        touch($filename);
        // Let's make sure the art directory is writable first.
        if (is_writable($filename)) {
            if (!($handle = fopen($filename, 'a'))) {
                echo "Cannot open file ({$filename})";
                exit;
            }
            // Write $somecontent to our opened file.
            if (fwrite($handle, $tmpimg) === FALSE) {
                echo "Cannot write to file ({$filename})";
                exit;
            }
            fclose($handle);
        } else {
            echo "The file {$filename} is not writable";
        }
        return $file;
    } else {
        $query = "UPDATE mp3act_albums SET album_art=\"fail\" WHERE album_id={$album_id}";
        mysql_query($query);
    }
}
Пример #2
0
function http_get($urls)
{
    $wantarray = is_array($urls);
    if (!$wantarray) {
        $urls = array($urls);
    }
    $bodies = array();
    $pass_urls = array();
    $pass_urls_indices = array();
    for ($i = 0; $i < count($urls); $i++) {
        $fname = md5($urls[$i] . strftime("%Y-%j-%H"));
        $b = @file_get_contents("/tmp/{$fname}");
        if ($b) {
            $bodies[$i] = $b;
        } else {
            $pass_urls[] = $urls[$i];
            $pass_urls_indices[] = $i;
        }
    }
    $b = _http_get($pass_urls);
    for ($i = 0; $i < count($pass_urls); $i++) {
        $bodies[$pass_urls_indices[$i]] = $b[$i];
        $fname = md5($pass_urls[$i] . strftime("%Y-%j-%H"));
        file_put_contents("/tmp/{$fname}", $b[$i]);
    }
    ksort($bodies);
    return $wantarray ? $bodies : $bodies[0];
}
function handleComments($pageId = null)
{
    if (isset($_POST['postComment'])) {
        // message field is used as "Honney Pot" trap
        if ($pageId && isset($_POST['message']) && !$_POST['message']) {
            $file = dirname(__FILE__) . '/' . $pageId . '.comments.dat';
            $data = is_file($file) ? file_get_contents($file) : null;
            $data = $data ? @json_decode($data) : array();
            if (trim($_POST['text'])) {
                $data[] = $comment = array('date' => date('Y-m-d'), 'time' => date('H:i'), 'user' => $_POST['name'] ? $_POST['name'] : 'anonymous', 'text' => substr($_POST['text'], 0, 200));
                file_put_contents($file, json_encode($data));
                // post info to builder
                if (function_exists('curl_init')) {
                    global $user_key, $user_hash, $comment_callback;
                    $res = _http_get($comment_callback, array('key' => $user_key, 'hash' => md5($user_key . $user_hash), 'id' => $pageId, 'date' => base64_encode($comment['date']), 'time' => base64_encode($comment['time']), 'name' => base64_encode($comment['user']), 'message' => base64_encode($comment['text'])));
                }
            }
        }
        list($ru) = explode('?', $_SERVER['REQUEST_URI']);
        list($ru) = explode('#', $ru);
        header('Location: ' . $ru . '#wb_comment_box');
        exit;
    }
}
Пример #4
0
            $str = str_replace('\'', '"', "[" . $matches[1] . "]");
            $submoduleUids = json_decode($str, true);
            $uids = array_merge($projectUids, $submoduleUids);
        } else {
            $uids = $projectUids;
        }
        $phonesResult = mysqli_query($connSlave, 'SELECT phone, mailprefix FROM `monitor` WHERE id IN (' . implode(',', $uids) . ')');
        while ($monitorPhone = mysqli_fetch_array($phonesResult, MYSQLI_ASSOC)) {
            $phone[] = $monitorPhone['phone'];
            $mailprefix[] = $monitorPhone['mailprefix'];
        }
        //短信接口
        $url = 'http://202.108.35.62/serverguard/SendV2.php?user=general&password=nbaa8a2a1d5b981deacb8c1e2general&phone=' . urlencode(implode(',', $phone)) . '&msg=' . urlencode($messageSend) . '&level=' . urlencode($submodule['level']);
        _http_get($url, array('timeout' => 1), $info);
        $url = 'http://i.alarm.mix.sina.com.cn/?s=client&a=message&format=json&to=' . urlencode(implode(',', $mailprefix)) . '&content=' . urlencode($messageSend) . '&level=' . urlencode($submodule['level']);
        _http_get($url, array('timeout' => 1), $info);
        memcache_delete($mc, $smsMsgKey);
        echo 'sms';
        //exit('sms');
    }
}
$mailMsgKey = implode('|', array('mail_msg', $submodule['id']));
$mailMsgInitRes = memcache_add($mc, $mailMsgKey, 1, false, 3600);
if ($mailMsgInitRes === false) {
    $mailMsgCount = memcache_increment($mc, $mailMsgKey, 1);
} else {
    $mailMsgCount = 1;
}
echo $mailMsgCount;
$mailWarningKey = implode('|', array('mail', $submodule['id']));
if ($mailMsgCount >= $submodule['mail_limit'] && $submodule['mail_status']) {