Example #1
1
function AddTextAdsExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    $numAds = 5;
    $operations = array();
    for ($i = 0; $i < $numAds; $i++) {
        // Create text ad.
        $textAd = new TextAd();
        $textAd->headline = 'Cruise #' . uniqid();
        $textAd->description1 = 'Visit the Red Planet in style.';
        $textAd->description2 = 'Low-gravity fun for everyone!';
        $textAd->displayUrl = 'www.example.com';
        $textAd->finalUrls = array('http://www.example.com');
        // Create ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->adGroupId = $adGroupId;
        $adGroupAd->ad = $textAd;
        // Set additional settings (optional).
        $adGroupAd->status = 'PAUSED';
        // Create operation.
        $operation = new AdGroupAdOperation();
        $operation->operand = $adGroupAd;
        $operation->operator = 'ADD';
        $operations[] = $operation;
    }
    // Make the mutate request.
    $result = $adGroupAdService->mutate($operations);
    // Display results.
    foreach ($result->value as $adGroupAd) {
        printf("Text ad with headline '%s' and ID '%s' was added.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
    }
}
 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
Example #3
1
 public function testCreatedCustomerWithSpecifiedRef()
 {
     $customerCreateEvent = new CustomerCreateOrUpdateEvent(1, "thelia", "thelia", "street address 1", "street address 2", "street address 3", "0102030405", "0607080910", "63000", "clermont-ferrand", 64, sprintf("*****@*****.**", uniqid()), uniqid(), 1, 0, 0, 0, 'My super company', 'testRef');
     /** @var Customer $customerAction */
     $customerAction = $this->customerAction;
     $customerAction->create($customerCreateEvent, null, $this->getMockEventDispatcher());
     $customerCreated = $customerCreateEvent->getCustomer();
     $this->assertInstanceOf("Thelia\\Model\\Customer", $customerCreated, "new customer created must be an instance of Thelia\\Model\\Customer");
     $this->assertFalse($customerCreated->isNew());
     $this->assertEquals($customerCreateEvent->getFirstname(), $customerCreated->getFirstname());
     $this->assertEquals($customerCreateEvent->getLastname(), $customerCreated->getLastname());
     $this->assertEquals($customerCreateEvent->getTitle(), $customerCreated->getTitleId());
     $this->assertEquals($customerCreateEvent->getEmail(), $customerCreated->getEmail());
     $this->assertEquals($customerCreateEvent->getReseller(), $customerCreated->getReseller());
     $this->assertEquals($customerCreateEvent->getSponsor(), $customerCreated->getSponsor());
     $this->assertEquals($customerCreateEvent->getDiscount(), $customerCreated->getDiscount());
     $this->assertEquals($customerCreateEvent->getRef(), $customerCreated->getRef());
     $addressCreated = $customerCreated->getDefaultAddress();
     $this->assertInstanceOf("Thelia\\Model\\Address", $addressCreated);
     $this->assertEquals($customerCreateEvent->getFirstname(), $addressCreated->getFirstname());
     $this->assertEquals($customerCreateEvent->getLastname(), $addressCreated->getLastname());
     $this->assertEquals($customerCreateEvent->getTitle(), $addressCreated->getTitleId());
     $this->assertEquals($customerCreateEvent->getAddress1(), $addressCreated->getAddress1());
     $this->assertEquals($customerCreateEvent->getAddress2(), $addressCreated->getAddress2());
     $this->assertEquals($customerCreateEvent->getAddress3(), $addressCreated->getAddress3());
     $this->assertEquals($customerCreateEvent->getZipcode(), $addressCreated->getZipcode());
     $this->assertEquals($customerCreateEvent->getCity(), $addressCreated->getCity());
     $this->assertEquals($customerCreateEvent->getCountry(), $addressCreated->getCountryId());
     $this->assertEquals($customerCreateEvent->getPhone(), $addressCreated->getPhone());
     $this->assertEquals($customerCreateEvent->getCellphone(), $addressCreated->getCellphone());
     $this->assertEquals($customerCreateEvent->getCompany(), $addressCreated->getCompany());
 }
Example #4
0
function generateHash($password)
{
    if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) {
        $salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22);
        return crypt($password, $salt);
    }
}
Example #5
0
 public function __construct()
 {
     $configFile = __DIR__ . '/../config.yml';
     $value = Yaml::parse(file_get_contents($configFile));
     $ariAddress = $value['examples']['client']['ari_address'];
     $dialString = $value['examples']['dial_example']['dial_string'];
     $logger = new \Zend\Log\Logger();
     $logWriter = new \Zend\Log\Writer\Stream("php://output");
     $logger->addWriter($logWriter);
     //$filter = new \Zend\Log\Filter\SuppressFilter(true);
     $filter = new \Zend\Log\Filter\Priority(\Zend\Log\Logger::NOTICE);
     $logWriter->addFilter($filter);
     // Connect to the ARI server
     $this->client = new Phparia($logger);
     $this->client->connect($ariAddress);
     $this->client->getAriClient()->onConnect(function () use($dialString) {
         try {
             $this->client->channels()->createChannel($dialString, null, null, null, null, $this->client->getStasisApplicationName(), 'dialed', '8185551212', 30, null, null, array('MYVARIABLE' => 'value'));
         } catch (\phparia\Exception\ServerException $e) {
             $this->log($e->getMessage());
         }
     });
     // Listen for the stasis start
     $this->client->onStasisStart(function (StasisStart $event) use($dialString) {
         if (count($event->getArgs()) > 0 && $event->getArgs()[0] === 'dialed') {
             $this->log('Detected outgoing call with variable MYVARIABLE=' . $event->getChannel()->getVariable('MYVARIABLE')->getValue());
             // Put the new channel in a bridge
             $channel = $event->getChannel();
             $this->bridge = $this->client->bridges()->createBridge(uniqid(), 'dtmf_events, mixing', 'dial_example_bridge');
             $this->bridge->addChannel($channel->getId());
         }
     });
     $this->client->run();
 }
Example #6
0
 /**
  * 开启事务
  * @return Database_Driver_MySQLI_Transaction
  */
 public function start()
 {
     if ($this->id) {
         throw new Exception('transaction has started');
     }
     # 推动连接主数据库
     $this->db_driver->connect(true);
     # 获取连接ID
     $this->_connection_id = $this->db_driver->connection_id();
     # 获取唯一ID
     $this->id = uniqid('TaId_' . rand());
     if (isset(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id])) {
         # 已存在事务,则该事务为子事务
         if ($this->_set_save_point()) {
             //保存事务点
             Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id][$this->id] = true;
         } else {
             $this->id = null;
             # 开启事务失败。
             throw new Exception('start sub transaction error');
         }
     } else {
         # 开启新事务
         $this->_query('SET AUTOCOMMIT=0;');
         if (true === $this->_query('START TRANSACTION;')) {
             # 如果没有建立到当前主服务器的连接,该操作会隐式的建立
             Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id] = array($this->id => true);
         } else {
             $this->id = null;
             # 开启事务失败。
             throw new Exception('start transaction error');
         }
     }
     return true;
 }
Example #7
0
 /**
  * Constructor. 
  * @param string name to use to store in session the captcha string;
  * @return nothing
  */
 function KT_CaptchaImage($name)
 {
     $this->name = 'KT_captcha_' . $name;
     $this->text = $this->getRandomText();
     $this->filename = substr(md5(uniqid(rand(), true)), 0, 8) . '.png';
     $this->lib = $GLOBALS['KT_prefered_image_lib'];
 }
Example #8
0
function smarty_block_form($params, $content, &$smarty, $repeat)
{
    if (!empty($content)) {
        // set default output vars
        $data = array('search_id' => FALSE, 'submit_token_id' => FALSE, 'class' => '', 'content' => $content, 'method' => 'post');
        $modules = $smarty->getTemplateVars('modules');
        if (!empty($modules)) {
            $module = '';
            $prefix = 'module=';
            foreach ($modules as $mod) {
                $module .= $prefix . $mod . '&amp;';
                $prefix = 'sub' . $prefix;
            }
        }
        if (isset($params['target'])) {
            $data['action'] = $params['target'];
        } else {
            $access = AccessObject::Instance();
            $pid = $access->getPermission($modules, $params['controller'], $params['action']);
            $data['action'] = '/?pid=' . $pid . '&' . $module . 'controller=' . $params['controller'] . '&amp;action=' . $params['action'];
        }
        if (isset($params['subfunction'])) {
            $data['action'] .= '&amp;subfunction=' . $params['subfunction'];
            if (isset($params['subfunctionaction'])) {
                $data['action'] .= '&amp;subfunctionaction=' . $params['subfunctionaction'];
            }
        }
        if (isset($params['id'])) {
            $data['action'] .= '&amp;id=' . $params['id'];
        }
        foreach ($params as $name => $value) {
            if ($name[0] === '_') {
                $data['action'] .= '&amp;' . substr($name, 1) . '=' . $value;
            }
        }
        if (isset($params['additional_data'])) {
            foreach ($params['additional_data'] as $name => $value) {
                $data['action'] .= '&amp;' . $name . '=' . $value;
            }
        }
        if (isset($params['class'])) {
            $data['class'] = $params['class'];
        }
        $data['original_action'] = $smarty->getTemplateVars('action');
        if (isset($_GET['search_id'])) {
            $data['search_id'] = $_GET['search_id'];
        }
        // there are some instances where we don't want the submit token
        if (strtoupper($params['submit_token']) !== 'FALSE') {
            $data['submit_token_id'] = uniqid();
            $_SESSION['submit_token'][$data['submit_token_id']] = TRUE;
        }
        $data['display_tags'] = !isset($params['notags']);
        if (isset($params['form_id'])) {
            $data['form_id'] = $params['form_id'];
        }
        // fetch smarty plugin template
        return smarty_plugin_template($smarty, $data, 'block.form');
    }
}
Example #9
0
 public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
 {
     $params = $compiler->getCompiledParams($params);
     $parsedParams = array();
     if (!isset($params['*'])) {
         $params['*'] = array();
     }
     foreach ($params['*'] as $param => $defValue) {
         if (is_numeric($param)) {
             $param = $defValue;
             $defValue = null;
         }
         $param = trim($param, '\'"');
         if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
             throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
         }
         $parsedParams[$param] = $defValue;
     }
     $params['name'] = substr($params['name'], 1, -1);
     $params['*'] = $parsedParams;
     $params['uuid'] = uniqid();
     $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
     $currentBlock =& $compiler->getCurrentBlock();
     $currentBlock['params'] = $params;
     return '';
 }
Example #10
0
 public function testGetValidateHash()
 {
     $password = uniqid();
     $hash = $this->_model->getHash($password);
     $this->assertTrue(is_string($hash));
     $this->assertTrue($this->_model->validateHash($password, $hash));
 }
Example #11
0
 /**
  * Renders audio player for the blog
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function renderAudioPlayer($uri, $options = array())
 {
     // Merge the options with the default options
     $options = array_replace_recursive(self::$defaultAudioOptions, $options);
     // Generate a random uid
     $uniqid = uniqid();
     $uid = 'audio-' . EBMM::getHash($uri . $uniqid);
     // Url to the audio
     $url = $this->normalizeURI($uri);
     // Get the track if there is no track provided
     if (!$options['track']) {
         $options['track'] = basename($url);
     }
     // Set a default artist if artist isn't set
     if (!$options['artist']) {
         $options['artist'] = JText::_('COM_EASYBLOG_BLOCKS_AUDIO_ARTIST');
     }
     $template = EB::template();
     $template->set('uid', $uid);
     $template->set('showTrack', $options['showTrack']);
     $template->set('showDownload', $options['showDownload']);
     $template->set('showArtist', $options['showArtist']);
     $template->set('autoplay', $options['autoplay']);
     $template->set('loop', $options['loop']);
     $template->set('artist', $options['artist']);
     $template->set('track', $options['track']);
     $template->set('url', $url);
     $output = $template->output('site/blogs/blocks/audio');
     return $output;
 }
Example #12
0
 /**
  * Generate the form key based on IP address
  *
  * @return string md5sum of IP address + unique number
  */
 private function generateFormkey()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     // mt_rand() is better than rand()
     $uniqid = uniqid(mt_rand(), true);
     return md5($ip . $uniqid);
 }
 function submit()
 {
     //Check required Fields
     $missing = false;
     if (!isset($_POST["sql"]) || strlen($_POST["sql"]) == 0) {
         $missing = true;
     }
     if ($missing) {
         $this->res->success = false;
         $this->res->message = "missing required field!";
         return null;
     }
     //get vars
     $sql = $_POST["sql"];
     $schema_id = $this->params['schema_id'];
     $schema = Doo::db()->getOne('Schemata', array('where' => 'id = ' . $schema_id));
     $async = isset($_POST['async']) ? $_POST['async'] : 0;
     $coord_name = isset($_POST['coord_name']) ? $_POST['coord_name'] : null;
     $query_id = isset($_POST["query_id"]) ? $_POST["query_id"] : strtoupper(md5(uniqid(rand(), true)));
     //init
     $shard_query = new ShardQuery($schema->schema_name);
     //error!
     if (!empty($shard_query->errors)) {
         //return
         $this->res->message = $shard_query->errors;
         $this->res->success = false;
         return null;
     }
     //set async
     $shard_query->async = $async == true ? true : false;
     //set coord shard
     if (isset($coord_name)) {
         $shard_query->set_coordinator($coord_name);
     }
     //execute query
     $stmt = $shard_query->query($sql);
     //error!
     if (!$stmt && !empty($shard_query->errors)) {
         //return
         $this->res->message = $shard_query->errors;
         $this->res->success = false;
         return null;
     }
     //empty results
     if ($stmt == null && empty($shard_query->errors)) {
         $this->res->data = array();
     }
     //build data
     if (!is_int($stmt)) {
         $this->res->data = $this->json_format($shard_query, $stmt);
         $shard_query->DAL->my_free_result($stmt);
     } else {
         //save job_id
         $this->res->data = $stmt;
     }
     //save message
     $this->res->message = $query_id;
     //return
     $this->res->success = true;
 }
Example #14
0
 function get_valid_layout($layout = array())
 {
     // parse
     $layout = wp_parse_args($layout, array('key' => uniqid(), 'name' => '', 'label' => '', 'display' => 'block', 'sub_fields' => array(), 'min' => '', 'max' => ''));
     // return
     return $layout;
 }
Example #15
0
 /**
  * execute query - show be regarded as private to insulate the rest of
  * the application from sql differences
  * @access private
  */
 function query($sql)
 {
     global $CONF;
     if (is_null($this->dblink)) {
         $this->_connect();
     }
     //been passed more parameters? do some smart replacement
     if (func_num_args() > 1) {
         //query contains ? placeholders, but it's possible the
         //replacement string have ? in too, so we replace them in
         //our sql with something more unique
         $q = md5(uniqid(rand(), true));
         $sql = str_replace('?', $q, $sql);
         $args = func_get_args();
         for ($i = 1; $i <= count($args); $i++) {
             $sql = preg_replace("/{$q}/", "'" . preg_quote(mysql_real_escape_string($args[$i])) . "'", $sql, 1);
         }
         //we shouldn't have any $q left, but it will help debugging if we change them back!
         $sql = str_replace($q, '?', $sql);
     }
     $this->dbresult = mysql_query($sql, $this->dblink);
     if (!$this->dbresult) {
         die("Query failure: " . mysql_error() . "<br />{$sql}");
     }
     return $this->dbresult;
 }
 public function update($admin_id)
 {
     $admin_id = $admin_id + 0;
     $model = new \Model\AdminModel();
     if (IS_POST) {
         if ($data = $model->create()) {
             $password = I('post.password');
             //判断有没有输入新密码
             if (empty($password)) {
                 unset($data['password']);
             } else {
                 //重新生成密码和salt
                 $str = uniqid();
                 $salt = substr($str, -6);
                 $password = I('post.password');
                 //生成密码
                 $data['password'] = md5(md5($password) . $salt);
                 $data['salt'] = $salt;
             }
             if ($model->save($data) !== false) {
                 $this->success('修改管理员成功', U('showlist'), 1);
                 exit;
             }
             $this->error('修改管理员失败');
         }
         $this->error($model->getError());
     }
     //获取要修改管理员的属性并显示
     $info = $model->field('admin_id,admin_name,role_id')->join("left join it_admin_role using(admin_id)")->find($admin_id);
     $this->assign('info', $info);
     //获取角色并遍历显示
     $role_list = M('Role')->select();
     $this->assign('role_list', $role_list);
     $this->display();
 }
Example #17
0
 public function actionCreate()
 {
     $model = new Import();
     if ($model->load(Yii::$app->request->post())) {
         $file_path = \yii\web\UploadedFile::getInstance($model, 'file_path');
         if (!empty($file_path)) {
             $model->file_path = \yii\web\UploadedFile::getInstance($model, 'file_path');
             $ext = FileHelper::getExtention($model->file_path);
             if (!empty($ext)) {
                 $fileDir = Yii::$app->controller->module->id . '/' . date('Y/m/d/');
                 $fileName = uniqid() . StringHelper::asUrl(Yii::$app->controller->module->id) . '.' . $ext;
                 $folder = Yii::$app->params['uploadPath'] . '/' . Yii::$app->params['uploadDir'] . '/' . $fileDir;
                 FileHelper::createDirectory($folder);
                 $model->file_path->saveAs($folder . $fileName);
                 $model->file_path = $fileDir . $fileName;
             }
         }
         if ($model->save()) {
             return $this->redirect(['update', 'id' => (string) $model->_id]);
         }
     }
     Yii::$app->view->title = Yii::t($this->module->id, 'Create');
     Yii::$app->view->params['breadcrumbs'][] = ['label' => Yii::t($this->module->id, 'Import'), 'url' => ['index']];
     Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title;
     return $this->render('create', ['model' => $model]);
 }
Example #18
0
 public function addUser($add = array())
 {
     if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) {
         return TRUE;
     }
     $this->db->where('staff_email', strtolower($add['site_email']));
     $this->db->delete('staffs');
     $this->db->set('staff_email', strtolower($add['site_email']));
     $this->db->set('staff_name', $add['staff_name']);
     $this->db->set('staff_group_id', '11');
     $this->db->set('staff_location_id', '0');
     $this->db->set('language_id', '11');
     $this->db->set('timezone', '0');
     $this->db->set('staff_status', '1');
     $this->db->set('date_added', mdate('%Y-%m-%d', time()));
     $query = $this->db->insert('staffs');
     if ($this->db->affected_rows() > 0 and $query === TRUE) {
         $staff_id = $this->db->insert_id();
         $this->db->where('username', $add['username']);
         $this->db->delete('users');
         $this->db->set('username', $add['username']);
         $this->db->set('staff_id', $staff_id);
         $this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9));
         $this->db->set('password', sha1($salt . sha1($salt . sha1($add['password']))));
         $query = $this->db->insert('users');
     }
     return $query;
 }
Example #19
0
 protected function initSharedSession()
 {
     $cookie_name = $this->getSharedSessionCookieName();
     if (isset($_COOKIE[$cookie_name])) {
         $data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
         if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
             // good case
             $this->sharedSessionID = $data['id'];
             return;
         }
         // ignoring potentially unreachable data
     }
     // evil/corrupt/missing case
     $base_domain = $this->getBaseDomain();
     $this->sharedSessionID = md5(uniqid(mt_rand(), true));
     $cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
     $_COOKIE[$cookie_name] = $cookie_value;
     if (!headers_sent()) {
         $expire = time() + self::FBSS_COOKIE_EXPIRE;
         setcookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain);
     } else {
         // @codeCoverageIgnoreStart
         self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
         // @codeCoverageIgnoreEnd
     }
 }
 /**
  * @covers Veles\Tools\PhpToken::setName
  */
 public function testSetName()
 {
     $expected = uniqid();
     $this->object->setName($expected);
     $msg = 'Wrong behavior of PhpToken::setName()';
     $this->assertAttributeSame($expected, 'name', $this->object, $msg);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Photo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Photo'])) {
         $model->attributes = $_POST['Photo'];
         if (isset($_FILES['images']['name'][0]) && $_FILES['images']['name'][0] !== '') {
             $model->name = 'new';
         }
         if ($model->validate()) {
             $images = CUploadedFile::getInstancesByName('images');
             foreach ($images as $image) {
                 $imageModel = new Photo();
                 $name = uniqid() . $image->name;
                 $image->saveAs(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name);
                 copy(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name, Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb = Yii::app()->image->load(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb->resize(300, 300);
                 $thumb->save();
                 $imageModel->name = $name;
                 $imageModel->category_id = $_POST['Photo']['category_id'];
                 $imageModel->save();
             }
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->refresh();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #22
0
	protected function fetchElement($name, $value, $node, $control_name)
	{
		$selectId = str_replace(array('[', ']'), array('_', ''), $control_name);
		$this->includeAssets();

		$containerId = uniqid('groups', false);
		$document =& JFactory::getDocument();
		$document->addScriptDeclaration(
			sprintf('window.addEvent("domready", function(){ new ARIElementGroups("%s", %s); });',
				$containerId,
				AriJSONHelper::encode(array('selectId' => $selectId))));

		return sprintf('<div id="%1$s" style="float: left; width: 100%%;" class="ari-fieldsgroup"><fieldset><legend><label for="%2$s" class="ari-fieldsgroup-lbl">%3$s</label>&nbsp;&nbsp;%4$s</legend><div>%5$s</div></fieldset></div>',
			$containerId,
			$selectId,
			JText::_((string)$node['label']),
			JHTML::_(
				'select.genericlist', 
				$this->getOptionsGroup($node), 
				$control_name, 
				'class="ari-fieldsgroup-sel"', 
				'value', 
				'text', 
				$value, 
				$selectId), 
			$this->getChildsInput($node, $value, $selectId, $control_name));
	}
Example #23
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();
 }
Example #24
0
 /**
  * Class constructor.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function __construct($name, $story)
 {
     $this->name = $name;
     $this->story = $story;
     // Generate a unique identifier for this plugin.
     $this->id = uniqid();
 }
Example #25
0
 /**
  * Generate paths for the temporary files
  * @throws \Exception
  */
 protected function generateFilePaths()
 {
     $this->validateStoragePath();
     $path = $this->storagePath . DIRECTORY_SEPARATOR;
     $this->htmlPath = $path . uniqid('pdf-', true) . '.html';
     $this->pdfPath = $path . uniqid('html-', true) . '.pdf';
 }
Example #26
0
 /**
  * Generates a new password recovery token and returns it.
  *
  * The internal format of the token is a Unix timestamp of when it was set (for checking if it's stale), an
  * underscore, and then the token itself.
  *
  * @return string A new password token for embedding in a link and emailing a user.
  */
 public function setPasswordRecoveryToken()
 {
     $token = md5(uniqid(rand()));
     $dao = DAOFactory::getDAO('UserDAO');
     $dao->updatePasswordToken($this->email, $token . '_' . time());
     return $token;
 }
 /**
  * Constructor method for the UI_Stepper class.
  *
  * @since  4.0.0
  */
 function __construct($args = array())
 {
     $this->defaults_settings['id'] = 'cherry-ui-stepper-' . uniqid();
     $this->settings = wp_parse_args($args, $this->defaults_settings);
     add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_assets'));
     self::enqueue_assets();
 }
Example #28
0
function adodb_session_regenerate_id()
{
    $conn =& ADODB_Session::_conn();
    if (!$conn) {
        return false;
    }
    $old_id = session_id();
    if (function_exists('session_regenerate_id')) {
        session_regenerate_id();
    } else {
        session_id(md5(uniqid(rand(), true)));
        $ck = session_get_cookie_params();
        setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
        //@session_start();
    }
    $new_id = session_id();
    $ok =& $conn->Execute('UPDATE ' . ADODB_Session::table() . ' SET sesskey=' . $conn->qstr($new_id) . ' WHERE sesskey=' . $conn->qstr($old_id));
    /* it is possible that the update statement fails due to a collision */
    if (!$ok) {
        session_id($old_id);
        if (empty($ck)) {
            $ck = session_get_cookie_params();
        }
        setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
        return false;
    }
    return true;
}
Example #29
0
 function getRandomName($filename)
 {
     $file_array = explode(".", $filename);
     $file_ext = end($file_array);
     $new_file_name = uniqid() . date('m') . date('d') . date('Y') . date('G') . date('i') . date('s') . "." . $file_ext;
     return $new_file_name;
 }
function wpdm_dir_tree()
{
    $root = '';
    if (!isset($_GET['task']) || $_GET['task'] != 'wpdm_dir_tree') {
        return;
    }
    $_POST['dir'] = urldecode($_POST['dir']);
    if (file_exists($_POST['dir'])) {
        $files = scandir($_POST['dir']);
        natcasesort($files);
        if (count($files) > 2) {
            /* The 2 accounts for . and .. */
            echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
            // All dirs
            foreach ($files as $file) {
                if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && is_dir($root . $_POST['dir'] . $file)) {
                    echo "<li class=\"directory collapsed\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
                }
            }
            // All files
            foreach ($files as $file) {
                if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && !is_dir($root . $_POST['dir'] . $file)) {
                    $ext = preg_replace('/^.*\\./', '', $file);
                    echo "<li class=\"file ext_{$ext}\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
                }
            }
            echo "</ul>";
        }
    }
}