Пример #1
0
 function isertUrlwebsite($id_content)
 {
     $curl = $this->getState('curl_api');
     $key = trim($this->getState('curl_key'));
     $url = trim(strip_tags(htmlspecialchars(JRequest::getString('url_img'))));
     if ($curl == 1) {
         require JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'googleApi.php';
         $Google = new GoogleURL($key);
         $url = $Google->shorten($url);
     } else {
         $url = $url;
     }
     $db = JFactory::getDbo();
     $sql_inert = "INSERT INTO #__tz_pinboard_website VALUES(NULL,'" . $url . "','" . $id_content . "','0','0')";
     $db->setQuery($sql_inert);
     $db->query();
 }
 /**
  * Add a new follower to the table
  **/
 protected function addFollower($data)
 {
     /**
      * Set up database connection
      */
     ORM::configure('mysql:host=localhost;dbname=' . DATABASE_TABLE);
     ORM::configure('username', DATABASE_USERNAME);
     ORM::configure('password', DATABASE_PASSWORD);
     if ($data['screen_name'] == TWITTER_USERNAME) {
         return;
     }
     // TODO change to production twitter handle
     $follow_code = md5($data['screen_name']);
     $follower = ORM::for_table('followers')->where('twitter_id', $data['id'])->find_one();
     if ($follower == false) {
         $follower = ORM::for_table('followers')->create();
         $follower->twitter_id = $data['id'];
         $follower->username = $data['screen_name'];
         $follower->follow_code = $follow_code;
     }
     $follower->created = date('Y-m-d H:i:s', time());
     $follower->save();
     /**
      * Send Direct Message
      **/
     $google = new GoogleURL(GOOGLE_API_KEY);
     $url = $google->shorten(WEB_APP_BASE_URL . "?follow_code={$follow_code}");
     $message = "Thanks for following, please visit " . $url . " within the hour to verify your age or you'll be blocked.";
     $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
     $message_resp = $connection->post('direct_messages/new', array('user_id' => $data['id'], 'text' => $message));
     System_Daemon::log(System_Daemon::LOG_INFO, "New request to follow, direct message http code resp was " . $connection->http_code);
     // get rid of db connection
     unset($follower);
     // get rid of db connection
 }