Beispiel #1
0
function startthelog($logname, $quick = FALSE)
{
    logit($logname, '-----------------------------------------------------------');
    $line = '';
    //logit($logname, $_SERVER['HTTP_REFERER']);
    if (!$quick) {
        // doing the dns lookup takes some extra time so use $quick to speed things up a bid
        $line = gethostbyaddr($_SERVER["REMOTE_HOST"]);
        if ($line == $_SERVER["REMOTE_ADDR"]) {
            $line = '** No DNS entry found for calling IP';
        }
        $line = ' - ' . $line;
    }
    logit($logname, $_SERVER["REMOTE_ADDR"] . $line);
    if (key_exists('HTTP_USER_AGENT', $_SERVER)) {
        logit($logname, $_SERVER['HTTP_USER_AGENT'] . $line);
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (substr(str_replace(chr(10), '', print_r($_POST, true)), 10) == '') {
            logit($logname, 'Called as a POST, but NO values were passed in');
        } else {
            logit($logname, 'POST values: ' . substr(str_replace(chr(10), '', print_r($_POST, true)), 10));
        }
    }
    if ($_SERVER["QUERY_STRING"] != '') {
        logit($logname, 'GET param string: ' . $_SERVER["QUERY_STRING"]);
    }
}
Beispiel #2
0
function SetSessionVals($clientuserrecord, $PDOconn, $logname)
{
    $cancontinue = TRUE;
    //load client details
    $_SESSION['clientdefaults']['clientid'] = $clientuserrecord->clientid;
    $theq = 'select * from client where clientid=:clientid';
    try {
        $pdoquery = $PDOconn->prepare($theq);
        $pdoquery->setFetchMode(PDO::FETCH_OBJ);
        $pdoquery->execute(array('clientid' => $_SESSION["clientdefaults"]["clientid"]));
        $client = $pdoquery->fetch();
    } catch (PDOException $e) {
        logit($logname, '  **ERROR** on line ' . __LINE__ . ' with query - ' . $theq . ' ' . $e->getMessage());
        $cancontinue = FALSE;
    }
    if ($cancontinue) {
        $_SESSION["clientdefaults"]["dbname"] = $client->dbname;
        $_SESSION["clientdefaults"]["host"] = $client->host;
        $_SESSION["clientdefaults"]["fullname"] = $client->fullname;
        $_SESSION["clientdefaults"]["schoollogo"] = $client->schoollogo;
        $_SESSION["clientdefaults"]["fedidprefix"] = $client->fedidprefix;
    }
    if ($cancontinue) {
        $cancontinue = GetTheHTMLs($_SESSION["userlanguage"], $_SESSION["clientdefaults"]["clientid"], $PDOconn, $logname);
    }
    if ($cancontinue) {
        header('Location: school.php');
    }
    return $cancontinue;
}
Beispiel #3
0
/**
 * Call the Yahoo Contact API
 * @param string $consumer_key obtained when you registered your app
 * @param string $consumer_secret obtained when you registered your app
 * @param string $guid obtained from getacctok
 * @param string $access_token obtained from getacctok
 * @param string $access_token_secret obtained from getacctok
 * @param bool $usePost use HTTP POST instead of GET
 * @param bool $passOAuthInHeader pass the OAuth credentials in HTTP header
 * @return response string with token or empty array on error
 */
function call_yql($consumer_key, $consumer_secret, $querynum, $access_token, $access_token_secret, $usePost = false, $passOAuthInHeader = true)
{
    $retarr = array();
    // return value
    $response = array();
    if ($querynum == 1) {
        $url = 'http://query.yahooapis.com/v1/yql';
        // Show my profile
        $params['q'] = 'select * from social.profile where guid=me';
    } elseif ($querynum == 2) {
        $url = 'http://query.yahooapis.com/v1/yql';
        // Find my friends
        $params['q'] = 'select * from social.connections where owner_guid=me';
    } else {
        // Since this information is public, use the non oauth endpoint 'public'
        $url = 'http://query.yahooapis.com/v1/public/yql';
        // Find all sushi restaurants in SF order by number of ratings desc
        $params['q'] = 'select Title,Address,Rating from local.search where query="sushi" and location="san francisco, ca"|sort(field="Rating.TotalRatings",descending="true")';
    }
    $params['format'] = 'json';
    $params['callback'] = 'cbfunc';
    $params['oauth_version'] = '1.0';
    $params['oauth_nonce'] = mt_rand();
    $params['oauth_timestamp'] = time();
    $params['oauth_consumer_key'] = $consumer_key;
    $params['oauth_token'] = $access_token;
    // compute hmac-sha1 signature and add it to the params list
    $params['oauth_signature_method'] = 'HMAC-SHA1';
    $params['oauth_signature'] = oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params, $consumer_secret, $access_token_secret);
    // Pass OAuth credentials in a separate header or in the query string
    if ($passOAuthInHeader) {
        $query_parameter_string = oauth_http_build_query($params, true);
        $header = build_oauth_header($params, "yahooapis.com");
        $headers[] = $header;
    } else {
        $query_parameter_string = oauth_http_build_query($params);
    }
    // POST or GET the request
    if ($usePost) {
        $request_url = $url;
        logit("call_yql:INFO:request_url:{$request_url}");
        logit("call_yql:INFO:post_body:{$query_parameter_string}");
        $headers[] = 'Content-Type: application/x-www-form-urlencoded';
        $response = do_post($request_url, $query_parameter_string, 80, $headers);
    } else {
        $request_url = $url . ($query_parameter_string ? '?' . $query_parameter_string : '');
        logit("call_yql:INFO:request_url:{$request_url}");
        $response = do_get($request_url, 80, $headers);
    }
    // extract successful response
    if (!empty($response)) {
        list($info, $header, $body) = $response;
        if ($body) {
            logit("call_yql:INFO:response:");
            print json_pretty_print($body);
        }
        $retarr = $response;
    }
    return $retarr;
}
Beispiel #4
0
 public function log_activity($user_id = null, $activity = '', $module = 'any')
 {
     if (!is_numeric($user_id) || empty($activity)) {
         logit('Not enough information provided to insert activity.');
     }
     $data = array('user_id' => $user_id, 'activity' => $activity, 'module' => $module);
     return parent::insert($data);
 }
Beispiel #5
0
 public function update_from_feed()
 {
     $xpath = "//a[contains(@href, \"mp3\")]";
     $url = $this->main_url;
     logit("Gathering ... {$url}");
     logit("Xpath: {$xpath}");
     $feed_contents = $this->read_feed($url);
     $doc = new DOMDocument();
     @$doc->loadHTML($feed_contents);
     $dx = new DOMXPath($doc);
     $entries = $dx->query($xpath);
     $all_bayans = array();
     $count = 0;
     foreach ($entries as $entry) {
         // if($count++ >= 40) return $all_bayans;
         logit("Found: " . htmlentities($doc->saveXML($entry)));
         $ps1 = $entry->previousSibling;
         $ps2 = $ps1->previousSibling;
         $ps3 = $ps2->previousSibling;
         $ps4 = $ps3->previousSibling;
         $ps5 = $ps4->previousSibling;
         $ps6 = $ps5->previousSibling;
         /* 
         logit(" -- ps1: " . htmlentities($doc->saveXML($ps1)));  
         logit(" -- ps2: " . htmlentities($doc->saveXML($ps2)));  
         logit(" -- ps3: " . htmlentities($doc->saveXML($ps3)));  
         logit(" -- ps4: " . htmlentities($doc->saveXML($ps4)));  
         logit(" -- ps5: " . htmlentities($doc->saveXML($ps5)));  
         logit(" -- ps6: " . htmlentities($doc->saveXML($ps6)));  
         */
         $ps4_dt = trim(strip_tags($ps4->nodeValue));
         $ps6_dt = trim(strip_tags($ps6->nodeValue));
         // check which format we have
         if ($this->validate_date($ps4_dt)) {
             // older format
             $date_str = $this->convert_date($ps4_dt);
             $title_str = trim(strip_tags($ps2->nodeValue));
         } else {
             if ($this->validate_date($ps6_dt)) {
                 // newer format
                 $date_str = $this->convert_date($ps6_dt);
                 $title_str = trim(strip_tags($ps4->nodeValue));
             } else {
                 logit(" =====> ERROR: COULDN'T UNDERSTAND THE FORMAT");
                 continue;
             }
         }
         $url_str = $this->prefix_to_url . $entry->getAttribute('href');
         logit(" --- url: " . $url_str);
         logit(" --- date: " . $date_str);
         logit(" --- title: " . $title_str);
         logit(" ------ ");
         $bayan = array('url' => $url_str, 'title' => $title_str, 'uploaded_on' => $date_str);
         $all_bayans[] = $bayan;
     }
     return $all_bayans;
 }
/**
 * Call the Yahoo Contact API
 * @param string $consumer_key obtained when you registered your app
 * @param string $consumer_secret obtained when you registered your app
 * @param string $guid obtained from getacctok
 * @param string $access_token obtained from getacctok
 * @param string $access_token_secret obtained from getacctok
 * @param bool $usePost use HTTP POST instead of GET
 * @param bool $passOAuthInHeader pass the OAuth credentials in HTTP header
 * @return response string with token or empty array on error
 */
function callcontact($consumer_key, $consumer_secret, $guid, $access_token, $access_token_secret, $usePost = false, $passOAuthInHeader = true, $_count)
{
    $retarr = array();
    // return value
    $response = array();
    $url = 'http://social.yahooapis.com/v1/user/' . $guid . '/contacts?count=' . $_count;
    $params['format'] = 'xml';
    $params['view'] = 'compact';
    $params['oauth_version'] = '1.0';
    $params['oauth_nonce'] = mt_rand();
    $params['oauth_timestamp'] = time();
    $params['oauth_consumer_key'] = $consumer_key;
    $params['oauth_token'] = $access_token;
    // compute hmac-sha1 signature and add it to the params list
    $params['oauth_signature_method'] = 'HMAC-SHA1';
    //$params['oauth_signature'] =
    // oauth_compute_hmac_sig($usePost? 'POST' : 'GET', $url, $params,
    // $consumer_secret, $access_token_secret);
    echo ',';
    echo $params['oauth_nonce'];
    echo ',';
    echo $params['oauth_timestamp'];
    echo ',';
    echo oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params, $consumer_secret, $access_token_secret);
    exit(0);
    // Pass OAuth credentials in a separate header or in the query string
    if ($passOAuthInHeader) {
        $query_parameter_string = oauth_http_build_query($params, true);
        $header = build_oauth_header($params, "yahooapis.com");
        $headers[] = $header;
    } else {
        $query_parameter_string = oauth_http_build_query($params);
    }
    // POST or GET the request
    if ($usePost && 0) {
        $request_url = $url;
        logit("callcontact:INFO:request_url:{$request_url}");
        logit("callcontact:INFO:post_body:{$query_parameter_string}");
        $headers[] = 'Content-Type: application/x-www-form-urlencoded';
        $response = do_post($request_url, $query_parameter_string, 80, $headers);
    } else {
        $request_url = $url . ($query_parameter_string ? '?' . $query_parameter_string : '');
        logit("callcontact:INFO:request_url:{$request_url}");
        $response = do_get($request_url, 80, $headers);
    }
    // extract successful response
    if (!empty($response)) {
        list($info, $header, $body) = $response;
        if ($body) {
            logit("callcontact:INFO:response:");
            print json_pretty_print($body);
        }
        $retarr = $response;
    }
    return $retarr;
}
Beispiel #7
0
 /**
  * Displays the Activities for a module
  *
  * @param string $module Name of the module
  * @param int    $limit  The number of activities to return
  *
  * @return string Displays the activities
  */
 public function activity_list($module = null, $limit = 25)
 {
     if (empty($module)) {
         logit('No module provided to `activity_list`.');
         return;
     }
     $this->load->helper('date');
     $activities = $this->activity_model->order_by('created_on', 'desc')->limit($limit, 0)->find_by_module($module);
     $this->load->view('activity_list', array('activities' => $activities));
 }
Beispiel #8
0
function log_hit($status)
{
    global $nolog, $logging;
    if (!isset($nolog) && $status != '404') {
        if ($logging == 'refer') {
            logit('refer', $status);
        } elseif ($logging == 'all') {
            logit('', $status);
        }
    }
}
/**
 * Refresh an access token using an expired request token
 * @param string $consumer_key obtained when you registered your app
 * @param string $consumer_secret obtained when you registered your app
 * @param string $old_access_token obtained previously
 * @param string $old_token_secret obtained previously
 * @param string $oauth_session_handle obtained previously
 * @param bool $usePost use HTTP POST instead of GET (default false)
 * @param bool $useHmacSha1Sig use HMAC-SHA1 signature (default false)
 * @return response string with token or empty array on error
 */
function refresh_access_token($consumer_key, $consumer_secret, $old_access_token, $old_token_secret, $oauth_session_handle, $usePost = false, $useHmacSha1Sig = true, $passOAuthInHeader = true)
{
    $retarr = array();
    // return value
    $response = array();
    $url = 'https://api.login.yahoo.com/oauth/v2/get_token';
    $params['oauth_version'] = '1.0';
    $params['oauth_nonce'] = mt_rand();
    $params['oauth_timestamp'] = time();
    $params['oauth_consumer_key'] = $consumer_key;
    $params['oauth_token'] = $old_access_token;
    $params['oauth_session_handle'] = $oauth_session_handle;
    // compute signature and add it to the params list
    if ($useHmacSha1Sig) {
        $params['oauth_signature_method'] = 'HMAC-SHA1';
        $params['oauth_signature'] = oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params, $consumer_secret, $old_token_secret);
    } else {
        $params['oauth_signature_method'] = 'PLAINTEXT';
        $params['oauth_signature'] = oauth_compute_plaintext_sig($consumer_secret, $old_token_secret);
    }
    // Pass OAuth credentials in a separate header or in the query string
    if ($passOAuthInHeader) {
        $query_parameter_string = oauth_http_build_query($params, true);
        $header = build_oauth_header($params, "yahooapis.com");
        $headers[] = $header;
    } else {
        $query_parameter_string = oauth_http_build_query($params);
    }
    // POST or GET the request
    if ($usePost) {
        $request_url = $url;
        logit("refacctok:INFO:request_url:{$request_url}");
        logit("refacctok:INFO:post_body:{$query_parameter_string}");
        $headers[] = 'Content-Type: application/x-www-form-urlencoded';
        $response = do_post($request_url, $query_parameter_string, 443, $headers);
    } else {
        $request_url = $url . ($query_parameter_string ? '?' . $query_parameter_string : '');
        logit("refacctok:INFO:request_url:{$request_url}");
        $response = do_get($request_url, 443, $headers);
    }
    // extract successful response
    if (!empty($response)) {
        list($info, $header, $body) = $response;
        $body_parsed = oauth_parse_str($body);
        if (!empty($body_parsed)) {
            logit("getacctok:INFO:response_body_parsed:");
            print_r($body_parsed);
        }
        $retarr = $response;
        $retarr[] = $body_parsed;
    }
    return $retarr;
}
Beispiel #10
0
/**
 * Adds a row to the visitor logs.
 *
 * This function follows the site's logging preferences.
 * If $logging preference is set to 'refer', only referrer
 * hits are logged. If $logging is set to 'none' or '$nolog'
 * global to TRUE, the function will ignore all hits.
 *
 * If the $status parameter is set to 404, the hit isn't logged.
 *
 * @param int $status HTTP status code
 * @example
 * log_hit(200);
 */
function log_hit($status)
{
    global $nolog, $logging;
    callback_event('log_hit');
    if (!isset($nolog) && $status != 404) {
        if ($logging == 'refer') {
            logit('refer', $status);
        } elseif ($logging == 'all') {
            logit('', $status);
        }
    }
}
function write($data, $log = true)
{
    global $socket;
    if (is_array($data)) {
        $line = "PRIVMSG " . $data[0] . " :" . $data[1];
    } else {
        $line = $data;
    }
    logit("<<\t" . $line, $log);
    if (!fwrite($socket, $line . "\n")) {
        die("ERROR socket write\n");
    }
}
Beispiel #12
0
 function get_request_token($callback = 'oob', $usePost = false, $useHmacSha1Sig = true, $passOAuthInHeader = false)
 {
     $retarr = array();
     // return value
     $response = array();
     $params['oauth_version'] = '1.0';
     $params['oauth_nonce'] = mt_rand();
     $params['oauth_timestamp'] = time();
     $params['oauth_consumer_key'] = $this->consumer_key;
     $params['oauth_callback'] = $callback;
     $headers = array();
     // compute signature and add it to the params list
     if ($useHmacSha1Sig) {
         $params['oauth_signature_method'] = 'HMAC-SHA1';
         $params['oauth_signature'] = oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $this->reqUrl, $params, $this->consumer_secret, null);
     } else {
         $params['oauth_signature_method'] = 'PLAINTEXT';
         $params['oauth_signature'] = oauth_compute_plaintext_sig($this->consumer_secret, null);
     }
     // Pass OAuth credentials in a separate header or in the query string
     if ($passOAuthInHeader) {
         $query_parameter_string = oauth_http_build_query($params, true);
         $header = build_oauth_header($params, "Twitter API");
         $headers[] = $header;
     } else {
         $query_parameter_string = oauth_http_build_query($params);
     }
     // POST or GET the request
     if ($usePost) {
         $request_url = $this->reqUrl;
         logit("getreqtok:INFO:request_url:{$request_url}");
         logit("getreqtok:INFO:post_body:{$query_parameter_string}");
         $headers[] = 'Content-Type: application/x-www-form-urlencoded';
         $response = do_post($request_url, $query_parameter_string, 80, $headers);
     } else {
         $request_url = $this->reqUrl . ($query_parameter_string ? '?' . $query_parameter_string : '');
         logit("getreqtok:INFO:request_url:{$request_url}");
         $response = do_get($request_url, 80, $headers);
     }
     // extract successful response
     if (!empty($response)) {
         list($info, $header, $body) = $response;
         $body_parsed = oauth_parse_str($body);
         if (!empty($body_parsed)) {
             logit("getreqtok:INFO:response_body_parsed:");
         }
         $retarr = $response;
         $retarr[] = $body_parsed;
     }
     return $retarr;
 }
Beispiel #13
0
function yim_checkinfo($username, $password, $return = array())
{
    // Add to refresh token here
    //Should check if session is valid
    $oauth_data = array_key_exists('oauth_data', $_SESSION) ? $_SESSION['oauth_data'] : array();
    $session_data = array_key_exists('session_data', $_SESSION) ? $_SESSION['session_data'] : array();
    if (count($oauth_data) <= 0 || count($session_data) <= 0 || !yim_session_is_valid($oauth_data, $session_data)) {
        $oauth_data = yim_login($username, $password);
        $session_data = yim_create_session();
        logit("PHP session active (" . session_id() . "). Created new Yahoo session with id: " . $session_data->sessionId . "\n\n");
    } else {
        logit("PHP session active (" . session_id() . "). Using Yahoo! session id: " . $session_data->sessionId . "\n\n");
    }
    return $session_data ? $session_data : false;
}
 public function find_by_module($modules = array())
 {
     if (empty($modules)) {
         logit('No module name given to `find_by_module`.');
         return false;
     }
     if (!is_array($modules)) {
         $modules = array($modules);
     }
     foreach ($modules as $module) {
         $this->db->or_where('module', $module);
     }
     $this->db->select('activity_id, activities.user_id, activity, module, activities.created_on, first_name, last_name, username, email, last_login');
     $this->db->join('users', 'activities.user_id = users.id', 'left');
     return $this->find_all();
 }
Beispiel #15
0
function updatesysdef($key, $value, $dbconn, $logname)
{
    try {
        $theq = " delete from sysdef.system_defaults where sd_item=:key";
        $pdoquery = $dbconn->prepare($theq);
        $pdoquery->execute(array(":key" => $key));
        $theq = " insert into sysdef.system_defaults (sd_value,sd_item)";
        $theq .= " values (:value,:key)";
        $pdoquery = $dbconn->prepare($theq);
        $pdoquery->execute(array(":key" => $key, ":value" => $value));
    } catch (PDOException $e) {
        logit($logname, '  **ERROR** on line ' . __LINE__ . ' with query - ' . $theq . ' ' . $e->getMessage());
        $results->errortext = $e->getMessage();
        $cancontinue = FALSE;
    }
}
Beispiel #16
0
function validate($params)
{
    global $tikilib, $userlib, $known_hosts, $intertiki_errfile, $intertiki_logfile, $logslib;
    $key = $params->getParam(0);
    $key = $key->scalarval();
    $login = $params->getParam(1);
    $login = $login->scalarval();
    $pass = $params->getParam(2);
    $pass = $pass->scalarval();
    $slave = $params->getParam(3);
    $slave = $slave->scalarval();
    if (!isset($known_hosts[$key]) or $known_hosts[$key]['ip'] != $_SERVER['REMOTE_ADDR']) {
        $msg = tra('Invalid server key');
        if ($intertiki_errfile) {
            logit($intertiki_errfile, $msg, $key, INTERTIKI_BADKEY, $known_hosts[$key]['name']);
        }
        $logslib->add_log('intertiki', $msg . ' from ' . $known_hosts[$key]['name'], $login);
        return new XML_RPC_Response(0, 101, $msg);
    }
    if (!$userlib->validate_user($login, $pass, '', '')) {
        $msg = tra('Invalid username or password');
        if ($intertiki_errfile) {
            logit($intertiki_errfile, $msg, $login, INTERTIKI_BADUSER, $known_hosts[$key]['name']);
        }
        $logslib->add_log('intertiki', $msg . ' from ' . $known_hosts[$key]['name'], $login);
        if (!$userlib->user_exists($login)) {
            // slave client is supposed to disguise 102 code as 101 not to show
            // crackers that user does not exists. 102 is required for telling slave
            // to delete user there
            return new XML_RPC_Response(0, 102, $msg);
        } else {
            return new XML_RPC_Response(0, 101, $msg);
        }
    }
    if ($intertiki_logfile) {
        logit($intertiki_logfile, "logged", $login, INTERTIKI_OK, $known_hosts[$key]['name']);
    }
    if ($slave) {
        $logslib->add_log('intertiki', 'auth granted from ' . $known_hosts[$key]['name'], $login);
        global $userlib;
        $user_details = $userlib->get_user_details($login);
        return new XML_RPC_Response(new XML_RPC_Value(serialize($user_details), "string"));
    } else {
        $logslib->add_log('intertiki', 'auth granted from ' . $known_hosts[$key]['name'], $login);
        return new XML_RPC_Response(new XML_RPC_Value(1, "boolean"));
    }
}
Beispiel #17
0
/**
* Call twitter to post a tweet
* @param string $consumer_key obtained when you registered your app
* @param string $consumer_secret obtained when you registered your app
* @param string $status_message
* @param string $access_token obtained from get_request_token
* @param string $access_token_secret obtained from get_request_token
* @param bool $usePost use HTTP POST instead of GET
* @param bool $passOAuthInHeader pass OAuth credentials in HTTP header
* @return response string or empty array on error
*/
function post_tweet($consumer_key, $consumer_secret, $status_message, $access_token, $access_token_secret, $usePost = false, $passOAuthInHeader = true)
{
    $retarr = array();
    // return value
    $response = array();
    //$url = 'http://api.twitter.com/1/statuses/update.json';
    $url = 'http://api.twitter.com/1.1/friendships/incoming.json';
    //$params['status'] = $status_message;
    $params['oauth_version'] = '1.0';
    $params['oauth_nonce'] = mt_rand();
    $params['oauth_timestamp'] = time();
    $params['oauth_consumer_key'] = $consumer_key;
    $params['oauth_token'] = $access_token;
    // compute hmac-sha1 signature and add it to the params list
    $params['oauth_signature_method'] = 'HMAC-SHA1';
    $params['oauth_signature'] = oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params, $consumer_secret, $access_token_secret);
    // Pass OAuth credentials in a separate header or in the query string
    if ($passOAuthInHeader) {
        $query_parameter_string = oauth_http_build_query($params, true);
        $header = build_oauth_header($params, "Twitter API");
        $headers[] = $header;
    } else {
        $query_parameter_string = oauth_http_build_query($params);
    }
    // POST or GET the request
    if ($usePost) {
        $request_url = $url;
        logit("tweet:INFO:request_url:{$request_url}");
        logit("tweet:INFO:post_body:{$query_parameter_string}");
        $headers[] = 'Content-Type: application/x-www-form-urlencoded';
        $response = do_post($request_url, $query_parameter_string, 80, $headers);
    } else {
        $request_url = $url . ($query_parameter_string ? '?' . $query_parameter_string : '');
        logit("tweet:INFO:request_url:{$request_url}");
        $response = do_get($request_url, 80, $headers);
    }
    // extract successful response
    if (!empty($response)) {
        list($info, $header, $body) = $response;
        if ($body) {
            logit("tweet:INFO:response:");
            print json_pretty_print($body);
        }
        $retarr = $response;
    }
    return $retarr;
}
function command($param = "", $log = "")
{
    $out = false;
    if ($line = exec("transmission-remote " . $param, $out)) {
        if (count($out) > 1) {
            $res = rtrim($out[0]);
        } else {
            if (preg_match("/\"(.+)\"/", $line, $reg)) {
                $res = $reg[1];
            }
        }
        if ($log !== false) {
            logit($param, !empty($res) ? $res : "", $log);
        }
    }
    return $out;
}
Beispiel #19
0
/**
 * Call the Yahoo Contact API
 * @param string $consumer_key obtained when you registered your app
 * @param string $consumer_secret obtained when you registered your app
 * @param string $guid obtained from getacctok
 * @param string $access_token obtained from getacctok
 * @param string $access_token_secret obtained from getacctok
 * @param bool $usePost use HTTP POST instead of GET
 * @param bool $passOAuthInHeader pass the OAuth credentials in HTTP header
 * @return response string with token or empty array on error
 */
function postcontact($consumer_key, $consumer_secret, $guid, $access_token, $access_token_secret, $usePost = false, $passOAuthInHeader = true)
{
    $retarr = array();
    // return value
    $response = array();
    $post_body = '{"contact":{"fields":[{"type":"name","value":{"givenName":"John","middleName":"","familyName":"Doe","prefix":"","suffix":"","givenNameSound":"","familyNameSound":""}},{"type":"email","value":"*****@*****.**"}]}}';
    $url = 'http://social.yahooapis.com/v1/user/' . $guid . '/contacts';
    $params['oauth_version'] = '1.0';
    $params['oauth_nonce'] = mt_rand();
    $params['oauth_timestamp'] = time();
    $params['oauth_consumer_key'] = $consumer_key;
    $params['oauth_token'] = $access_token;
    // compute hmac-sha1 signature and add it to the params list
    $params['oauth_signature_method'] = 'HMAC-SHA1';
    $params['oauth_signature'] = oauth_compute_hmac_sig($usePost ? 'POST' : 'GET', $url, $params, $consumer_secret, $access_token_secret);
    // Pass OAuth credentials in a separate header or in the query string
    if ($passOAuthInHeader) {
        $query_parameter_string = oauth_http_build_query($params, true);
        $header = build_oauth_header($params, "yahooapis.com");
        $headers[] = $header;
        $request_url = $url;
    } else {
        $query_parameter_string = oauth_http_build_query($params);
        $request_url = $url . '?' . $query_parameter_string;
    }
    // POST or GET the request
    if ($usePost) {
        logit("postcontact:INFO:request_url:{$request_url}");
        logit("postcontact:INFO:post_body:{$post_body}");
        $headers[] = 'Content-Type: application/json';
        $response = do_post($request_url, $post_body, 80, $headers);
    } else {
        logit("postcontact:INFO:request_url:{$request_url}");
        $response = do_get($request_url, 80, $headers);
    }
    // extract successful response
    if (!empty($response)) {
        list($info, $header, $body) = $response;
        if ($body) {
            logit("postcontact:INFO:response:");
            print json_pretty_print($body);
        }
        $retarr = $response;
    }
    return $retarr;
}
Beispiel #20
0
function getFilePath($rawFilePath, $caller)
{
    include '../../_paths.php';
    logit($caller, "getFilePath:" . $rawFilePath);
    if ($rawFilePath == "''" || $rawFilePath == "") {
        return $rawFilePath;
    }
    $path_info = pathinfo($rawFilePath);
    $fileExtension = $path_info['extension'];
    // get file extension
    logit($caller, "File Extension:" . $fileExtension);
    if ($fileExtension == "flv" || $fileExtension == "f4v") {
        $rawFilePath = $videoRootPath . $rawFilePath;
        logit($caller, "Regular Video file extension:" . $fileExtension . ". Returning path:" . $rawFilePath);
    } else {
        logit($caller, "Non video file extension:" . $fileExtension . ". Returning same path");
    }
    return $rawFilePath;
}
Beispiel #21
0
function convertSingleF4vFile($fileName)
{
    $OS = strtoupper(substr(PHP_OS, 0, 3));
    if ($fileName != "") {
        $fullFilePath = $videoRootPath . $fileName;
        $newname = substr($fileName, 0, strlen($fileName) - 4);
        $convertedFile = $videoRootPath . $newname . "_converted.f4v";
        $backupfile = $videoRootPath . $newname . "_backup.f4v";
        if ($OS == "WIN") {
            logit("f4vconverter.php", $fullFilePath . " to " . $convertedFile);
            exec("f4vpp.exe -i \"" . $fullFilePath . "\" -o \"" . $convertedFile . "\"", $output);
            logit("f4vconverter.php", implode(",", $output));
        } else {
            logit("f4vconverter.php", $fullFilePath . " to " . $convertedFile);
            exec("./f4vpp -i \"" . $fullFilePath . "\" -o \"" . $convertedFile . "\"", $output);
            logit("f4vconverter.php", implode(",", $output));
        }
        rename($fullFilePath, $backupfile);
        rename($convertedFile, $fullFilePath);
    }
}
Beispiel #22
0
function PDOconnect($dbname, $server, $logfile)
{
    $dbname = strtolower($dbname);
    $port = 5432;
    logit($logfile, "Connecting to " . $dbname . ' on ' . $server);
    try {
        $dbconn = new PDO("pgsql:dbname={$dbname}; host={$server}; port={$port}", 'postgres', '123PASSword$%^');
        $dbconn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
        $dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    } catch (PDOException $e) {
        logit($logfile, "  **ERROR** The client connection failed! \n" . $e);
        logit('caughterrors', '  **ERROR** on line ' . __LINE__ . ' of ' . __FILE__ . ' error message:' . $e->getMessage());
        logit('caughterrors', print_r($_SESSION, true));
        echo "<h4>We're sorry, a database error occurred.  Please try again later.</h4>";
        // inform someone about the error
        mail('*****@*****.**', $logfile . ' Error', 'called from: ' . $_SERVER["REMOTE_HOST"] . "<br><br>" . "database connection error<br>" . "trying to connect to: {$dbname} {$server} {$port}<br>" . "From: winmamserver@gmail.com \r\n" . "Content-type: text/html; charset=iso-8859-1");
        //abort - someday should maybe change this so that the calling program deals with the failure
        exit;
    }
    return $dbconn;
}
Beispiel #23
0
 public function add()
 {
     if (filter_var($this->request['receipient'], FILTER_VALIDATE_EMAIL)) {
         if ($this->get_left_inv() > 0) {
             $uniq = $this->gen_unique($this->request['receipient']);
             $invationcheck = DB_DataObject::factory('invitations');
             $invationcheck->id_invhash = $uniq;
             if ($invationcheck->find(TRUE)) {
                 $invationcheck->fetch();
                 $this->session_msg($this->request['receipient'] . ' ' . e('already_invated'));
             } else {
                 $message = e('auto_inv_pre_text');
                 $message .= "\n-----------------\n";
                 $message .= trim(ltrim(trim($this->request['message']), '.'));
                 $message .= "\n\n-----------------\n";
                 $message .= e('auto_follow_this') . "\n" . link_for('register', 'invite&code=' . $uniq);
                 $message .= "\n\n" . e('auto_days_valid') . ' [' . $this->inv_valid_time_days . "]\n";
                 $message .= e('auto_inv_post_text', array($this->inv_abuse_mailaddr));
                 if (mail($this->request['receipient'], e('auto_inv_subj'), $message, $this->inv_mailh)) {
                     $invitations = DB_DataObject::factory('invitations');
                     $invitations->id_users = $this->id;
                     $this->request['time'] = TIME;
                     $this->request['id_invhash'] = $this->gen_unique($this->request['receipient']);
                     $this->request['id_active'] = 0;
                     $save_invation = $this->arc_encrypt_input($invitations, $this->request);
                     $save_invation->insert();
                     logit("[" . $this->id . "] generated hash [" . $this->request['id_invhash'] . "] and invitated someone.");
                     $this->session_msg($this->request['receipient'] . ' ' . e("successfully_invated"));
                 } else {
                     throw new arcException("[" . $this->id . "] Problem sending Invationmail TO SOMEONE.");
                 }
             }
         } else {
             $this->session_msg(e('inv_max_invs') . ' ' . $this->max_invs_per_month);
         }
     } else {
         $this->session_msg($this->request['receipient'] . ' ' . e('invalid_mail_address'));
     }
     redirect('invitation');
 }
<body>
<?php 
include '../../../_logger.php';
function ispringconversion_handler($file_path, $file_name)
{
    logit("iSPringHandler.php", "Welcome To iSpring");
    $file_path = str_replace('../../', "", $file_path);
    $swffile_folder = realpath(".././" . $file_path) . '\\_isp__' . $file_name;
    logit("iSPringHandler.php", "File Path is" . $file_path);
    logit("iSPringHandler.php", "File Name is " . $file_name);
    logit("iSPringHandler.php", "SWF Folder Path  is " . $swffile_folder);
    $swf_file = $file_name . '.swf';
    try {
        $isprComobj = new COM("iSpring.PresentationConverter");
        logit("iSPringHandler.php", "SWFFF COM");
        $listener =& new CEventListener($file_name, realpath(".././" . $file_path));
        com_event_sink($isprComobj, $listener, "_iSpringEvents");
    } catch (Exception $e) {
        echo $e;
    }
    //echo "Opening presentation\n";
    $isprComobj->Settings->Playback->Player->CorePlugins->AddBuiltInPlugin(1);
    $isprComobj->Settings->Navigation->KeyboardEnabled = false;
    $isprComobj->Settings->Navigation->AdvanceOnMouseClick = false;
    try {
        $isprComobj->OpenPresentation(realpath(".././" . $file_path . "/@@-OriginalDocs-@@/" . $file_name));
    } catch (Exception $e) {
        echo $e;
    }
    try {
        //$isprComobj->Presentation->Slides->SaveThumbnails($thum_folder ."/".$file_name.'_files',"thumbnail_",2,140,140,90);
    } catch (Exception $e) {
        //echo $e;
    }
    try {
        $isprComobj->GenerateFlash($swffile_folder, $swf_file, 0, "");
    } catch (Exception $e) {
        echo $e;
    }
Beispiel #25
0
function check_share_permission($sharerid, $permission)
{
    #require_once "access_check.php" ;
    #$filename= basename(__FILE__) ;
    #access_check( $filename ) ;
    include_once "logit.php";
    $athlete_id = $_SESSION['athlete_id'];
    // Assume that the athlete has full permissions for his own data
    if ($athlete_id == $sharerid) {
        return true;
    }
    // Break down permission
    preg_match_all("/\\S+/", $permission, $matches);
    $parts = $matches[0];
    $action = $parts[0];
    $object = $parts[1];
    $permitted = $parts[2];
    // Check permission exists for this athlete_id
    // We need to check that the sharing user is granting this athlete permission
    // Global user id = 99999  only allow this user to view globally permitted logs
    if ($athlete_id != 99999) {
        // user is local so:
        $query = "SELECT permission from share_permissions where \n   athlete_id={$sharerid}\n   AND ( permission='{$permission}' \n   OR permission='{$action} {$object} local'\n   OR permission='{$action} {$object} global' )";
    } else {
        // user is not so:
        $query = "SELECT permission from share_permissions where \n   athlete_id={$sharerid}\n   AND \n   permission='{$action} {$object} global'";
    }
    $result = do_sql($query) or die('Query failed: ' . pg_last_error());
    if (pg_num_rows($result) > 0) {
        logit("Access granted by {$sharerid} for {$permission} ");
        return true;
    } else {
        logit("Access DENIED by {$sharerid} for {$permission} ");
        return false;
    }
    // END OF FUNCTION
}
Beispiel #26
0
 function extract_bayan_info_xpath($feed_contents, $xpath)
 {
     logit("Extracting xpath: " . $xpath);
     $doc = new DOMDocument();
     @$doc->loadHTML($feed_contents);
     $dx = new DOMXPath($doc);
     $entries = $dx->query($xpath);
     $all_bayans = array();
     foreach ($entries as $entry) {
         $bayan = array();
         $children = $entry->childNodes;
         $title_node = $children->item(0);
         $title_str = $title_node->nodeValue;
         $tags_node = $children->item(4);
         $tags_str = $tags_node->nodeValue;
         $uploaded_on_node = $children->item(8);
         $uploaded_on_str = $uploaded_on_node->nodeValue;
         // TODO: FIX the date format
         $url_node = $children->item(10);
         $children = $url_node->childNodes;
         $url_str = "";
         foreach ($children as $child) {
             $node_str = $child->ownerDocument->saveXML($child);
             if (preg_match('/href="(.*\\.mp3)/', $node_str, $matches)) {
                 $url_str = $matches[1];
             }
         }
         // var_dump($title_str, $tags_str, $uploaded_on_str, $url_str);
         $bayan['title'] = $title_str;
         $bayan['tags'] = $tags_str;
         $bayan['uploaded_on'] = $uploaded_on_str;
         $bayan['url'] = $url_str;
         $all_bayans[] = $bayan;
     }
     return $all_bayans;
 }
Beispiel #27
0
 function com()
 {
     global $set, $db, $apx;
     $_REQUEST['id'] = (int) $_REQUEST['id'];
     if (!$_REQUEST['id']) {
         die('missing ID!');
     }
     $res = $db->first("SELECT b.username,a.com_text FROM " . PRE . "_guestbook AS a LEFT JOIN " . PRE . "_user AS b ON a.com_userid=b.userid WHERE a.id='" . $_REQUEST['id'] . "' LIMIT 1");
     if ($_POST['send'] == 1) {
         if (!checkToken()) {
             infoInvalidToken();
         } elseif (!$_POST['id'] || !$_POST['text'] && !$_POST['delcom']) {
             infoNotComplete();
         } else {
             if ($_POST['delcom']) {
                 $db->query("UPDATE " . PRE . "_guestbook SET com_userid='',com_text='',com_time='' WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
             } else {
                 $db->query("UPDATE " . PRE . "_guestbook SET com_userid=IF(com_userid,com_userid,'" . $apx->user->info['userid'] . "'),com_text='" . addslashes($_POST['text']) . "',com_time=IF(com_time,com_time,'" . time() . "') WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
             }
             logit('GUESTBOOK_COM', 'ID #' . $_REQUEST['id']);
             printJSRedirect(get_index('guestbook.show'));
         }
     } else {
         $_POST['text'] = $res['com_text'];
         if ($res['username']) {
             $username = $res['username'];
         } else {
             $username = $apx->user->info['username'];
         }
         $apx->tmpl->assign('ID', $_REQUEST['id']);
         $apx->tmpl->assign('USERNAME', compatible_hsc($username));
         $apx->tmpl->assign('TEXT', compatible_hsc($_POST['text']));
         $apx->tmpl->assign('DELCOM', (int) $_POST['delcom']);
         $apx->tmpl->parse('com');
     }
 }
Beispiel #28
0
get_header();
?>

<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

		<?php 
$args = array('post_type' => 'cals_team_members');
$cals_teams_query = new WP_Query($args);
// Start the loop.
while (have_posts()) {
    the_post();
    $meta = get_post_custom(get_the_ID());
    logit($meta, '$meta: ');
    logit($cals_teams_query, '$cals_teams_query');
    /*			//This is bad b/c I want to display label&data without needing to know meta key
    			if( isset($meta['calsteams_office_location_2']) ){
    				echo $meta['calsteams_office_location_2'][0] ;
    			}*/
    foreach ($meta as $key => $value) {
        /*				echo "key: $key, value: $value[0] <br>";
        
        				if($key =='calsteams_office_location'){
        					echo "Office Location: " . $value[0]; 
        				}*/
        switch ($key) {
            case 'calsteams_office_location':
                echo "Office Location: " . $value[0];
                break;
            default:
}
// ----- only run from command line -----
if (!env_is_cli()) {
    die;
}
// ----- params -----
set_time_limit(0);
error_reporting(E_ALL);
define('CAPTURE', 'onepercent');
// ----- includes -----
include "../../config.php";
// load base config file
include "../../common/functions.php";
// load base functions file
include "../common/functions.php";
// load capture function file
require BASE_FILE . 'capture/common/tmhOAuth/tmhOAuth.php';
$thislockfp = script_lock(CAPTURE);
if (!is_resource($thislockfp)) {
    logit(CAPTURE . ".error.log", "script invoked but will not continue because a process is already holding the lock file.");
    die;
    // avoid double execution of script
}
if (dbserver_has_utf8mb4_support() == false) {
    logit(CAPTURE . ".error.log", "DMI-TCAT requires at least MySQL version 5.5.3 - please upgrade your server");
    exit;
}
// ----- connection -----
dbconnect();
// connect to database @todo, rewrite mysql calls with pdo
tracker_run();
Beispiel #30
0
 function sendpm_exec()
 {
     global $apx, $db, $set;
     //Token prüfen
     if (!checkToken()) {
         printInvalidToken();
         return;
     }
     //FORWARDER
     if (!isset($_REQUEST['done'])) {
         tmessage('sending', array('FORWARDER' => 'action.php?action=user.sendpm&amp;doit=1&amp;sectoken=' . $apx->session->get('sectoken') . '&amp;done=0'));
         return;
     }
     //VARS
     $done = (int) $_REQUEST['done'];
     $countPerCall = 50;
     @set_time_limit(600);
     //Newsletter-Info auslesen
     $newsletter = $set['user']['sendpm_data'];
     if (!isset($newsletter['text'])) {
         die('no valid newsletter!');
     }
     $newsletter['text_clear'] = $newsletter['text'];
     while (preg_match('#\\[([a-z0-9]+)(=.*?)?\\](.*?)\\[/\\1\\]#si', $newsletter['text_clear'])) {
         $text = preg_replace('#\\[([a-z0-9]+)(=.*?)?\\](.*?)\\[/\\1\\]#si', '\\3', $newsletter['text_clear']);
     }
     //SEND NEWSLETTER
     if (is_array($newsletter['groups']) && count($newsletter['groups'])) {
         $data = $db->fetch("SELECT userid, email, pub_poppm, pub_mailpm FROM " . PRE . "_user WHERE active=1 AND reg_key='' AND groupid IN (" . implode(',', $newsletter['groups']) . ") ORDER BY email ASC LIMIT " . $done . "," . $countPerCall);
     } else {
         $data = $db->fetch("SELECT userid, email, pub_poppm, pub_mailpm FROM " . PRE . "_user WHERE active=1 AND reg_key='' ORDER BY email ASC LIMIT " . $done . "," . $countPerCall);
     }
     if (count($data)) {
         foreach ($data as $res) {
             ++$i;
             $this->sendpm_send($res, $newsletter['subject'], $newsletter['text'], $newsletter['text_clear']);
         }
         ////// FORWARDER
         //Vorgang beendet
         if ($i < $countPerCall) {
             $db->query("UPDATE " . PRE . "_config SET value='' WHERE module='user' AND varname='sendpm_data' LIMIT 1");
             logit('USER_SENDPM');
             message($apx->lang->get('MSG_OK'));
             return;
         } else {
             tmessage('sending', array('FORWARDER' => 'action.php?action=user.sendpm&amp;doit=1&amp;sectoken=' . $apx->session->get('sectoken') . '&amp;done=' . ($done + $countPerCall)));
             return;
         }
     } else {
         $db->query("UPDATE " . PRE . "_config SET value='' WHERE module='user' AND varname='sendpm_data' LIMIT 1");
         logit('USER_SENDPM');
         message($apx->lang->get('MSG_OK'));
         return;
     }
 }