当前位置: 首页>>代码示例>>PHP>>正文


PHP osc_content_path函数代码示例

本文整理汇总了PHP中osc_content_path函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_content_path函数的具体用法?PHP osc_content_path怎么用?PHP osc_content_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了osc_content_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: digitalgoods_install

function digitalgoods_install()
{
    DGModel::newInstance()->import('digitalgoods/struct.sql');
    @mkdir(osc_content_path() . 'uploads/digitalgoods/');
    osc_set_preference('upload_path', osc_content_path() . 'uploads/digitalgoods/', 'digitalgoods', 'STRING');
    osc_set_preference('max_files', '1', 'digitalgoods', 'INTEGER');
    osc_set_preference('allowed_ext', 'zip,rar,tgz', 'digitalgoods', 'INTEGER');
}
开发者ID:syedfiraat4,项目名称:bikade.com,代码行数:8,代码来源:index.php

示例2: qrcode_install

function qrcode_install()
{
    @mkdir(osc_content_path() . 'uploads/qrcode/');
    $conn = getConnection();
    osc_set_preference('upload_path', osc_content_path() . 'uploads/qrcode/', 'qrcode', 'STRING');
    osc_set_preference('upload_url', osc_base_url() . 'oc-content/uploads/qrcode/', 'qrcode', 'STRING');
    osc_set_preference('code_size', '2', 'qrcode', 'INTEGER');
    $conn->commit();
}
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:9,代码来源:index.php

示例3: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'contact_post':
             //contact_post
             $yourName = Params::getParam('yourName');
             $yourEmail = Params::getParam('yourEmail');
             $subject = Params::getParam('subject');
             $message = Params::getParam('message');
             if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
                 if (!osc_check_recaptcha()) {
                     osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                     Session::newInstance()->_setForm("yourName", $yourName);
                     Session::newInstance()->_setForm("yourEmail", $yourEmail);
                     Session::newInstance()->_setForm("subject", $subject);
                     Session::newInstance()->_setForm("message_body", $message);
                     $this->redirectTo(osc_contact_url());
                     return false;
                     // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                 }
             }
             if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                 osc_add_flash_error_message(_m('Please enter a correct email'));
                 Session::newInstance()->_setForm("yourName", $yourName);
                 Session::newInstance()->_setForm("subject", $subject);
                 Session::newInstance()->_setForm("message_body", $message);
                 $this->redirectTo(osc_contact_url());
             }
             $message = sprintf(__("%s (%s) left this message : %s"), $yourName, $yourEmail, $message);
             $params = array('reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact form') . ': ' . $subject, 'to' => osc_contact_email(), 'to_name' => __('Administrator'), 'body' => $message, 'alt_body' => $message);
             if (osc_contact_attachment()) {
                 $attachment = Params::getFiles('attachment');
                 $resourceName = $attachment['name'];
                 $tmpName = $attachment['tmp_name'];
                 $resourceType = $attachment['type'];
                 $path = osc_content_path() . 'uploads/' . time() . '_' . $resourceName;
                 if (!is_writable(osc_content_path() . 'uploads/')) {
                     osc_add_flash_error_message(_m('There have been some errors sending the message'));
                     $this->redirectTo(osc_contact_url());
                 }
                 if (!move_uploaded_file($tmpName, $path)) {
                     unset($path);
                 }
             }
             if (isset($path)) {
                 $params['attachment'] = $path;
             }
             osc_sendMail($params);
             osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
             $this->redirectTo(osc_contact_url());
             break;
         default:
             //contact
             $this->doView('contact.php');
     }
 }
开发者ID:semul,项目名称:Osclass,代码行数:56,代码来源:contact.php

示例4: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'media':
             // calling the media view
             $max_upload = (int) ini_get('upload_max_filesize');
             $max_post = (int) ini_get('post_max_size');
             $memory_limit = (int) ini_get('memory_limit');
             $upload_mb = min($max_upload, $max_post, $memory_limit) * 1024;
             $this->_exportVariableToView('max_size_upload', $upload_mb);
             $this->doView('settings/media.php');
             break;
         case 'media_post':
             // updating the media config
             osc_csrf_check();
             $status = 'ok';
             $error = '';
             $iUpdated = 0;
             $maxSizeKb = Params::getParam('maxSizeKb');
             $dimThumbnail = strtolower(Params::getParam('dimThumbnail'));
             $dimPreview = strtolower(Params::getParam('dimPreview'));
             $dimNormal = strtolower(Params::getParam('dimNormal'));
             $keepOriginalImage = Params::getParam('keep_original_image');
             $forceAspectImage = Params::getParam('force_aspect_image');
             $forceJPEG = Params::getParam('force_jpeg');
             $use_imagick = Params::getParam('use_imagick');
             $type_watermark = Params::getParam('watermark_type');
             $watermark_color = Params::getParam('watermark_text_color');
             $watermark_text = Params::getParam('watermark_text');
             switch ($type_watermark) {
                 case 'none':
                     $iUpdated += osc_set_preference('watermark_text_color', '');
                     $iUpdated += osc_set_preference('watermark_text', '');
                     $iUpdated += osc_set_preference('watermark_image', '');
                     break;
                 case 'text':
                     $iUpdated += osc_set_preference('watermark_text_color', $watermark_color);
                     $iUpdated += osc_set_preference('watermark_text', $watermark_text);
                     $iUpdated += osc_set_preference('watermark_image', '');
                     $iUpdated += osc_set_preference('watermark_place', Params::getParam('watermark_text_place'));
                     break;
                 case 'image':
                     // upload image & move to path
                     $watermark_file = Params::getFiles('watermark_image');
                     if ($watermark_file['tmp_name'] != '' && $watermark_file['size'] > 0) {
                         if ($watermark_file['error'] == UPLOAD_ERR_OK) {
                             if ($watermark_file['type'] == 'image/png') {
                                 $tmpName = $watermark_file['tmp_name'];
                                 $path = osc_content_path() . 'uploads/watermark.png';
                                 if (move_uploaded_file($tmpName, $path)) {
                                     $iUpdated += osc_set_preference('watermark_image', $path);
                                 } else {
                                     $status = 'error';
                                     $error .= _m('There was a problem uploading the watermark image') . "<br />";
                                 }
                             } else {
                                 $status = 'error';
                                 $error .= _m('The watermark image has to be a .PNG file') . "<br />";
                             }
                         } else {
                             $status = 'error';
                             $error .= _m('There was a problem uploading the watermark image') . "<br />";
                         }
                     }
                     $iUpdated += osc_set_preference('watermark_text_color', '');
                     $iUpdated += osc_set_preference('watermark_text', '');
                     $iUpdated += osc_set_preference('watermark_place', Params::getParam('watermark_image_place'));
                     break;
                 default:
                     break;
             }
             // format parameters
             $maxSizeKb = trim(strip_tags($maxSizeKb));
             $dimThumbnail = trim(strip_tags($dimThumbnail));
             $dimPreview = trim(strip_tags($dimPreview));
             $dimNormal = trim(strip_tags($dimNormal));
             $keepOriginalImage = $keepOriginalImage != '' ? true : false;
             $forceAspectImage = $forceAspectImage != '' ? true : false;
             $forceJPEG = $forceJPEG != '' ? true : false;
             $use_imagick = $use_imagick != '' ? true : false;
             if (!preg_match('|([0-9]+)x([0-9]+)|', $dimThumbnail, $match)) {
                 $dimThumbnail = is_numeric($dimThumbnail) ? $dimThumbnail . "x" . $dimThumbnail : "100x100";
             }
             if (!preg_match('|([0-9]+)x([0-9]+)|', $dimPreview, $match)) {
                 $dimPreview = is_numeric($dimPreview) ? $dimPreview . "x" . $dimPreview : "100x100";
             }
             if (!preg_match('|([0-9]+)x([0-9]+)|', $dimNormal, $match)) {
                 $dimNormal = is_numeric($dimNormal) ? $dimNormal . "x" . $dimNormal : "100x100";
             }
             // is imagick extension loaded?
             if (!@extension_loaded('imagick')) {
                 $use_imagick = false;
             }
             // max size allowed by PHP configuration?
             $max_upload = (int) ini_get('upload_max_filesize');
             $max_post = (int) ini_get('post_max_size');
             $memory_limit = (int) ini_get('memory_limit');
             $upload_mb = min($max_upload, $max_post, $memory_limit) * 1024;
             // set maxSizeKB equals to PHP configuration if it's bigger
             if ($maxSizeKb > $upload_mb) {
//.........这里部分代码省略.........
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:media.php

示例5: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add':
             $this->doView("appearance/add.php");
             break;
         case 'add_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=appearance');
             }
             osc_csrf_check();
             $filePackage = Params::getFiles('package');
             if (isset($filePackage['size']) && $filePackage['size'] != 0) {
                 $path = osc_themes_path();
                 (int) ($status = osc_unzip_file($filePackage['tmp_name'], $path));
                 @unlink($filePackage['tmp_name']);
             } else {
                 $status = 3;
             }
             switch ($status) {
                 case 0:
                     $msg = _m('The theme folder is not writable');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 1:
                     $msg = _m('The theme has been installed correctly');
                     osc_add_flash_ok_message($msg, 'admin');
                     break;
                 case 2:
                     $msg = _m('The zip file is not valid');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 3:
                     $msg = _m('No file was uploaded');
                     osc_add_flash_error_message($msg, 'admin');
                     $this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=add");
                     break;
                 case -1:
                 default:
                     $msg = _m('There was a problem adding the theme');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=appearance");
             break;
         case 'delete':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=appearance');
             }
             osc_csrf_check();
             $theme = Params::getParam('webtheme');
             if ($theme != '') {
                 if ($theme != osc_current_web_theme()) {
                     if (file_exists(osc_content_path() . "themes/" . $theme . "/functions.php")) {
                         include osc_content_path() . "themes/" . $theme . "/functions.php";
                     }
                     osc_run_hook("theme_delete_" . $theme);
                     if (osc_deleteDir(osc_content_path() . "themes/" . $theme . "/")) {
                         osc_add_flash_ok_message(_m("Theme removed successfully"), "admin");
                     } else {
                         osc_add_flash_error_message(_m("There was a problem removing the theme"), "admin");
                     }
                 } else {
                     osc_add_flash_error_message(_m("Current theme can not be deleted"), "admin");
                 }
             } else {
                 osc_add_flash_error_message(_m("No theme selected"), "admin");
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=appearance");
             break;
             /* widgets */
         /* widgets */
         case 'widgets':
             $info = WebThemes::newInstance()->loadThemeInfo(osc_theme());
             $this->_exportVariableToView("info", $info);
             $this->doView('appearance/widgets.php');
             break;
         case 'add_widget':
             $this->doView('appearance/add_widget.php');
             break;
         case 'edit_widget':
             $id = Params::getParam('id');
             $widget = Widget::newInstance()->findByPrimaryKey($id);
             $this->_exportVariableToView("widget", $widget);
             $this->doView('appearance/add_widget.php');
             break;
         case 'delete_widget':
             osc_csrf_check();
             Widget::newInstance()->delete(array('pk_i_id' => Params::getParam('id')));
             osc_add_flash_ok_message(_m('Widget removed correctly'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
             break;
         case 'edit_widget_post':
             osc_csrf_check();
             if (!osc_validate_text(Params::getParam("description"))) {
                 osc_add_flash_error_message(_m('Description field is required'), 'admin');
//.........这里部分代码省略.........
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:appearance.php

示例6: uploadItemResources

 public function uploadItemResources($aResources, $itemId)
 {
     if ($aResources != '') {
         $wat = new Watermark();
         $itemResourceManager = ItemResource::newInstance();
         $numImagesItems = osc_max_images_per_item();
         $numImages = $itemResourceManager->countResources($itemId);
         foreach ($aResources['error'] as $key => $error) {
             if ($numImagesItems == 0 || $numImagesItems > 0 && $numImages < $numImagesItems) {
                 if ($error == UPLOAD_ERR_OK) {
                     $numImages++;
                     $tmpName = $aResources['tmp_name'][$key];
                     $itemResourceManager->insert(array('fk_i_item_id' => $itemId));
                     $resourceId = $itemResourceManager->dao->insertedId();
                     // Create normal size
                     $normal_path = $path = osc_content_path() . 'uploads/' . $resourceId . '.jpg';
                     $size = explode('x', osc_normal_dimensions());
                     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
                     if (osc_is_watermark_text()) {
                         $wat->doWatermarkText($path, osc_watermark_text_color(), osc_watermark_text(), 'image/jpeg');
                     } elseif (osc_is_watermark_image()) {
                         $wat->doWatermarkImage($path, 'image/jpeg');
                     }
                     // Create preview
                     $path = osc_content_path() . 'uploads/' . $resourceId . '_preview.jpg';
                     $size = explode('x', osc_preview_dimensions());
                     ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                     // Create thumbnail
                     $path = osc_content_path() . 'uploads/' . $resourceId . '_thumbnail.jpg';
                     $size = explode('x', osc_thumbnail_dimensions());
                     ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
                     if (osc_keep_original_image()) {
                         $path = osc_content_path() . 'uploads/' . $resourceId . '_original.jpg';
                         move_uploaded_file($tmpName, $path);
                     }
                     $s_path = 'oc-content/uploads/';
                     $resourceType = 'image/jpeg';
                     $itemResourceManager->update(array('s_path' => $s_path, 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => $resourceType), array('pk_i_id' => $resourceId, 'fk_i_item_id' => $itemId));
                     osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
                 }
             }
         }
         unset($itemResourceManager);
     }
 }
开发者ID:ranjithinnergys,项目名称:OSClass,代码行数:45,代码来源:ItemActions.php

示例7: doModel


//.........这里部分代码省略.........
             // calling the media view
             $this->doView('settings/media.php');
             break;
         case 'media_post':
             // updating the media config
             $iUpdated = 0;
             $maxSizeKb = Params::getParam('maxSizeKb');
             $allowedExt = Params::getParam('allowedExt');
             $dimThumbnail = Params::getParam('dimThumbnail');
             $dimPreview = Params::getParam('dimPreview');
             $dimNormal = Params::getParam('dimNormal');
             $keepOriginalImage = Params::getParam('keep_original_image');
             $use_imagick = Params::getParam('use_imagick');
             $type_watermark = Params::getParam('watermark_type');
             $watermark_color = Params::getParam('watermark_text_color');
             $watermark_text = Params::getParam('watermark_text');
             $watermark_image = Params::getParam('watermark_image');
             switch ($type_watermark) {
                 case 'none':
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_text_color'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_text'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_image'));
                     break;
                 case 'text':
                     $iUpdated += Preference::newInstance()->update(array('s_value' => $watermark_color), array('s_name' => 'watermark_text_color'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => $watermark_text), array('s_name' => 'watermark_text'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_image'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => Params::getParam('watermark_text_place')), array('s_name' => 'watermark_place'));
                     break;
                 case 'image':
                     // upload image & move to path
                     if ($_FILES['watermark_image']['error'] == UPLOAD_ERR_OK) {
                         $tmpName = $_FILES['watermark_image']['tmp_name'];
                         $path = osc_content_path() . 'uploads/watermark.png';
                         if (move_uploaded_file($tmpName, $path)) {
                             $iUpdated += Preference::newInstance()->update(array('s_value' => $path), array('s_name' => 'watermark_image'));
                         } else {
                             $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_image'));
                         }
                     }
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_text_color'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => ''), array('s_name' => 'watermark_text'));
                     $iUpdated += Preference::newInstance()->update(array('s_value' => Params::getParam('watermark_image_place')), array('s_name' => 'watermark_place'));
                     break;
                 default:
                     break;
             }
             // format parameters
             $maxSizeKb = strip_tags($maxSizeKb);
             $allowedExt = strip_tags($allowedExt);
             $dimThumbnail = strip_tags($dimThumbnail);
             $dimPreview = strip_tags($dimPreview);
             $dimNormal = strip_tags($dimNormal);
             $keepOriginalImage = $keepOriginalImage != '' ? true : false;
             $use_imagick = $use_imagick != '' ? true : false;
             if (!extension_loaded('imagick')) {
                 $use_imagick = false;
             }
             $iUpdated += Preference::newInstance()->update(array('s_value' => $maxSizeKb), array('s_name' => 'maxSizeKb'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $allowedExt), array('s_name' => 'allowedExt'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $dimThumbnail), array('s_name' => 'dimThumbnail'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $dimPreview), array('s_name' => 'dimPreview'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $dimNormal), array('s_name' => 'dimNormal'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $keepOriginalImage), array('s_name' => 'keep_original_image'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $use_imagick), array('s_name' => 'use_imagick'));
             if ($iUpdated > 0) {
开发者ID:nsswaga,项目名称:OSClass,代码行数:67,代码来源:settings.php

示例8: osc_downloadFile

function osc_downloadFile($sourceFile, $downloadedFile)
{
    require_once LIB_PATH . 'libcurlemu/libcurlemu.inc.php';
    @set_time_limit(0);
    $fp = @fopen(osc_content_path() . 'downloads/' . $downloadedFile, 'w+');
    if ($fp) {
        $ch = curl_init($sourceFile);
        @curl_setopt($ch, CURLOPT_TIMEOUT, 50);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
        return true;
    } else {
        return false;
    }
}
开发者ID:ricktaylord,项目名称:OSClass,代码行数:18,代码来源:utils.php

示例9: VALUES

    // email_new_admin
    $comm->query(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_new_admin', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $comm->query(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', '{WEB_TITLE} - Success creating admin account!', '<p>Hi {ADMIN_NAME},</p><p>The admin of {WEB_LINK} has created an account for you,</p><ul><li>Username: {USERNAME}</li><li>Password: {PASSWORD}</li></ul><p>You can access the admin panel here {WEB_ADMIN_LINK}.</p><p>Thank you!</p><p>Regards,</p>')", DB_TABLE_PREFIX, $comm->insertedId()));
    osc_set_preference('warn_expiration', '0', 'osclass', 'INTEGER');
    $comm->query(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_warn_expiration', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $comm->query(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', '{WEB_TITLE} - Your ad is about to expire', '<p>Hi {USER_NAME},</p><p>Your listing <a href=\"{ITEM_URL}\">{ITEM_TITLE}</a> is about to expire at {WEB_LINK}.')", DB_TABLE_PREFIX, $comm->insertedId()));
    osc_set_preference('force_aspect_image', '0', 'osclass', 'BOOLEAN');
}
if (osc_version() < 321) {
    if (function_exists('osc_calculate_location_slug')) {
        osc_calculate_location_slug(osc_subdomain_type());
    }
}
if (osc_version() < 330) {
    @mkdir(osc_content_path() . 'uploads/temp/');
    @mkdir(osc_content_path() . 'downloads/oc-temp/', 0777);
    @unlink(osc_lib_path() . 'osclass/classes/Watermark.php');
    osc_set_preference('title_character_length', '100', 'osclass', 'INTEGER');
    osc_set_preference('description_character_length', '5000', 'osclass', 'INTEGER');
}
if (osc_version() < 340) {
    $comm->query(sprintf("ALTER TABLE `%st_widget` ADD INDEX `idx_s_description` (`s_description`);", DB_TABLE_PREFIX));
    osc_set_preference('force_jpeg', '0', 'osclass', 'BOOLEAN');
    @unlink(ABS_PATH . '.maintenance');
    // THESE LINES PROBABLY HIT LOW TIMEOUT SCRIPTS, RUN THE LAST OF THE UPGRADE PROCESS
    //osc_calculate_location_slug('country');
    //osc_calculate_location_slug('region');
    //osc_calculate_location_slug('city');
}
if (osc_version() < 343) {
    // update t_alerts - Save them in plain json instead of base64
开发者ID:Benn,项目名称:Osclass,代码行数:31,代码来源:upgrade-funcs.php

示例10: doWatermarkImage

 public function doWatermarkImage($filepath, $mime = 'image/png')
 {
     $path_watermark = osc_content_path() . 'uploads/watermark.png';
     if (osc_use_imagick()) {
         $im = new Imagick($filepath);
         $wm = new Imagick($path_watermark);
         $geo = $im->getImageGeometry();
         $wgeo = $wm->getImageGeometry();
         switch (osc_watermark_place()) {
             case 'tl':
                 $dest_x = 0;
                 $dest_y = 0;
                 break;
             case 'tr':
                 $dest_x = $geo['width'] - $wgeo['width'];
                 $dest_y = 0;
                 break;
             case 'bl':
                 $dest_x = 0;
                 $dest_y = $geo['height'] - $wgeo['height'];
                 break;
             case 'br':
                 $dest_x = $geo['width'] - $wgeo['width'];
                 $dest_y = $geo['height'] - $wgeo['height'];
                 break;
             default:
                 $dest_x = $geo['width'] / 2 - $wgeo['width'] / 2;
                 $dest_y = $geo['height'] / 2 - $wgeo['height'] / 2;
                 break;
         }
         $im->compositeImage($wm, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
         $this->saveImageFile($im, 'image/jpeg', $filepath);
         $im->destroy();
         $wm->destroy();
     } else {
         $watermark = imagecreatefrompng($path_watermark);
         $watermark_width = imagesx($watermark);
         $watermark_height = imagesy($watermark);
         $image = imagecreatetruecolor($watermark_width, $watermark_height);
         $image = $this->getImageResource($filepath, $mime);
         $size = getimagesize($filepath);
         switch (osc_watermark_place()) {
             case 'tl':
                 $dest_x = 0;
                 $dest_y = 0;
                 break;
             case 'tr':
                 $dest_x = $size[0] - $watermark_width;
                 $dest_y = 0;
                 break;
             case 'bl':
                 $dest_x = 0;
                 $dest_y = $size[1] - $watermark_height;
                 break;
             case 'br':
                 $dest_x = $size[0] - $watermark_width;
                 $dest_y = $size[1] - $watermark_height;
                 break;
             default:
                 $dest_x = $size[0] / 2 - $watermark_width / 2;
                 $dest_y = $size[1] / 2 - $watermark_height / 2;
                 break;
         }
         $this->imagecopymerge_alpha($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
         $this->saveImageFile($image, 'image/jpeg', $filepath);
         imagedestroy($image);
         imagedestroy($watermark);
     }
 }
开发者ID:nsswaga,项目名称:OSClass,代码行数:69,代码来源:Watermark.php

示例11: doModel


//.........这里部分代码省略.........
             }
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $message = "";
             $error = 0;
             $remove_error_msg = "";
             $sql_error_msg = "";
             $rm_errors = 0;
             $perms = osc_save_permissions();
             osc_change_permissions();
             $maintenance_file = ABS_PATH . '.maintenance';
             $fileHandler = @fopen($maintenance_file, 'w');
             fclose($fileHandler);
             /***********************
              **** DOWNLOAD FILE ****
              ***********************/
             if (Params::getParam('file') != '') {
                 $tmp = explode("/", Params::getParam('file'));
                 $filename = end($tmp);
                 $result = osc_downloadFile(Params::getParam('file'), $filename);
                 if ($result) {
                     // Everything is OK, continue
                     /**********************
                      ***** UNZIP FILE *****
                      **********************/
                     @mkdir(ABS_PATH . 'oc-temp', 0777);
                     $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, ABS_PATH . 'oc-temp/');
                     if ($res == 1) {
                         // Everything is OK, continue
                         /**********************
                          ***** COPY FILES *****
                          **********************/
                         $fail = -1;
                         if ($handle = opendir(ABS_PATH . 'oc-temp')) {
                             $fail = 0;
                             while (false !== ($_file = readdir($handle))) {
                                 if ($_file != '.' && $_file != '..' && $_file != 'remove.list' && $_file != 'upgrade.sql' && $_file != 'customs.actions') {
                                     $data = osc_copy(ABS_PATH . "oc-temp/" . $_file, ABS_PATH . $_file);
                                     if ($data == false) {
                                         $fail = 1;
                                     }
                                 }
                             }
                             closedir($handle);
                             if ($fail == 0) {
                                 // Everything is OK, continue
                                 /**********************
                                  **** REMOVE FILES ****
                                  **********************/
                                 if (file_exists(ABS_PATH . 'oc-temp/remove.list')) {
                                     $lines = file(ABS_PATH . 'oc-temp/remove.list', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                     foreach ($lines as $line_num => $r_file) {
                                         $unlink = @unlink(ABS_PATH . $r_file);
                                         if (!$unlink) {
                                             $remove_error_msg .= sprintf(__('Error removing file: %s'), $r_file) . "<br/>";
                                         }
                                     }
                                 }
                                 // Removing files is not important for the rest of the proccess
开发者ID:nsswaga,项目名称:OSClass,代码行数:67,代码来源:ajax.php

示例12: doModel

    function doModel()
    {
        switch ($this->action) {
            case 'contact_post':
                //contact_post
                osc_csrf_check();
                $yourName = Params::getParam('yourName');
                $yourEmail = Params::getParam('yourEmail');
                $subject = Params::getParam('subject');
                $message = Params::getParam('message');
                if (osc_recaptcha_private_key() != '') {
                    if (!osc_check_recaptcha()) {
                        osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                        Session::newInstance()->_setForm('yourName', $yourName);
                        Session::newInstance()->_setForm('yourEmail', $yourEmail);
                        Session::newInstance()->_setForm('subject', $subject);
                        Session::newInstance()->_setForm('message_body', $message);
                        $this->redirectTo(osc_contact_url());
                        return false;
                        // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                    }
                }
                if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                    osc_add_flash_error_message(_m('Please enter a correct email'));
                    Session::newInstance()->_setForm('yourName', $yourName);
                    Session::newInstance()->_setForm('subject', $subject);
                    Session::newInstance()->_setForm('message_body', $message);
                    $this->redirectTo(osc_contact_url());
                }
                $message_name = sprintf(__('Name: %s'), $yourName);
                $message_email = sprintf(__('Email: %s'), $yourEmail);
                $message_subject = sprintf(__('Subject: %s'), $subject);
                $message_body = sprintf(__('Message: %s'), $message);
                $message_date = sprintf(__('Date: %s at %s'), date('l F d, Y'), date('g:i a'));
                $message_IP = sprintf(__('IP Address: %s'), get_ip());
                $message = <<<MESSAGE
{$message_name}
{$message_email}
{$message_subject}
{$message_body}

{$message_date}
{$message_IP}
MESSAGE;
                $params = array('from' => osc_contact_email(), 'to' => osc_contact_email(), 'to_name' => osc_page_title(), 'reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact'), 'body' => nl2br($message));
                if (osc_contact_attachment()) {
                    $attachment = Params::getFiles('attachment');
                    if (isset($attachment['tmp_name'])) {
                        $resourceName = $attachment['name'];
                        $tmpName = $attachment['tmp_name'];
                        $resourceType = $attachment['type'];
                        $path = osc_content_path() . 'uploads/' . time() . '_' . $resourceName;
                        if (!is_writable(osc_content_path() . 'uploads/')) {
                            osc_add_flash_error_message(_m('There have been some errors sending the message'));
                            $this->redirectTo(osc_contact_url());
                        }
                        if (!move_uploaded_file($tmpName, $path)) {
                            unset($path);
                        }
                    }
                }
                if (isset($path)) {
                    $params['attachment'] = $path;
                }
                osc_run_hook('pre_contact_post', $params);
                osc_sendMail(osc_apply_filter('contact_params', $params));
                osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
                $this->redirectTo(osc_contact_url());
                break;
            default:
                //contact
                $this->doView('contact.php');
        }
    }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:74,代码来源:contact.php

示例13: doModel


//.........这里部分代码省略.........
                 require_once osc_admin_base_path() . $ajaxfile;
             } else {
                 echo json_encode(array('error' => __('no action defined')));
             }
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $message = "";
             $error = 0;
             $remove_error_msg = "";
             $sql_error_msg = "";
             $rm_errors = 0;
             $perms = osc_save_permissions();
             osc_change_permissions();
             /***********************
              **** DOWNLOAD FILE ****
              ***********************/
             if (Params::getParam('file') != '') {
                 $tmp = explode("/", Params::getParam('file'));
                 $filename = end($tmp);
                 $result = osc_downloadFile(Params::getParam('file'), $filename);
                 if ($result) {
                     // Everything is OK, continue
                     /**********************
                      ***** UNZIP FILE *****
                      **********************/
                     @mkdir(ABS_PATH . 'oc-temp', 0777);
                     $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, ABS_PATH . 'oc-temp/');
                     if ($res == 1) {
                         // Everything is OK, continue
                         /**********************
                          ***** COPY FILES *****
                          **********************/
                         $fail = -1;
                         if ($handle = opendir(ABS_PATH . 'oc-temp')) {
                             $fail = 0;
                             while (false !== ($_file = readdir($handle))) {
                                 if ($_file != '.' && $_file != '..' && $_file != 'remove.list' && $_file != 'upgrade.sql' && $_file != 'customs.actions') {
                                     $data = osc_copy(ABS_PATH . "oc-temp/" . $_file, ABS_PATH . $_file);
                                     if ($data == false) {
                                         $fail = 1;
                                     }
                                 }
                             }
                             closedir($handle);
                             if ($fail == 0) {
                                 // Everything is OK, continue
                                 /**********************
                                  **** REMOVE FILES ****
                                  **********************/
                                 if (file_exists(ABS_PATH . 'oc-temp/remove.list')) {
                                     $lines = file(ABS_PATH . 'oc-temp/remove.list', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                     foreach ($lines as $line_num => $r_file) {
                                         $unlink = @unlink(ABS_PATH . $r_file);
                                         if (!$unlink) {
                                             $remove_error_msg .= __('Error removing file: ') . $r_file . "<br/>";
                                         }
                                     }
                                 }
                                 // Removing files is not important for the rest of the proccess
开发者ID:hashemgamal,项目名称:OSClass,代码行数:67,代码来源:ajax.php

示例14: time

            LatestSearches::newInstance()->purgeDate(date('Y-m-d H:i:s', time() - 3600));
        } else {
            if (!in_array($purge, array('forever', 'day', 'week'))) {
                LatestSearches::newInstance()->purgeNumber($purge);
            }
        }
        osc_update_location_stats(true, 'auto');
        // WARN EXPIRATION EACH HOUR (COMMENT TO DISABLE)
        // NOTE: IF THIS IS ENABLE, SAME CODE SHOULD BE DISABLE ON CRON DAILY
        if (is_numeric(osc_warn_expiration()) && osc_warn_expiration() > 0) {
            $items = Item::newInstance()->findByHourExpiration(24 * osc_warn_expiration());
            foreach ($items as $item) {
                osc_run_hook('hook_email_warn_expiration', $item);
            }
        }
        $files = glob(osc_content_path() . 'uploads/temp/qqfile_*');
        if (is_array($files)) {
            foreach ($files as $file) {
                if (time() - filectime($file) > 2 * 3600) {
                    @unlink($file);
                }
            }
        }
        osc_run_hook('cron_hourly');
    }
}
// Daily crons
$cron = Cron::newInstance()->getCronByType('DAILY');
if (is_array($cron)) {
    $i_next = strtotime($cron['d_next_exec']);
    if (CLI && Params::getParam('cron-type') === 'daily' || $i_now - $i_next >= 0 && !CLI) {
开发者ID:mylastof,项目名称:os-class,代码行数:31,代码来源:cron.php

示例15: osc_market

function osc_market($section, $code)
{
    $plugin = false;
    $re_enable = false;
    $message = "";
    $data = array();
    $download_post_data = array('api_key' => osc_market_api_connect());
    /************************
     *** CHECK VALID CODE ***
     ************************/
    if ($code != '' && $section != '') {
        if (stripos($code, "http://") === FALSE) {
            // OSCLASS OFFICIAL REPOSITORY
            $url = osc_market_url($section, $code);
            $data = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));
            $data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
        } else {
            // THIRD PARTY REPOSITORY
            if (osc_market_external_sources()) {
                $download_post_data = array();
                $data = json_decode(osc_file_get_contents($code), true);
            } else {
                return array('error' => 9, 'message' => __('No external sources are allowed'), 'data' => $data);
            }
        }
        /***********************
         **** DOWNLOAD FILE ****
         ***********************/
        if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
            if ($data['e_type'] == 'THEME') {
                $folder = 'themes/';
            } else {
                if ($data['e_type'] == 'LANGUAGE') {
                    $folder = 'languages/';
                } else {
                    // PLUGINS
                    $folder = 'plugins/';
                    $plugin = Plugins::findByUpdateURI($data['s_update_url']);
                    if ($plugin != false) {
                        if (Plugins::isEnabled($plugin)) {
                            Plugins::runHook($plugin . '_disable');
                            Plugins::deactivate($plugin);
                            $re_enable = true;
                        }
                    }
                }
            }
            $filename = date('YmdHis') . "_" . osc_sanitize_string($data['s_title']) . "_" . $data['s_version'] . ".zip";
            $url_source_file = $data['s_source_file'];
            $result = osc_downloadFile($url_source_file, $filename, $download_post_data);
            if ($result) {
                // Everything is OK, continue
                /**********************
                 ***** UNZIP FILE *****
                 **********************/
                @mkdir(osc_content_path() . 'downloads/oc-temp/');
                $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
                if ($res == 1) {
                    // Everything is OK, continue
                    /**********************
                     ***** COPY FILES *****
                     **********************/
                    $fail = -1;
                    if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
                        $folder_dest = ABS_PATH . "oc-content/" . $folder;
                        if (function_exists('posix_getpwuid')) {
                            $current_user = posix_getpwuid(posix_geteuid());
                            $ownerFolder = posix_getpwuid(fileowner($folder_dest));
                        }
                        $fail = 0;
                        while (false !== ($_file = readdir($handle))) {
                            if ($_file != '.' && $_file != '..') {
                                $copyprocess = osc_copy(osc_content_path() . "downloads/oc-temp/" . $_file, $folder_dest . $_file);
                                if ($copyprocess == false) {
                                    $fail = 1;
                                }
                            }
                        }
                        closedir($handle);
                        // Additional actions is not important for the rest of the proccess
                        // We will inform the user of the problems but the upgrade could continue
                        // Also remove the zip package
                        /****************************
                         ** REMOVE TEMPORARY FILES **
                         ****************************/
                        @unlink(osc_content_path() . 'downloads/' . $filename);
                        $path = osc_content_path() . 'downloads/oc-temp';
                        $rm_errors = 0;
                        $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
                        for ($dir->rewind(); $dir->valid(); $dir->next()) {
                            if ($dir->isDir()) {
                                if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
                                    if (!rmdir($dir->getPathname())) {
                                        $rm_errors++;
                                    }
                                }
                            } else {
                                if (!unlink($dir->getPathname())) {
                                    $rm_errors++;
                                }
//.........这里部分代码省略.........
开发者ID:naneri,项目名称:Osclass,代码行数:101,代码来源:utils.php


注:本文中的osc_content_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。