Exemplo n.º 1
1
 /**
  * Returns the cookie as a string.
  *
  * @return string The cookie
  */
 public function __toString()
 {
     $str = urlencode($this->getName()) . '=';
     if ('' === (string) $this->getValue()) {
         $str .= 'deleted; expires=' . gmdate('D, d-M-Y H:i:s T', time() - 31536001);
     } else {
         $str .= urlencode($this->getValue());
         if ($this->getExpiresTime() !== 0) {
             $str .= '; expires=' . gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime());
         }
     }
     if ($this->path) {
         $str .= '; path=' . $this->path;
     }
     if ($this->getDomain()) {
         $str .= '; domain=' . $this->getDomain();
     }
     if (true === $this->isSecure()) {
         $str .= '; secure';
     }
     if (true === $this->isHttpOnly()) {
         $str .= '; httponly';
     }
     return $str;
 }
Exemplo n.º 2
1
 /**
  * Get fonts URL.
  *
  * @return string
  */
 function educator_theme_fonts_url()
 {
     $fonts = array();
     $fonts[] = get_theme_mod('headings_font', 'Open Sans');
     $fonts[] = get_theme_mod('body_font', 'Open Sans');
     $font_families = array();
     $available_fonts = apply_filters('ib_theme_get_fonts', array());
     foreach ($fonts as $font_name) {
         if (isset($font_families[$font_name])) {
             continue;
         }
         if (isset($available_fonts[$font_name])) {
             $font = $available_fonts[$font_name];
             $font_families[$font_name] = urlencode($font_name);
             if (!empty($font['font_styles'])) {
                 $font_families[$font_name] .= ':' . $font['font_styles'];
             }
         }
     }
     if (empty($font_families)) {
         return false;
     }
     $query_args = array(array('family' => implode('|', $font_families)));
     $charater_sets = get_theme_mod('charater_sets', 'latin,latin-ext');
     if (!empty($charater_sets)) {
         $query_args['subset'] = educator_sanitize_character_sets($charater_sets);
     }
     return add_query_arg($query_args, '//fonts.googleapis.com/css');
 }
Exemplo n.º 3
0
 protected function callFunction($class, $function, $params)
 {
     $paramString = "/";
     foreach ($params as $param) {
         $paramString .= urlencode($param) . "/";
     }
     $url = Config::WWWPath . "/server/json.php/v1." . $class . "." . $function . $paramString;
     if (TestConf::verbosity > 3) {
         echo "\tCalling URL: " . $url . "\n";
     }
     if (!function_exists('curl_init')) {
         die('You must have cUrl installed to run this test.');
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_REFERER, Config::WWWPath . '/server/test');
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     $output = curl_exec($ch);
     curl_close($ch);
     if (TestConf::verbosity == 5) {
         echo "\t\tResult: " . $this->stripComments($output) . "\n";
     }
     if (TestConf::verbosity > 5) {
         echo "\t\tResult: " . $output . "\n";
     }
     return $output;
 }
Exemplo n.º 4
0
 function getPublicKeyFromServer($server, $email)
 {
     /* refactor to 
     		$command = "gpg --keyserver ".escapeshellarg($server)." --search-keys ".escapeshellarg($email)."";
     		echo "$command\n\n";
     		
     		//execute the gnupg command
     		exec($command, $result);
     		*/
     $curl = new curl();
     // get Fingerprint
     $data = $curl->get("http://" . $server . ":11371/pks/lookup?search=" . urlencode($email) . "&op=index&fingerprint=on&exact=on");
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     //$pub = $matches[1][1];
     preg_match_all("/<a href=\"(.*?)\">(\\w*)<\\/a>/", $matches[1][1], $matches);
     $url = $matches[1][0];
     $keyID = $matches[2][0];
     // get Public Key
     $data = $curl->get("http://" . $server . ":11371" . $url);
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     $pub_key = trim($matches[1][0]);
     return array("keyID" => $keyID, "public_key" => $pub_key);
 }
Exemplo n.º 5
0
function uamloginurl($username, $response)
{
    global $lanIP;
    $username = urlencode($username);
    $response = urlencode($response);
    return "http://{$lanIP}:3990/login?username={$username}&response={$response}";
}
Exemplo n.º 6
0
 public function actionToken($state)
 {
     // only poeple on the list should be generating new tokens
     if (!$this->context->token->checkAccess($_SERVER['REMOTE_ADDR'])) {
         echo "Oh sorry man, this is a private party!";
         mail($this->context->token->getEmail(), 'Notice', 'The token is maybe invalid!');
         $this->terminate();
     }
     // facebook example code...
     $stoken = $this->session->getSection('token');
     if (!isset($_GET['code'])) {
         $stoken->state = md5(uniqid(rand(), TRUE));
         //CSRF protection
         $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&scope=" . $this->context->token->getAppPermissions() . "&state=" . $stoken->state;
         echo "<script> top.location.href='" . $dialog_url . "'</script>";
         $this->terminate();
     }
     if (isset($stoken->state) && $stoken->state === $_GET['state']) {
         $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&client_secret=" . $this->context->token->getAppSecret() . "&code=" . $_GET['code'];
         $response = file_get_contents($token_url);
         $params = null;
         parse_str($response, $params);
         $date = new DateTime();
         $date->add(new DateInterval('PT' . $params["expires"] . 'S'));
         $this->context->token->saveToken($params['access_token'], $date);
         echo "Thanks for your token :)";
     } else {
         echo "The state does not match. You may be a victim of CSRF.";
     }
     $this->terminate();
 }
Exemplo n.º 7
0
/**
 * Advanced pagination. Differenced between simple and advanced paginations is that 
 * advanced pagination uses template so its output can be changed in a great number of ways.
 * 
 * All variables are just passed to the template, nothing is done inside the function!
 *
 * @access public
 * @param DataPagination $pagination Pagination object
 * @param string $url_base Base URL in witch we will insert current page number
 * @param string $template Template that will be used. It can be absolute path to existing file
 *   or template name that used with get_template_path will return real template path
 * @param string $page_placeholder Short string inside of $url_base that will be replaced with
 *   current page numer
 * @return null
 */
function advanced_pagination(DataPagination $pagination, $url_base, $template = 'advanced_pagination', $page_placeholder = '#PAGE#')
{
    tpl_assign(array('advanced_pagination_object' => $pagination, 'advanced_pagination_url_base' => $url_base, 'advanced_pagination_page_placeholder' => urlencode($page_placeholder)));
    // tpl_assign
    $template_path = is_file($template) ? $template : get_template_path($template);
    return tpl_fetch($template_path);
}
 function startTestsInSandcastle($workflow)
 {
     // extract information we need from workflow or CLI
     $diffID = $workflow->getDiffId();
     $username = exec("whoami");
     if ($diffID == null || $username == null) {
         // there is no diff and we can't extract username
         // we cannot schedule sandcasstle job
         return;
     }
     // list of tests we want to run in sandcastle
     $tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite");
     // construct a job definition for each test and add it to the master plan
     foreach ($tests as $test) {
         $arg[] = array("name" => "RocksDB diff " . $diffID . " test " . $test, "steps" => $this->getSteps($diffID, $username, $test));
     }
     // we cannot submit the parallel execution master plan to sandcastle
     // we need supply the job plan as a determinator
     // so we construct a small job that will spit out the master job plan
     // which sandcastle will parse and execute
     $arg_encoded = base64_encode(json_encode($arg));
     $command = array("name" => "Run diff " . $diffID . "for user " . $username, "steps" => array());
     $command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode", "determinator" => true, "user" => "root");
     // submit to sandcastle
     $url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user=krad&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
     $cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=659387027470559 ' . '-F token=AeO_3f2Ya3TujjnxGD4 "' . $url . '"';
     $output = shell_exec($cmd);
     // extract sandcastle URL from the response
     preg_match('/url": "(.+)"/', $output, $sandcastle_url);
     echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
     // Ask phabricator to display it on the diff UI
     $this->postURL($diffID, $sandcastle_url[1]);
 }
Exemplo n.º 9
0
 function do_paging()
 {
     if ($this->total_users_for_query > $this->users_per_page) {
         // have to page the results
         $this->paging_text = paginate_links(array('total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'prev_text' => '&laquo; Previous Page', 'next_text' => 'Next Page &raquo;', 'base' => 'users.php?%_%', 'format' => 'userspage=%#%', 'add_args' => array('usersearch' => urlencode($this->search_term))));
     }
 }
Exemplo n.º 10
0
 public function getAll()
 {
     global $lC_Language, $lC_Vqmod;
     $media = $_GET['media'];
     $lC_DirectoryListing = new lC_DirectoryListing('includes/modules/product_attributes');
     $lC_DirectoryListing->setIncludeDirectories(false);
     $lC_DirectoryListing->setStats(true);
     $localFiles = $lC_DirectoryListing->getFiles();
     $addonFiles = lC_Addons_Admin::getAdminAddonsProductAttributesFiles();
     $files = array_merge((array) $localFiles, (array) $addonFiles);
     $cnt = 0;
     $result = array('aaData' => array());
     $installed_modules = array();
     foreach ($files as $file) {
         include $lC_Vqmod->modCheck($file['path']);
         $class = substr($file['name'], 0, strrpos($file['name'], '.'));
         if (class_exists('lC_ProductAttributes_' . $class)) {
             $moduleClass = 'lC_ProductAttributes_' . $class;
             $mod = new $moduleClass();
             $lC_Language->loadIniFile('modules/product_attributes/' . $class . '.php');
             $title = '<td>' . $lC_Language->get('product_attributes_' . $mod->getCode() . '_title') . '</td>';
             $action = '<td class="align-right vertical-center"><span class="button-group compact">';
             if ($mod->isInstalled()) {
                 $action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? '#' : 'javascript://" onclick="uninstallModule(\'' . $mod->getCode() . '\', \'' . urlencode($mod->getTitle()) . '\')') . '" class="button icon-minus-round icon-red' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_uninstall')) . '</a>';
             } else {
                 $action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? '#' : 'javascript://" onclick="installModule(\'' . $mod->getCode() . '\', \'' . urlencode($lC_Language->get('product_attributes_' . $mod->getCode() . '_title')) . '\')') . '" class="button icon-plus-round icon-green' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('button_install')) . '</a>';
             }
             $action .= '</span></td>';
             $result['aaData'][] = array("{$title}", "{$action}");
             $cnt++;
         }
     }
     $result['total'] = $cnt;
     return $result;
 }
Exemplo n.º 11
0
 public function sendResetPasswordEmail($emailOrUserId)
 {
     $user = new User();
     $user->Load("email = ?", array($emailOrUserId));
     if (empty($user->id)) {
         $user = new User();
         $user->Load("username = ?", array($emailOrUserId));
         if (empty($user->id)) {
             return false;
         }
     }
     $params = array();
     //$params['user'] = $user->first_name." ".$user->last_name;
     $params['url'] = CLIENT_BASE_URL;
     $newPassHash = array();
     $newPassHash["CLIENT_NAME"] = CLIENT_NAME;
     $newPassHash["oldpass"] = $user->password;
     $newPassHash["email"] = $user->email;
     $newPassHash["time"] = time();
     $json = json_encode($newPassHash);
     $encJson = AesCtr::encrypt($json, $user->password, 256);
     $encJson = urlencode($user->id . "-" . $encJson);
     $params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
     $emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
     $this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
     return true;
 }
 /**
  * @uses ModelAsController::getNestedController()
  * @param SS_HTTPRequest $request
  * @param DataModel $model
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->setRequest($request);
     $this->setDataModel($model);
     $this->pushCurrent();
     // Create a response just in case init() decides to redirect
     $this->response = new SS_HTTPResponse();
     $this->init();
     // If we had a redirection or something, halt processing.
     if ($this->response->isFinished()) {
         $this->popCurrent();
         return $this->response;
     }
     // If the database has not yet been created, redirect to the build page.
     if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
         $this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
         $this->popCurrent();
         return $this->response;
     }
     try {
         $result = $this->getNestedController();
         if ($result instanceof RequestHandler) {
             $result = $result->handleRequest($this->getRequest(), $model);
         } else {
             if (!$result instanceof SS_HTTPResponse) {
                 user_error("ModelAsController::getNestedController() returned bad object type '" . get_class($result) . "'", E_USER_WARNING);
             }
         }
     } catch (SS_HTTPResponse_Exception $responseException) {
         $result = $responseException->getResponse();
     }
     $this->popCurrent();
     return $result;
 }
Exemplo n.º 13
0
function get_recipe($recipe)
{
    global $doc, $xpath;
    $url = 'http://www.marmiton.org/recettes/recherche.aspx?aqt=' . urlencode($recipe);
    $pageList = file_get_contents($url);
    // get response list and match recipes titles
    if (preg_match_all('#m_titre_resultat[^\\<]*<a .*title="(.+)".* href="(.+)"#isU', $pageList, $matchesList)) {
        // echo"<xmp>";print_r($matchesList[1]);echo"</xmp>";
        // for each recipes titles
        // foreach($matchesList[1] as $recipeTitle) {
        // }
        // take first recipe
        $n = 0;
        $url = 'http://www.marmiton.org' . $matchesList[2][$n];
        $pageRecipe = file_get_contents($url);
        // get recipe (minimize/clean before dom load)
        if (preg_match('#<div class="m_content_recette_main">.*<div id="recipePrevNext2"></div>\\s*</div>#isU', $pageRecipe, $match)) {
            $recipe = $match[0];
            $recipe = preg_replace('#<script .*</script>#isU', '', $recipe);
            $doc = loadDOC($pageRecipe);
            $xpath = new DOMXpath($doc);
            $recipeTitle = fetchOne('//h1[@class="m_title"]');
            $recipeMain = fetchOne('//div[@class="m_content_recette_main"]');
            return '<div class="recipe_root">' . $recipeTitle . $recipeMain . '</div>';
        }
    }
}
Exemplo n.º 14
0
function serve($slimapp,$token){
    if ($token==''){
        //redirect to gate to get token
        $nexturl = $slimapp->global['lms_token_server'] . '?next=' . urlencode($slimapp->global['lms_url']); 
        if ($nextcommand!='')
            $nexturl . '&nextc=' . $nextcommand;
        $slimapp->redirect($nexturl,302);
    }

    $result=array();
    $slimapp->token_extractor_instance->setToken($token);
    if ($slimapp->token_extractor_instance->isTokenValid()){
        foreach($slimapp->token_extractor_instance->get_commands() as $k=>$cmds){
            if (!empty($cmds)){
                $fname  = $cmds['command'];
                $args   = $cmds['args'];
                $result[]=$fname($args);
            } else {
                $result[]=array('errcode'=>1010, 'msg'=>'invalid command due to time expiration');
            }
        }
    } else {
        $result[]=array('errcode'=>1000, 'msg'=>'invalid Token');
    }
    $slimapp->response->headers->set('Content-Type','application/json');
    $slimapp->response->headers->set('Access-Control-Allow-Origin','*');
    $slimapp->response->write(json_encode($result));
}
Exemplo n.º 15
0
 public function process($args)
 {
     $this->output = "";
     if (strlen(trim($args)) > 0) {
         try {
             $url = "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=3&type=video&q=" . urlencode($args) . "&key=" . $this->apikey;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
             $respuesta = curl_exec($ch);
             curl_close($ch);
             $resultados = json_decode($respuesta);
             if (isset($resultados->error)) {
                 $this->output = "Ocurrió un problema al realizar la busqueda: " . $resultados->error->errors[0]->reason;
             } else {
                 if (count($resultados->items) > 0) {
                     $videos = array();
                     foreach ($resultados->items as $video) {
                         array_push($videos, "http://www.youtube.com/watch?v=" . $video->id->videoId . " - " . $video->snippet->title);
                     }
                     $this->output = join("\n", $videos);
                 } else {
                     $this->output = "No se pudieron obtener resultados al realizar la busqueda indicada.";
                 }
             }
         } catch (Exception $e) {
             $this->output = "Ocurrió un problema al realizar la busqueda: " . $e->getMessage();
         }
     } else {
         $this->output = "Digame que buscar que no soy adivino.";
     }
 }
Exemplo n.º 16
0
function getLocationsOfHashtag($hashtag)
{
    require_once __DIR__ . '/config.php';
    $url = 'https://api.twitter.com/1.1/search/tweets.json';
    $getfield = '?lang=en&count=15&q=%40' . $hashtag;
    $requestMethod = 'GET';
    $twitter = new TwitterAPIExchange($twitterSettings);
    $response = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();
    $result = json_decode($response, true);
    $cities = array();
    foreach ($result['statuses'] as $item) {
        if (!empty($item['user']['location'])) {
            $cities[] = $item['user']['location'];
        }
    }
    $locations = array();
    $googleKey = '&key=' . $googleSettings['server_key'];
    foreach ($cities as $city) {
        $response = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=" . urlencode($city) . $googleKey);
        $result = json_decode($response, true);
        foreach ($result['results'] as $item) {
            $item['geometry']['location']['city'] = $city;
            $locations[] = $item['geometry']['location'];
        }
    }
    return $locations;
}
Exemplo n.º 17
0
 /**
  * 检查签名
  * @param  String  $power_id  资源ID
  * @param  String  $signature 签名
  * @return bool
  */
 private function check_power_key()
 {
     $this->load->model('accessModel/Power_model', 'power');
     $power = $this->power->get($this->power_id);
     if (empty($power)) {
         log_message('debug', sprintf("%s---power_id:%s,signature:%s, power_id is not exists", $this->session_id, $this->power_id, $this->signature));
         return FALSE;
     }
     //组织签名数据
     $post = $this->input->post();
     unset($post['signature']);
     if (isset($post['callback'])) {
         $post['callback'] = urlencode($post['callback']);
     }
     if (isset($post['username'])) {
         $post['username'] = urlencode($post['username']);
     }
     //比对签名
     $this->load->helper('signature');
     $t_signature = get_signature($post, $power['power_key']);
     //var_dump($t_signature);
     log_message('debug', sprintf("%s--signature:%s,t_signature:%s", $this->session_id, $this->signature, $t_signature));
     $cmp_resut = strcmp($this->signature, $t_signature);
     if ($cmp_resut == 0) {
         return TRUE;
     } else {
         log_message('ERROR', sprintf("%s--signature:%s,t_signature:%s", $this->session_id, $this->signature, $t_signature));
         return FALSE;
     }
 }
Exemplo n.º 18
0
 /**
  * 普通接口发短信
  * apikey 为云片分配的apikey
  * text 为短信内容
  * mobile 为接受短信的手机号
  */
 public function sendSms($text, $mobile)
 {
     $url = "http://yunpian.com/v1/sms/send.json";
     $encoded_text = urlencode("{$text}");
     $post_string = "apikey={$this->api_key}&text={$encoded_text}&mobile={$mobile}";
     return $this->sock_post($url, $post_string);
 }
Exemplo n.º 19
0
 function request($info)
 {
     $httpObj = new http_class();
     $nhHttp = new nhhttp($httpObj);
     $partnerId = 10;
     //Điền partnerID đc cung cấp
     $key = 'x@l0-th1nkn3t';
     // Điền key của Partner đc cung cấp
     //print_r($_REQUEST);
     $paymentMethodList = split("\\.", trim($_REQUEST['m']));
     //print_r($paymentMethodList);
     $paymentMethod = trim($paymentMethodList[0]);
     $postValue = array();
     $postValue['o'] = "requestTransaction";
     $postValue['itemid'] = $info['product_id'];
     $postValue['itemdesc'] = urlencode($info['name']);
     $postValue['price'] = $info['price'];
     $postValue['method'] = 'Mua_ngay';
     $postValue['partnerId'] = $partnerId;
     $signal = $this->encodeSignal($postValue['itemid'] . $postValue['itemdesc'] . $postValue['price'] . $postValue['method'] . '|' . $key);
     $postValue['signal'] = $signal;
     $postValue['param'] = "";
     $return = $nhHttp->post("http://payment.xalo.vn/api", $postValue);
     $result = explode("|", $return[0]);
     return $result;
 }
Exemplo n.º 20
0
 function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     if (empty($instance['user_id']) || 'invalid' === $instance['user_id']) {
         if (current_user_can('edit_theme_options')) {
             echo $args['before_widget'];
             echo '<p>' . sprintf(__('You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s">Full instructions</a>.', 'jetpack'), esc_url(admin_url('widgets.php')), 'http://support.wordpress.com/widgets/goodreads-widget/#goodreads-user-id') . '</p>';
             echo $args['after_widget'];
         }
         return;
     }
     if (!array_key_exists($instance['shelf'], $this->shelves)) {
         return;
     }
     $instance['user_id'] = absint($instance['user_id']);
     // Set widget ID based on shelf.
     $this->goodreads_widget_id = $instance['user_id'] . '_' . $instance['shelf'];
     if (empty($title)) {
         $title = esc_html__('Goodreads', 'jetpack');
     }
     echo $args['before_widget'];
     echo $args['before_title'] . $title . $args['after_title'];
     $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode($instance['user_id']) . '.' . urlencode($instance['title']) . ':%20' . urlencode($instance['shelf']) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode($instance['shelf']) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr($this->goodreads_widget_id);
     echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr($this->goodreads_widget_id) . '"></div>' . "\n";
     echo '<script src="' . esc_url($goodreads_url) . '"></script>' . "\n";
     echo $args['after_widget'];
     do_action('jetpack_stats_extra', 'widget', 'goodreads');
 }
Exemplo n.º 21
0
function getBucketObjects($s3, $bucket, $prefix = '')
{
    // Start with empty result array
    $objects = array();
    // Start at beginning of bucket
    $next = '';
    // Retrieve 1000 objects at a time until there are no more
    do {
        // Get next 1000 objects
        $res = $s3->list_objects($bucket, array('marker' => urlencode($next), 'prefix' => $prefix));
        // Make sure the call succeeded
        if (!$res->isOK()) {
            return null;
        }
        // Get the list of objects
        $contents = $res->body->Contents;
        // Append each object to the result array
        foreach ($contents as $object) {
            $objects[] = $object;
        }
        // See if there's more, get next key if so
        $isTruncated = $res->body->IsTruncated == 'true';
        if ($isTruncated) {
            $next = $objects[count($objects) - 1]->Key;
        }
    } while ($isTruncated);
    return $objects;
}
function kill($description = false, $type = 'norecord')
{
    // You may want to define your own error handling system here.
    switch ($type) {
        case 'onpage':
            echo "<h3>{$description}</h3>";
            die;
            break;
        case 'error':
            $showerror = true;
            break;
        case 'inline':
            $print = $description;
            header("Location: " . URL . "error/?error=" . urlencode($print));
            exit;
            break;
        default:
            if (PRODUCTION) {
                // If in production, show an error page and no further insight.
                header("HTTP/1.0 404 Not Found");
                header("Location: {$basedir}error.php");
                die;
            } else {
                header("HTTP/1.0 404 Not Found");
                echo '<p><strong>' . nl2br($description) . '</strong></p>' . nl2br(getinfo());
                die;
            }
    }
}
Exemplo n.º 23
0
 public function collectData(array $param)
 {
     $page = 0;
     $tags = '';
     if (isset($param['p'])) {
         $page = (int) preg_replace("/[^0-9]/", '', $param['p']);
         $page = $page - 1;
         $page = $page * 50;
     }
     if (isset($param['t'])) {
         $tags = urlencode($param['t']);
     }
     $html = $this->file_get_html("http://mspabooru.com/index.php?page=post&s=list&tags={$tags}&pid={$page}") or $this->returnError('Could not request Mspabooru.', 404);
     foreach ($html->find('div[class=content] span') as $element) {
         $item = new \Item();
         $item->uri = 'http://mspabooru.com/' . $element->find('a', 0)->href;
         $item->postid = (int) preg_replace("/[^0-9]/", '', $element->getAttribute('id'));
         $item->timestamp = time();
         $item->thumbnailUri = $element->find('img', 0)->src;
         $item->tags = $element->find('img', 0)->getAttribute('alt');
         $item->title = 'Mspabooru | ' . $item->postid;
         $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: ' . $item->tags;
         $this->items[] = $item;
     }
 }
Exemplo n.º 24
0
/**
 * Sends an header ( 'Location ...' ) to the browser.
 *
 * @param   string   Destination
 * @param   array    Get-Variables
 * @param   bool  if the target we are creating for a redirect
 *                   should be a relative or an absolute url
 *
 * @return bool false if params is not an array
 *
 * @author  Florian Lippert <*****@*****.**>
 * @author  Martin Burchert <*****@*****.**>
 *
 * @changes martin@2005-01-29
 *          - added isRelative parameter
 *          - speed up the url generation
 *          - fixed bug #91
 */
function redirectTo($destination, $get_variables = array(), $isRelative = false)
{
    $params = array();
    if (is_array($get_variables)) {
        foreach ($get_variables as $key => $value) {
            $params[] = urlencode($key) . '=' . urlencode($value);
        }
        $params = '?' . implode($params, '&');
        if ($isRelative) {
            $protocol = '';
            $host = '';
            $path = './';
        } else {
            if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
                $protocol = 'https://';
            } else {
                $protocol = 'http://';
            }
            $host = $_SERVER['HTTP_HOST'];
            if (dirname($_SERVER['PHP_SELF']) == '/') {
                $path = '/';
            } else {
                $path = dirname($_SERVER['PHP_SELF']) . '/';
            }
        }
        header('Location: ' . $protocol . $host . $path . $destination . $params);
        exit;
    } elseif ($get_variables == null) {
        header('Location: ' . $destination);
        exit;
    }
    return false;
}
Exemplo n.º 25
0
 protected function prepare()
 {
     include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     try {
         $this->api = $api = Sputnik::get_plugin($this->id);
     } catch (Exception $e) {
         status_header(500);
         $this->header();
         echo '<p>' . $e->getMessage() . '</p>';
         $this->footer();
         return;
     }
     if (!Sputnik::is_purchased($this->api->slug)) {
         wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id)));
         die;
     }
     if (!current_user_can('install_plugins')) {
         wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik'));
     }
     check_admin_referer($this->nonce_prefix . $this->api->slug);
     include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     $title = sprintf($this->title_format, $this->api->name . ' ' . $this->api->version);
     $nonce = $this->nonce_prefix . $this->id;
     $url = 'update.php?action=install-plugin&plugin=' . $this->id;
     if (isset($_GET['from'])) {
         $url .= '&from=' . urlencode(stripslashes($_GET['from']));
     }
     $type = 'web';
     //Install plugin type, From Web or an Upload.
     if ($this->api->is_theme) {
         $this->upgrader = new Sputnik_ThemeUpgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
     } else {
         $this->upgrader = new Sputnik_Upgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
     }
 }
Exemplo n.º 26
0
 public function pdt($txn)
 {
     $params = array('at' => $this->atPaypal, 'tx' => $txn, 'cmd' => '_notify-synch');
     $content = '';
     foreach ($params as $key => $val) {
         $content .= '&' . $key . '=' . urlencode($val);
     }
     $c = curl_init();
     curl_setopt($c, CURLOPT_URL, $this->paypalEndpoint);
     curl_setopt($c, CURLOPT_VERBOSE, TRUE);
     curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_POST, 1);
     curl_setopt($c, CURLOPT_POSTFIELDS, $content);
     $response = curl_exec($c);
     if (!$response) {
         echo "FAILED: " . curl_error($c) . "(" . curl_errno($c) . ")";
         curl_close($c);
         return false;
     } else {
         $str = urldecode($response);
         $res = explode("\n", strip_tags($str));
         $result = array();
         foreach ($res as $val) {
             $r = explode("=", $val);
             if (count($r) > 1) {
                 $result[$r[0]] = $r[1];
             }
         }
         curl_close($c);
         return $result;
     }
 }
Exemplo n.º 27
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($category, $query)
 {
     $api = "http://api.themoviedb.org/3/search/movie?api_key=6bf6b9f2b6f6902c19e0e94c66c22ebb";
     $client = new \GuzzleHttp\Client();
     $response = $client->get($api, ['query' => ['query' => urlencode($query)]])->json();
     return view('nodes.create')->with('results', $response['results']);
 }
Exemplo n.º 28
0
function sendMessage($phoneTo, $textMessage)
{
    $user = "******";
    $password = "******";
    $api_id = "3356658";
    $baseurl = "http://api.clickatell.com";
    $text = urlencode($textMessage);
    $to = $phoneTo;
    // auth call
    $url = "{$baseurl}/http/auth?user={$user}&password={$password}&api_id={$api_id}";
    // do auth call
    $ret = file($url);
    // explode our response. return string is on first line of the data returned
    $sess = explode(":", $ret[0]);
    if ($sess[0] == "OK") {
        $sess_id = trim($sess[1]);
        // remove any whitespace
        $url = "{$baseurl}/http/sendmsg?session_id={$sess_id}&to={$to}&text={$text}";
        // do sendmsg call
        $ret = file($url);
        $send = explode(":", $ret[0]);
        if ($send[0] == "ID") {
            // echo "success\nmessage ID: ". $send[1];
            return true;
        } else {
            // echo "send message failed";
            return false;
        }
    } else {
        // echo "Authentication failure: ". $ret[0];
        return false;
    }
}
 function ajax_calls($call, $data)
 {
     global $sitepress_settings, $sitepress;
     switch ($call) {
         case 'set_pickup_mode':
             $method = intval($data['icl_translation_pickup_method']);
             $iclsettings['translation_pickup_method'] = $method;
             $sitepress->save_settings($iclsettings);
             if (!empty($sitepress_settings)) {
                 $data['site_id'] = $sitepress_settings['site_id'];
                 $data['accesskey'] = $sitepress_settings['access_key'];
                 $data['create_account'] = 0;
                 $data['pickup_type'] = $method;
                 $icl_query = new ICanLocalizeQuery();
                 $res = $icl_query->updateAccount($data);
             }
             if ($method == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) {
                 wp_clear_scheduled_hook('icl_hourly_translation_pickup');
             } else {
                 wp_schedule_event(time(), 'hourly', 'icl_hourly_translation_pickup');
             }
             echo json_encode(array('message' => 'OK'));
             break;
         case 'pickup_translations':
             if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) {
                 $fetched = $this->poll_for_translations(true);
                 echo json_encode(array('message' => 'OK', 'fetched' => urlencode('&nbsp;' . sprintf(__('Fetched %d translations.', 'sitepress'), $fetched))));
             } else {
                 echo json_encode(array('error' => __('Manual pick up is disabled.', 'sitepress')));
             }
             break;
     }
 }
Exemplo n.º 30
0
 public function viewthread_modoption()
 {
     global $_G;
     if (!$_G['adminid']) {
         return false;
     }
     $usergroupsfeedlist = unserialize($_G['setting']['qqgroup_usergroup_feed_list']);
     if (empty($usergroupsfeedlist) || !in_array($_G['groupid'], $usergroupsfeedlist)) {
         if (self::$util->isfounder($_G['member']) == false) {
             return false;
         }
     }
     $tid = $_G['tid'];
     $title = urlencode(trim($_G['forum_thread']['subject']));
     $post = C::t('forum_post')->fetch_all_by_tid_position($_G['fotum_thread']['posttableid'], $_G['tid'], 1);
     include_once libfile('function/discuzcode');
     $content = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", '', trim($post[0]['message']));
     $content = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", '', $content);
     $content = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", '', $content);
     $content = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", '', $content);
     $content = strip_tags(discuzcode($content, 0, 0, 0));
     $content = preg_replace('%\\[attach\\].*\\[/attach\\]%im', '', $content);
     $content = str_replace('&nbsp;', ' ', $content);
     $content = urlencode(cutstr($content, 50, ''));
     include template('qqgroup:push');
     return trim($return);
 }