コード例 #1
0
ファイル: home.php プロジェクト: Sala/skype-stats
function saveSkypeInput($input)
{
    global $DB, $smileys;
    /**
     * Match all the lines from skype like this one -> [05-Jan-15 10:02:31] <name>:
     */
    preg_match_all("/\\[(\\d\\d-.{3}-\\d\\d \\d\\d[:]\\d\\d[:]\\d\\d)] ([^:]*): (.*)/", $input, $lines);
    $users = array();
    $logs = array();
    for ($i = 0; $i < count($lines[0]); $i++) {
        $date = date("Y-m-d H:i:s", strtotime($lines[1][$i]));
        $user = $lines[2][$i];
        $text = $lines[3][$i];
        if (!in_array($user, $users)) {
            $users[] = $user;
        }
        /* save individual users */
        $user_id = array_search($user, $users);
        if ($user_id !== FALSE) {
            $user_id += 1;
        }
        /* check for links in the text */
        preg_match("/http[^\\s]*/", $text, $output);
        if (!empty($output)) {
            $link = $output[0];
        } else {
            $link = '';
        }
        /* check for smileys */
        $smiley = '';
        foreach ($smileys as $s) {
            if (strpos($text, $s) !== FALSE) {
                /* We store only the first smiley */
                $smiley = $s;
                break;
            }
        }
        /* check to see if we have a quote in the text */
        preg_match("/\\[[^\\s]*, [^\\s]* \\d{1,2}, \\d{4} \\d{2}[:]\\d{2}\\] ([^:]*)/", $input, $output);
        if (!empty($output)) {
            $q_user = $output[1];
            if (!in_array($q_user, $users)) {
                $users[] = $q_user;
            }
            $quote = array_search($q_user, $users);
        } else {
            $quote = 0;
        }
        /* we count the amount of ")" but only for the ones that have ":" before so it would look like a smiley*/
        preg_match_all("/[:|;][^\\s]+\\)+/", $text, $output);
        /* How much fun is in this link #lol */
        $fun = substr_count($text, ")");
        $fun += substr_count($text, "lol");
        $logs[] = array('date' => $date, 'user' => $user_id, 'message' => $text, 'link' => $link, 'smiley' => $smiley, 'quote' => $quote, 'fun' => $fun);
    }
    $response = saveUsers($users);
    if (!empty($response)) {
        return $response;
    }
    $response = saveLogs($logs);
    if (!empty($response)) {
        return $response;
    }
    return array('message' => 'Import finished successfully!', 'type' => 'success');
}
コード例 #2
0
ファイル: cron.router.php プロジェクト: parkerj/eduTrac-SIS
                                Content-Transfer-Encoding: base64  
                                Content-Disposition: attachment  

                                <?php 
                                echo $attachment;
                                ?>
 
                                --PHP-mixed-<?php 
                                echo $random_hash;
                                ?>
-- 

                                <?php 
                                $message = ob_get_clean();
                                $mail_sent = $email->etsis_mail($cronjob['maillogaddress'], 'Cronjob log ' . date('Y-m-d H:i:s') . ' for ' . htmlspecialchars($cronjob['url']), $message, $headers);
                                saveLogs($mail_sent ? 'Mail sent' : 'Mail failed');
                            }
                        }
                        curl_close($ch);
                    }
                    // update cronjob list as the user can change stuff...
                    $cronjobs = getCronjobs();
                }
            }
            $cronjobs['run'] = false;
            saveCronjobs($cronjobs);
        } else {
            die('cronjob database file not found...');
        }
    });
    $app->get('/activityLog/', function () {