Пример #1
0
 protected function render()
 {
     try {
         $prop = $this->props;
         $services = $prop->service ?: $prop->services;
         if ($services) {
             $vm = $this->context->getDataBinder()->getViewModel();
             $injector = $this->context->injector;
             $aliases = preg_split('/\\s+/', $services, -1, PREG_SPLIT_NO_EMPTY);
             if (exists($as = $prop->as)) {
                 if (count($aliases) > 1) {
                     throw new ComponentException($this, "When using the <kbd>as</kbd> property, you can only specify one value for the <kbd>service</kbd> property");
                 }
                 $service = $injector->make($services);
                 $vm->{$as} = $service;
             } else {
                 foreach ($aliases as $alias) {
                     $service = $injector->get($alias);
                     $vm->{$alias} = $service;
                 }
             }
         }
     } catch (NotFoundException $e) {
         throw new ComponentException($this, $e->getMessage());
     }
 }
Пример #2
0
 public function __isset()
 {
     if (exists($this->color)) {
         return TRUE;
     }
     return FALSE;
 }
 public function getImageUrl($path, array $params = [])
 {
     if (exists($path)) {
         return rtrim(substr($this->urlBuilder->getUrl($path, $params), 1), '?');
     }
     return '';
 }
Пример #4
0
 function getImplementationType()
 {
     global $zuckerreports_config;
     if ($zuckerreports_config["team_implementation"] == "auto") {
         if (file_exists("modules/Teams/Team.php")) {
             return "sugar";
         } else {
             if (!empty($zuckerreports_config["teams"])) {
                 return "simple";
             } else {
                 return "none";
             }
         }
     } else {
         if ($zuckerreports_config["team_implementation"] == "sugar" && exists("modules/Teams/Team.php")) {
             return "sugar";
         } else {
             if ($zuckerreports_config["team_implementation"] == "simple") {
                 return "simple";
             } else {
                 return "none";
             }
         }
     }
 }
Пример #5
0
 protected function evaluate()
 {
     $prop = $this->props;
     $np = Parser::NAMELESS_PROP;
     if (isset($prop->{$np})) {
         if ($prop->{$np}) {
             //      if ($prop->getComputed($np))
             return $this->getChildren();
         }
         return $this->getChildren('else');
     }
     $v = $prop->get('value');
     $not = $prop->not;
     if (exists($prop->matches)) {
         if (preg_match("%{$prop->matches}%", $v) xor $not) {
             return $this->getChildren();
         }
         return $this->getChildren('else');
     }
     if ($prop->case) {
         foreach ($prop->case as $param) {
             if ($v == $param->props->is) {
                 return $param->getChildren();
             }
         }
         return $this->getChildren('else');
     }
     if (toBool($v) xor $not) {
         return $this->getChildren();
     }
     return $this->getChildren('else');
 }
Пример #6
0
 private function getError($item)
 {
     if (exists($this->errors[$item])) {
         return $this->errors[$item];
     } else {
         return "";
     }
 }
 function makeBody($content = '', $stream = 'php://memory')
 {
     $s = new Stream($stream, 'wb+');
     if (exists($content)) {
         $s->write($content);
     }
     return $s;
 }
Пример #8
0
function isLoggedIn()
{
    if (!empty($_SESSION['logged_in']) && exists($connection, 'user_id', 'users', 'user_id', $_SESSION['logged_in']) == true) {
        return true;
    } else {
        return false;
    }
}
Пример #9
0
 public function testUnPlug()
 {
     $class = __NAMESPACE__ . '\\FakePlug';
     plug('fake', [_CLASS => $class]);
     $this->assertTrue(exists('fake', 'PlugIn'));
     unPlug('fake');
     $this->assertFalse(exists('fake', 'PlugIn'));
 }
Пример #10
0
 protected function render()
 {
     $prop = $this->props;
     $scopeProps = $this->getDataBinder()->getProps();
     $name = $prop->name;
     if (isset($scopeProps) && !exists($scopeProps->{$name})) {
         $scopeProps->{$name} = $prop->default;
     }
 }
Пример #11
0
 /**
  * Registers a stylesheet on the Page.
  */
 protected function render()
 {
     $prop = $this->props;
     if (exists($prop->src)) {
         $this->context->getAssetsService()->addStylesheet($prop->src, $this->props->prepend);
     } else {
         if ($this->hasChildren()) {
             $this->context->getAssetsService()->addInlineCss($this, $prop->name, $this->props->prepend);
         }
     }
 }
Пример #12
0
 protected function viewModel(ViewModel $viewModel)
 {
     $settings = $viewModel->adminSettings = $this->adminSettings;
     if ($settings->showMenu()) {
         $target = $settings->topMenuTarget();
         $viewModel->topMenu = exists($target) ? isset($this->navigation[$target]) ? $this->navigation[$target] : null : $this->navigation;
     }
     $viewModel->sideMenu = get($this->navigation->getCurrentTrail($settings->sideMenuOffset()), 0);
     $user = $this->session->user();
     $viewModel->devMode = $user && $user->roleField() == UserInterface::USER_ROLE_DEVELOPER;
 }
Пример #13
0
 function test_exists()
 {
     $this->assertTrue(exists($GLOBALS['_name']));
     $foo = '';
     $bar = array();
     $this->assertFalse(exists($foo));
     $this->assertFalse(exists($bar));
     $this->assertEqual(use_default('', 'foo'), 'foo');
     $this->assertEqual(use_default('bar', 'foo'), 'bar');
     $this->assertNotEqual(use_default('bar', 'foo'), 'foo');
     $this->assertNotEqual(use_default('', 'foo'), '');
 }
Пример #14
0
 protected function render()
 {
     $viewModel = $this->getViewModel();
     $prop = $this->props;
     $count = $prop->get('count', -1);
     if (exists($prop->each)) {
         $this->parseIteratorExp($prop->each, $idxVar, $itVar);
     } else {
         $idxVar = $itVar = null;
     }
     if (!is_null($for = $prop->of)) {
         $first = true;
         foreach ($for as $i => $v) {
             if ($idxVar) {
                 $viewModel->{$idxVar} = $i;
             }
             $viewModel->{$itVar} = $v;
             if ($first) {
                 $first = false;
                 $this->runChildren('header');
             } else {
                 $this->runChildren('glue');
             }
             $this->runChildren();
             if (!--$count) {
                 break;
             }
         }
         if ($first) {
             $this->runChildren('noData');
         } else {
             $this->runChildren('footer');
         }
         return;
     }
     if ($count > 0) {
         for ($i = 0; $i < $count; ++$i) {
             $viewModel->{$idxVar} = $viewModel->{$itVar} = $i;
             if ($i == 0) {
                 $this->runChildren('header');
             } else {
                 $this->runChildren('glue');
             }
             $this->runChildren();
         }
         if ($i) {
             $this->runChildren('footer');
             return;
         }
     }
     $this->runChildren('noData');
 }
Пример #15
0
 /**
  * Adds an inline script to the HEAD section of the page.
  *
  * @param string|RenderableInterface $code    Javascript code without the script tags.
  * @param string                     $name    An identifier for the script, to prevent duplication.
  *                                            When multiple scripts with the same name are added, only the last one is
  *                                            considered.
  * @param bool                       $prepend If true, prepend to current list instead of appending.
  * @return $this
  */
 function addInlineScript($code, $name = null, $prepend = false)
 {
     if (exists($name)) {
         $this->assets->inlineScripts[$name] = $code;
     } else {
         if ($prepend) {
             array_unshift($this->assets->inlineScripts, $code);
         } else {
             $this->assets->inlineScripts[] = $code;
         }
     }
     return $this;
 }
 function loadModel($modelClass, $subModelPath = '', $id = null)
 {
     $id = $this->requestedId ?: $id;
     $this->requestedId = $id;
     /** @var Model $modelClass */
     $model = exists($id) ? $modelClass::query()->findOrFail($id) : new $modelClass();
     if ($subModelPath === '') {
         $this->model = $model;
     } else {
         setAt($this->model, $subModelPath, $model);
     }
     return $model;
 }
Пример #17
0
 /**
  * Generates a javascript representation of the provided options, stripping the ones that are null or empty strings.
  *
  * @param array  $options A map of options.
  * @param string $indent  Indentation level, composed of spaces.
  * @return string
  */
 static function makeOptions(array $options, $indent = '')
 {
     $o = mapAndFilter($options, function ($v, $k) use($indent) {
         if (is_object($v)) {
             if (method_exists($v, 'toArray')) {
                 $v = $v->toArray();
             } else {
                 $v = (array) $v;
             }
         }
         return exists($v) ? "{$k}: " . json_encode($v, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : null;
     });
     return "{\n{$indent}  " . implode(",\n{$indent}  ", $o) . "\n{$indent}}";
 }
Пример #18
0
function register()
{
    if (empty($_POST["first_name"]) || empty($_POST["last_name"])) {
        $GLOBALS["errors"]["noName"] = "You need to enter your first and last name";
    }
    if (empty($_POST["country"])) {
        $GLOBALS["errors"]["noCountry"] = "You need to enter the country that you live in";
    }
    if (empty($_POST["city"])) {
        $GLOBALS["errors"]["noCity"] = "You need to enter the city that you live in";
    }
    if (empty($_POST["password"])) {
        $GLOBALS["errors"]["noPassword"] = "******";
    }
    if ($_POST["password"] !== $_POST["password2"]) {
        $GLOBALS["errors"]["passwordMatch"] = "Passwords don't match";
    }
    if (empty($_POST["email"])) {
        $GLOBALS["errors"]["noEmail"] = "You need to enter your email address";
    }
    if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $GLOBALS["errors"]["notValidEmail"] = "You need to enter a valid email address";
    }
    if (empty($_POST["phone"])) {
        $GLOBALS["errors"]["noPhone"] = "You need to enter your phone number";
    }
    //Checking if the email has already registered
    if (exists("email", $_POST["email"])) {
        $GLOBALS["errors"]["emailRegistered"] = "A user with that email has already registered";
    }
    if (empty($GLOBALS["errors"])) {
        //I shouldn't use this hash function, but I will for now. I should really use password_hash()
        $password = password_hash($_POST["password"], PASSWORD_DEFAULT);
        $country = $_POST["country"];
        $city = $_POST["city"];
        $full_name = $_POST["first_name"] . " " . $_POST["last_name"];
        $email = $_POST["email"];
        $phone = $_POST["phone"];
        $query = "INSERT INTO users (country, city, password, full_name, email, phone) VALUES (?, ?, ?, ?, ?, ?)";
        $stmt = $GLOBALS["conn"]->prepare($query);
        if (!$stmt) {
            echo "Error: " . $GLOBALS["conn"]->error;
        }
        $stmt->bind_param("sssssi", $country, $city, $password, $full_name, $email, $phone);
        $stmt->execute();
        $stmt->close();
        $GLOBALS["success_message"] = "Registration successful!";
    }
}
 protected function preRender()
 {
     $prop = $this->props;
     // Output a hidden checkbox that will submit an empty value if the visible checkbox is not checked.
     // Does not apply to checkboxes of array fields.
     if (exists($prop->name) && !str_endsWith($prop->name, '[]')) {
         echo "<input type=checkbox name=\"{$prop->name}\" value=\"\" checked style=\"display:none\">";
     }
     $id = property($prop, 'id');
     if ($id) {
         $prop->containerId = $prop->id . 'Container';
     }
     echo "<!--CHECKBOX-->";
     parent::preRender();
 }
 static function startUp(KernelInterface $kernel, ModuleInfo $moduleInfo)
 {
     $kernel->onConfigure(function (MatisseSettings $matisseSettings, ModelControllerInterface $modelController, InjectorInterface $injector, ContentServerSettings $contentServerSettings, AssetsService $assetsService) use($moduleInfo) {
         $matisseSettings->registerMacros($moduleInfo)->registerComponents(['Button' => C\Button::class, 'Checkbox' => C\Checkbox::class, 'DataGrid' => C\DataGrid::class, 'Dropzone' => C\Dropzone::class, 'Field' => C\Field::class, 'FileUpload' => C\FileUpload::class, 'HtmlEditor' => C\HtmlEditor::class, 'Image' => C\Image::class, 'ImageField' => C\ImageField::class, 'Input' => C\Input::class, 'Label' => C\Label::class, 'Link' => C\Link::class, 'MainMenu' => C\MainMenu::class, 'NavigationPath' => C\NavigationPath::class, 'Paginator' => C\Paginator::class, 'RadioButton' => C\RadioButton::class, 'Select' => C\Select::class, 'Switch' => C\Switch_::class, 'Tab' => C\Tab::class, 'TabPage' => C\TabPage::class, 'Tabs' => C\Tabs::class]);
         $assetsService->registerAssets($moduleInfo->name, ['dist/components.css']);
         $modelController->registerExtension($injector->makeFactory(ImageFieldHandler::class));
         File::deleting(function (File $model) use($contentServerSettings, $injector) {
             if (exists($model->path)) {
                 $path = "{$contentServerSettings->fileArchivePath()}/{$model->path}";
                 if (file_exists($path)) {
                     unlink($path);
                 }
                 $glideServer = $injector->make(Server::class);
                 $glideServer->deleteCache($model->path);
             }
         });
     });
 }
Пример #21
0
 /**
  * Loads the macro with the name specified by the `macro` property.
  *
  * @param array|null $props
  * @param Component  $parent
  */
 protected function onCreate(array $props = null, Component $parent = null)
 {
     //    inspect("Macro: ".get ($props, 'macro'));
     //    $z = get_object_vars($this);
     //    foreach ($z as &$v)
     //      $v = is_object($v) ? 'ID='.Debug::objectId($v) : $v;
     //    inspect ($z);
     $this->parent = $parent;
     $name = get($props, 'macro');
     if (exists($name)) {
         try {
             $frag = $this->context->getMacrosService()->loadMacro($name, $path);
             $this->macroInstance = $frag->getFirstChild();
             $this->props->setMacro($this->macroInstance);
             $this->setShadowDOM($this->macroInstance);
         } catch (FileIOException $e) {
             /** @noinspection PhpUndefinedVariableInspection */
             self::throwUnknownComponent($this->context, $name, $parent, $filename);
         }
     }
     parent::onCreate($props, $parent);
 }
Пример #22
0
 function deleteRelated($notice)
 {
     if ($notice->object_type == Blog_entry::TYPE) {
         $entry = Blog_entry::fromNotice($notice);
         if (exists($entry)) {
             $entry->delete();
         }
     }
 }
Пример #23
0
<div class="page-content">

<?php 
if (exists() && ($page = the_page())) {
    echo '<h2>' . $page->name . '</h2>';
    echo nl2br($page->text);
} else {
    echo read_template_part('404');
}
?>

</div>
Пример #24
0
{
    $i = 0;
    if ($data == NULL) {
        return FALSE;
    }
    foreach ($data as $user) {
        if ($user['login'] === $login) {
            return $i;
        }
        $i++;
    }
    return FALSE;
}
if ($_POST['login'] === "" or $_POST['oldpwd'] === "" or $_POST['newpwd'] === "" or $_POST['submit'] !== "OK") {
    error();
}
if (file_exists("private/passwd") === FALSE) {
    error();
}
$data = unserialize(file_get_contents("private/passwd"));
if (($index = exists($_POST['login'], $data)) === FALSE) {
    error();
}
if ($data[$index]['passwd'] != hash("whirlpool", $_POST['oldpwd'])) {
    error();
}
$hash = hash("whirlpool", $_POST['newpwd']);
$data[$index]['passwd'] = $hash;
$serial = serialize($data);
file_put_contents("private/passwd", $serial);
echo "OK" . PHP_EOL;
Пример #25
0
 public function offsetExists($offset)
 {
     if (isset($this->rootlist)) {
         return exists($this->rootlist[$offset]);
     } else {
         return $offset < $this->length;
     }
 }
Пример #26
0
 protected function render()
 {
     $prop = $this->props;
     if ($prop->disabled) {
         $this->attr('disabled', 'disabled');
     }
     $this->attrIf($prop->tabIndex, 'tabindex', $prop->tabIndex);
     $this->attr('type', $prop->type);
     if (exists($prop->action)) {
         $this->beginAttr('onclick', null, ';');
         if ($prop->confirm) {
             $msg = str_encodeJavasciptStr($prop->message, "'");
             $this->context->getAssetsService()->addInlineScript("function confirm_{$prop->id}()\n{\n  swal({\n    title: '',\n    text: {$msg},\n    type: 'warning',\n    showCancelButton: true\n  },\n  function() {\n    selenia.doAction('{$prop->action}','{$prop->param}');\n  });\n}", "confirm_{$prop->id}");
             $this->attrValue("confirm_{$prop->id}()");
         } else {
             $this->attrValue("selenia." . ($prop->type == 'submit' ? 'set' : 'do') . "Action('{$prop->action}','{$prop->param}')");
         }
         $this->endAttr();
     } else {
         if (exists($prop->script)) {
             $this->attr('onclick', $prop->script);
         } else {
             if (exists($prop->url)) {
                 $this->attr('onclick', "selenia.go('{$prop->url}',event);");
             }
         }
     }
     if (exists($prop->help)) {
         $this->attr('title', $prop->help);
     }
     $this->beginContent();
     if (exists($prop->icon)) {
         $this->tag('i', ['class' => $prop->icon]);
     }
     $txt = trim($prop->label);
     echo strlen($txt) ? $txt : (exists($prop->icon) ? '' : '&nbsp;');
 }
Пример #27
0
 /**
  * Adds (or replaces) the content of the `value` property (or the component's content) to a named block on the page.
  */
 protected function render()
 {
     $prop = $this->props;
     $content = exists($prop->value) ? $prop->value : $this->getChildren();
     $blocksService = $this->context->getBlocksService();
     if ($prop->preRender && is_array($content)) {
         $content = $this->attachSetAndGetContent($content);
     }
     if (exists($name = $prop->of)) {
         if (!preg_match('/^\\w+$/', $name)) {
             throw new ComponentException($this, "Invalid block name: <kbd>{$name}</kbd>");
         }
         if ($prop->byDefault && $blocksService->hasBlock($name)) {
             return;
         }
         $blocksService->getBlock($name)->set($content);
     } elseif (exists($name = $prop->appendTo)) {
         if ($prop->byDefault && $blocksService->hasBlock($name)) {
             return;
         }
         $blocksService->getBlock($name)->append($content);
     } elseif (exists($name = $prop->prependTo)) {
         if ($prop->byDefault && $blocksService->hasBlock($name)) {
             return;
         }
         $blocksService->getBlock($name)->prepend($content);
     } else {
         throw new ComponentException($this, "One of these properties must be set:<p><kbd>of | appendTo | prependTo</kbd>");
     }
 }
Пример #28
0
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($email, 'req', 'Please email address');
    $obj->add_fields($email, 'email', 'Please valid email address');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>' .{$error}. '</font>";
    } else {
        if (exists($email)) {
            $errorMsg = "<font color='#FF0000' family='verdana' size=2>Email Address already added.</font>";
        } else {
            $_SESSION['success_msg'] = 'New Email address has been saved successfully.';
            $dataArr = array('email' => $email);
            $update_site = $obj_setting->save('notification_emails', $dataArr);
            echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/email_noti/view.php";</script>';
            exit;
        }
    }
}
function exists($email)
{
    $rsObj = mysql_query("SELECT id  FROM `notification_emails` WHERE `email` =  '" . $email . "'");
    if (mysql_num_rows($rsObj) > 0) {
        return true;
Пример #29
0
            return false;
        } else {
            return false;
        }
    }
}
// Generate filename
//$filename = md5(mt_rand()).'.jpg';
$filename = $_REQUEST['filename'] . '.jpg';
$path_img = 'http://oduquangcao.vn/tmp2/allinonenew/images/' . $filename;
// Read RAW data
$data = file_get_contents('php://input');
// Read string as an image file
$image = file_get_contents('data://' . substr($data, 5));
// Save to disk
if (exists($path_img)) {
    unset($path_img);
    if (!file_put_contents('images/' . $filename, $image)) {
        header('HTTP/1.1 503 Service Unavailable');
        exit;
    }
} else {
    if (!file_put_contents('images/' . $filename, $image)) {
        header('HTTP/1.1 503 Service Unavailable');
        exit;
    }
}
// Clean up memory
//unset($data);
//unset($image);
// Return file URL
Пример #30
0
<div class="left">

<?php 
if (exists()) {
    $item = the_item();
    echo '<article class="array_item">

<div class="table" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">

<div class="left">
<img src="' . store_avatar($item->image) . '" alt="" itemprop="photo" />
<span class="rating"><span style="width:' . $item->stars * 16 . 'px;"></span></span>
<div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">
<span itemprop="average" style="display: none;">' . number_format($item->stars, 2) . '</span>
<span itemprop="best" style="display: none;">5</span>
</div>
<a href="' . $item->reviews_link . '"><span itemprop="votes">' . $item->reviews . '</span> reviews</a>
</div>

<div class="right">
<div class="title" itemprop="itemreviewed">' . $item->name . '</div>
<div class="description">' . (!empty($item->description) ? nl2br($item->description) : 'no description') . '</div>

<div class="links">
<a href="' . tlink('plugin/click.html', 'id=' . $item->ID) . '" target="_blank" class="btn open_site">Open website</a>';
    if (me()) {
        if (is_favorite()) {
            echo '<a href="' . tlink('ajax/favorite.html', 'action=remFavorite&amp;id=' . $item->ID, 'this') . '" class="btn remove_favorite">-Favorite</a>';
        } else {
            echo '<a href="' . tlink('ajax/favorite.html', 'action=addFavorite&amp;id=' . $item->ID, 'this') . '" class="btn add_favorite">+Favorite</a>';
        }